diff --git a/ui/react-components/components/AddAppointment/AddAppointment.test.jsx b/ui/react-components/components/AddAppointment/AddAppointment.test.jsx index 7bf4832b6..e6353f387 100644 --- a/ui/react-components/components/AddAppointment/AddAppointment.test.jsx +++ b/ui/react-components/components/AddAppointment/AddAppointment.test.jsx @@ -35,7 +35,7 @@ const clickOnFirstDayOfNextMonth = (container) => { const nextMonth = moment().add(1, 'month'); // Get the moment object for the next month const firstDayNextMonth = nextMonth.startOf('month'); const datePickerInput = container.querySelector('.bx--date-picker__input'); - fireEvent.change(datePickerInput, {target: {value: firstDayNextMonth.format("MM/DD/YYYY") }}); + fireEvent.change(datePickerInput, {target: {value: firstDayNextMonth.format("DD/MM/YYYY") }}); fireEvent.blur(datePickerInput) return firstDayNextMonth; }; @@ -156,7 +156,7 @@ describe('Add Appointment', () => { const selectedDate = clickOnFirstDayOfNextMonth(container) const dateInputField = container.querySelector('.bx--date-picker__input'); - expect(dateInputField.value).toBe(selectedDate.format('MM/DD/YYYY')); + expect(dateInputField.value).toBe(selectedDate.format('DD/MM/YYYY')); fireEvent.click(getByText('Check and Save')); @@ -230,8 +230,8 @@ describe('Add Appointment', () => { "defaultNumberOfOccurrences": 10 } }; - const today = moment().format("MM/DD/YYYY"); - const fiveDaysFromToday = moment().add(5, 'days').format("MM/DD/YYYY"); + const today = moment().format("DD/MM/YYYY"); + const fiveDaysFromToday = moment().add(5, 'days').format("DD/MM/YYYY"); const {getByText, container, queryAllByText, getByTestId, queryByText} = renderWithReactIntl(); const saveAppointmentSpy = jest.spyOn(addAppointmentService, 'saveRecurring'); @@ -425,8 +425,8 @@ describe('Add Appointment', () => { appointmentParams={appointmentParams}/>); expect(container.querySelectorAll('.bx--time-picker__input-field')[0].value).toBe(today.format('h:mm').toLowerCase()); expect(container.querySelectorAll('.bx--time-picker__input-field')[1].value).toBe(addTwoHoursFromNow.format('h:mm').toLowerCase()); - const dateInputField = getByPlaceholderText('mm/dd/yyyy'); - expect(dateInputField.value).toBe(today.format('MM/DD/YYYY')); + const dateInputField = getByPlaceholderText('dd/mm/yyyy'); + expect(dateInputField.value).toBe(today.format('DD/MM/YYYY')); }); it('should populate the start date, start time and end time coming as prop for recurring appointment', function () { @@ -445,9 +445,9 @@ describe('Add Appointment', () => { expect(container.querySelectorAll('.bx--time-picker__input-field')[0].value).toBe(today.format('h:mm').toLowerCase()); expect(container.querySelectorAll('.bx--time-picker__input-field')[1].value).toBe(addTwoHoursFromNow.format('h:mm').toLowerCase()); - const dateInputField = getAllByPlaceholderText('mm/dd/yyyy')[0]; + const dateInputField = getAllByPlaceholderText('dd/mm/yyyy')[0]; - expect(dateInputField.value).toBe(today.format('MM/DD/YYYY')); + expect(dateInputField.value).toBe(today.format('DD/MM/YYYY')); }); it('should not add second provider when maxAppointmentProvidersAllowed is 1', async () => { @@ -549,8 +549,8 @@ describe('Add Appointment', () => { const {container, getByPlaceholderText, queryByText} = renderWithReactIntl(); const selectedDate = clickOnFirstDayOfNextMonth(container); - const dateInputField = getByPlaceholderText('mm/dd/yyyy'); - expect(dateInputField.value).toBe(selectedDate.format('MM/DD/YYYY')); + const dateInputField = getByPlaceholderText('dd/mm/yyyy'); + expect(dateInputField.value).toBe(selectedDate.format('DD/MM/YYYY')); }); }); diff --git a/ui/react-components/components/DatePickerCarbon/DatePickerCarbon.jsx b/ui/react-components/components/DatePickerCarbon/DatePickerCarbon.jsx index 759e52dd3..4c0ad647d 100644 --- a/ui/react-components/components/DatePickerCarbon/DatePickerCarbon.jsx +++ b/ui/react-components/components/DatePickerCarbon/DatePickerCarbon.jsx @@ -8,7 +8,7 @@ const DatePickerCarbon = props => { const {onChange, value, title, minDate, testId, width, isDisabled, isRequired, showWarning, intl} = props; let defaultTime = value; if( value && value instanceof moment){ - defaultTime = value.format("MM/DD/YYYY"); + defaultTime = value.format("DD/MM/YYYY"); } let titleText= title && const warningText = intl.formatMessage({ @@ -17,10 +17,10 @@ const DatePickerCarbon = props => { }); return ( <div data-testid={testId || "datePicker"}> - <DatePicker datePickerType={"single"} onChange={onChange} disabled={isDisabled} minDate={minDate} value={defaultTime}> + <DatePicker datePickerType={"single"} onChange={onChange} disabled={isDisabled} minDate={minDate} value={defaultTime} dateFormat={"d/m/Y"}> <DatePickerInput id={"Appointment Date"} - placeholder={"mm/dd/yyyy"} + placeholder={"dd/mm/yyyy"} labelText={titleText} size={"md"} style={{width: width || "250px"}} diff --git a/ui/react-components/components/EditAppointment/EditAppointment.jsx b/ui/react-components/components/EditAppointment/EditAppointment.jsx index efb86f42f..8658c775a 100644 --- a/ui/react-components/components/EditAppointment/EditAppointment.jsx +++ b/ui/react-components/components/EditAppointment/EditAppointment.jsx @@ -580,9 +580,9 @@ const EditAppointment = props => { return undefined; } if( moment(date).isBefore(moment().startOf("day"))){ - return moment(date).format("MM-DD-YYYY"); + return moment(date).format("DD-MM-YYYY"); } - return moment().format("MM-DD-YYYY") + return moment().format("DD-MM-YYYY") } const handleStatusChange = value => { @@ -783,8 +783,8 @@ const EditAppointment = props => { value={appointmentDetails.recurringEndDate} isDisabled={componentsDisableStatus.endDate} intl={intl} - minDate={(appointmentDetails.appointmentDate && moment(appointmentDetails.appointmentDate).format("MM-DD-YYYY")) - || moment().format("MM-DD-YYYY")} + minDate={(appointmentDetails.appointmentDate && moment(appointmentDetails.appointmentDate).format("DD-MM-YYYY")) + || moment().format("DD-MM-YYYY")} testId={"recurring-end-date-selector"}/> </div>)} <div className={classNames(recurringContainerBlock)}> diff --git a/ui/react-components/components/EditAppointment/EditAppointment.spec.jsx b/ui/react-components/components/EditAppointment/EditAppointment.spec.jsx index def21a16f..aff139fdd 100644 --- a/ui/react-components/components/EditAppointment/EditAppointment.spec.jsx +++ b/ui/react-components/components/EditAppointment/EditAppointment.spec.jsx @@ -38,7 +38,7 @@ const clickOnFirstDayOfNextMonth = (container) => { const nextMonth = moment().add(1, 'month'); // Get the moment object for the next month const firstDayNextMonth = nextMonth.startOf('month'); const datePickerInput = container.querySelector('.bx--date-picker__input'); - fireEvent.change(datePickerInput, {target: {value: firstDayNextMonth.format("MM/DD/YYYY") }}); + fireEvent.change(datePickerInput, {target: {value: firstDayNextMonth.format("DD/MM/YYYY") }}); fireEvent.blur(datePickerInput) return firstDayNextMonth; }; @@ -446,7 +446,7 @@ describe('Edit Appointment', () => { }); await flushPromises(); const dateSelectedField = containerInDom.querySelector('.bx--date-picker__input'); - expect(moment(dateSelectedField.value).date()).toBe(11); + expect(moment(dateSelectedField.value,'DD/MM/YYYY').date()).toBe(11); }) });