Skip to content

Commit 7da89a8

Browse files
committed
Merge branch 'main' into DIAL-11-Add-DB-channeltype-channel
2 parents cbeb52b + 73a92f3 commit 7da89a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2378
-338
lines changed

client/package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
"embla-carousel-react": "^8.0.0-rc23",
5353
"i18next": "^23.9.0",
5454
"i18next-browser-languagedetector": "^7.2.0",
55+
"i18next-chained-backend": "^4.6.2",
5556
"i18next-http-backend": "^2.4.3",
57+
"i18next-localstorage-backend": "^4.2.0",
5658
"lucide-react": "^0.335.0",
5759
"next-themes": "^0.2.1",
5860
"react": "^18.2.0",

client/public/locales/en/translation.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

client/public/locales/vi/translation.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

client/src/apis/auth.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { ENDPOINTS } from '@/constants';
2+
import http_client from '@/lib/http-client';
3+
import { TForgotPass } from '@/lib/schema/forgot-pass';
4+
import { TLogin } from '@/lib/schema/login';
5+
import { TRegister } from '@/lib/schema/register';
6+
import { TSetPass } from '@/lib/schema/set-pass';
7+
import { TBaseResponse, TToken } from '@/types/share';
8+
9+
class Auth {
10+
login(data: TLogin): Promise<TBaseResponse<TToken>> {
11+
return http_client.post(ENDPOINTS.AUTH.LOGIN, data);
12+
}
13+
// TODO: SHOULD BE CHANGE TYPE ANY TO TYPE USER
14+
register(data: TRegister): Promise<TBaseResponse<any>> {
15+
return http_client.post(ENDPOINTS.AUTH.REGISTER, data);
16+
}
17+
18+
forgotPassword(data: TForgotPass): Promise<TBaseResponse<null>> {
19+
return http_client.post(ENDPOINTS.AUTH.FORGOT_PASSWORD, data);
20+
}
21+
22+
setPassword(data: TSetPass): Promise<TBaseResponse<null>> {
23+
return http_client.post(ENDPOINTS.AUTH.RESET_PASSWORD, data);
24+
}
25+
26+
// TODO: SHOULD BE CHANGE TYPE ANY TO TYPE USER
27+
getCurrentUser(): Promise<TBaseResponse<any>> {
28+
return http_client.get(ENDPOINTS.AUTH.CURRENT_USER);
29+
}
30+
31+
refreshToken(): Promise<TBaseResponse<TToken>> {
32+
return http_client.post(ENDPOINTS.AUTH.REFRESH_TOKEN);
33+
}
34+
}
35+
36+
export const auth = new Auth();

client/src/assets/login-banner.png

72 KB
Loading

client/src/assets/logo.png

21.5 KB
Loading

client/src/components/btn-lang.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { lngs } from '@/i18n';
2+
import { ELang } from '@/types/share';
3+
import { useTranslation } from 'react-i18next';
4+
import { Button } from './ui';
5+
6+
export const ButtonLang = () => {
7+
const { i18n } = useTranslation();
8+
9+
return (
10+
<Button
11+
variant="outline"
12+
size="sm"
13+
onClick={() => {
14+
i18n.changeLanguage(
15+
i18n.language === ELang.EN ? ELang.VI : ELang.EN
16+
);
17+
}}
18+
className="min-w-24"
19+
>
20+
{lngs[i18n.language as ELang]}
21+
</Button>
22+
);
23+
};
24+
25+
export default ButtonLang;
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { useErrorsLngChange } from '@/hooks/use-errors-lng-change';
2+
import { TForgotPass, useForgotPassSchema } from '@/lib/schema/forgot-pass';
3+
import { zodResolver } from '@hookform/resolvers/zod';
4+
import { useForm } from 'react-hook-form';
5+
import { useTranslation } from 'react-i18next';
6+
import {
7+
Button,
8+
Form,
9+
FormControl,
10+
FormField,
11+
FormItem,
12+
FormLabel,
13+
FormMessage,
14+
Input,
15+
} from '../ui';
16+
17+
type Props = {
18+
loading?: boolean;
19+
onSubmit?: (data: TForgotPass) => void;
20+
};
21+
22+
export const ForgotPassForm = ({ loading, onSubmit }: Props) => {
23+
const { t } = useTranslation(['set_pass', 'forms']);
24+
25+
const schema = useForgotPassSchema();
26+
27+
const form = useForm<TForgotPass>({
28+
resolver: zodResolver(schema),
29+
mode: 'onChange',
30+
});
31+
32+
const handleSubmit = (data: TForgotPass) => {
33+
onSubmit?.(data);
34+
};
35+
36+
useErrorsLngChange(form);
37+
38+
return (
39+
<Form {...form}>
40+
<form className="space-y-3" onSubmit={form.handleSubmit(handleSubmit)}>
41+
<FormField
42+
control={form.control}
43+
name="email"
44+
render={({ field }) => {
45+
return (
46+
<FormItem>
47+
<FormLabel required>
48+
{t('email.label', {
49+
ns: 'forms',
50+
})}
51+
</FormLabel>
52+
<FormControl>
53+
<Input
54+
{...field}
55+
placeholder={t('email.placeholder', {
56+
ns: 'forms',
57+
})}
58+
/>
59+
</FormControl>
60+
<FormMessage />
61+
</FormItem>
62+
);
63+
}}
64+
/>
65+
<Button className="w-full" type="submit" loading={loading}>
66+
{t('btn_submit', {
67+
ns: 'set_pass',
68+
})}
69+
</Button>
70+
</form>
71+
</Form>
72+
);
73+
};
74+
75+
export default ForgotPassForm;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './forgot-pass';
2+
export * from './login';
3+
export * from './register';
4+
export * from './set-pass';

0 commit comments

Comments
 (0)