-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: vterentev <vaterentev@icloud.com>
- Loading branch information
Showing
32 changed files
with
288 additions
and
595 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export enum EntityState { | ||
ENTITY_STATE_CREATED = 0, // Профиль создан | ||
ENTITY_STATE_LOADING = 1, // Профиль загружается | ||
ENTITY_STATE_ACTIVE = 2, // Профиль активен | ||
ENTITY_STATE_INITIALIZE = 3, // Подготовка профиля | ||
ENTITY_STATE_ERROR = 4, // Ошибка при работе с профилем | ||
|
||
ENTITY_STATE_DISABLED = 99999, // Профиль выключен | ||
} | ||
|
||
export enum EntityStateOption { | ||
"OPTION_0" = "Создан", // Профиль создан | ||
"OPTION_1" = "Загружается", // Профиль загружается | ||
"OPTION_2" = "Активен", // Профиль активен | ||
"OPTION_3" = "Подготовка", // Подготовка профиля | ||
"OPTION_4" = "Ошибка", // Ошибка при работе с профилем | ||
"OPTION_99999" = "Недоступен", // Профиль выключен | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
export * from "./analytics-interval"; | ||
export * from "./auth"; | ||
export * from "./entityState"; | ||
export * from "./entity-state"; | ||
export * from "./integration"; | ||
export * from "./notificationType"; | ||
export * from "./notification-type"; | ||
export * from "./project-type"; | ||
export * from "./storages"; | ||
export * from "./systems"; | ||
export * from "./texture-protocol"; | ||
export * from "./textures"; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,53 @@ | ||
import { useRouter } from "next/navigation"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { isAxiosError } from "axios"; | ||
import { toast } from "sonner"; | ||
|
||
import { TPostSignInRequest, TPostSignUpRequest } from "@/shared/api/contracts"; | ||
import { DASHBOARD_PAGES } from "@/shared/routes"; | ||
import { authService } from "@/shared/services"; | ||
import { useToast } from "@/shared/ui/use-toast"; | ||
import { isAxiosError } from "@/shared/lib/isAxiosError/isAxiosError"; | ||
|
||
export const useRegistration = () => { | ||
const route = useRouter(); | ||
const { toast } = useToast(); | ||
|
||
return useMutation({ | ||
mutationKey: ["signup"], | ||
mutationFn: (data: TPostSignUpRequest) => authService.signUp(data), | ||
onSuccess: () => { | ||
toast({ | ||
title: "Успешная регистрация", | ||
toast.success("Успешная регистрация", { | ||
description: "Добро пожаловать в платформу", | ||
}); | ||
|
||
route.push(DASHBOARD_PAGES.PROFILES); | ||
}, | ||
onError: (error) => { | ||
if (isAxiosError(error)) { | ||
toast({ | ||
variant: "destructive", | ||
title: (error.response && error.response.data.message) || "Ошибка!", | ||
description: | ||
(error.response && error.response.data.errors?.[0]) || | ||
"Ошибка сервиса авторизации. Обратитесь к администратору платформы", | ||
}); | ||
} | ||
isAxiosError({ | ||
toast, | ||
error, | ||
customDescription: "Ошибка сервиса авторизации. Обратитесь к администратору платформы", | ||
}); | ||
}, | ||
}); | ||
}; | ||
|
||
export const useLogin = () => { | ||
const route = useRouter(); | ||
const { toast } = useToast(); | ||
|
||
return useMutation({ | ||
mutationKey: ["signin"], | ||
mutationFn: (data: TPostSignInRequest) => authService.signIn(data), | ||
onSuccess: () => { | ||
toast({ | ||
title: "Успешная авторизация", | ||
toast.success("Успешная авторизация", { | ||
description: "Добро пожаловать в платформу", | ||
}); | ||
route.push(DASHBOARD_PAGES.PROFILES); | ||
}, | ||
onError: (error) => { | ||
if (isAxiosError(error)) { | ||
toast({ | ||
variant: "destructive", | ||
title: (error.response && error.response.data.message) || "Ошибка!", | ||
description: | ||
(error.response && error.response.data.errors?.[0]) || | ||
"Ошибка сервиса авторизации. Обратитесь к администратору платформы", | ||
}); | ||
} | ||
isAxiosError({ | ||
toast, | ||
error, | ||
customDescription: "Ошибка сервиса авторизации. Обратитесь к администратору платформы", | ||
}); | ||
}, | ||
}); | ||
}; |
Oops, something went wrong.