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
24 changes: 23 additions & 1 deletion src/screens/Picking/PickingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ type PickingContextType = {
revalidateCurrentTask: (callback?: (task: PickTask | undefined) => void) => void;
/** Advances to the next task in the list */
goToNextTask: () => void;
/** Whether the move-to-staging step should be skipped because the pick task's facility does not track internal transactions */
skipStagingStep: boolean;
};

const PickingContext = React.createContext<PickingContextType | undefined>(undefined);
Expand All @@ -82,6 +84,8 @@ export function PickingProvider({ children }: { children: React.ReactNode }) {
const homeRoute = HOME_ROUTE_BY_ENTRY_POINT[entryPoint];
const allTasksCount = tasks.length;
const currentTask = allTasksCount > 0 && currentTaskIndex < allTasksCount ? tasks[currentTaskIndex] : undefined;
// Move to staging only applies to facilities that track internal transactions.
const skipStagingStep = currentTask?.internalTransactionsEnabled === false;

const startSession = async (deliveryType: DeliveryType, ordersCount: number): Promise<boolean> => {
setEntryPoint('BATCH');
Expand Down Expand Up @@ -220,6 +224,23 @@ export function PickingProvider({ children }: { children: React.ReactNode }) {
return;
}

if (skipStagingStep) {
Alert.alert(
'No Additional Tasks',
'No new pick tasks were created. This location does not track internal transactions, so staging is not required.',
[
{
text: 'OK',
onPress: () => {
resetSession();
resetToRoutes([{ name: 'Drawer', params: { screen: 'Dashboard' } }, { name: homeRoute }]);
}
}
]
);
return;
}

Alert.alert('No Additional Tasks', 'No new pick tasks were created. Proceeding to staging location drop.', [
{
text: 'OK',
Expand Down Expand Up @@ -317,7 +338,8 @@ export function PickingProvider({ children }: { children: React.ReactNode }) {
dropCurrentTask,
dropCurrentTaskAtStagingLocation,
revalidateCurrentTask,
goToNextTask
goToNextTask,
skipStagingStep
}}
>
{children}
Expand Down
10 changes: 9 additions & 1 deletion src/screens/Picking/PickingMoveToStaging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ export default function PickingMoveToStagingScreen() {
return;
}

// Tasks whose facility does not track internal transactions don't need to be staged.
const stagingEligibleTasks = response.data.filter((task) => task.internalTransactionsEnabled !== false);

if (stagingEligibleTasks.length === 0) {
Alert.alert('Staging Not Required', 'The picked items for this container do not require a move to staging.');
return;
}

// Navigate to the staging screen with the fetched tasks
navigate('PickingStagingDrop', { tasks: response.data });
navigate('PickingStagingDrop', { tasks: stagingEligibleTasks });
})
);

Expand Down
18 changes: 15 additions & 3 deletions src/screens/Picking/PickingPickOutboundContainerScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export default function PickingPickOutboundContainerScreen() {
revalidateCurrentTask,
goToNextTask,
revalidateTasksForRequisition,
homeRoute
homeRoute,
skipStagingStep,
resetSession
} = usePickingContext();
const { params } = useRoute<PickingPickOutboundContainerScreenProps>();
const parsedQuantityPicked = params?.quantityPicked ? Number(params.quantityPicked) : undefined;
Expand Down Expand Up @@ -79,7 +81,9 @@ export default function PickingPickOutboundContainerScreen() {
allTasksCount,
goToNextTask,
homeRoute,
omitStagingLocationStep
omitStagingLocationStep,
skipStagingStep,
resetSession
});
}
},
Expand All @@ -95,7 +99,15 @@ export default function PickingPickOutboundContainerScreen() {
return;
}

revalidateTaskAndProceed({ revalidateCurrentTask, currentTaskIndex, allTasksCount, goToNextTask, homeRoute });
revalidateTaskAndProceed({
revalidateCurrentTask,
currentTaskIndex,
allTasksCount,
goToNextTask,
homeRoute,
skipStagingStep,
resetSession
});
});

setOutboundContainerId(EMPTY_STRING);
Expand Down
17 changes: 14 additions & 3 deletions src/screens/Picking/PickingPickQuantityScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@ import { usePickingContext } from './PickingContext';
import styles from './styles';

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

Expand Down Expand Up @@ -111,7 +120,9 @@ export default function PickingPickQuantityScreen() {
allTasksCount,
goToNextTask,
homeRoute,
omitStagingLocationStep
omitStagingLocationStep,
skipStagingStep,
resetSession
});
},
reasonCode?.name
Expand Down
37 changes: 34 additions & 3 deletions src/screens/Picking/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ type PickingFlowNavigation = {
/** Screen the session started from, reset to when it ends so finished screens are unreachable */
homeRoute: string;
omitStagingLocationStep?: boolean;
/** Whether the move-to-staging step should be skipped because the facility does not track internal transactions */
skipStagingStep?: boolean;
resetSession?: () => void;
};

function returnHome(homeRoute: string) {
Expand All @@ -33,7 +36,9 @@ export function proceedToNextOrComplete({
allTasksCount,
goToNextTask,
homeRoute,
omitStagingLocationStep
omitStagingLocationStep,
skipStagingStep,
resetSession
}: PickingFlowNavigation) {
if (currentTaskIndex + 1 < allTasksCount) {
goToNextTask();
Expand All @@ -46,6 +51,23 @@ export function proceedToNextOrComplete({
return;
}

if (skipStagingStep) {
Alert.alert(
'All Picks Complete',
'You have completed all picks. This location does not track internal transactions, so staging is not required.',
[
{
text: 'OK',
onPress: () => {
resetSession?.();
returnHome(homeRoute);
}
}
]
);
return;
}

Alert.alert('All Picks Complete', 'You have completed all picks. Proceeding to staging location drop.', [
{
text: 'OK',
Expand All @@ -65,7 +87,9 @@ export function revalidateTaskAndProceed({
allTasksCount,
goToNextTask,
homeRoute,
omitStagingLocationStep
omitStagingLocationStep,
skipStagingStep,
resetSession
}: PickingFlowNavigation & {
revalidateCurrentTask: (callback: (revalidatedTask: PickTask | undefined) => void) => void;
}) {
Expand All @@ -82,6 +106,13 @@ export function revalidateTaskAndProceed({
return;
}

proceedToNextOrComplete({ currentTaskIndex, allTasksCount, goToNextTask, homeRoute });
proceedToNextOrComplete({
currentTaskIndex,
allTasksCount,
goToNextTask,
homeRoute,
skipStagingStep,
resetSession
});
});
}
2 changes: 2 additions & 0 deletions src/types/picking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export type PickTask = {
deliveryTypeCode?: DeliveryTypeCode;

facility?: Location;
/** Whether the task's facility tracks internal transactions (mirrors facility.supports(TRACK_INTERNAL_TRANSACTIONS)) */
internalTransactionsEnabled?: boolean;
location?: Location;
outboundContainer?: Container | null;
stagingLocation?: Location | null;
Expand Down