Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: validation issue in event publish when image is present is fixed #84

Merged
merged 1 commit into from
Jan 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/pages/Dashboard/AddEvent/AddEvent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ function AddEvent() {
navigate(`${PathName.Dashboard}/${calendarId}${PathName.Events}`).catch((error) => console.log(error)),
);
})
.catch((error) => console.log(error));
.catch((error) => {
console.log(error);
});
};

useEffect(() => {
Expand Down Expand Up @@ -636,15 +638,20 @@ function AddEvent() {
<Form.Item
label={t('dashboard.events.addEditEvent.otherInformation.image.title')}
name="dragger-wrap"
initialValue={eventData?.image && eventData?.image?.original}
rules={[
({ getFieldValue }) => ({
validator() {
if (!getFieldValue('dragger') || getFieldValue('dragger')?.length == 0) {
console.log(getFieldValue('dragger'));
if (
(getFieldValue('dragger') != undefined && getFieldValue('dragger')?.length > 0) ||
(eventData?.image?.original && !getFieldValue('dragger')) ||
(eventData?.image?.original && getFieldValue('dragger')?.length > 0)
) {
return Promise.resolve();
} else
return Promise.reject(
new Error(t('dashboard.events.addEditEvent.validations.otherInformation.emptyImage')),
);
} else return Promise.resolve();
},
}),
]}>
Expand Down