Skip to content

Commit

Permalink
fix: refactor data exchange signature
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyArt1 committed May 11, 2024
1 parent 25a2272 commit 34f0eb9
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/app/[lang]/identification/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function Form() {
watch,
} = useForm<CedulaForm>({
reValidateMode: 'onSubmit',
resolver: zodResolver(createCedulaSchema({ intl })),
resolver: zodResolver(createCedulaSchema(intl)),
});

const cedulaFormValue = watch('cedula', '');
Expand Down
2 changes: 1 addition & 1 deletion src/app/[lang]/liveness/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function Form({ cedula }: Props) {
register,
formState: { errors },
} = useForm<TermsForm>({
resolver: zodResolver(createTermsSchema({ intl })),
resolver: zodResolver(createTermsSchema(intl)),
});

const onSubmit = handleSubmit(() => setOpen(true));
Expand Down
2 changes: 1 addition & 1 deletion src/app/[lang]/register/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function Form({ cedula }: Props) {
watch,
} = useForm<RegisterForm>({
mode: 'onChange',
resolver: zodResolver(createRegisterSchema({ intl }, cedula)),
resolver: zodResolver(createRegisterSchema(intl, cedula)),
});

const password = watch('password');
Expand Down
2 changes: 1 addition & 1 deletion src/app/[lang]/verification/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function Form({ flow, returnTo, code }: Props) {

const { handleSubmit, setValue } = useForm<VerificationForm>({
reValidateMode: 'onSubmit',
resolver: zodResolver(createVerificationSchema({ intl })),
resolver: zodResolver(createVerificationSchema(intl)),
});

const [loading, setLoading] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion src/common/validation-schemas/cedula.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod';

import { Context } from '@/app/[lang]/provider';

export const createCedulaSchema = ({ intl: { validations } }: Context) =>
export const createCedulaSchema = ({ validations }: Context['intl']) =>
z.object({
cedula: z
.string()
Expand Down
2 changes: 1 addition & 1 deletion src/common/validation-schemas/register.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from 'zod';
import { Context } from '@/app/[lang]/provider';

export const createRegisterSchema = (
{ intl: { validations } }: Context,
{ validations }: Context['intl'],
cedula: string,
) =>
z
Expand Down
2 changes: 1 addition & 1 deletion src/common/validation-schemas/report.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod';

import { Context } from '@/app/[lang]/provider';

export const createReportSchema = ({ intl: { validations } }: Context) =>
export const createReportSchema = ({ validations }: Context['intl']) =>
z.object({
email: z.string().email(validations.email.invalid),
name: z.string().optional(),
Expand Down
2 changes: 1 addition & 1 deletion src/common/validation-schemas/terms.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod';

import { Context } from '@/app/[lang]/provider';

export const createTermsSchema = ({ intl }: Context) =>
export const createTermsSchema = (intl: Context['intl']) =>
z.object({
accepted: z.literal(true, {
required_error: intl.terms.check,
Expand Down
2 changes: 1 addition & 1 deletion src/common/validation-schemas/verification.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod';

import { Context } from '@/app/[lang]/provider';

export const createVerificationSchema = ({ intl: { validations } }: Context) =>
export const createVerificationSchema = ({ validations }: Context['intl']) =>
z.object({
code: z.string().min(6, validations.code.min).max(6, validations.code.max),
});
2 changes: 1 addition & 1 deletion src/components/LivenessQuickStart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function LivenessQuickStart({ cedula }: Props) {

const { intl } = useLanguage();

const displayText = useLocalizedText({ intl });
const displayText = useLocalizedText(intl);

const fetchCreateLiveness: () => Promise<void> = async () => {
await fetch(`/api/biometric`, { method: 'POST' })
Expand Down
6 changes: 2 additions & 4 deletions src/components/LivenessQuickStart/localizedText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import type {
} from '@aws-amplify/ui-react-liveness/dist/types/components/FaceLivenessDetector/displayText';

export const useLocalizedText = ({
intl: {
liveness: { hints, camera, instructions, stream, error },
},
}: Context) =>
liveness: { hints, camera, instructions, stream, error },
}: Context['intl']) =>
({
...({
hintMoveFaceFrontOfCameraText: hints.moveFaceFrontOfCamera,
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserFeedbackModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function UserFeedbackModal({ open, onClose }: Props) {
register,
reset,
} = useForm<Report>({
resolver: zodResolver(createReportSchema({ intl })),
resolver: zodResolver(createReportSchema(intl)),
});

const sendFeedback = handleSubmit(({ email, comments, name = '' }) => {
Expand Down

0 comments on commit 34f0eb9

Please sign in to comment.