|
@@ -4,7 +4,7 @@ import { api } from "@/api"
|
|
import router from "@/router"
|
|
import router from "@/router"
|
|
import { getLocalToken, removeLocalToken, saveLocalToken } from "@/utils";
|
|
import { getLocalToken, removeLocalToken, saveLocalToken } from "@/utils";
|
|
import type { AppNotification } from '@/interfaces';
|
|
import type { AppNotification } from '@/interfaces';
|
|
-import type { IUserProfile, IUserProfileCreate, IUserProfileUpdate, MainState, Video} from '@/interfaces';
|
|
|
|
|
|
+import type { IUserProfile, IUserProfileCreate, IUserProfileUpdate, MainState, Video } from '@/interfaces';
|
|
import i18n from '@/plugins/i18n'
|
|
import i18n from '@/plugins/i18n'
|
|
|
|
|
|
const defaultState: MainState = {
|
|
const defaultState: MainState = {
|
|
@@ -84,7 +84,7 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
},
|
|
},
|
|
async updateUserProfile(payload: IUserProfileUpdate) {
|
|
async updateUserProfile(payload: IUserProfileUpdate) {
|
|
try {
|
|
try {
|
|
- const loadingNotification = { content: "saving", showProgress: true };
|
|
|
|
|
|
+ const loadingNotification = { content: i18n.global.t("saving"), showProgress: true };
|
|
await this.addNotification(loadingNotification);
|
|
await this.addNotification(loadingNotification);
|
|
const response = (
|
|
const response = (
|
|
await Promise.all([
|
|
await Promise.all([
|
|
@@ -189,54 +189,54 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
await this.checkApiError(error);
|
|
await this.checkApiError(error);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- async passwordRecovery(username: string ) {
|
|
|
|
- const loadingNotification = {
|
|
|
|
- content: "Sending password recovery email",
|
|
|
|
- showProgress: true,
|
|
|
|
- };
|
|
|
|
- try {
|
|
|
|
- this.addNotification(loadingNotification);
|
|
|
|
- await Promise.all([
|
|
|
|
- api.passwordRecovery(username),
|
|
|
|
- await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
|
|
|
|
- ]);
|
|
|
|
- this.removeNotification(loadingNotification);
|
|
|
|
- this.addNotification({
|
|
|
|
- content: "Password recovery email sent",
|
|
|
|
- color: "success",
|
|
|
|
- });
|
|
|
|
- await this.logOut();
|
|
|
|
- } catch (error) {
|
|
|
|
- this.removeNotification(loadingNotification);
|
|
|
|
- this.addNotification({ color: "error", content: "Incorrect username" });
|
|
|
|
- }
|
|
|
|
|
|
+ async passwordRecovery(username: string) {
|
|
|
|
+ const loadingNotification = {
|
|
|
|
+ content: i18n.global.t("sendingEmail"),
|
|
|
|
+ showProgress: true,
|
|
|
|
+ };
|
|
|
|
+ try {
|
|
|
|
+ this.addNotification(loadingNotification);
|
|
|
|
+ await Promise.all([
|
|
|
|
+ api.passwordRecovery(username),
|
|
|
|
+ await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
|
|
|
|
+ ]);
|
|
|
|
+ this.removeNotification(loadingNotification);
|
|
|
|
+ this.addNotification({
|
|
|
|
+ content: i18n.global.t("passwordMailSent"),
|
|
|
|
+ color: "success",
|
|
|
|
+ });
|
|
|
|
+ await this.logOut();
|
|
|
|
+ } catch (error) {
|
|
|
|
+ this.removeNotification(loadingNotification);
|
|
|
|
+ this.addNotification({ color: "error", content: i18n.global.t("incorrectUsername") });
|
|
|
|
+ }
|
|
},
|
|
},
|
|
async resetPassword(password: string, token: string) {
|
|
async resetPassword(password: string, token: string) {
|
|
- const loadingNotification = { content: "Resetting password", showProgress: true };
|
|
|
|
- try {
|
|
|
|
- this.addNotification(loadingNotification);
|
|
|
|
- await Promise.all([
|
|
|
|
- api.resetPassword(token, password),
|
|
|
|
- await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
|
|
|
|
- ]);
|
|
|
|
- this.removeNotification(loadingNotification);
|
|
|
|
- this.addNotification( {
|
|
|
|
- content: "Password successfully reset",
|
|
|
|
- color: "success",
|
|
|
|
- });
|
|
|
|
- await this.logOut();
|
|
|
|
- } catch (error) {
|
|
|
|
- this.removeNotification(loadingNotification);
|
|
|
|
- this.addNotification({
|
|
|
|
- color: "error",
|
|
|
|
- content: "Error resetting password",
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ const loadingNotification = { content: "Resetting password", showProgress: true };
|
|
|
|
+ try {
|
|
|
|
+ this.addNotification(loadingNotification);
|
|
|
|
+ await Promise.all([
|
|
|
|
+ api.resetPassword(token, password),
|
|
|
|
+ await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
|
|
|
|
+ ]);
|
|
|
|
+ this.removeNotification(loadingNotification);
|
|
|
|
+ this.addNotification({
|
|
|
|
+ content: "Password successfully reset",
|
|
|
|
+ color: "success",
|
|
|
|
+ });
|
|
|
|
+ await this.logOut();
|
|
|
|
+ } catch (error) {
|
|
|
|
+ this.removeNotification(loadingNotification);
|
|
|
|
+ this.addNotification({
|
|
|
|
+ color: "error",
|
|
|
|
+ content: "Error resetting password",
|
|
|
|
+ });
|
|
|
|
+ }
|
|
},
|
|
},
|
|
async uploadPlot(title: string, file: File) {
|
|
async uploadPlot(title: string, file: File) {
|
|
const mainStore = useMainStore();
|
|
const mainStore = useMainStore();
|
|
try {
|
|
try {
|
|
- const loadingNotification = { content: "sending", showProgress: true };
|
|
|
|
|
|
+ const loadingNotification = { content: i18n.global.t("sending"), showProgress: true };
|
|
mainStore.addNotification(loadingNotification);
|
|
mainStore.addNotification(loadingNotification);
|
|
const response = (
|
|
const response = (
|
|
await Promise.all([
|
|
await Promise.all([
|
|
@@ -246,8 +246,8 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
);
|
|
);
|
|
mainStore.removeNotification(loadingNotification);
|
|
mainStore.removeNotification(loadingNotification);
|
|
mainStore.addNotification({
|
|
mainStore.addNotification({
|
|
- content: "File received",
|
|
|
|
- color: "success",
|
|
|
|
|
|
+ content: i18n.global.t("fileReceived"),
|
|
|
|
+ color: "success",
|
|
})
|
|
})
|
|
} catch (error) {
|
|
} catch (error) {
|
|
await mainStore.checkApiError(error);
|
|
await mainStore.checkApiError(error);
|
|
@@ -264,7 +264,7 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
await mainStore.checkApiError(error);
|
|
await mainStore.checkApiError(error);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- }
|
|
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|