Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/screens/Picking/PickingPickQuantityScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { usePickingContext } from './PickingContext';
import styles from './styles';

export default function PickingPickQuantityScreen() {
const { currentTask, currentTaskIndex, allTasksCount, shortPickTask, goToNextTask } = usePickingContext();
const { tasks, currentTask, currentTaskIndex, allTasksCount, shortPickTask, goToNextTask } = usePickingContext();
const dispatch = useDispatch();
const isFocused = useIsFocused();

Expand Down Expand Up @@ -98,8 +98,13 @@ export default function PickingPickQuantityScreen() {
return;
}

// Skip staging if any other task was short picked without a reason code.
const omitStagingLocationStep = tasks.some(
(task, index) =>
index !== currentTaskIndex && task.quantityPicked < task.quantityRequired && !task.reasonCode
);
// Skip revalidation: task is closed server-side, and GET /pick-tasks/:id 404s if the requisition is canceled.
proceedToNextOrComplete(currentTaskIndex, allTasksCount, goToNextTask);
proceedToNextOrComplete(currentTaskIndex, allTasksCount, goToNextTask, omitStagingLocationStep);
},
reasonCode?.name
);
Expand Down
21 changes: 20 additions & 1 deletion src/screens/Picking/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@ import { Alert } from 'react-native';
import { navigate, resetToRoutes } from '../../NavigationService';
import { PickTask } from '../../types/picking';

export function proceedToNextOrComplete(currentTaskIndex: number, allTasksCount: number, goToNextTask: () => void) {
export function proceedToNextOrComplete(
currentTaskIndex: number,
allTasksCount: number,
goToNextTask: () => void,
omitStagingLocationStep?: boolean
) {
if (currentTaskIndex + 1 < allTasksCount) {
goToNextTask();
navigate('PickingPickLocation');
return;
}

if (omitStagingLocationStep) {
Alert.alert(
'Short Pick Without Reason Code',
'You have completed all picks with a short pick without a reason code. This task will remain available to pick. You will be redirected to the Pick Type screen.',
[
{
text: 'OK',
onPress: () => navigate('PickingPickType')
}
]
);
return;
}

Alert.alert('All Picks Complete', 'You have completed all picks. Proceeding to staging location drop.', [
{
text: 'OK',
Expand Down