UI resetpassword

This commit is contained in:
setthawutttty 2025-02-21 16:39:50 +07:00
parent 3272fae13b
commit 4aa7a659a4
3 changed files with 59 additions and 44 deletions

View file

@ -220,7 +220,7 @@ function closeDialog() {
async function onSubmit() {
showLoader()
await http
.post(config.API.resetPassword, {
.post(config.API.changePassword, {
password: newPassword.value,
})
.then(async (res) => {

View file

@ -2,6 +2,9 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import axios from 'axios'
import http from '@/plugins/http'
import config from '@/app.config'
import { useRouter } from 'vue-router'
import { useQuasar } from 'quasar'
import { useCounterMixin } from '@/stores/mixin'
@ -12,37 +15,27 @@ import env from '@/api/index'
const router = useRouter()
const mixin = useCounterMixin()
const $q = useQuasar() // noti quasar
const { showLoader, hideLoader } = mixin
const isReset = ref<boolean>(false)
const isFalse = ref<boolean>(false)
const { showLoader, hideLoader, messageError } = mixin
const username = ref<string>('')
const password = ref<string>('')
async function onSubmit() {
showLoader()
const formdata = new URLSearchParams()
formdata.append('username', username.value)
formdata.append('password', password.value)
await axios
.post(`${env.API_URI}/org/login/checkin`, formdata, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
http
.post(config.API.resetPassword, {
username: username.value,
})
.then(async (res) => {
setAuthenCheckin(res.data.result)
.then((res) => {
if (res.data.result) {
isReset.value = true
isFalse.value = false
} else {
isFalse.value = true
}
})
.catch((err) => {
$q.dialog({
component: CustomComponent,
componentProps: {
title: `ข้อความแจ้งเตือน`,
message: `${err.response.data.message}`,
icon: 'warning',
color: 'red',
onlycancel: true,
},
})
.catch((e) => {
messageError($q, e)
})
.finally(() => {
hideLoader()
@ -73,7 +66,15 @@ onMounted(async () => {})
@validation-success="onSubmit"
style="max-width: 100%; min-width: 30%"
>
<div class="row">
<q-banner
v-if="isFalse"
class="bg-amber-1 text-warning q-mb-sm"
style="border-top: 2px solid #f2c037; border-radius: 0 0 4px 4px"
>
<q-icon name="mdi-alert" size="sm" class="q-mr-xs"></q-icon
>ไมพบชอผใชงานในระบบ
</q-banner>
<div class="row" v-if="!isReset">
<div class="col-12 q-mb-sm text-left">
<label
for="username"
@ -98,24 +99,37 @@ onMounted(async () => {})
type="submit"
></q-btn>
</div>
<div class="col-12 q-mb-xs">
<q-btn
unelevated
outline
color="teal-5"
class="full-width"
style="font-size: 16px; border-radius: 8px"
@click="router.push(`/login`)"
><q-icon left name="mdi-chevron-left" />
<div class="text-center">กลบไปทการเขาสระบบ</div>
</q-btn>
</div>
<div class="text-left text-weight-medium">
ระบอผใชงานหรอทอยเมลของค
เราจะสงคำแนะนำในการสรางรหสผานใหมให
</div>
</div>
<q-banner class="bg-green-1 text-green q-mb-sm" rounded v-else>
<q-icon name="mdi-check-circle" size="sm"></q-icon>ณจะได
e-mail เพอเปลยนรหสผานใหม
</q-banner>
<div class="q-mb-xs">
<q-btn
unelevated
outline
color="teal-5"
class="full-width"
style="font-size: 16px; border-radius: 8px"
@click="router.push(`/login`)"
><q-icon left name="mdi-chevron-left" />
<div class="text-center">กลบไปทการเขาสระบบ</div>
</q-btn>
</div>
</q-form>
<div
class="text-weight-medium bg-grey-3 text-center q-py-sm"
style="
border-radius: 0 0 10px 10px;
margin: 20px -40px -30px;
padding: 15px 35px;
font-size: 13px;
"
>
อนชอผใชหรอทอยเมลของค
แลวเราจะสงคำแนะนำเกยวกบวสรางรหสผานใหมให
</div>
</div>
</div>
</div>