Skip to content

Commit

Permalink
Fix: resolve validation issue idurar#1202
Browse files Browse the repository at this point in the history
  • Loading branch information
dhuruvandb committed Dec 16, 2024
1 parent ce83ef7 commit 2a47730
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default function AdminForm({ isUpdateForm = false }) {
{
required: true,
},
{
pattern: /^[A-Za-z][A-Za-z'-]+$/,
message: 'Please enter a valid First Name',
}
]}
>
<Input autoComplete="off" />
Expand All @@ -38,6 +42,10 @@ export default function AdminForm({ isUpdateForm = false }) {
{
required: true,
},
{
pattern: /^[A-Za-z][A-Za-z'-]+$/,
message: 'Please enter a valid Last Name',
}
]}
>
<Input autoComplete="off" />
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/modules/ProfileModule/components/UpdateAdmin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ const UpdateAdmin = ({ config }) => {
}, [currentAdmin]);

const handleSubmit = () => {
form.submit();
form
.validateFields()
.then((values) => {
onSubmit(values);
updatePanel.close();
})
.catch((errorInfo) => {
console.log('Form validation failed:', errorInfo);
});
};

const onSubmit = (fieldsValue) => {
Expand Down Expand Up @@ -58,7 +66,6 @@ const UpdateAdmin = ({ config }) => {
key={`${uniqueId()}`}
onClick={() => {
handleSubmit();
updatePanel.close();
}}
type="primary"
icon={<SaveOutlined />}
Expand Down

0 comments on commit 2a47730

Please sign in to comment.