pukaad-ui-lib 1.254.0 → 1.256.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/input/input-profile-name.vue +10 -10
- package/dist/runtime/components/modal/modal-forgot-password.vue +12 -17
- package/dist/runtime/components/modal/modal-phone-OTP.d.vue.ts +2 -2
- package/dist/runtime/components/modal/modal-phone-OTP.vue +61 -9
- package/dist/runtime/components/modal/modal-phone-OTP.vue.d.ts +2 -2
- package/dist/runtime/components/modal/modal-secure.d.vue.ts +1 -0
- package/dist/runtime/components/modal/modal-secure.vue +4 -3
- package/dist/runtime/components/modal/modal-secure.vue.d.ts +1 -0
- package/dist/runtime/components/modal/modal.vue +5 -14
- package/package.json +1 -1
- /package/dist/runtime/assets/svg/socials/{Whatsapp.svg → WhatsApp.svg} +0 -0
package/dist/module.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<InputTextField
|
|
3
|
-
ref="inputTextFieldRef"
|
|
4
|
-
v-bind="props"
|
|
5
|
-
:rules="props.rules || defaultRules"
|
|
6
|
-
v-model="modelValue"
|
|
7
|
-
>
|
|
8
|
-
<template v-for="(_, name) in $slots" v-slot:[name]="slotData">
|
|
9
|
-
<slot :name="name" v-bind="slotData || {}" />
|
|
10
|
-
</template>
|
|
11
|
-
</InputTextField>
|
|
2
|
+
<InputTextField
|
|
3
|
+
ref="inputTextFieldRef"
|
|
4
|
+
v-bind="props"
|
|
5
|
+
:rules="props.rules || defaultRules"
|
|
6
|
+
v-model="modelValue"
|
|
7
|
+
>
|
|
8
|
+
<template v-for="(_, name) in $slots" v-slot:[name]="slotData">
|
|
9
|
+
<slot :name="name" v-bind="slotData || {}" />
|
|
10
|
+
</template>
|
|
11
|
+
</InputTextField>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
14
|
<script setup>
|
|
@@ -45,6 +45,11 @@ const modalProps = computed(() => ({
|
|
|
45
45
|
phoneOTP: {
|
|
46
46
|
phone: phone.value,
|
|
47
47
|
phoneLabel: maskedPhone.value,
|
|
48
|
+
requestPath: "/auth/forgot-password/send-otp",
|
|
49
|
+
requestBody: { phone: phone.value, method: "sms" },
|
|
50
|
+
verifyPath: "/auth/forgot-password/verify-otp",
|
|
51
|
+
verifyBody: { phone: phone.value },
|
|
52
|
+
initialExpiredTime: expiredTime.value,
|
|
48
53
|
confirmedText: "\u0E16\u0E31\u0E14\u0E44\u0E1B"
|
|
49
54
|
},
|
|
50
55
|
emailOTP: {
|
|
@@ -74,7 +79,13 @@ const handleComplete = async (key, data) => {
|
|
|
74
79
|
return;
|
|
75
80
|
}
|
|
76
81
|
if (key === "phoneOTP") {
|
|
77
|
-
|
|
82
|
+
const token = data?.reset_token;
|
|
83
|
+
if (!token) {
|
|
84
|
+
$toast?.error?.("\u0E44\u0E21\u0E48\u0E1E\u0E1A reset token");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
resetToken.value = token;
|
|
88
|
+
modalStates.passwordNew = true;
|
|
78
89
|
return;
|
|
79
90
|
}
|
|
80
91
|
if (key === "emailOTP") {
|
|
@@ -114,22 +125,6 @@ const callSendOTP = async () => {
|
|
|
114
125
|
isLoading.value = false;
|
|
115
126
|
}
|
|
116
127
|
};
|
|
117
|
-
const callVerifyOTP = async (code) => {
|
|
118
|
-
isLoading.value = true;
|
|
119
|
-
try {
|
|
120
|
-
const res = await api("/auth/forgot-password/verify-otp", {
|
|
121
|
-
method: "POST",
|
|
122
|
-
body: { phone: phone.value, code }
|
|
123
|
-
});
|
|
124
|
-
resetToken.value = res.data.reset_token;
|
|
125
|
-
modalStates.passwordNew = true;
|
|
126
|
-
} catch (e) {
|
|
127
|
-
const msg = e?.data?.message?.description || e?.data?.message || "OTP \u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E2B\u0E23\u0E37\u0E2D\u0E2B\u0E21\u0E14\u0E2D\u0E32\u0E22\u0E38";
|
|
128
|
-
$toast?.error?.(msg);
|
|
129
|
-
} finally {
|
|
130
|
-
isLoading.value = false;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
128
|
watch(isOpen, (v) => {
|
|
134
129
|
if (v) {
|
|
135
130
|
phone.value = "";
|
|
@@ -8,11 +8,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
8
8
|
"update:modelValue": (value: boolean) => any;
|
|
9
9
|
} & {
|
|
10
10
|
close: () => any;
|
|
11
|
-
complete: (
|
|
11
|
+
complete: (data?: any) => any;
|
|
12
12
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
13
13
|
onClose?: (() => any) | undefined;
|
|
14
14
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
15
|
-
onComplete?: ((
|
|
15
|
+
onComplete?: ((data?: any) => any) | undefined;
|
|
16
16
|
}>, {
|
|
17
17
|
phone: string;
|
|
18
18
|
confirmedText: string;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
<InputOTP name="otp" columnGap="auto" v-model="valueOTP" :error="otpError" />
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
|
+
|
|
16
17
|
<div class="text-center font-body-large">
|
|
17
18
|
<template v-if="countdown !== '00:00'">
|
|
18
19
|
กรุณารอ <span class="text-primary">{{ countdown }}</span> นาที
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
</div>
|
|
27
28
|
|
|
28
29
|
<template #footer="{ meta }">
|
|
29
|
-
<Button type="submit" color="primary" :disabled="!meta.valid" class="w-full">
|
|
30
|
+
<Button type="submit" color="primary" :disabled="!meta.valid || isLoading" class="w-full">
|
|
30
31
|
{{ props.confirmedText }}
|
|
31
32
|
</Button>
|
|
32
33
|
</template>
|
|
@@ -35,12 +36,19 @@
|
|
|
35
36
|
|
|
36
37
|
<script setup>
|
|
37
38
|
import { ref, watch } from "vue";
|
|
39
|
+
import { useNuxtApp } from "nuxt/app";
|
|
40
|
+
import { useApi } from "../../composables/useApi";
|
|
38
41
|
import { useCountDown } from "../../composables/useCountDown";
|
|
39
42
|
const emit = defineEmits(["complete", "close"]);
|
|
40
43
|
const props = defineProps({
|
|
41
44
|
phoneLabel: { type: String, required: false, default: "" },
|
|
42
45
|
phone: { type: String, required: false, default: "" },
|
|
43
46
|
confirmedText: { type: String, required: false, default: "\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19" },
|
|
47
|
+
requestPath: { type: String, required: false },
|
|
48
|
+
requestBody: { type: Object, required: false },
|
|
49
|
+
verifyPath: { type: String, required: false },
|
|
50
|
+
verifyBody: { type: Object, required: false },
|
|
51
|
+
initialExpiredTime: { type: String, required: false },
|
|
44
52
|
name: { type: String, required: false },
|
|
45
53
|
type: { type: String, required: false },
|
|
46
54
|
gap: { type: Number, required: false },
|
|
@@ -49,33 +57,77 @@ const props = defineProps({
|
|
|
49
57
|
placeholder: { type: String, required: false }
|
|
50
58
|
});
|
|
51
59
|
const isOpen = defineModel({ type: Boolean, ...{ default: false } });
|
|
60
|
+
const { $toast } = useNuxtApp();
|
|
61
|
+
const api = useApi();
|
|
52
62
|
const textRef = ref("");
|
|
53
63
|
const valueOTP = ref("");
|
|
54
64
|
const otpError = ref("");
|
|
65
|
+
const isLoading = ref(false);
|
|
55
66
|
const { CountdownTime } = useCountDown();
|
|
56
67
|
const expireAt = ref("");
|
|
57
68
|
const countdown = CountdownTime(expireAt);
|
|
58
|
-
const
|
|
59
|
-
|
|
69
|
+
const handleSendOTP = async () => {
|
|
70
|
+
try {
|
|
71
|
+
isLoading.value = true;
|
|
72
|
+
const path = props.requestPath ?? "/me/phone-otp-request";
|
|
73
|
+
const body = props.requestBody ?? { phone: props.phone };
|
|
74
|
+
if (!props.requestBody && !props.phone) {
|
|
75
|
+
throw new Error("\u0E01\u0E23\u0E38\u0E13\u0E32\u0E23\u0E30\u0E1A\u0E38 phone");
|
|
76
|
+
}
|
|
77
|
+
const response = await api(path, {
|
|
78
|
+
method: "POST",
|
|
79
|
+
body
|
|
80
|
+
});
|
|
81
|
+
if (response?.data?.expired_time) {
|
|
82
|
+
expireAt.value = response.data.expired_time;
|
|
83
|
+
} else {
|
|
84
|
+
expireAt.value = new Date(Date.now() + 5 * 60 * 1e3).toISOString();
|
|
85
|
+
}
|
|
86
|
+
if (response?.data?.ref) {
|
|
87
|
+
textRef.value = response.data.ref;
|
|
88
|
+
}
|
|
89
|
+
} catch (err) {
|
|
90
|
+
const msg = err?.data?.message?.description || err?.data?.message || "\u0E1E\u0E1A\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E43\u0E19\u0E01\u0E32\u0E23\u0E2A\u0E48\u0E07 OTP";
|
|
91
|
+
$toast?.error?.(msg);
|
|
92
|
+
} finally {
|
|
93
|
+
isLoading.value = false;
|
|
94
|
+
}
|
|
60
95
|
};
|
|
61
96
|
const onResend = () => {
|
|
62
97
|
valueOTP.value = "";
|
|
63
98
|
otpError.value = "";
|
|
64
|
-
|
|
99
|
+
handleSendOTP();
|
|
65
100
|
};
|
|
66
|
-
const onVerifyOTP = () => {
|
|
67
|
-
|
|
101
|
+
const onVerifyOTP = async () => {
|
|
102
|
+
try {
|
|
103
|
+
isLoading.value = true;
|
|
104
|
+
const path = props.verifyPath ?? "/me/phone-otp-verify";
|
|
105
|
+
const body = props.verifyBody ? { ...props.verifyBody, code: valueOTP.value } : { code: valueOTP.value, phone: props.phone };
|
|
106
|
+
const response = await api(path, {
|
|
107
|
+
method: "POST",
|
|
108
|
+
body
|
|
109
|
+
});
|
|
68
110
|
otpError.value = "";
|
|
69
|
-
emit("complete", valueOTP.value);
|
|
111
|
+
emit("complete", response?.data || valueOTP.value);
|
|
70
112
|
isOpen.value = false;
|
|
71
|
-
}
|
|
113
|
+
} catch (err) {
|
|
72
114
|
otpError.value = "\u0E23\u0E2B\u0E31\u0E2A\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07";
|
|
115
|
+
} finally {
|
|
116
|
+
isLoading.value = false;
|
|
73
117
|
}
|
|
74
118
|
};
|
|
75
119
|
watch(isOpen, (value) => {
|
|
76
120
|
textRef.value = "";
|
|
77
121
|
valueOTP.value = "";
|
|
78
122
|
otpError.value = "";
|
|
79
|
-
if (value)
|
|
123
|
+
if (value) {
|
|
124
|
+
if (props.initialExpiredTime) {
|
|
125
|
+
expireAt.value = props.initialExpiredTime;
|
|
126
|
+
} else {
|
|
127
|
+
handleSendOTP();
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
expireAt.value = "";
|
|
131
|
+
}
|
|
80
132
|
});
|
|
81
133
|
</script>
|
|
@@ -8,11 +8,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
8
8
|
"update:modelValue": (value: boolean) => any;
|
|
9
9
|
} & {
|
|
10
10
|
close: () => any;
|
|
11
|
-
complete: (
|
|
11
|
+
complete: (data?: any) => any;
|
|
12
12
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
13
13
|
onClose?: (() => any) | undefined;
|
|
14
14
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
15
|
-
onComplete?: ((
|
|
15
|
+
onComplete?: ((data?: any) => any) | undefined;
|
|
16
16
|
}>, {
|
|
17
17
|
phone: string;
|
|
18
18
|
confirmedText: string;
|
|
@@ -12,6 +12,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
12
12
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
13
13
|
onComplete?: ((state: ModalSecureState) => any) | undefined;
|
|
14
14
|
}>, {
|
|
15
|
+
phone: string;
|
|
15
16
|
email: string;
|
|
16
17
|
twoFaEnabled: boolean;
|
|
17
18
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component v-for="modal in modals" :key="modal.key" :is="modal.component" :email="props.email"
|
|
3
|
-
@complete="(data) => handleComplete(modal.key, data)"
|
|
4
|
-
@close="isOpen = false" v-model="modalStates[modal.key]" />
|
|
2
|
+
<component v-for="modal in modals" :key="modal.key" :is="modal.component" :email="props.email" :phone="props.phone"
|
|
3
|
+
mode="secure" @complete="(data) => handleComplete(modal.key, data)"
|
|
4
|
+
:confirmed-text="isLastStep ? '\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19' : '\u0E16\u0E31\u0E14\u0E44\u0E1B'" @close="isOpen = false" v-model="modalStates[modal.key]" />
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup>
|
|
@@ -20,6 +20,7 @@ const emit = defineEmits(["complete"]);
|
|
|
20
20
|
const props = defineProps({
|
|
21
21
|
state: { type: String, required: true },
|
|
22
22
|
email: { type: String, required: false, default: "" },
|
|
23
|
+
phone: { type: String, required: false, default: "" },
|
|
23
24
|
twoFaEnabled: { type: Boolean, required: true, default: false }
|
|
24
25
|
});
|
|
25
26
|
const isOpen = defineModel({ type: Boolean, ...{
|
|
@@ -12,6 +12,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
12
12
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
13
13
|
onComplete?: ((state: ModalSecureState) => any) | undefined;
|
|
14
14
|
}>, {
|
|
15
|
+
phone: string;
|
|
15
16
|
email: string;
|
|
16
17
|
twoFaEnabled: boolean;
|
|
17
18
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<ShadDialog v-model:open="isOpen">
|
|
3
|
-
<ShadDialogContent
|
|
4
|
-
:
|
|
5
|
-
|
|
6
|
-
:no-padding="props.disablePadding"
|
|
7
|
-
:disable-outside-pointer-events="false"
|
|
8
|
-
v-slot="{ meta }"
|
|
9
|
-
@submit="onSubmit"
|
|
10
|
-
@close="onClose"
|
|
11
|
-
>
|
|
3
|
+
<ShadDialogContent :class="props.class" :disabled-close-btn="props.disabledCloseBtn"
|
|
4
|
+
:no-padding="props.disablePadding" :disable-outside-pointer-events="false" v-slot="{ meta }" @submit="onSubmit"
|
|
5
|
+
@close="onClose">
|
|
12
6
|
<Loading :loading="props.loading" :text="props.loadingText" />
|
|
13
7
|
<ShadDialogHeader :class="props.disablePadding ? 'bg-background' : ''">
|
|
14
8
|
<slot name="header">
|
|
@@ -24,12 +18,9 @@
|
|
|
24
18
|
</ShadDialogDescription>
|
|
25
19
|
</slot>
|
|
26
20
|
</ShadDialogHeader>
|
|
27
|
-
<div
|
|
28
|
-
:class="props.contentMaxHeight ? '-mx-6 px-6' : void 0"
|
|
29
|
-
:style="
|
|
21
|
+
<div :class="props.contentMaxHeight ? '-mx-6 px-6' : void 0" :style="
|
|
30
22
|
props.contentMaxHeight ? { maxHeight: `${props.contentMaxHeight}px`, overflowY: 'auto' } : void 0
|
|
31
|
-
"
|
|
32
|
-
>
|
|
23
|
+
">
|
|
33
24
|
<slot name="default" :meta="meta" />
|
|
34
25
|
</div>
|
|
35
26
|
<ShadDialogFooter v-if="$slots.footer">
|
package/package.json
CHANGED
|
File without changes
|