Skip to content

Commit

Permalink
Load associated plannings when modal opens
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Aug 27, 2024
1 parent e05b429 commit e644275
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions client/actions/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ const openIgnoreCancelSaveModal = ({
selectors.planning.storedPlannings(getState());
const item = get(storedItems, itemId) || {};

if (itemType === ITEM_TYPE.EVENT) {
// Load associated plannings so they can be used later
dispatch(eventsApi.loadAssociatedPlannings(item));
}

if (!isExistingItem(item)) {
delete item._id;
}
Expand Down
2 changes: 1 addition & 1 deletion client/components/IgnoreCancelSaveModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class IgnoreCancelSaveModalComponent extends React.Component<IProps, ISta
return (
<UpdateRecurringEventsForm
original={this.props.modalProps.item}
updates={this.props.modalProps.updates}
updates={this.props.modalProps.updates as Partial<IEventItem>}
onEventUpdateMethodChange={this.onEventUpdateMethodChange}
onPlanningUpdateMethodChange={this.onPlanningUpdateMethodChange}
modalProps={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ function getRecurringPlanningToUpdate(
updates: Partial<IEventItem>,
plannings: {[planningId: string]: IPlanningItem}
): Array<IPlanningItem['_id']> {
const originalCoverages: IPlanningEmbeddedCoverageMap = (original.planning_ids || [])
const originalCoverages: IPlanningEmbeddedCoverageMap = (original.planning_ids ?? [])
.map((planningId) => plannings[planningId])
.reduce((planningItems, planningItem) => {
planningItems[planningItem?._id] = (planningItem?.coverages ?? []).reduce(
planningItems[planningItem._id] = (planningItem.coverages ?? []).reduce(
(embeddedCoverages, coverage) => {
embeddedCoverages[coverage.coverage_id] = eventUtils.convertCoverageToEventEmbedded(coverage);

Expand Down

0 comments on commit e644275

Please sign in to comment.