From 7bf73c701feee7ce5feaa55c66170c0245bc0e7b Mon Sep 17 00:00:00 2001 From: ardier16 Date: Tue, 1 Oct 2024 14:36:19 +0300 Subject: [PATCH] Update light verification view --- src/pages/ProofRequestsDemo/index.tsx | 77 ++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 14 deletions(-) diff --git a/src/pages/ProofRequestsDemo/index.tsx b/src/pages/ProofRequestsDemo/index.tsx index 88384e3..a54be53 100644 --- a/src/pages/ProofRequestsDemo/index.tsx +++ b/src/pages/ProofRequestsDemo/index.tsx @@ -18,7 +18,8 @@ import { v4 as uuid } from 'uuid' import { config } from '@/config' import { ErrorHandler } from '@/helpers' import { useForm } from '@/hooks' -import { UiCheckbox, UiSwitch, UiTextField } from '@/ui' +import { Transitions } from '@/theme/constants' +import { UiSwitch, UiTextField } from '@/ui' const apiClient = new JsonApiClient({ baseUrl: config.VERIFICATOR_API_URL, @@ -176,7 +177,6 @@ enum FieldNames { MinimumAge = 'minimumAge', Nationality = 'nationality', EventId = 'eventId', - isLightVerificationEnabled = 'isLightVerificationEnabled', } const DEFAULT_VALUES = { @@ -184,7 +184,6 @@ const DEFAULT_VALUES = { [FieldNames.MinimumAge]: '18', [FieldNames.Nationality]: 'UKR', [FieldNames.EventId]: '12345678900987654321', - [FieldNames.isLightVerificationEnabled]: false, } function ProofAttributesStep({ @@ -192,6 +191,7 @@ function ProofAttributesStep({ }: { onSubmit: (verificationCheckEndpoint: string, deepLink: string) => void }) { + const [isLightVerification, setIsLightVerification] = useState(true) const { handleSubmit, control, isFormDisabled, getErrorMessage, disableForm, enableForm } = useForm(DEFAULT_VALUES, yup => yup.object().shape({ @@ -285,9 +285,7 @@ function ProofAttributesStep({ const minimumAge = Number(formData[FieldNames.MinimumAge]) const nationality = formData[FieldNames.Nationality] - const isLightVerificationEnabled = formData[FieldNames.isLightVerificationEnabled] - - if (isLightVerificationEnabled) { + if (isLightVerification) { await handleVerificationLight({ age_lower_bound: minimumAge ? minimumAge : undefined, uniqueness: Boolean(formData[FieldNames.Uniqueness]), @@ -310,12 +308,33 @@ function ProofAttributesStep({ enableForm() }, - [disableForm, enableForm, handleVerification, handleVerificationLight], + [disableForm, enableForm, handleVerification, handleVerificationLight, isLightVerification], ) return ( + ({ + p: 0.5, + background: theme.palette.action.active, + borderRadius: 25, + overflow: 'hidden', + })} + > + setIsLightVerification(true)} + /> + setIsLightVerification(false)} + /> + )} /> - ( - - )} - /> @@ -484,3 +496,40 @@ function VerificationStatusStep({ ) } + +function TabButton({ + text, + isActive, + onClick, +}: { + text: string + isActive: boolean + onClick: () => void +}) { + const { palette, spacing } = useTheme() + + return ( + + + {text} + + + ) +}