Skip to content

Commit b8f2900

Browse files
refactor: remove unused imports
1 parent fcdb024 commit b8f2900

5 files changed

Lines changed: 13 additions & 14 deletions

File tree

packages/user/src/components/Login/LoginWrapper.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useTranslation } from "@prefabs.tech/react-i18n";
22
import { Message } from "@prefabs.tech/react-ui";
33
import { FC, useState } from "react";
4-
import { toast } from "react-toastify";
54

65
import { DEFAULT_PATHS } from "@/constants";
76
import { login } from "@/supertokens";

packages/user/src/components/Signup/SignupWrapper.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useTranslation } from "@prefabs.tech/react-i18n";
22
import { Message } from "@prefabs.tech/react-ui";
33
import React, { useState } from "react";
4-
import { toast } from "react-toastify";
54

65
import { DEFAULT_PATHS } from "@/constants";
76
import { signup } from "@/supertokens";

packages/user/src/hooks/useUserNavigationMenu.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useTranslation } from "@prefabs.tech/react-i18n";
2-
import { toast } from "react-toastify";
32

43
import { DEFAULT_PATHS } from "@/constants";
54
import { logout } from "@/supertokens";

packages/user/src/views/ResetPassword.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { useState } from "react";
44
import { useNavigate } from "react-router-dom";
55
import { toast } from "react-toastify";
66

7-
import { useConfig } from "../hooks";
8-
97
import { ResetPasswordForm } from "@/components";
108
import { DEFAULT_PATHS } from "@/constants";
119
import { resetPassword } from "@/supertokens";
1210

11+
import { useConfig } from "../hooks";
12+
1313
export const ResetPassword = ({ centered = true }: { centered?: boolean }) => {
1414
const { t } = useTranslation("user");
1515
const config = useConfig();

packages/user/src/views/SignupFirstUser.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useTranslation } from "@prefabs.tech/react-i18n";
22
import { AuthPage, Message } from "@prefabs.tech/react-ui";
33
import { useEffect, useState } from "react";
44
import { useNavigate } from "react-router-dom";
5-
import { toast } from "react-toastify";
65

76
import { getIsFirstUser, signUpFirstUser } from "@/api/user";
87
import { DEFAULT_PATHS } from "@/constants";
@@ -23,7 +22,7 @@ export const SignUpFirstUser = ({
2322
const { setUser } = useUser();
2423

2524
const [loading, setLoading] = useState(false);
26-
const [isError, setIsError] = useState(false);
25+
const [error, setError] = useState<"loginError" | "signupError" | null>(null);
2726

2827
const [signUpFirstUserLoading, setSignUpFirstUserLoading] = useState(false);
2928
const [loginLoading, setLoginLoading] = useState(false);
@@ -38,7 +37,7 @@ export const SignUpFirstUser = ({
3837
}
3938
})
4039
.catch(() => {
41-
setIsError(true);
40+
setError("signupError");
4241
})
4342
.finally(() => {
4443
setLoading(false);
@@ -59,12 +58,10 @@ export const SignUpFirstUser = ({
5958
.then((result: any) => {
6059
if (result?.user) {
6160
setUser(result.user);
62-
toast.success(`${t("login.messages.success")}`);
6361
}
6462
})
6563
.catch(() => {
6664
setLoginLoading(false);
67-
toast.error(t("firstUser.login.messages.error"));
6865
navigate(config.customPaths?.login || DEFAULT_PATHS.LOGIN);
6966
})
7067
.finally(() => {
@@ -73,19 +70,24 @@ export const SignUpFirstUser = ({
7370
})
7471
.catch(() => {
7572
setSignUpFirstUserLoading(false);
76-
setIsError(true);
73+
setError("signupError");
7774
});
7875
};
7976

77+
const message =
78+
error === "signupError"
79+
? t("firstUser.signup.messages.error")
80+
: t("firstUser.login.messages.error");
81+
8082
const renderPageContent = () => {
8183
return (
8284
<>
83-
{isError && (
85+
{error && (
8486
<Message
8587
enableClose={true}
86-
message={t("firstUser.signup.messages.error")}
88+
message={message}
8789
onClose={() => {
88-
setIsError(false);
90+
setError(null);
8991
}}
9092
severity="danger"
9193
/>

0 commit comments

Comments
 (0)