complete Complete User Request Submission section RAD-1

This commit is contained in:
2026-01-03 19:14:30 +03:30
commit 7137ec5792
393 changed files with 152602 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
import { defineStore } from 'pinia'
import axios from "axios";
import { Inertia } from '@inertiajs/inertia'
export const useAuthStore = defineStore('AuthStore', {
state: () => ({
loginForm:{
email : '',
password : '',
remember : false,
},
registerForm:{
name : '',
email : '',
password : '',
password_confirmation : '',
},
loaderLoginForm : false,
loaderRegisterForm : false,
errorsLoginForm : [],
errorsRegisterForm : [],
}),
actions: {
login() {
this.loaderLoginForm = true;
axios.post('/admin/auth/login' , this.loginForm).then(res => {
this.resetLoginForm();
this.loaderLoginForm = false;
this.errorsLoginForm = [];
Inertia.get('/');
}).catch(error => {
this.loaderLoginForm = false;
this.errorsLoginForm = error.response.data?.errors ?? [];
});
},
register(){
this.loaderRegisterForm = true;
axios.post('/admin/auth/register' , this.registerForm).then(res => {
this.resetRegisterForm();
this.loaderRegisterForm = false;
this.errorsRegisterForm = [];
Inertia.get('/');
}).catch(error => {
this.loaderRegisterForm = false;
this.errorsRegisterForm = error.response.data?.errors ?? [];
});
},
resetLoginForm() {
this.loginForm = {
email : '',
password : '',
remember : false,
}
},
resetRegisterForm() {
this.registerForm = {
name : '',
email : '',
password : '',
password_confirmation : '',
}
},
}
})