Skip to content

Commit

Permalink
Fixed createdOneDamage by filtering parts by inspectionId
Browse files Browse the repository at this point in the history
  • Loading branch information
dlymonkai committed Dec 9, 2024
1 parent ac01573 commit 5a6d722
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/common/src/state/actions/createdOneDamage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ export function createdOneDamage(state: MonkState, action: MonkCreatedOneDamageA
const newDamages = damages.filter(
(damage) => ![payload.damage.id, payload.localId].includes(damage.id),
);
const partsRelated = action.payload.damage.parts
.map((part) => parts.find((value) => value.type === part)?.id)
const partsRelated = payload.damage.parts
.map(
(part) =>
parts
.filter((value) => value.inspectionId === payload.damage.inspectionId)
.find((value) => value.type === part)?.id,
)
.filter((v) => v !== undefined) as string[];
const newParts = parts.map((part) => {
if (partsRelated.includes(part.id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('CreatedOneDamage action handlers', () => {
id: 'part-id',
type: VehiclePart.ROOF,
damages: [] as string[],
inspectionId: 'inspections-test',
};
state.inspections.push({
id: 'inspections-test',
Expand Down

0 comments on commit 5a6d722

Please sign in to comment.