Skip to content

Commit 8a94d5d

Browse files
authored
Merge pull request #880 from sanger/fix-save-draft-cytassist
fix issue with save draft button
2 parents 8523924 + b4b98d3 commit 8a94d5d

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/components/slotMapper/MultipleLabwareSlotMapper.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ const MultipleLabwareSlotMapper: React.FC<SlotMapperProps> = ({
127127

128128
useEffect(() => {
129129
if (!currentOutput?.slotCopyContent) return;
130-
console.log(' === ON CHANGE ');
131130
onChange?.(currentOutput.labware, currentOutput?.slotCopyContent, anySourceMapped);
132131
}, [onChange, currentOutput, anySourceMapped]);
133132

src/lib/machines/slotCopy/slotCopyMachine.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import { ClientError } from 'graphql-request';
2121
import { DestinationSelectionMode } from '../../../components/slotMapper/slotMapper.types';
2222
import { Draft } from 'immer';
2323
import { flaggedLabwareLayout } from '../../factories/labwareFactory';
24-
import { initialOutputLabware } from '../../../pages/CytAssist';
2524
import { eventBus } from '../../../eventBus';
25+
import { initialOutputLabware } from '../../../pages/CytAssist';
2626

2727
/**
2828
* Context for SlotCopy Machine
@@ -636,7 +636,12 @@ export const slotCopyMachine = createMachine(
636636
...context,
637637
serverErrors: null,
638638
sources: [],
639-
destinations: [initialOutputLabware]
639+
destinations: [
640+
{
641+
labware: initialOutputLabware.labware,
642+
slotCopyDetails: { lpNumber: context.destinations[0].slotCopyDetails.lpNumber, contents: [] }
643+
}
644+
]
640645
};
641646
}
642647
return context;
@@ -767,21 +772,24 @@ export const slotCopyMachine = createMachine(
767772
assignDraftedCytAssist: assign(({ context, event }) => {
768773
if (event.type !== 'xstate.done.actor.reloadDraftedCytAssist') return context;
769774
return produce(context, (draft) => {
770-
const layout = flaggedLabwareLayout(event.output.reloadSlotCopy!.labwareType!);
771-
if (!layout) return draft;
772775
if (event.output.reloadSlotCopy) {
776+
const draftedLayout = flaggedLabwareLayout(event.output.reloadSlotCopy!.labwareType!);
773777
const { sources, operationType, workNumber, executionType, lpNumber, ...copyDetails } =
774778
event.output.reloadSlotCopy;
775779
draft.destinations[0] = {
776-
labware: layout,
780+
labware: draftedLayout || initialOutputLabware.labware,
777781
slotCopyDetails: {
778782
...draft.destinations[0].slotCopyDetails,
779783
...copyDetails
780784
}
781785
};
782-
draft.sources = event.output.inputLabware?.map((labware) => {
783-
return { labware, cleanedOutAddresses: event.output.cleanedOutInputAddresses.get(labware.id) ?? [] };
784-
});
786+
if (event.output.inputLabware) {
787+
draft.sources = event.output.inputLabware.map((labware) => {
788+
return { labware, cleanedOutAddresses: event.output.cleanedOutInputAddresses.get(labware.id) ?? [] };
789+
});
790+
} else {
791+
draft.sources = [];
792+
}
785793
}
786794
});
787795
}),

0 commit comments

Comments
 (0)