diff --git a/src/screens/Sortation/ContainerMismatchDialog.tsx b/src/screens/Sortation/ContainerMismatchDialog.tsx index 94f4716f..b6ea4919 100644 --- a/src/screens/Sortation/ContainerMismatchDialog.tsx +++ b/src/screens/Sortation/ContainerMismatchDialog.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { Modal, View } from 'react-native'; +import { Alert, Modal, View } from 'react-native'; import { Text } from 'react-native-paper'; import Button from '../../components/Button'; @@ -32,15 +32,26 @@ export function ContainerMismatchDialog({ }; const handleOverride = () => { - handleDismiss(); + setDialogInput(EMPTY_STRING); onScan(scannedContainer); }; const handleScanSubmit = () => { - if (dialogInput && dialogInput.trim()) { - handleDismiss(); - onScan(dialogInput.trim()); + const trimmedInput = dialogInput?.trim(); + if (!trimmedInput) { + return; + } + + if (trimmedInput !== scannedContainer) { + Alert.alert( + 'Container Mismatch', + 'The scanned container does not match. Please scan the same container to confirm the override.' + ); + setDialogInput(EMPTY_STRING); + return; } + + onScan(trimmedInput); }; const displayExpectedContainer = expectedContainer || HYPHEN; diff --git a/src/screens/Sortation/SortationContainerScreen.tsx b/src/screens/Sortation/SortationContainerScreen.tsx index 7a49aafe..fc0d4b75 100644 --- a/src/screens/Sortation/SortationContainerScreen.tsx +++ b/src/screens/Sortation/SortationContainerScreen.tsx @@ -79,9 +79,9 @@ export default function SortationContainerScreen() { function handleDialogScan(resolvedCode: string) { setIsDialogVisible(false); - confirmContainer(resolvedCode, true); setPutawayContainerBarcode(EMPTY_STRING); setPendingContainerCode(''); + confirmContainer(resolvedCode, true); } function confirmContainer(code: string, override: boolean) { @@ -162,7 +162,11 @@ export default function SortationContainerScreen() { visible={isDialogVisible} scannedContainer={pendingContainerCode} expectedContainer={task?.container?.locationNumber ?? ''} - onDismiss={() => setIsDialogVisible(false)} + onDismiss={() => { + setIsDialogVisible(false); + setPutawayContainerBarcode(EMPTY_STRING); + setPendingContainerCode(''); + }} onScan={handleDialogScan} />