add user consent url
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { pathsConfig } from '@/packages/shared/src/config';
|
||||
import { ExternalLink } from '@/public/assets/external-link';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Button } from '@kit/ui/button';
|
||||
import { Checkbox } from '@kit/ui/checkbox';
|
||||
@@ -20,21 +21,22 @@ import {
|
||||
FormMessage,
|
||||
} from '@kit/ui/form';
|
||||
import { Input } from '@kit/ui/input';
|
||||
import { toast } from '@kit/ui/sonner';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
import { UpdateAccountSchemaClient } from '../_lib/schemas/update-account.schema';
|
||||
import { onUpdateAccount } from '../_lib/server/update-account';
|
||||
import { toast } from '@kit/ui/sonner';
|
||||
import { pathsConfig } from '@/packages/shared/src/config';
|
||||
|
||||
type UpdateAccountFormValues = z.infer<ReturnType<typeof UpdateAccountSchemaClient>>;
|
||||
type UpdateAccountFormValues = z.infer<
|
||||
ReturnType<typeof UpdateAccountSchemaClient>
|
||||
>;
|
||||
|
||||
export function UpdateAccountForm({
|
||||
defaultValues,
|
||||
isEmailUser,
|
||||
}: {
|
||||
defaultValues: UpdateAccountFormValues,
|
||||
isEmailUser: boolean,
|
||||
defaultValues: UpdateAccountFormValues;
|
||||
isEmailUser: boolean;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const { t } = useTranslation('account');
|
||||
@@ -45,10 +47,13 @@ export function UpdateAccountForm({
|
||||
defaultValues,
|
||||
});
|
||||
|
||||
const { firstName, lastName, personalCode, email, userConsent } = defaultValues;
|
||||
const { firstName, lastName, personalCode, email, userConsent } =
|
||||
defaultValues;
|
||||
|
||||
const defaultValues_weight = "weight" in defaultValues ? defaultValues.weight : null;
|
||||
const defaultValues_height = "height" in defaultValues ? defaultValues.height : null;
|
||||
const defaultValues_weight =
|
||||
'weight' in defaultValues ? defaultValues.weight : null;
|
||||
const defaultValues_height =
|
||||
'height' in defaultValues ? defaultValues.height : null;
|
||||
|
||||
const hasFirstName = !!firstName;
|
||||
const hasLastName = !!lastName;
|
||||
@@ -64,8 +69,12 @@ export function UpdateAccountForm({
|
||||
personalCode: values.personalCode || personalCode,
|
||||
email: values.email || email,
|
||||
phone: values.phone,
|
||||
weight: ((("weight" in values && values.weight) ?? defaultValues_weight) || null) as number,
|
||||
height: ((("height" in values && values.height) ?? defaultValues_height) || null) as number,
|
||||
weight: ((('weight' in values && values.weight) ??
|
||||
defaultValues_weight) ||
|
||||
null) as number,
|
||||
height: ((('height' in values && values.height) ??
|
||||
defaultValues_height) ||
|
||||
null) as number,
|
||||
userConsent: values.userConsent ?? userConsent,
|
||||
city: values.city,
|
||||
});
|
||||
@@ -81,7 +90,7 @@ export function UpdateAccountForm({
|
||||
router.push(pathsConfig.app.selectPackage);
|
||||
}
|
||||
} catch (error) {
|
||||
console.info("promiseresult error", error);
|
||||
console.info('promiseresult error', error);
|
||||
toast.error(t('updateAccount.updateAccountError'));
|
||||
toast.dismiss(loading);
|
||||
}
|
||||
@@ -205,7 +214,9 @@ export function UpdateAccountForm({
|
||||
value={field.value ?? ''}
|
||||
onChange={(e) =>
|
||||
field.onChange(
|
||||
e.target.value === '' ? null : Number(e.target.value),
|
||||
e.target.value === ''
|
||||
? null
|
||||
: Number(e.target.value),
|
||||
)
|
||||
}
|
||||
/>
|
||||
@@ -230,7 +241,9 @@ export function UpdateAccountForm({
|
||||
value={field.value ?? ''}
|
||||
onChange={(e) =>
|
||||
field.onChange(
|
||||
e.target.value === '' ? null : Number(e.target.value),
|
||||
e.target.value === ''
|
||||
? null
|
||||
: Number(e.target.value),
|
||||
)
|
||||
}
|
||||
/>
|
||||
@@ -260,7 +273,7 @@ export function UpdateAccountForm({
|
||||
</div>
|
||||
|
||||
<Link
|
||||
href={''}
|
||||
href={t('account:updateAccount:userConsentUrlPath')}
|
||||
className="flex flex-row items-center gap-2 text-sm hover:underline"
|
||||
target="_blank"
|
||||
>
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
"button": "Continue",
|
||||
"userConsentLabel": "I agree to the use of personal data on the platform",
|
||||
"userConsentUrlTitle": "View privacy policy",
|
||||
"userConsentUrlPath": "https://medreport.ee/privaatsustingimused/",
|
||||
"updateAccountLoading": "Updating account details...",
|
||||
"updateAccountSuccess": "Account details updated",
|
||||
"updateAccountError": "Updating account details error"
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
"button": "Jätka",
|
||||
"userConsentLabel": "Nõustun isikuandmete kasutamisega platvormil",
|
||||
"userConsentUrlTitle": "Vaata isikuandmete töötlemise põhimõtteid",
|
||||
"userConsentUrlPath": "https://medreport.ee/privaatsustingimused/",
|
||||
"updateAccountLoading": "Konto andmed uuendatakse...",
|
||||
"updateAccountSuccess": "Konto andmed uuendatud",
|
||||
"updateAccountError": "Konto andmete uuendamine ebaõnnestus"
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
"button": "Продолжить",
|
||||
"userConsentLabel": "Я согласен на использование персональных данных на платформе",
|
||||
"userConsentUrlTitle": "Посмотреть политику конфиденциальности",
|
||||
"userConsentUrlPath": "https://medreport.ee/privaatsustingimused/",
|
||||
"updateAccountLoading": "Обновление данных аккаунта...",
|
||||
"updateAccountSuccess": "Данные аккаунта обновлены",
|
||||
"updateAccountError": "Не удалось обновить данные аккаунта"
|
||||
|
||||
Reference in New Issue
Block a user