From e77109b460b11f18011d7c1a61b5ba22fb666272 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Thu, 20 Jun 2024 12:52:46 +0530 Subject: [PATCH 01/20] fix: removed extra sentence from french translation for image --- src/locales/fr/transalationFr.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/fr/transalationFr.json b/src/locales/fr/transalationFr.json index b3460447..4c2e2036 100644 --- a/src/locales/fr/transalationFr.json +++ b/src/locales/fr/transalationFr.json @@ -254,7 +254,7 @@ "title": "Image", "mainImage": "Image principale", "additionalImages": "Images supplémentaires", - "subHeading": "Les images doivent être au format paysage ou carré et mesurer au moins 600 px de large. Uniquement les fichiers .jpeg et .png sont acceptés.", + "subHeading": "Uniquement les fichiers .jpeg et .png sont acceptés.", "dragAndDrop": "ou glisser pour télécharger", "browse": "Parcourir", "imageGallery": "Galerie d'images", From 1f4cf71be1fcd77ddaf2c94fa82fcb6a2b43d3c9 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Thu, 20 Jun 2024 12:56:57 +0530 Subject: [PATCH 02/20] fix: fixed the font size of additional image label --- src/constants/formFields.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/constants/formFields.js b/src/constants/formFields.js index f2fa180c..95786897 100644 --- a/src/constants/formFields.js +++ b/src/constants/formFields.js @@ -390,7 +390,6 @@ export const formFieldValue = [ {name?.includes(mappedFieldTypes.IMAGE) && ( diff --git a/src/pages/Dashboard/CreateNewOrganization/CreateNewOrganization.jsx b/src/pages/Dashboard/CreateNewOrganization/CreateNewOrganization.jsx index f47111ec..63cd2b9d 100644 --- a/src/pages/Dashboard/CreateNewOrganization/CreateNewOrganization.jsx +++ b/src/pages/Dashboard/CreateNewOrganization/CreateNewOrganization.jsx @@ -1261,6 +1261,7 @@ function CreateNewOrganization() { isExternalSourceFetching, mandatoryFields: formFieldProperties?.mandatoryFields?.standardFields ?? [], adminOnlyFields: formFieldProperties?.adminOnlyFields?.standardFields ?? [], + setShowDialog, }); } }); diff --git a/src/pages/Dashboard/CreateNewPerson/CreateNewPerson.jsx b/src/pages/Dashboard/CreateNewPerson/CreateNewPerson.jsx index e306ebb9..035daeab 100644 --- a/src/pages/Dashboard/CreateNewPerson/CreateNewPerson.jsx +++ b/src/pages/Dashboard/CreateNewPerson/CreateNewPerson.jsx @@ -789,6 +789,7 @@ function CreateNewPerson() { form, mandatoryFields: formFieldProperties?.mandatoryFields?.standardFields ?? [], adminOnlyFields: formFieldProperties?.adminOnlyFields?.standardFields ?? [], + setShowDialog, }); } }); diff --git a/src/pages/Dashboard/CreateNewPlace/CreateNewPlace.jsx b/src/pages/Dashboard/CreateNewPlace/CreateNewPlace.jsx index 48bf9bd6..f4186cd0 100644 --- a/src/pages/Dashboard/CreateNewPlace/CreateNewPlace.jsx +++ b/src/pages/Dashboard/CreateNewPlace/CreateNewPlace.jsx @@ -1884,6 +1884,7 @@ function CreateNewPlace() { data-cy="form-item-event-multiple-image" hidden={!imageConfig?.enableGallery}> 0 From d6f17143bce9b205790835b8fcbd1124a150ffed Mon Sep 17 00:00:00 2001 From: syam babu Date: Fri, 28 Jun 2024 13:37:59 +0530 Subject: [PATCH 10/20] fix: disabled selecting same date as start and end date on range picker --- .../RecurringEvents/RecurringEvents.jsx | 4 +++ src/pages/Dashboard/AddEvent/AddEvent.jsx | 35 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/components/RecurringEvents/RecurringEvents.jsx b/src/components/RecurringEvents/RecurringEvents.jsx index 0cbee163..09187266 100644 --- a/src/components/RecurringEvents/RecurringEvents.jsx +++ b/src/components/RecurringEvents/RecurringEvents.jsx @@ -24,6 +24,8 @@ const RecurringEvents = function ({ eventDetails, setFormFields, dateType, + disabledDate, + onCalendarChange, }) { const [nummberofDates, setNumberofDates] = useState(numberOfDaysEvent); const [isModalVisible, setIsModalVisible] = useState(false); @@ -341,6 +343,8 @@ const RecurringEvents = function ({ 0 && (

tags at the end + if (values.dateRangePicker) { + const [startDate, endDate] = values.dateRangePicker; + if (moment(startDate).isSame(endDate, 'day')) { + setDateType(dateTypes.SINGLE); + } + } + + console.log(values); + if (dateType === dateTypes.SINGLE) { if (values?.startTime) startDateTime = dateTimeConverter(values?.datePicker, values?.startTime); else @@ -2306,7 +2318,7 @@ function AddEvent() {

- {t('dashboard.events.addEditEvent.dates.heading')} + {t('dashboard.events.addEditEvent.dates.heading')} hello

@@ -2442,7 +2454,18 @@ function AddEvent() { }, ]} data-cy="form-item-date-range-label"> - + { + setStartDate(dates?.[0]); + setEndDate(dates?.[1]); + }} + disabledDate={(current) => + (startDate && current.isSame(startDate, 'day')) || + (endDate && current.isSame(endDate, 'day')) + } + data-cy="date-range" + /> )} {dateType === dateTypes.MULTIPLE && ( @@ -2453,6 +2476,14 @@ function AddEvent() { numberOfDaysEvent={eventData?.subEvents?.length} form={form} eventDetails={eventData} + onCalendarChange={(dates) => { + setStartDate(dates?.[0]); + setEndDate(dates?.[1]); + }} + disabledDate={(current) => + (startDate && current.isSame(startDate, 'day')) || + (endDate && current.isSame(endDate, 'day')) + } setFormFields={setFormValue} dateType={dateType} /> From 8ee87552e5842b463534b0c5624f39acc69470d7 Mon Sep 17 00:00:00 2001 From: syam babu Date: Fri, 28 Jun 2024 15:36:42 +0530 Subject: [PATCH 11/20] fix: useBlocker trigger not resetting issue fixed. closes #1191 --- .../Card/MandatoryField/MandatoryField.jsx | 4 +-- src/pages/Dashboard/AddUser/AddUser.jsx | 2 ++ .../CalendarSettings/CalendarSettings.jsx | 3 ++- .../MandatoryFields/MandatoryFields.jsx | 1 + src/pages/Dashboard/Settings/Settings.jsx | 27 +++---------------- .../WidgetSettings/WidgetSettings.jsx | 2 +- 6 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/components/Card/MandatoryField/MandatoryField.jsx b/src/components/Card/MandatoryField/MandatoryField.jsx index 87b8347c..b05b3912 100644 --- a/src/components/Card/MandatoryField/MandatoryField.jsx +++ b/src/components/Card/MandatoryField/MandatoryField.jsx @@ -34,7 +34,7 @@ function MandatoryField(props) { setAddedFields(updatedFields); setAvailableFields([...availableFields, removedField]); - setDirtyStatus(); + setDirtyStatus(true); } }; @@ -54,7 +54,7 @@ function MandatoryField(props) { }); setAddedFields([...addedFields, { ...field, isRequiredField: true }]); setAvailableFields(updatedFields); - setDirtyStatus(); + setDirtyStatus(true); }; useEffect(() => { diff --git a/src/pages/Dashboard/AddUser/AddUser.jsx b/src/pages/Dashboard/AddUser/AddUser.jsx index c18eeb39..7f059330 100644 --- a/src/pages/Dashboard/AddUser/AddUser.jsx +++ b/src/pages/Dashboard/AddUser/AddUser.jsx @@ -270,6 +270,7 @@ const AddUser = () => { formInstance .validateFields() .then((values) => { + setIsFormDirty(false); let organizations = values?.organizers[calendarId]; organizations = organizations?.map((organizer) => { return { entityId: organizer?.value }; @@ -317,6 +318,7 @@ const AddUser = () => { formInstance .validateFields() .then((values) => { + setIsFormDirty(false); let organizations = values?.organizers[calendarId]; organizations = organizations?.map((organizer) => { return { entityId: organizer?.value }; diff --git a/src/pages/Dashboard/Settings/CalendarSettings/CalendarSettings.jsx b/src/pages/Dashboard/Settings/CalendarSettings/CalendarSettings.jsx index 1216f0c3..68a49aff 100644 --- a/src/pages/Dashboard/Settings/CalendarSettings/CalendarSettings.jsx +++ b/src/pages/Dashboard/Settings/CalendarSettings/CalendarSettings.jsx @@ -150,6 +150,7 @@ function CalendarSettings({ setDirtyStatus, tabKey }) { updateCalendar({ calendarId, data }) .unwrap() .then(() => { + setDirtyStatus(false); getCalendar({ id: calendarId, sessionId: timestampRef }) .unwrap() .then((response) => { @@ -358,7 +359,7 @@ function CalendarSettings({ setDirtyStatus, tabKey }) { name="calendar-settings" initialValues={initialValues} onFieldsChange={() => { - setDirtyStatus(); + setDirtyStatus(true); }}> {calendarSettingsFormFields.GENERAL_SETTINGS.map((item, index) => { return ( diff --git a/src/pages/Dashboard/Settings/MandatoryFields/MandatoryFields.jsx b/src/pages/Dashboard/Settings/MandatoryFields/MandatoryFields.jsx index a3c11452..7b9cfd47 100644 --- a/src/pages/Dashboard/Settings/MandatoryFields/MandatoryFields.jsx +++ b/src/pages/Dashboard/Settings/MandatoryFields/MandatoryFields.jsx @@ -185,6 +185,7 @@ function MandatoryFields({ setDirtyStatus, tabKey }) { updateCalendar({ data: calendarData, calendarId: currentCalendarData.id }) .unwrap() .then(() => { + setDirtyStatus(false); getCalendar({ id: calendarId, sessionId: timestampRef }) .unwrap() .then(() => { diff --git a/src/pages/Dashboard/Settings/Settings.jsx b/src/pages/Dashboard/Settings/Settings.jsx index 7a181f7d..52fa2ee5 100644 --- a/src/pages/Dashboard/Settings/Settings.jsx +++ b/src/pages/Dashboard/Settings/Settings.jsx @@ -84,42 +84,21 @@ const Settings = () => { { label: t('dashboard.settings.tab2'), key: '2', - children: ( - { - if (!isFormDirty) setIsFormDirty(true); - }} - /> - ), + children: , disabled: false, adminOnly: true, }, { label: t('dashboard.settings.tab3'), key: '3', - children: currentCalendarData && ( - { - if (!isFormDirty) setIsFormDirty(true); - }} - /> - ), + children: currentCalendarData && , disabled: false, adminOnly: true, }, { label: t('dashboard.settings.tab4'), key: '4', - children: ( - { - if (!isFormDirty) setIsFormDirty(true); - }} - /> - ), + children: , disabled: false, adminOnly: true, }, diff --git a/src/pages/Dashboard/Settings/WidgetSettings/WidgetSettings.jsx b/src/pages/Dashboard/Settings/WidgetSettings/WidgetSettings.jsx index 1099a54f..9b70cec4 100644 --- a/src/pages/Dashboard/Settings/WidgetSettings/WidgetSettings.jsx +++ b/src/pages/Dashboard/Settings/WidgetSettings/WidgetSettings.jsx @@ -192,7 +192,7 @@ const WidgetSettings = ({ setDirtyStatus, tabKey }) => { setIframeCode( ``, ); - setDirtyStatus(); + setDirtyStatus(true); } }; From 06718d963fb74a439829a47ad77afd6d143d9639 Mon Sep 17 00:00:00 2001 From: syam babu Date: Fri, 28 Jun 2024 15:45:59 +0530 Subject: [PATCH 12/20] fix: fixed language select dropdown not working on the first click. closes #1191 --- src/pages/Dashboard/AddUser/AddUser.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/Dashboard/AddUser/AddUser.jsx b/src/pages/Dashboard/AddUser/AddUser.jsx index 7f059330..9be7cd49 100644 --- a/src/pages/Dashboard/AddUser/AddUser.jsx +++ b/src/pages/Dashboard/AddUser/AddUser.jsx @@ -93,10 +93,6 @@ const AddUser = () => { return calendar?.calendarId === calendarId; }); - useEffect(() => { - console.log(selectedCalendars); - }, [selectedCalendars]); - const [getUser, { isFetching: isUserFetching }] = useLazyGetUserByIdQuery({ sessionId: timestampRef }); const [getUserSearch] = useLazyGetAllUsersQuery({ sessionId: timestampRef }); @@ -846,7 +842,11 @@ const AddUser = () => { validateNotEmpty(_, value, t('dashboard.settings.addUser.validationTexts.language')), }, ]}> - setFormItemValues({ value, fieldType: 'languagePreference' })} + data-cy="select-user-language" + /> {isCurrentUser && ( From 79169ada94dbc9506b0e499d2470823e3454cac4 Mon Sep 17 00:00:00 2001 From: syam babu Date: Fri, 28 Jun 2024 17:25:27 +0530 Subject: [PATCH 13/20] fix: added feature to convert custom date event with only 1 occurance to a single date event. closes #1152 --- src/pages/Dashboard/AddEvent/AddEvent.jsx | 78 ++++++++++++++--------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/src/pages/Dashboard/AddEvent/AddEvent.jsx b/src/pages/Dashboard/AddEvent/AddEvent.jsx index 46a49644..48726f60 100644 --- a/src/pages/Dashboard/AddEvent/AddEvent.jsx +++ b/src/pages/Dashboard/AddEvent/AddEvent.jsx @@ -448,36 +448,12 @@ function AddEvent() { }); // Use a regular expression to remove


tags at the end - if (values.dateRangePicker) { - const [startDate, endDate] = values.dateRangePicker; - if (moment(startDate).isSame(endDate, 'day')) { - setDateType(dateTypes.SINGLE); - } - } - - console.log(values); + let datePickerValue = values?.datePicker; + let startTimeValue = values?.startTime; + let endTimeValue = values?.endTime; + let dateTypeValue = dateType; - if (dateType === dateTypes.SINGLE) { - if (values?.startTime) startDateTime = dateTimeConverter(values?.datePicker, values?.startTime); - else - startDateTime = moment - .tz(values?.datePicker, eventData?.scheduleTimezone ?? 'Canada/Eastern') - .format('YYYY-MM-DD'); - if (values?.endTime) endDateTime = dateTimeConverter(values?.datePicker, values?.endTime); - } - if (dateType === dateTypes.RANGE) { - if (values?.startTime) startDateTime = dateTimeConverter(values?.dateRangePicker[0], values?.startTime); - else - startDateTime = moment - .tz(values?.dateRangePicker[0], eventData?.scheduleTimezone ?? 'Canada/Eastern') - .format('YYYY-MM-DD'); - if (values?.endTime) endDateTime = dateTimeConverter(values?.dateRangePicker[1], values?.endTime); - else - endDateTime = moment - .tz(values?.dateRangePicker[1], eventData?.scheduleTimezone ?? 'Canada/Eastern') - .format('YYYY-MM-DD'); - } - if (dateType === dateTypes.MULTIPLE) { + if (dateTypeValue === dateTypes.MULTIPLE) { const recurEvent = { frequency: values.frequency, startDate: @@ -502,8 +478,50 @@ function AddEvent() { customDates: form.getFieldsValue().frequency === 'CUSTOM' ? form.getFieldsValue().customDates : undefined, }; - recurringEvent = recurEvent; + + let customDatesFlag = recurEvent?.customDates ? true : false; + let customTimeFlag = false; + + if (customDatesFlag && recurEvent.customDates.length === 1) { + const customTime = recurEvent.customDates[0]?.customTime; + if (!customTime || customTime.length <= 1) { + customDatesFlag = false; + customTimeFlag = customTime ? true : false; + } + } + + if (!customDatesFlag) { + dateTypeValue = dateTypes.SINGLE; + const singleCustomDate = recurEvent.customDates[0]; + datePickerValue = moment(singleCustomDate?.startDate); + if (customTimeFlag) { + startTimeValue = singleCustomDate?.customTime[0]?.startTime; + endTimeValue = singleCustomDate?.customTime[0]?.endTime; + } + } else recurringEvent = recurEvent; + } + + if (dateTypeValue === dateTypes.SINGLE) { + if (startTimeValue) startDateTime = dateTimeConverter(datePickerValue, startTimeValue); + else + startDateTime = moment + .tz(datePickerValue, eventData?.scheduleTimezone ?? 'Canada/Eastern') + .format('YYYY-MM-DD'); + if (endTimeValue) endDateTime = dateTimeConverter(datePickerValue, endTimeValue); + } + if (dateTypeValue === dateTypes.RANGE) { + if (values?.startTime) startDateTime = dateTimeConverter(values?.dateRangePicker[0], values?.startTime); + else + startDateTime = moment + .tz(values?.dateRangePicker[0], eventData?.scheduleTimezone ?? 'Canada/Eastern') + .format('YYYY-MM-DD'); + if (values?.endTime) endDateTime = dateTimeConverter(values?.dateRangePicker[1], values?.endTime); + else + endDateTime = moment + .tz(values?.dateRangePicker[1], eventData?.scheduleTimezone ?? 'Canada/Eastern') + .format('YYYY-MM-DD'); } + if (values?.eventType) { additionalType = values?.eventType?.map((eventTypeId) => { return { From b67b3e554d13d957d901ed3d57ea7d264fb02793 Mon Sep 17 00:00:00 2001 From: syam babu Date: Fri, 28 Jun 2024 17:27:41 +0530 Subject: [PATCH 14/20] fix added comment --- src/pages/Dashboard/AddEvent/AddEvent.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/Dashboard/AddEvent/AddEvent.jsx b/src/pages/Dashboard/AddEvent/AddEvent.jsx index 48726f60..e1b58daf 100644 --- a/src/pages/Dashboard/AddEvent/AddEvent.jsx +++ b/src/pages/Dashboard/AddEvent/AddEvent.jsx @@ -479,6 +479,7 @@ function AddEvent() { form.getFieldsValue().frequency === 'CUSTOM' ? form.getFieldsValue().customDates : undefined, }; + // following code looks at custom date and convert them to a single day event if there is only one occurance let customDatesFlag = recurEvent?.customDates ? true : false; let customTimeFlag = false; From 35565f5ec6c6fd0283277513a42920ff62a84a5f Mon Sep 17 00:00:00 2001 From: syam babu Date: Mon, 1 Jul 2024 17:28:11 +0530 Subject: [PATCH 15/20] fix: added feature to convert recurring events with only one subevent to single events. closes #1152 --- .../RecurringEvents/RecurringEvents.jsx | 3 +- src/pages/Dashboard/AddEvent/AddEvent.jsx | 98 +++++++++++++++---- src/utils/getWeekDayDates.js | 30 ++++++ 3 files changed, 109 insertions(+), 22 deletions(-) create mode 100644 src/utils/getWeekDayDates.js diff --git a/src/components/RecurringEvents/RecurringEvents.jsx b/src/components/RecurringEvents/RecurringEvents.jsx index 09187266..70cc3029 100644 --- a/src/components/RecurringEvents/RecurringEvents.jsx +++ b/src/components/RecurringEvents/RecurringEvents.jsx @@ -26,6 +26,8 @@ const RecurringEvents = function ({ dateType, disabledDate, onCalendarChange, + setSubEventCount, + subEventCount, }) { const [nummberofDates, setNumberofDates] = useState(numberOfDaysEvent); const [isModalVisible, setIsModalVisible] = useState(false); @@ -34,7 +36,6 @@ const RecurringEvents = function ({ const [isCustom, setIsCustom] = useState(false); const [selectedWeekDays, setSelectedWeekDays] = useState([]); const [dateModified, setDateModified] = useState(false); - const [subEventCount, setSubEventCount] = useState(0); const startDateRecur = Form.useWatch('startDateRecur', form); const { t } = useTranslation(); Form.useWatch('endTimeRecur', form); diff --git a/src/pages/Dashboard/AddEvent/AddEvent.jsx b/src/pages/Dashboard/AddEvent/AddEvent.jsx index e1b58daf..4813e348 100644 --- a/src/pages/Dashboard/AddEvent/AddEvent.jsx +++ b/src/pages/Dashboard/AddEvent/AddEvent.jsx @@ -108,6 +108,7 @@ import { groupEventsByDate } from '../../../utils/groupSubEventsConfigByDate'; import MultipleImageUpload from '../../../components/MultipleImageUpload'; import { adminCheckHandler } from '../../../utils/adminCheckHandler'; import { getCurrentCalendarDetailsFromUserDetails } from '../../../utils/getCurrentCalendarDetailsFromUserDetails'; +import { getWeekDayDates } from '../../../utils/getWeekDayDates'; const { TextArea } = Input; @@ -161,6 +162,7 @@ function AddEvent() { const [getAllTaxonomy] = useLazyGetAllTaxonomyQuery({ sessionId: timestampRef }); const [dateType, setDateType] = useState(); + const [subEventCount, setSubEventCount] = useState(0); const [startDate, setStartDate] = useState(); const [endDate, setEndDate] = useState(); const [ticketType, setTicketType] = useState(); @@ -235,9 +237,29 @@ function AddEvent() { let mainImageData = eventData?.image?.find((image) => image?.isMain) || null; const calendarContentLanguage = currentCalendarData?.contentLanguage; - const dateTimeConverter = (date, time) => { - let dateSelected = date.format('DD-MM-YYYY'); - let timeSelected = time.format('hh:mm:ss a'); + const dateTimeConverter = (date, time, isAdjustedCustomDate = false) => { + let dateSelected; + let timeSelected; + + // Determine if the date is already in the 'DD-MM-YYYY' format. + // This is to hadle for cases where the date comes from a recurring event configurations that are being converted to single event + if (moment.isMoment(date)) { + dateSelected = date.format('DD-MM-YYYY'); + } else { + dateSelected = date; + } + + // adjustedCustomDate is used to handle dates that are coming from custom recurring event config + if (isAdjustedCustomDate) { + return moment.tz(dateSelected + ' ' + time, 'DD-MM-YYYY HH:mm a', 'Canada/Eastern'); + } + + if (moment.isMoment(time)) { + timeSelected = time.format('hh:mm:ss a'); + } else { + timeSelected = time; + } + // Combine date and time and explicitly set the timezone to 'Canada/Eastern' let dateTime = moment.tz(dateSelected + ' ' + timeSelected, 'DD-MM-YYYY HH:mm a', 'Canada/Eastern'); return dateTime.toISOString(); @@ -452,6 +474,13 @@ function AddEvent() { let startTimeValue = values?.startTime; let endTimeValue = values?.endTime; let dateTypeValue = dateType; + let customTimeFlag = false; + let customStartTimeFlag = false; + let customEndTimeFlag = false; + let customDatesFlag = false; + let multipleDatesFlag = false; + let multipleStartTimeFlag = false; + let multipleEndTimeFlag = false; if (dateTypeValue === dateTypes.MULTIPLE) { const recurEvent = { @@ -480,35 +509,50 @@ function AddEvent() { }; // following code looks at custom date and convert them to a single day event if there is only one occurance - let customDatesFlag = recurEvent?.customDates ? true : false; - let customTimeFlag = false; + customDatesFlag = !!recurEvent?.customDates; if (customDatesFlag && recurEvent.customDates.length === 1) { - const customTime = recurEvent.customDates[0]?.customTime; - if (!customTime || customTime.length <= 1) { - customDatesFlag = false; - customTimeFlag = customTime ? true : false; - } + const customTimes = recurEvent.customDates[0]?.customTimes || []; + customTimeFlag = customTimes.length == 1; + customDatesFlag = customTimes.length <= 1; + } else if (subEventCount == 1) { + multipleDatesFlag = true; + dateTypeValue = dateTypes.SINGLE; + datePickerValue = getWeekDayDates(recurEvent); + } else { + customDatesFlag = false; } - if (!customDatesFlag) { + if (customDatesFlag) { dateTypeValue = dateTypes.SINGLE; - const singleCustomDate = recurEvent.customDates[0]; + const singleCustomDate = recurEvent.customDates?.[0]; datePickerValue = moment(singleCustomDate?.startDate); if (customTimeFlag) { - startTimeValue = singleCustomDate?.customTime[0]?.startTime; - endTimeValue = singleCustomDate?.customTime[0]?.endTime; + startTimeValue = singleCustomDate?.customTimes?.[0]?.startTime; + endTimeValue = singleCustomDate?.customTimes?.[0]?.endTime; + if (startTimeValue) customStartTimeFlag = true; + if (endTimeValue) customEndTimeFlag = true; + } else { + startTimeValue = undefined; + endTimeValue = undefined; } - } else recurringEvent = recurEvent; + } else if (multipleDatesFlag) { + startTimeValue = recurEvent?.startTime; + endTimeValue = recurEvent?.endTime; + if (startTimeValue) multipleStartTimeFlag = true; + if (endTimeValue) multipleEndTimeFlag = true; + } else { + recurringEvent = recurEvent; + } } if (dateTypeValue === dateTypes.SINGLE) { - if (startTimeValue) startDateTime = dateTimeConverter(datePickerValue, startTimeValue); + if (startTimeValue) startDateTime = dateTimeConverter(datePickerValue, startTimeValue, customTimeFlag); else startDateTime = moment .tz(datePickerValue, eventData?.scheduleTimezone ?? 'Canada/Eastern') .format('YYYY-MM-DD'); - if (endTimeValue) endDateTime = dateTimeConverter(datePickerValue, endTimeValue); + if (endTimeValue) endDateTime = dateTimeConverter(datePickerValue, endTimeValue, customTimeFlag); } if (dateTypeValue === dateTypes.RANGE) { if (values?.startTime) startDateTime = dateTimeConverter(values?.dateRangePicker[0], values?.startTime); @@ -729,12 +773,22 @@ function AddEvent() { if (nameEn) name['en'] = nameEn; if (nameFr) name['fr'] = nameFr; + const startTimeFlag = values?.startTime && !(customDatesFlag || multipleDatesFlag); + const endTimeFlag = values?.endTime && !(customDatesFlag || multipleDatesFlag); eventObj = { name: !(Object.keys(name).length > 0) ? { ...name, ...eventData?.name } : name, - ...(values?.startTime && { startDateTime }), - ...(!values?.startTime && { startDate: startDateTime }), - ...(values?.endTime && { endDateTime }), - ...(!values?.endTime && { endDate: endDateTime }), + ...((startTimeFlag || customStartTimeFlag || multipleStartTimeFlag) && { + startDateTime, + }), + ...((startTimeFlag || !(customStartTimeFlag || multipleStartTimeFlag)) && { + startDate: startDateTime, + }), + ...((endTimeFlag || customEndTimeFlag || multipleEndTimeFlag) && { + endDateTime, + }), + ...((endTimeFlag || !(customEndTimeFlag || multipleEndTimeFlag)) && { + endDate: endDateTime, + }), eventStatus: values?.eventStatus, ...((values?.englishEditor || values?.frenchEditor) && { description }), ...(values?.eventAccessibility && { @@ -2495,6 +2549,8 @@ function AddEvent() { numberOfDaysEvent={eventData?.subEvents?.length} form={form} eventDetails={eventData} + subEventCount={subEventCount} + setSubEventCount={setSubEventCount} onCalendarChange={(dates) => { setStartDate(dates?.[0]); setEndDate(dates?.[1]); diff --git a/src/utils/getWeekDayDates.js b/src/utils/getWeekDayDates.js new file mode 100644 index 00000000..64cbf31e --- /dev/null +++ b/src/utils/getWeekDayDates.js @@ -0,0 +1,30 @@ +import moment from 'moment'; + +const weekDaysMap = { + sunday: 0, + monday: 1, + tuesday: 2, + wednesday: 3, + thursday: 4, + friday: 5, + saturday: 6, +}; + +export const getWeekDayDates = (schedule) => { + const { startDate, endDate, weekDays } = schedule; + const start = moment(startDate); + const end = moment(endDate); + const targetWeekDays = weekDays.map((day) => weekDaysMap[day.toLowerCase()]); + + let dates = []; + let currentDate = moment(start); + + while (currentDate <= end) { + if (targetWeekDays.includes(currentDate.day())) { + dates.push(currentDate.format('YYYY-MM-DD')); + } + currentDate.add(1, 'days'); + } + + return dates.length > 0 ? dates[0] : startDate; +}; From 7510fa006e28b53362995011d1a9f3b1465ff40f Mon Sep 17 00:00:00 2001 From: syam babu Date: Tue, 2 Jul 2024 13:13:26 +0530 Subject: [PATCH 16/20] fix: code clean up --- src/pages/Dashboard/AddEvent/AddEvent.jsx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/pages/Dashboard/AddEvent/AddEvent.jsx b/src/pages/Dashboard/AddEvent/AddEvent.jsx index 4813e348..57c3cc63 100644 --- a/src/pages/Dashboard/AddEvent/AddEvent.jsx +++ b/src/pages/Dashboard/AddEvent/AddEvent.jsx @@ -1,4 +1,3 @@ -/* eslint-disable no-unused-vars */ import React, { useEffect, useState, useRef, useCallback } from 'react'; import './addEvent.css'; import { Form, Row, Col, Input, message, Button, notification } from 'antd'; @@ -470,6 +469,10 @@ function AddEvent() { }); // Use a regular expression to remove


tags at the end + // Below code handles dates and time for single, range and multiple dates + // custom dates that has only one occurance will be converted to single event + // multiple dates that has only one occurance will be converted to single event + let datePickerValue = values?.datePicker; let startTimeValue = values?.startTime; let endTimeValue = values?.endTime; @@ -512,10 +515,12 @@ function AddEvent() { customDatesFlag = !!recurEvent?.customDates; if (customDatesFlag && recurEvent.customDates.length === 1) { + // sets flags for customTime and customDates inclusion const customTimes = recurEvent.customDates[0]?.customTimes || []; customTimeFlag = customTimes.length == 1; customDatesFlag = customTimes.length <= 1; } else if (subEventCount == 1) { + // sets flags and values for multipleDay event with only one occurance multipleDatesFlag = true; dateTypeValue = dateTypes.SINGLE; datePickerValue = getWeekDayDates(recurEvent); @@ -524,6 +529,7 @@ function AddEvent() { } if (customDatesFlag) { + // custom dates to single event conversion logic dateTypeValue = dateTypes.SINGLE; const singleCustomDate = recurEvent.customDates?.[0]; datePickerValue = moment(singleCustomDate?.startDate); @@ -554,6 +560,7 @@ function AddEvent() { .format('YYYY-MM-DD'); if (endTimeValue) endDateTime = dateTimeConverter(datePickerValue, endTimeValue, customTimeFlag); } + if (dateTypeValue === dateTypes.RANGE) { if (values?.startTime) startDateTime = dateTimeConverter(values?.dateRangePicker[0], values?.startTime); else @@ -773,20 +780,22 @@ function AddEvent() { if (nameEn) name['en'] = nameEn; if (nameFr) name['fr'] = nameFr; - const startTimeFlag = values?.startTime && !(customDatesFlag || multipleDatesFlag); - const endTimeFlag = values?.endTime && !(customDatesFlag || multipleDatesFlag); + const isStartDateConvertedCustomDates = values?.startTime && !(customDatesFlag || multipleDatesFlag); + const isEndDateConvertedCustomDates = values?.endTime && !(customDatesFlag || multipleDatesFlag); + const isCustomOrMultipleDatesHasEndTime = customEndTimeFlag || multipleEndTimeFlag; + const isCustomOrMultipleDatesHasStartTime = customStartTimeFlag || multipleStartTimeFlag; eventObj = { name: !(Object.keys(name).length > 0) ? { ...name, ...eventData?.name } : name, - ...((startTimeFlag || customStartTimeFlag || multipleStartTimeFlag) && { + ...((isStartDateConvertedCustomDates || isCustomOrMultipleDatesHasStartTime) && { startDateTime, }), - ...((startTimeFlag || !(customStartTimeFlag || multipleStartTimeFlag)) && { + ...((isStartDateConvertedCustomDates || !isCustomOrMultipleDatesHasStartTime) && { startDate: startDateTime, }), - ...((endTimeFlag || customEndTimeFlag || multipleEndTimeFlag) && { + ...((isEndDateConvertedCustomDates || isCustomOrMultipleDatesHasEndTime) && { endDateTime, }), - ...((endTimeFlag || !(customEndTimeFlag || multipleEndTimeFlag)) && { + ...((isEndDateConvertedCustomDates || !isCustomOrMultipleDatesHasEndTime) && { endDate: endDateTime, }), eventStatus: values?.eventStatus, From 340b1a50d6c0448f7cc84e86a4a929a05086e9d1 Mon Sep 17 00:00:00 2001 From: syam babu Date: Tue, 2 Jul 2024 13:26:04 +0530 Subject: [PATCH 17/20] fix: refactored code --- src/pages/Dashboard/AddEvent/AddEvent.jsx | 28 ++++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/pages/Dashboard/AddEvent/AddEvent.jsx b/src/pages/Dashboard/AddEvent/AddEvent.jsx index 57c3cc63..95cda148 100644 --- a/src/pages/Dashboard/AddEvent/AddEvent.jsx +++ b/src/pages/Dashboard/AddEvent/AddEvent.jsx @@ -477,10 +477,12 @@ function AddEvent() { let startTimeValue = values?.startTime; let endTimeValue = values?.endTime; let dateTypeValue = dateType; + let customTimeFlag = false; let customStartTimeFlag = false; let customEndTimeFlag = false; let customDatesFlag = false; + let multipleDatesFlag = false; let multipleStartTimeFlag = false; let multipleEndTimeFlag = false; @@ -511,7 +513,6 @@ function AddEvent() { form.getFieldsValue().frequency === 'CUSTOM' ? form.getFieldsValue().customDates : undefined, }; - // following code looks at custom date and convert them to a single day event if there is only one occurance customDatesFlag = !!recurEvent?.customDates; if (customDatesFlag && recurEvent.customDates.length === 1) { @@ -528,25 +529,30 @@ function AddEvent() { customDatesFlag = false; } + // following code convert custom date to a single day event if there is only one occurance if (customDatesFlag) { - // custom dates to single event conversion logic + // Custom dates to single event conversion logic dateTypeValue = dateTypes.SINGLE; const singleCustomDate = recurEvent.customDates?.[0]; - datePickerValue = moment(singleCustomDate?.startDate); + datePickerValue = singleCustomDate ? moment(singleCustomDate.startDate) : undefined; + if (customTimeFlag) { - startTimeValue = singleCustomDate?.customTimes?.[0]?.startTime; - endTimeValue = singleCustomDate?.customTimes?.[0]?.endTime; - if (startTimeValue) customStartTimeFlag = true; - if (endTimeValue) customEndTimeFlag = true; + const customTimes = singleCustomDate?.customTimes?.[0] || {}; + startTimeValue = customTimes.startTime ?? undefined; + endTimeValue = customTimes.endTime ?? undefined; + + customStartTimeFlag = !!startTimeValue; + customEndTimeFlag = !!endTimeValue; } else { startTimeValue = undefined; endTimeValue = undefined; } } else if (multipleDatesFlag) { - startTimeValue = recurEvent?.startTime; - endTimeValue = recurEvent?.endTime; - if (startTimeValue) multipleStartTimeFlag = true; - if (endTimeValue) multipleEndTimeFlag = true; + startTimeValue = recurEvent?.startTime ?? undefined; + endTimeValue = recurEvent?.endTime ?? undefined; + + multipleStartTimeFlag = !!startTimeValue; + multipleEndTimeFlag = !!endTimeValue; } else { recurringEvent = recurEvent; } From fbe48c7c5cd6e81732dda8d4a287c770c2aeac29 Mon Sep 17 00:00:00 2001 From: syam babu Date: Tue, 2 Jul 2024 16:03:11 +0530 Subject: [PATCH 18/20] fix: minor adjustments to date formatting --- src/pages/Dashboard/AddEvent/AddEvent.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Dashboard/AddEvent/AddEvent.jsx b/src/pages/Dashboard/AddEvent/AddEvent.jsx index 95cda148..69da1cf7 100644 --- a/src/pages/Dashboard/AddEvent/AddEvent.jsx +++ b/src/pages/Dashboard/AddEvent/AddEvent.jsx @@ -245,7 +245,7 @@ function AddEvent() { if (moment.isMoment(date)) { dateSelected = date.format('DD-MM-YYYY'); } else { - dateSelected = date; + dateSelected = moment(date).format('DD-MM-YYYY'); } // adjustedCustomDate is used to handle dates that are coming from custom recurring event config From 7aeb2c28a7c55862d4edb76b0039f1471b735258 Mon Sep 17 00:00:00 2001 From: syam babu Date: Tue, 2 Jul 2024 16:55:44 +0530 Subject: [PATCH 19/20] fix: fixed warning not appearing in bilingual inputs of general settings page --- src/constants/calendarSettingsForm.js | 70 ++++++++++--------- .../CalendarSettings/CalendarSettings.jsx | 1 + 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/constants/calendarSettingsForm.js b/src/constants/calendarSettingsForm.js index 5df5dcf4..ece38ad9 100644 --- a/src/constants/calendarSettingsForm.js +++ b/src/constants/calendarSettingsForm.js @@ -143,39 +143,45 @@ export const calendarSettingsFormFields = { { name: 'calendarName', label: {(t) => t('dashboard.settings.calendarSettings.calendarName')}, - field: ({ t }) => ( - - -