diff --git a/i18n/en.pot b/i18n/en.pot index 0e6ac05309..2d47d39df3 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-12-15T15:25:38.375Z\n" -"PO-Revision-Date: 2024-12-15T15:25:38.375Z\n" +"POT-Creation-Date: 2025-01-02T12:54:39.984Z\n" +"PO-Revision-Date: 2025-01-02T12:54:39.984Z\n" msgid "Choose one or more dates..." msgstr "Choose one or more dates..." @@ -1288,6 +1288,12 @@ msgstr "Write a note about this event" msgid "This event doesn't have any notes" msgstr "This event doesn't have any notes" +msgid "after" +msgstr "after" + +msgid "before" +msgstr "before" + msgid "Schedule date info" msgstr "Schedule date info" @@ -1302,32 +1308,32 @@ msgid_plural "The scheduled date is {{count}} days {{position}} the suggested da msgstr[0] "The scheduled date is {{count}} day {{position}} the suggested date." msgstr[1] "The scheduled date is {{count}} days {{position}} the suggested date." -msgid "after" -msgstr "after" - -msgid "before" -msgstr "before" - msgid "There are {{count}} scheduled event in {{orgUnitName}} on this day." msgid_plural "There are {{count}} scheduled event in {{orgUnitName}} on this day." msgstr[0] "There are {{count}} scheduled event in {{orgUnitName}} on this day." msgstr[1] "There are {{count}} scheduled events in {{orgUnitName}} on this day." +msgid "Schedule date / Due date" +msgstr "Schedule date / Due date" + +msgid "Please provide a valid organisation unit" +msgstr "Please provide a valid organisation unit" + msgid "Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}" msgstr "Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}" msgid "Schedule info" msgstr "Schedule info" -msgid "Schedule date / Due date" -msgstr "Schedule date / Due date" - msgid "Event notes" msgstr "Event notes" msgid "Write a note about this scheduled event" msgstr "Write a note about this scheduled event" +msgid "Program or stage is invalid" +msgstr "Program or stage is invalid" + msgid "Save note" msgstr "Save note" @@ -1424,9 +1430,6 @@ msgstr "Report date" msgid "Please enter a date" msgstr "Please enter a date" -msgid "Please provide a valid organisation unit" -msgstr "Please provide a valid organisation unit" - msgid "Please select a valid event" msgstr "Please select a valid event" diff --git a/src/core_modules/capture-core/components/Widget/widgetCollapsible.types.js b/src/core_modules/capture-core/components/Widget/widgetCollapsible.types.js index 3f182d8f8e..6392f0fc94 100644 --- a/src/core_modules/capture-core/components/Widget/widgetCollapsible.types.js +++ b/src/core_modules/capture-core/components/Widget/widgetCollapsible.types.js @@ -2,7 +2,7 @@ import type { Node } from 'react'; export type WidgetCollapsibleProps = {| - header: Node, + header?: Node, children: Node, open: boolean, onOpen: () => void, diff --git a/src/core_modules/capture-core/components/Widget/widgetNonCollapsible.types.js b/src/core_modules/capture-core/components/Widget/widgetNonCollapsible.types.js index 3af55c409b..4e1e8e4f3d 100644 --- a/src/core_modules/capture-core/components/Widget/widgetNonCollapsible.types.js +++ b/src/core_modules/capture-core/components/Widget/widgetNonCollapsible.types.js @@ -2,7 +2,7 @@ import type { Node } from 'react'; export type WidgetNonCollapsibleProps = {| - header: Node, + header?: Node, children: Node, color?: string, borderless?: boolean, diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/dataEntryFieldLabels.module.css b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/dataEntryFieldLabels.module.css index 19bf2d5799..27d4299344 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/dataEntryFieldLabels.module.css +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/dataEntryFieldLabels.module.css @@ -41,7 +41,7 @@ } .orgUnitLabel { - padding-top: 3px; + padding-top: 13px; } .selectLabel { diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/InfoBox/InfoBox.component.js b/src/core_modules/capture-core/components/WidgetEventSchedule/InfoBox/InfoBox.component.js index d62a901d0d..eacbbf5588 100644 --- a/src/core_modules/capture-core/components/WidgetEventSchedule/InfoBox/InfoBox.component.js +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/InfoBox/InfoBox.component.js @@ -10,9 +10,13 @@ const styles = { infoBox: { marginTop: spacersNum.dp16, padding: spacersNum.dp16, + width: 'fit-content', }, }; +const getDayDifference = (startDate: string, endDate: string): number => + moment(startDate).diff(moment(endDate), 'days'); + const InfoBoxPlain = ({ scheduleDate, suggestedScheduleDate, @@ -21,38 +25,49 @@ const InfoBoxPlain = ({ orgUnitName, classes, }: Props) => { - if (!scheduleDate || !suggestedScheduleDate) { return null; } - const differenceScheduleDateAndSuggestedDate = moment(scheduleDate).diff(moment(suggestedScheduleDate), 'days'); + if (!scheduleDate || !suggestedScheduleDate) { + return null; + } + + const dayDifference = getDayDifference(scheduleDate, suggestedScheduleDate); + const absoluteDifference = Math.abs(dayDifference); + const position = dayDifference > 0 ? i18n.t('after') : i18n.t('before'); + const scheduledDateMatchesSuggested = scheduleDate === suggestedScheduleDate; return ( - {hideDueDate ? <> - {i18n.t('Scheduled automatically for {{suggestedScheduleDate}}', { suggestedScheduleDate })} - : <> - {scheduleDate === suggestedScheduleDate ? - i18n.t('The scheduled date matches the suggested date, but can be changed if needed.') - : - i18n.t( - 'The scheduled date is {{count}} days {{position}} the suggested date.', - { - position: differenceScheduleDateAndSuggestedDate > 0 ? i18n.t('after') : i18n.t('before'), - count: Math.abs(differenceScheduleDateAndSuggestedDate), - defaultValue: 'The scheduled date is {{count}} day {{position}} the suggested date.', - defaultValue_plural: 'The scheduled date is {{count}} days {{position}} the suggested date.', - }) - } - {' '} - {i18n.t('There are {{count}} scheduled event in {{orgUnitName}} on this day.', { - count: eventCountInOrgUnit, - orgUnitName, - defaultValue: 'There are {{count}} scheduled event in {{orgUnitName}} on this day.', - defaultValue_plural: 'There are {{count}} scheduled events in {{orgUnitName}} on this day.', - interpolation: { - escapeValue: false, - }, - })}} + {hideDueDate ? ( + <> + {i18n.t('Scheduled automatically for {{suggestedScheduleDate}}', { suggestedScheduleDate })} + + ) : ( + <> + {scheduledDateMatchesSuggested + ? i18n.t('The scheduled date matches the suggested date, but can be changed if needed.') + : i18n.t( + 'The scheduled date is {{count}} days {{position}} the suggested date.', + { + position, + count: absoluteDifference, + defaultValue: 'The scheduled date is {{count}} day {{position}} the suggested date.', + defaultValue_plural: 'The scheduled date is {{count}} days {{position}} the suggested date.', + }, + ) + } + {' '} + {i18n.t('There are {{count}} scheduled event in {{orgUnitName}} on this day.', { + count: eventCountInOrgUnit, + orgUnitName, + defaultValue: 'There are {{count}} scheduled event in {{orgUnitName}} on this day.', + defaultValue_plural: 'There are {{count}} scheduled events in {{orgUnitName}} on this day.', + interpolation: { + escapeValue: false, + }, + })} + + )} ); }; -export const InfoBox: ComponentType<$Diff> = (withStyles(styles)(InfoBoxPlain)); +export const InfoBox: ComponentType<$Diff> = withStyles(styles)(InfoBoxPlain); diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/ScheduleDate.component.js b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/ScheduleDate.component.js index ca3f806f2d..9f8c790587 100644 --- a/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/ScheduleDate.component.js +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/ScheduleDate.component.js @@ -1,18 +1,46 @@ // @flow import React, { type ComponentType } from 'react'; -import { spacersNum } from '@dhis2/ui'; +import i18n from '@dhis2/d2-i18n'; import withStyles from '@material-ui/core/styles/withStyles'; -import { DateField } from 'capture-core/components/FormFields/New'; -import { InfoBox } from '../InfoBox'; +import { spacers, colors } from '@dhis2/ui'; +import { + DateField, + withDefaultFieldContainer, + withLabel, + withDisplayMessages, + withInternalChangeHandler, +} from 'capture-core/components/FormFields/New'; + import type { Props } from './scheduleDate.types'; +import labelTypeClasses from './dataEntryFieldLabels.module.css'; +import { InfoBox } from '../InfoBox'; +import { baseInputStyles } from '../ScheduleOrgUnit/commonProps'; + + +const ScheduleDateField = withDefaultFieldContainer()( + withLabel({ + onGetCustomFieldLabeClass: () => labelTypeClasses.dateLabel, + })( + withDisplayMessages()( + withInternalChangeHandler()( + DateField, + ), + ), + ), +); const styles = { - container: { + infoBox: { + padding: `0 ${spacers.dp16} ${spacers.dp16} ${spacers.dp16}`, + }, + fieldWrapper: { display: 'flex', - marginTop: spacersNum.dp4, + flexWrap: 'wrap', }, - button: { - paddingRight: spacersNum.dp16, + fieldLabel: { + color: colors.grey900, + padding: `${spacers.dp16} ${spacers.dp24} 0 ${spacers.dp16}`, + fontSize: '14px', }, }; @@ -22,35 +50,51 @@ const ScheduleDatePlain = ({ setScheduleDate, orgUnit, serverSuggestedScheduleDate, + displayDueDateLabel, eventCountInOrgUnit, classes, hideDueDate, -}: Props) => (<> - {!hideDueDate &&
- {}} - onFocus={() => { }} - onRemoveFocus={() => { }} - onBlur={(e, internalComponentError) => { - const { error } = internalComponentError; - if (error) { - setScheduleDate(''); - return; - } - setScheduleDate(e); - }} - /> -
} - -); +}: Props) => ( +
+ {!hideDueDate ? + { }} + onFocus={() => { }} + onRemoveFocus={() => { }} + onBlur={(e, internalComponentError) => { + const { error } = internalComponentError; + if (error) { + setScheduleDate(''); + return; + } + setScheduleDate(e); + }} + /> + : +
+ {displayDueDateLabel ?? i18n.t('Schedule date / Due date', { + interpolation: { escapeValue: false }, + }, + )} +
+ } +
+ +
+
+); + export const ScheduleDate: ComponentType<$Diff> = (withStyles(styles)(ScheduleDatePlain)); diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/dataEntryFieldLabels.module.css b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/dataEntryFieldLabels.module.css new file mode 100644 index 0000000000..c795dd8efc --- /dev/null +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/dataEntryFieldLabels.module.css @@ -0,0 +1,3 @@ +.dateLabel { + padding-top: 13px; +} diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/scheduleDate.types.js b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/scheduleDate.types.js index ede74d4e37..6776f07c43 100644 --- a/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/scheduleDate.types.js +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/scheduleDate.types.js @@ -5,6 +5,7 @@ export type Props = {| stageId: string, programId: string, enrolledAt: string, + displayDueDateLabel: string, scheduleDate?: ?string, serverScheduleDate?: ?string, setScheduleDate: (date: string) => void, diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleOrgUnit/ScheduleOrgUnit.component.js b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleOrgUnit/ScheduleOrgUnit.component.js new file mode 100644 index 0000000000..9718127671 --- /dev/null +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleOrgUnit/ScheduleOrgUnit.component.js @@ -0,0 +1,74 @@ +// @flow +import React, { useState } from 'react'; +import i18n from '@dhis2/d2-i18n'; +import { isValidOrgUnit } from 'capture-core-utils/validators/form'; +import labelTypeClasses from './dataEntryFieldLabels.module.css'; +import { baseInputStyles } from './commonProps'; +import { + SingleOrgUnitSelectField, + withDefaultFieldContainer, + withDisplayMessages, + withInternalChangeHandler, + withLabel, +} from '../../FormFields/New'; + +type OrgUnitValue = {| + checked: boolean, + id: string, + children: number, + name: string, + displayName: string, + path: string, + selected: string[], +|} + +type Props = { + onSelectOrgUnit: (orgUnit: OrgUnitValue) => void, + onDeselectOrgUnit: () => void, + orgUnit: OrgUnitValue, +}; + +const OrgUnitFieldForForm = withDefaultFieldContainer()( + withLabel({ + onGetCustomFieldLabeClass: () => labelTypeClasses.dateLabel, + })( + withDisplayMessages()( + withInternalChangeHandler()( + SingleOrgUnitSelectField, + ), + ), + ), +); + +export const ScheduleOrgUnit = ({ + onSelectOrgUnit, + onDeselectOrgUnit, + orgUnit, +}: Props) => { + const [touched, setTouched] = useState(false); + + const handleSelect = (event) => { + setTouched(true); + onSelectOrgUnit(event); + }; + + const handleDeselect = () => { + setTouched(true); + onDeselectOrgUnit(); + }; + + const shouldShowError = (!isValidOrgUnit(orgUnit) && touched); + const errorMessages = i18n.t('Please provide a valid organisation unit'); + + return ( + + ); +}; diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleOrgUnit/commonProps.js b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleOrgUnit/commonProps.js new file mode 100644 index 0000000000..909d053c6d --- /dev/null +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleOrgUnit/commonProps.js @@ -0,0 +1,6 @@ +// @flow + +export const baseInputStyles = { + inputContainerStyle: { flexBasis: 150 }, + labelContainerStyle: { flexBasis: 200 }, +}; diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleOrgUnit/dataEntryFieldLabels.module.css b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleOrgUnit/dataEntryFieldLabels.module.css new file mode 100644 index 0000000000..c795dd8efc --- /dev/null +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleOrgUnit/dataEntryFieldLabels.module.css @@ -0,0 +1,3 @@ +.dateLabel { + padding-top: 13px; +} diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.component.js b/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.component.js index d29cbd8a3a..a86780b8c4 100644 --- a/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.component.js +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.component.js @@ -1,9 +1,11 @@ // @flow -import React, { type ComponentType } from 'react'; -import { spacersNum, spacers, colors } from '@dhis2/ui'; +import React, { type ComponentType, useEffect } from 'react'; +import { spacersNum } from '@dhis2/ui'; import withStyles from '@material-ui/core/styles/withStyles'; import i18n from '@dhis2/d2-i18n'; +import { isValidOrgUnit } from 'capture-core-utils/validators/form'; import { DataSection } from '../DataSection'; +import { Widget } from '../Widget'; import { ScheduleButtons } from './ScheduleButtons'; import { ScheduleDate } from './ScheduleDate'; import { ScheduleText } from './ScheduleText'; @@ -11,43 +13,12 @@ import { NoteSection } from '../WidgetNote'; import type { Props } from './widgetEventSchedule.types'; import { CategoryOptions } from './CategoryOptions/CategoryOptions.component'; import { Assignee } from './Assignee'; +import { ScheduleOrgUnit } from './ScheduleOrgUnit/ScheduleOrgUnit.component'; const styles = () => ({ wrapper: { - padding: `${spacers.dp16} 0`, - maxWidth: '55.75rem', - }, - fieldWrapper: { - display: 'flex', - flexWrap: 'wrap', - justifyContent: 'space-between', - padding: `${spacers.dp8} ${spacers.dp16}`, - }, - fieldLabel: { - color: colors.grey900, - paddingTop: spacersNum.dp16, - paddingRight: spacersNum.dp16, - }, - fieldContent: { - flexBasis: '200px', - flexGrow: 1, - }, - containerWrapper: { - padding: `${spacers.dp8} ${spacers.dp16}`, - }, - container: { - display: 'flex', - alignItems: 'center', - paddingTop: 8, - paddingBottom: 8, - }, - label: { - flexBasis: 200, - paddingLeft: 5, - }, - field: { - flexBasis: 150, - flexGrow: 1, + paddingLeft: spacersNum.dp16, + minWidth: '300px', }, }); @@ -64,7 +35,9 @@ const WidgetEventSchedulePlain = ({ classes, scheduleDate, suggestedScheduleDate, + setScheduledOrgUnit, serverSuggestedScheduleDate, + setIsFormValid, notes, programCategory, enableUserAssignment, @@ -75,70 +48,92 @@ const WidgetEventSchedulePlain = ({ assignee, categoryOptionsError, ...passOnProps -}: Props) => ( -
- { + const onSelectOrgUnit = (e: { id: string, displayName: string, path: string }) => { + setScheduledOrgUnit({ + id: e.id, + name: e.displayName, + path: e.path, + }); + }; + + const onDeselectOrgUnit = () => { + setScheduledOrgUnit(undefined); + }; + + useEffect(() => { + const formIsValid = () => Boolean(isValidOrgUnit(orgUnit) && scheduleDate); + setIsFormValid(formIsValid()); + }, [orgUnit, scheduleDate, setIsFormValid]); + + return ( + -
-
- {displayDueDateLabel ?? i18n.t('Schedule date / Due date', { - interpolation: { escapeValue: false } }, - )} -
-
+
+ + -
+ + {programCategory && + + } + + + + {enableUserAssignment && ( + + + + )} + +
- - {programCategory && - - } - - - - {enableUserAssignment && ( - - - - )} - - -
-); +
+ ); +}; export const WidgetEventScheduleComponent: ComponentType<$Diff> = withStyles(styles)(WidgetEventSchedulePlain); diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.container.js b/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.container.js index 4132d024e9..0ca4cd2d70 100644 --- a/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.container.js +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.container.js @@ -21,13 +21,12 @@ import { useCategoryCombinations } from '../DataEntryDhis2Helpers/AOC/useCategor import { convertFormToClient, convertClientToServer } from '../../converters'; import { pipe } from '../../../capture-core-utils'; - export const WidgetEventSchedule = ({ enrollmentId, teiId, stageId, programId, - orgUnitId, + orgUnitId: initialOrgUnitId, onSave, onSaveSuccessActionType, onSaveErrorActionType, @@ -39,26 +38,32 @@ export const WidgetEventSchedule = ({ }: ContainerProps) => { const { program, stage } = useMemo(() => getProgramAndStageForProgram(programId, stageId), [programId, stageId]); const dispatch = useDispatch(); - const orgUnit = { id: orgUnitId, name: useOrgUnitNameWithAncestors(orgUnitId).displayName }; const { programStageScheduleConfig } = useScheduleConfigFromProgramStage(stageId); const { programConfig } = useScheduleConfigFromProgram(programId); const suggestedScheduleDate = useDetermineSuggestedScheduleDate({ programStageScheduleConfig, programConfig, initialScheduleDate, ...passOnProps, }); + const orgUnitData = useOrgUnitNameWithAncestors(initialOrgUnitId); + const orgUnit = initialOrgUnitId && orgUnitData + ? { id: initialOrgUnitId, name: orgUnitData.displayName } : undefined; const { currentUser, noteId } = useNoteDetails(); const [scheduleDate, setScheduleDate] = useState(''); + const [scheduledOrgUnit, setScheduledOrgUnit] = useState(orgUnit); + const [isFormValid, setIsFormValid] = useState(false); const convertFn = pipe(convertFormToClient, convertClientToServer); const serverScheduleDate = convertFn(scheduleDate, dataElementTypes.DATE); const serverSuggestedScheduleDate = convertFn(suggestedScheduleDate, dataElementTypes.DATE); const [notes, setNotes] = useState([]); const [assignee, setAssignee] = useState(storedAssignee); - const { events } = useEventsInOrgUnit(orgUnitId, serverScheduleDate); const { eventId } = useLocationQuery(); + const selectedOrgUnitId = scheduledOrgUnit?.id || initialOrgUnitId; + const { events = [] } = useEventsInOrgUnit(selectedOrgUnitId, serverScheduleDate); const eventCountInOrgUnit = events .filter(event => moment(event.scheduledAt).format('YYYY-MM-DD') === serverScheduleDate).length; const [selectedCategories, setSelectedCategories] = useState({}); const [categoryOptionsError, setCategoryOptionsError] = useState(); const { programCategory } = useCategoryCombinations(programId); + useEffect(() => { if (!scheduleDate && suggestedScheduleDate) { setScheduleDate(suggestedScheduleDate); } }, [suggestedScheduleDate, scheduleDate]); @@ -68,6 +73,7 @@ export const WidgetEventSchedule = ({ }, [storedAssignee]); const onHandleSchedule = useCallback(() => { + if (!isFormValid) { return; } if (programCategory?.categories && Object.keys(selectedCategories).length !== programCategory?.categories?.length) { const errors = programCategory.categories @@ -81,9 +87,9 @@ export const WidgetEventSchedule = ({ } dispatch(requestScheduleEvent({ scheduleDate: serverScheduleDate, + orgUnitId: selectedOrgUnitId, notes, programId, - orgUnitId, stageId, teiId, enrollmentId, @@ -100,7 +106,7 @@ export const WidgetEventSchedule = ({ serverScheduleDate, notes, programId, - orgUnitId, + selectedOrgUnitId, stageId, teiId, enrollmentId, @@ -111,15 +117,9 @@ export const WidgetEventSchedule = ({ onSaveErrorActionType, programCategory, assignee, + isFormValid, ]); - React.useEffect(() => { - if (suggestedScheduleDate && !scheduleDate) { - setScheduleDate(suggestedScheduleDate); - } - }, [scheduleDate, suggestedScheduleDate]); - - const onAddNote = (note) => { const newNote = { storedBy: currentUser.userName, @@ -159,7 +159,7 @@ export const WidgetEventSchedule = ({ if (!program || !stage || !(program instanceof TrackerProgram)) { return (
- {i18n.t('program or stage is invalid')}; + {i18n.t('Program or stage is invalid')};
); } @@ -167,9 +167,7 @@ export const WidgetEventSchedule = ({ const eventAccess = getProgramEventAccess(programId, stageId); if (!eventAccess?.write) { return ( - + ); } @@ -189,10 +187,12 @@ export const WidgetEventSchedule = ({ serverSuggestedScheduleDate={serverSuggestedScheduleDate} onCancel={onCancel} setScheduleDate={setScheduleDate} + setScheduledOrgUnit={setScheduledOrgUnit} + setIsFormValid={setIsFormValid} onSchedule={onHandleSchedule} onAddNote={onAddNote} eventCountInOrgUnit={eventCountInOrgUnit} - orgUnit={orgUnit} + orgUnit={scheduledOrgUnit} notes={notes} selectedCategories={selectedCategories} categoryOptionsError={categoryOptionsError} @@ -201,7 +201,5 @@ export const WidgetEventSchedule = ({ onSetAssignee={onSetAssignee} {...passOnProps} /> - ); }; - diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/widgetEventSchedule.types.js b/src/core_modules/capture-core/components/WidgetEventSchedule/widgetEventSchedule.types.js index 7b89143d02..3ba2bc967a 100644 --- a/src/core_modules/capture-core/components/WidgetEventSchedule/widgetEventSchedule.types.js +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/widgetEventSchedule.types.js @@ -36,6 +36,12 @@ export type Props = {| scheduleDate?: ?string, serverScheduleDate?: ?string, suggestedScheduleDate?: ?string, + setScheduledOrgUnit: (orgUnit: ?{ + id: string, + name: string, + path: string, + }) => void, + setIsFormValid: (valid: boolean) => void, serverSuggestedScheduleDate?: ?string, eventCountInOrgUnit: number, notes: Array<{value: string}>, @@ -48,7 +54,7 @@ export type Props = {| onSetAssignee: () => void, assignee?: UserFormField | null, onCancel: () => void, - setScheduleDate: (date: string) => void, + setScheduleDate: (date: ?string) => void, onAddNote: (note: string) => void, onResetCategoryOption: (categoryId: string) => void, onClickCategoryOption: (optionId: string, categoryId: string) => void,