Files
mohadese namavar ec84dfd222 init git
2024-06-16 00:22:14 +04:30

46 lines
1.3 KiB
JavaScript

export const useOtpCodeStore = defineStore('otp-code', {
state: () => {
return {
number: null,
code: null,
type: null,
verify: false
}
},
actions: {
async withoutToken(body) {
const method = 'post'
const result = await useFetch(`/api/otp/numberwithouttoken`, { method, body });
if (result.status.value == 'success')
this.number = body.number
return result;
},
async forgotPassword(body) {
const method = 'post'
const result = await useFetch(`/api/otp/forgotpassword`, { method, body });
if (result.status.value == 'success')
this.number = body.number
return result;
},
async check(code) {
const method = 'post'
const body = { phoneNumber: this.number, otp: parseInt(code) }
const result = await useFetch(`/api/otp/numberCheck`, { method, body });
if (result.status.value == 'success') {
this.verify = true
this.code = body.otp
}
return result;
},
async send(type, form) {
this.type = type
this[type] = form[type]
return await axios.post(`/${type}`, form);
},
}
})