From 3f11b768112ddfb40809b8a58a30c7b37305056e Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Fri, 8 May 2026 10:37:58 +0500 Subject: [PATCH] mobile: fix form validation in set your name dialog --- .../app/screens/settings/user-section.jsx | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/apps/mobile/app/screens/settings/user-section.jsx b/apps/mobile/app/screens/settings/user-section.jsx index b87cccfb7..ea8430517 100644 --- a/apps/mobile/app/screens/settings/user-section.jsx +++ b/apps/mobile/app/screens/settings/user-section.jsx @@ -29,6 +29,10 @@ import ImagePicker from "react-native-image-crop-picker"; import Icon from "react-native-vector-icons/MaterialCommunityIcons"; import { db } from "../../common/database"; import { presentDialog } from "../../components/dialog/functions"; +import { + createFormRef, + validators +} from "../../components/ui/input/form-input"; import { PlanLimits } from "../../components/sheets/plan-limits"; import AppIcon from "../../components/ui/AppIcon"; import { Button } from "../../components/ui/button"; @@ -197,27 +201,34 @@ const SettingsUserSection = ({ item }) => { title: strings.setFullName(), paragraph: strings.setFullNameDesc(), positiveText: strings.save(), - input: true, - inputPlaceholder: strings.enterFullName(), - defaultValue: userProfile?.fullName, - positivePress: async (value) => { - if (!value || !value.trim()) { - ToastManager.error( - new Error(strings.nameIsRequired()), - undefined, - "local" - ); - return; - } - db.settings - .setProfile({ - fullName: value - }) - .then(async () => { + form: { + formRef: createFormRef({ + fullName: userProfile?.fullName || "" + }), + items: [ + { + name: "fullName", + placeholder: strings.enterFullName(), + defaultValue: userProfile?.fullName, + validators: [ + validators.required(strings.nameIsRequired()) + ] + } + ], + onFormSubmit: async (form) => { + try { + await db.settings.setProfile({ + fullName: form.getValue("fullName") + }); useUserStore.setState({ profile: db.settings.getProfile() }); - }); + return true; + } catch (e) { + form.setError("fullName", e.message); + return false; + } + } } }); }}