From 1923e180d4bf1e995fe2a7b42f317492e59b165a Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Fri, 22 Nov 2024 13:27:15 +0100 Subject: [PATCH] e-mail and phone validation in group-subheader component --- src/Components/Input/TextInput.tsx | 7 +- src/Components/Profile/ProfileForm.tsx | 98 ++++++++++--------- .../Profile/Subcomponents/ContactInfoForm.tsx | 4 + .../Profile/Subcomponents/FormHeader.tsx | 1 + 4 files changed, 62 insertions(+), 48 deletions(-) diff --git a/src/Components/Input/TextInput.tsx b/src/Components/Input/TextInput.tsx index 0ab98c15..54217e7c 100644 --- a/src/Components/Input/TextInput.tsx +++ b/src/Components/Input/TextInput.tsx @@ -13,6 +13,8 @@ type InputTextProps = { defaultValue?: string placeholder?: string autocomplete?: string + pattern?: string + required?: boolean updateFormValue?: (value: string) => void } @@ -26,6 +28,8 @@ export function TextInput({ defaultValue, placeholder, autocomplete, + pattern, + required = true, updateFormValue, }: InputTextProps) { const [inputValue, setInputValue] = useState(defaultValue || '') @@ -50,7 +54,8 @@ export function TextInput({ ) : null} -
- +
{ + e.preventDefault() + void onUpdateItem( + state, + item, + tags, + addTag, + setLoading, + navigate, + updateItem, + addItem, + user, + urlParams, + ) + }} + > +
+ - {template === 'onepager' && ( - - )} + {template === 'onepager' && ( + + )} - {template === 'simple' && } + {template === 'simple' && } - {template === 'flex' && ( - - )} + {template === 'flex' && ( + + )} - {template === 'tabs' && ( - linkItem(id, item, updateItem)} - unlinkItem={(id) => unlinkItem(id, item, updateItem)} - setUrlParams={setUrlParams} - > - )} + {template === 'tabs' && ( + linkItem(id, item, updateItem)} + unlinkItem={(id) => unlinkItem(id, item, updateItem)} + setUrlParams={setUrlParams} + > + )} -
- +
+ +
-
+
) diff --git a/src/Components/Profile/Subcomponents/ContactInfoForm.tsx b/src/Components/Profile/Subcomponents/ContactInfoForm.tsx index 9a87fc6a..ed5cea1e 100644 --- a/src/Components/Profile/Subcomponents/ContactInfoForm.tsx +++ b/src/Components/Profile/Subcomponents/ContactInfoForm.tsx @@ -22,6 +22,7 @@ export const ContactInfoForm = ({ setState((prevState) => ({ @@ -41,6 +42,9 @@ export const ContactInfoForm = ({ setState((prevState) => ({ diff --git a/src/Components/Profile/Subcomponents/FormHeader.tsx b/src/Components/Profile/Subcomponents/FormHeader.tsx index a20a778f..357ad7a4 100644 --- a/src/Components/Profile/Subcomponents/FormHeader.tsx +++ b/src/Components/Profile/Subcomponents/FormHeader.tsx @@ -44,6 +44,7 @@ export const FormHeader = ({ item, state, setState }) => { /> setState((prevState) => ({