From a4fefc68827465b96a02a3ac0adeeeffeb9d0213 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 26 Jun 2025 14:39:09 +0300 Subject: [PATCH] tweak buttons, prevent u13 --- src/components/dialogs/BirthDateSettings.tsx | 38 ++++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/components/dialogs/BirthDateSettings.tsx b/src/components/dialogs/BirthDateSettings.tsx index 2c733f4344..92953ae9e0 100644 --- a/src/components/dialogs/BirthDateSettings.tsx +++ b/src/components/dialogs/BirthDateSettings.tsx @@ -4,7 +4,7 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {cleanError} from '#/lib/strings/errors' -import {getDateAgo} from '#/lib/strings/time' +import {getDateAgo, simpleAreDatesEqual} from '#/lib/strings/time' import {logger} from '#/logger' import {isIOS, isWeb} from '#/platform/detection' import { @@ -13,6 +13,7 @@ import { usePreferencesSetBirthDateMutation, } from '#/state/queries/preferences' import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' +import {is13} from '#/screens/Signup/state' import {atoms as a, platform, useTheme, web} from '#/alf' import * as Dialog from '#/components/Dialog' import {DateField} from '#/components/forms/DateField' @@ -36,7 +37,7 @@ export function BirthDateSettingsDialog({ label={_(msg`My Birthday`)} style={web({maxWidth: 400})}> - + My Birthday @@ -74,6 +75,7 @@ function BirthdayInner({ preferences: UsePreferencesQueryResponse }) { const {_} = useLingui() + const t = useTheme() const [date, setDate] = React.useState(preferences.birthDate || new Date()) const { isPending, @@ -81,7 +83,8 @@ function BirthdayInner({ error, mutateAsync: setBirthDate, } = usePreferencesSetBirthDateMutation() - const hasChanged = date !== preferences.birthDate + const hasChanged = + !preferences.birthDate || !simpleAreDatesEqual(date, preferences.birthDate) const onSave = React.useCallback(async () => { try { @@ -95,6 +98,8 @@ function BirthdayInner({ } }, [date, setBirthDate, control, hasChanged]) + const isUnder13 = !is13(date) + return ( @@ -112,18 +117,37 @@ function BirthdayInner({ ) : undefined} - + {isUnder13 && ( + + You must be at least 13 years of age. + + )} + + + {isWeb && ( + + )}