|
@@ -3,7 +3,7 @@ import { defineStore } from "pinia";
|
|
|
import { api } from "@/api"
|
|
|
import router from "@/router"
|
|
|
import { getLocalToken, removeLocalToken, saveLocalToken } from "@/utils";
|
|
|
-import type { IUserProfile, IUserProfileRegister, IUserProfileUpdate } from '@/interfaces';
|
|
|
+import type { IUserProfile, IUserProfileCreate, IUserProfileUpdate } from '@/interfaces';
|
|
|
|
|
|
export interface AppNotification {
|
|
|
content: string;
|
|
@@ -93,13 +93,13 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
|
await this.checkApiError(error);
|
|
|
}
|
|
|
},
|
|
|
- async updateUserProfile(payload: IUserProfileUpdate) {
|
|
|
+ async updateUserProfile(user: IUserProfileUpdate) {
|
|
|
try {
|
|
|
const loadingNotification = { content: "saving", showProgress: true };
|
|
|
await this.addNotification(loadingNotification);
|
|
|
const response = (
|
|
|
await Promise.all([
|
|
|
- api.updateMe(this.token, payload),
|
|
|
+ api.updateMe(this.token, user),
|
|
|
await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
|
|
|
])
|
|
|
)[0];
|
|
@@ -174,7 +174,7 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
|
}, payload.timeout);
|
|
|
});
|
|
|
},
|
|
|
- async register(payload: IUserProfileRegister) {
|
|
|
+ async register(user: IUserProfileCreate) {
|
|
|
const loadingNotification = {
|
|
|
content: "Sgining up...",
|
|
|
showProgress: true,
|
|
@@ -183,7 +183,7 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
|
this.addNotification(loadingNotification);
|
|
|
const response = (
|
|
|
await Promise.all([
|
|
|
- api.registerUser(payload),
|
|
|
+ api.registerUser(user),
|
|
|
await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
|
|
|
])
|
|
|
)[0];
|
|
@@ -196,7 +196,7 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
|
await this.checkApiError(error);
|
|
|
}
|
|
|
},
|
|
|
- async passwordRecovery(payload: {username: string }) {
|
|
|
+ async passwordRecovery(email: string) {
|
|
|
const loadingNotification = {
|
|
|
content: "Sending password recovery email",
|
|
|
showProgress: true,
|
|
@@ -204,7 +204,7 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
|
try {
|
|
|
this.addNotification(loadingNotification);
|
|
|
await Promise.all([
|
|
|
- api.passwordRecovery(payload.username),
|
|
|
+ api.passwordRecovery(email),
|
|
|
await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
|
|
|
]);
|
|
|
this.removeNotification(loadingNotification);
|
|
@@ -218,12 +218,12 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
|
this.addNotification({ color: "error", content: "Incorrect username" });
|
|
|
}
|
|
|
},
|
|
|
- async resetPassword(payload: {password: string; token: string }) {
|
|
|
+ async resetPassword(token: string, password: string ) {
|
|
|
const loadingNotification = { content: "Resetting password", showProgress: true };
|
|
|
try {
|
|
|
this.addNotification(loadingNotification);
|
|
|
await Promise.all([
|
|
|
- api.resetPassword(payload.password, payload.token),
|
|
|
+ api.resetPassword(token, password),
|
|
|
await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
|
|
|
]);
|
|
|
this.removeNotification(loadingNotification);
|