Skip to content

Commit

Permalink
fix: code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Dec 9, 2024
1 parent b240a15 commit 0a9847d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
export { getCategoryOptionsValidatorContainers } from './categoryOptions.validatorContainersGetter';
export { getEventDateValidatorContainers } from './eventDate.validatorContainersGetter';
export { getNoteValidatorContainers } from './note.validatorContainersGetter';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @flow

import { convertGeometryOut } from 'capture-core/components/DataEntries/converters';
import { loadNewDataEntry } from '../../../DataEntry/actions/dataEntryLoadNew.actions';
import { getEventDateValidatorContainers, getOrgUnitValidatorContainers } from '../fieldValidators';
Expand Down Expand Up @@ -43,8 +42,11 @@ const dataEntryPropsToInclude: DataEntryPropsToInclude = [

export const getOpenDataEntryActions =
(dataEntryId: string, itemId: string, programCategory?: ProgramCategory, orgUnit: Object) => {
const { id, name, path } = orgUnit || {};
const defaultDataEntryValues = { id, name, path };
const defaultDataEntryValues = {
orgUnit: orgUnit
? { id: orgUnit.id, name: orgUnit.name, path: orgUnit.path }
: undefined,
};
if (programCategory && programCategory.categories) {
dataEntryPropsToInclude.push(...programCategory.categories.map(category => ({
id: `attributeCategoryOptions-${category.id}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export const useLifecycle = ({
useEffect(() => {
if (!isLoading) {
dispatch(batchActions([
...getOpenDataEntryActions(dataEntryId, itemId, programCategory),
...getOpenDataEntryActions(dataEntryId, itemId, programCategory, orgUnit),
]));
dataEntryReadyRef.current = true;
delayRulesExecutionRef.current = true;
}
}, [dispatch, dataEntryId, itemId, program, formFoundation, isLoading, programCategory]);
}, [dispatch, dataEntryId, itemId, program, formFoundation, isLoading, programCategory, orgUnit]);

const eventsRef = useRef();
const attributesRef = useRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const WidgetEventSchedule = ({
const { currentUser, noteId } = useNoteDetails();
const [scheduleDate, setScheduleDate] = useState('');
const [scheduledOrgUnit, setScheduledOrgUnit] = useState(orgUnitInitial);
console.log('scheduledOrgUnit', scheduledOrgUnit);
const convertFn = pipe(convertFormToClient, convertClientToServer);
const serverScheduleDate = convertFn(scheduleDate, dataElementTypes.DATE);
const serverSuggestedScheduleDate = convertFn(suggestedScheduleDate, dataElementTypes.DATE);
Expand Down

0 comments on commit 0a9847d

Please sign in to comment.