Skip to content

Commit 7c4946f

Browse files
authored
Fix register to keep the email on component state (#33)
* fix Tarhche and dashboard persian title in all pages * store email in state and reload in form filed on component rerender for registration
1 parent 7a57f45 commit 7c4946f

File tree

11 files changed

+20
-12
lines changed

11 files changed

+20
-12
lines changed

src/app/(auth)/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {Container} from "@mantine/core";
44

55
export const metadata: Metadata = {
66
title: {
7-
default: "احراز هویت | طرحچه",
8-
template: "%s | احراز هویت | طرحچه",
7+
default: "احراز هویت | طرح‌چه",
8+
template: "%s | احراز هویت | طرح‌چه",
99
},
1010
};
1111

src/app/(dashboard)/dashboard/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {APP_PATHS} from "@/lib/app-paths";
77

88
export const metadata: Metadata = {
99
title: {
10-
template: `%s | ${buildTitle("داشبرد", {withBrand: true})}`,
11-
default: buildTitle("داشبرد"),
10+
template: `%s | ${buildTitle("پنل کاربری", {withBrand: true})}`,
11+
default: buildTitle("پنل کاربری"),
1212
},
1313
};
1414

src/app/(dashboard)/dashboard/not-found.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {NotFound} from "@/components/not-found";
33
function NotFoundPage() {
44
return (
55
<NotFound
6-
anchorText="داشبرد"
6+
anchorText="پنل کاربری"
77
title="این صفحه وجود ندارد"
88
anchorLink="/dashboard"
99
/>

src/app/(dashboard)/dashboard/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Title} from "@mantine/core";
33
function DashboardPage() {
44
return (
55
<div>
6-
<Title>داشبرد</Title>
6+
<Title>پنل کاربری</Title>
77
</div>
88
);
99
}

src/app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import "./globals.css";
88

99
export const metadata: Metadata = {
1010
title: {
11-
default: "طرحچه",
12-
template: "%s | طرحچه",
11+
default: "طرح‌چه",
12+
template: "%s | طرح‌چه",
1313
},
1414
description: "طرح‌چه",
1515
};

src/constants/strings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const BRAND_NAME = "طرحچه";
1+
export const BRAND_NAME = "طرح‌چه";
22

33
export const ACCESS_TOKEN_COOKIE_NAME = "access_token";
44
export const REFRESH_TOKEN_COOKIE_NAME = "refresh_token";

src/features/auth/actions/register-user.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ import {registerUser as signUpUser} from "@/dal/public/auth";
55
type SuccessRegisterState = {
66
success: true;
77
message: string;
8+
email : string;
89
};
910

1011
type FailureRegisterState = {
1112
success: false;
1213
errorMessage: string;
14+
email : string;
1315
};
1416

1517
type UntouchedState = {
1618
success: undefined;
19+
email : string;
1720
};
1821

1922
type State = SuccessRegisterState | FailureRegisterState | UntouchedState;
@@ -31,6 +34,7 @@ export async function registerUser(
3134
return {
3235
success: true,
3336
message: "",
37+
email: email,
3438
};
3539
} catch (e) {
3640
if (e instanceof DALDriverError) {
@@ -39,12 +43,14 @@ export async function registerUser(
3943
return {
4044
success: false,
4145
errorMessage: errors.identity,
46+
email: email ?? "",
4247
};
4348
}
4449
}
4550
}
4651
return {
4752
success: false,
4853
errorMessage: "خطایی ناشناخته اتفاق افتاد لطفا دوباره تلاش نمایید",
54+
email: email ?? "",
4955
};
5056
}

src/features/auth/components/register-form.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {registerUser} from "../actions/register-user";
1717
export function RegisterForm() {
1818
const [state, dispatch, isPending] = useActionState(registerUser, {
1919
success: undefined,
20+
email: undefined,
2021
});
2122

2223
const renderFeedbackAlert = () => {
@@ -79,6 +80,7 @@ export function RegisterForm() {
7980
mt={"md"}
8081
required
8182
disabled={state.success}
83+
defaultValue={state.email}
8284
/>
8385
{renderFeedbackAlert()}
8486
{(state.success === false || state.success === undefined) && (

src/features/breadcrumbs/components/breadcrumbs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function DashboardBreadcrumbs({crumbs}: Props) {
1313
<Breadcrumbs
1414
crumbs={[
1515
{
16-
label: "داشبرد",
16+
label: "پنل کاربری",
1717
href: `${APP_PATHS.dashboard.index}`,
1818
},
1919
...crumbs,

src/features/dashboard-layout/components/layout-shell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function LayoutShell({children}: Props) {
4848
size="sm"
4949
/>
5050
<Text component={Link} href={"/"}>
51-
طرحچه
51+
طرح‌چه
5252
</Text>
5353
</Group>
5454
<Group h="100%" align="center">

0 commit comments

Comments
 (0)