Skip to content

Commit 54b688c

Browse files
authored
[HUMAN App] refactor: reset password services (#3180)
1 parent 950bf8a commit 54b688c

12 files changed

Lines changed: 53 additions & 44 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './reset-password';

packages/apps/human-app/frontend/src/modules/worker/services/reset-password.ts renamed to packages/apps/human-app/frontend/src/modules/worker/reset-password/hooks/reset-password.ts

File renamed without changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './reset-password-success.page';
2+
export * from './reset-password.page';

packages/apps/human-app/frontend/src/modules/worker/views/reset-password/reset-password-success.page.tsx renamed to packages/apps/human-app/frontend/src/modules/worker/reset-password/reset-password-success.page.tsx

File renamed without changes.

packages/apps/human-app/frontend/src/modules/worker/views/reset-password/reset-password.page.tsx renamed to packages/apps/human-app/frontend/src/modules/worker/reset-password/reset-password.page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ import queryString from 'query-string';
1010
import { Button } from '@/shared/components/ui/button';
1111
import { Password } from '@/shared/components/data-entry/password/password';
1212
import { PageCard } from '@/shared/components/ui/page-card';
13-
import type { ResetPasswordDto } from '@/modules/worker/services/reset-password';
14-
import {
15-
resetPasswordDtoSchema,
16-
useResetPasswordMutation,
17-
} from '@/modules/worker/services/reset-password';
1813
import { Alert } from '@/shared/components/ui/alert';
1914
import { getErrorMessageForError } from '@/shared/errors';
2015
import { routerPaths } from '@/router/router-paths';
2116
import { HCaptchaForm } from '@/shared/components/hcaptcha';
2217
import { useResetMutationErrors } from '@/shared/hooks/use-reset-mutation-errors';
18+
import {
19+
type ResetPasswordDto,
20+
resetPasswordDtoSchema,
21+
useResetPasswordMutation,
22+
} from './hooks';
2323

2424
export function ResetPasswordWorkerPage() {
2525
const location = useLocation();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './send-reset-link';

packages/apps/human-app/frontend/src/modules/worker/services/send-reset-link.ts renamed to packages/apps/human-app/frontend/src/modules/worker/send-reset-link/hooks/send-reset-link.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,10 @@
1-
/* eslint-disable camelcase -- ... */
21
import { z } from 'zod';
32
import { useMutation, useQueryClient } from '@tanstack/react-query';
43
import { useNavigate } from 'react-router-dom';
5-
import { t } from 'i18next';
64
import { apiClient } from '@/api/api-client';
75
import { apiPaths } from '@/api/api-paths';
86
import { routerPaths } from '@/router/router-paths';
9-
10-
export const sendResetLinkEmailDtoSchema = z.object({
11-
email: z
12-
.string()
13-
.min(1, t('worker.sendResetLinkForm.noEmailError'))
14-
.email(t('worker.sendResetLinkForm.invalidEmailError')),
15-
});
16-
17-
export type SendResetLinkEmail = z.infer<typeof sendResetLinkEmailDtoSchema>;
18-
19-
export const sendResetLinkHcaptchaDtoSchema = z.object({
20-
h_captcha_token: z.string().min(1, t('validation.captcha')).default('token'),
21-
});
22-
23-
export type SendResetLinkHcaptcha = z.infer<
24-
typeof sendResetLinkHcaptchaDtoSchema
25-
>;
26-
27-
export const sendResetLinkDtoSchema = sendResetLinkEmailDtoSchema.merge(
28-
sendResetLinkHcaptchaDtoSchema
29-
);
30-
31-
export type SendResetLinkDto = SendResetLinkEmail & SendResetLinkHcaptcha;
7+
import { type SendResetLinkDto } from '../schemas';
328

339
const SendResetLinkSuccessResponseSchema = z.unknown();
3410

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './send-reset-link-success.page';
2+
export * from './send-reset-link.page';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { t } from 'i18next';
2+
import { z } from 'zod';
3+
4+
const sendResetLinkEmailDtoSchema = z.object({
5+
email: z
6+
.string()
7+
.min(1, t('worker.sendResetLinkForm.noEmailError'))
8+
.email(t('worker.sendResetLinkForm.invalidEmailError')),
9+
});
10+
11+
type SendResetLinkEmail = z.infer<typeof sendResetLinkEmailDtoSchema>;
12+
13+
export const sendResetLinkHcaptchaDtoSchema = z.object({
14+
// eslint-disable-next-line camelcase
15+
h_captcha_token: z.string().min(1, t('validation.captcha')).default('token'),
16+
});
17+
18+
export type SendResetLinkHcaptcha = z.infer<
19+
typeof sendResetLinkHcaptchaDtoSchema
20+
>;
21+
22+
export const sendResetLinkDtoSchema = sendResetLinkEmailDtoSchema.merge(
23+
sendResetLinkHcaptchaDtoSchema
24+
);
25+
26+
export type SendResetLinkDto = SendResetLinkEmail & SendResetLinkHcaptcha;

packages/apps/human-app/frontend/src/modules/worker/views/send-reset-link/send-reset-link-success.page.tsx renamed to packages/apps/human-app/frontend/src/modules/worker/send-reset-link/send-reset-link-success.page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import { PageCard } from '@/shared/components/ui/page-card';
88
import { Button } from '@/shared/components/ui/button';
99
import { useLocationState } from '@/modules/worker/hooks/use-location-state';
1010
import { env } from '@/shared/env';
11-
import type { SendResetLinkHcaptcha } from '@/modules/worker/services/send-reset-link';
12-
import {
13-
sendResetLinkHcaptchaDtoSchema,
14-
useSendResetLinkMutation,
15-
} from '@/modules/worker/services/send-reset-link';
1611
import { Alert } from '@/shared/components/ui/alert';
1712
import { getErrorMessageForError } from '@/shared/errors';
1813
import { HCaptchaForm } from '@/shared/components/hcaptcha';
1914
import { MailTo } from '@/shared/components/ui/mail-to';
2015
import { useResetMutationErrors } from '@/shared/hooks/use-reset-mutation-errors';
2116
import { useColorMode } from '@/shared/contexts/color-mode';
2217
import { onlyDarkModeColor } from '@/shared/styles/dark-color-palette';
18+
import { useSendResetLinkMutation } from './hooks';
19+
import {
20+
sendResetLinkHcaptchaDtoSchema,
21+
type SendResetLinkHcaptcha,
22+
} from './schemas';
2323

2424
export function SendResetLinkWorkerSuccessPage() {
2525
const { colorPalette, isDarkMode } = useColorMode();

0 commit comments

Comments
 (0)