diff --git a/apps/condo/domains/news/components/NewsForm/BaseNewsForm.tsx b/apps/condo/domains/news/components/NewsForm/BaseNewsForm.tsx index 5be14cd1d36..032702cba91 100644 --- a/apps/condo/domains/news/components/NewsForm/BaseNewsForm.tsx +++ b/apps/condo/domains/news/components/NewsForm/BaseNewsForm.tsx @@ -1156,6 +1156,21 @@ export const BaseNewsForm: React.FC = ({ 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 ( @@ -1594,7 +1609,11 @@ export const BaseNewsForm: React.FC = ({ key='submit' type='primary' children={ShareButtonMessage} - onClick={handleSave} + onClick={() => { + if (validateBeforeSave()) return + + handleSave() + }} disabled={isLoading} />, ]}