mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-05-18 05:05:36 +02:00
mobile: fix form validation in set your name dialog
This commit is contained in:
@@ -29,6 +29,10 @@ import ImagePicker from "react-native-image-crop-picker";
|
|||||||
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
|
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
|
||||||
import { db } from "../../common/database";
|
import { db } from "../../common/database";
|
||||||
import { presentDialog } from "../../components/dialog/functions";
|
import { presentDialog } from "../../components/dialog/functions";
|
||||||
|
import {
|
||||||
|
createFormRef,
|
||||||
|
validators
|
||||||
|
} from "../../components/ui/input/form-input";
|
||||||
import { PlanLimits } from "../../components/sheets/plan-limits";
|
import { PlanLimits } from "../../components/sheets/plan-limits";
|
||||||
import AppIcon from "../../components/ui/AppIcon";
|
import AppIcon from "../../components/ui/AppIcon";
|
||||||
import { Button } from "../../components/ui/button";
|
import { Button } from "../../components/ui/button";
|
||||||
@@ -197,27 +201,34 @@ const SettingsUserSection = ({ item }) => {
|
|||||||
title: strings.setFullName(),
|
title: strings.setFullName(),
|
||||||
paragraph: strings.setFullNameDesc(),
|
paragraph: strings.setFullNameDesc(),
|
||||||
positiveText: strings.save(),
|
positiveText: strings.save(),
|
||||||
input: true,
|
form: {
|
||||||
inputPlaceholder: strings.enterFullName(),
|
formRef: createFormRef({
|
||||||
defaultValue: userProfile?.fullName,
|
fullName: userProfile?.fullName || ""
|
||||||
positivePress: async (value) => {
|
}),
|
||||||
if (!value || !value.trim()) {
|
items: [
|
||||||
ToastManager.error(
|
{
|
||||||
new Error(strings.nameIsRequired()),
|
name: "fullName",
|
||||||
undefined,
|
placeholder: strings.enterFullName(),
|
||||||
"local"
|
defaultValue: userProfile?.fullName,
|
||||||
);
|
validators: [
|
||||||
return;
|
validators.required(strings.nameIsRequired())
|
||||||
}
|
]
|
||||||
db.settings
|
}
|
||||||
.setProfile({
|
],
|
||||||
fullName: value
|
onFormSubmit: async (form) => {
|
||||||
})
|
try {
|
||||||
.then(async () => {
|
await db.settings.setProfile({
|
||||||
|
fullName: form.getValue("fullName")
|
||||||
|
});
|
||||||
useUserStore.setState({
|
useUserStore.setState({
|
||||||
profile: db.settings.getProfile()
|
profile: db.settings.getProfile()
|
||||||
});
|
});
|
||||||
});
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
form.setError("fullName", e.message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user