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); }, } })