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(condo): DOMA-10125 add time validate #5545

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
21 changes: 20 additions & 1 deletion apps/condo/domains/news/components/NewsForm/BaseNewsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,21 @@ export const BaseNewsForm: React.FC<BaseNewsFormProps> = ({
return getSteps().length - 1
}, [getSteps])

const validateBeforeSave = () => {
if (!selectAppsFormValues.validBefore) return false

const validBeforeValue: dayjs.Dayjs = dayjs(selectAppsFormValues.validBefore)

if (validBeforeValue.isBefore(dayjs())) {
setCurrentStep(0)
notification.error({ message: PastTimeErrorMessage })

return true
}

return false
}

return (
<Row gutter={BIG_HORIZONTAL_GUTTER}>
<Col span={24} flex='auto'>
Expand Down Expand Up @@ -1594,7 +1609,11 @@ export const BaseNewsForm: React.FC<BaseNewsFormProps> = ({
key='submit'
type='primary'
children={ShareButtonMessage}
onClick={handleSave}
onClick={() => {
if (validateBeforeSave()) return

handleSave()
}}
disabled={isLoading}
/>,
]}
Expand Down
Loading