Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed hammer categories #772

Merged
merged 3 commits into from
Sep 15, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('submit task', () => {
const options = await $$('[role=option]');
for (const opt of options) {
const text = await opt.getText();
if (text === 'Delivery') {
if (text === 'Delivery - 1:1') {
return opt;
}
}
Expand Down
63 changes: 27 additions & 36 deletions packages/react-components/lib/tasks/create-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ interface DropoffActivity {
};
}

interface DeliveryHuntingTaskDescription {
interface DeliveryCustomTaskDescription {
activities: [pickup_cart: PickupActivity, dropoff_cart: DropoffActivity];
}

type TaskDescription = DeliveryTaskDescription | DeliveryHuntingTaskDescription;
type TaskDescription = DeliveryTaskDescription | DeliveryCustomTaskDescription;

const classes = {
title: 'dialogue-info-value',
Expand Down Expand Up @@ -111,13 +111,13 @@ const StyledDialog = styled((props: DialogProps) => <Dialog {...props} />)(({ th
function getShortDescription(taskRequest: TaskRequest): string {
switch (taskRequest.category) {
case 'delivery': {
return `[Delivery] from [${taskRequest.description.pickup.place}] to [${taskRequest.description.dropoff.place}]`;
return `[Delivery - 1:1] from [${taskRequest.description.pickup.place}] to [${taskRequest.description.dropoff.place}]`;
}
case 'delivery_sequential_hunting': {
return `[Delivery - Sequential Hunting] payload [${taskRequest.description.activities[0].cart_rfid}] from [${taskRequest.description.activities[0].pickup_zone}] to [${taskRequest.description.activities[1].dropoff_point}]`;
case 'delivery_sequential_lot_pick_up': {
return `[Delivery - Sequential lot pick up] payload [${taskRequest.description.activities[0].cart_rfid}] from [${taskRequest.description.activities[0].pickup_zone}] to [${taskRequest.description.activities[1].dropoff_point}]`;
}
case 'delivery_area_hunting': {
return `[Delivery - Area Hunting] payload [${taskRequest.description.activities[0].cart_rfid}] from [${taskRequest.description.activities[0].pickup_zone}] to [${taskRequest.description.activities[1].dropoff_point}]`;
case 'delivery_area_pick_up': {
return `[Delivery - Area pick up] payload [${taskRequest.description.activities[0].cart_rfid}] from [${taskRequest.description.activities[0].pickup_zone}] to [${taskRequest.description.activities[1].dropoff_point}]`;
}
default:
return `[Unknown] type "${taskRequest.category}"`;
Expand Down Expand Up @@ -260,19 +260,19 @@ function DeliveryTaskForm({
);
}

interface DeliveryHuntingProps {
taskDesc: DeliveryHuntingTaskDescription;
interface DeliveryCustomProps {
taskDesc: DeliveryCustomTaskDescription;
pickupZones: string[];
dropoffPoints: string[];
onChange(taskDesc: TaskDescription): void;
}

function DeliveryHuntingTaskForm({
function DeliveryCustomTaskForm({
taskDesc,
pickupZones = [],
dropoffPoints = [],
onChange,
}: DeliveryHuntingProps) {
}: DeliveryCustomProps) {
const theme = useTheme();
const pickup_activity: PickupActivity = {
category: 'perform_action',
Expand Down Expand Up @@ -322,7 +322,6 @@ function DeliveryHuntingTaskForm({
id="cart_rfid"
fullWidth
label="Cart RFID"
defaultValue={pickup_activity.description.cart_rfid}
value={taskDesc.activities[0].description.cart_rfid}
inputProps={{ min: 0 }}
onChange={(ev) => {
Expand Down Expand Up @@ -448,7 +447,7 @@ function defaultDeliveryTask(): DeliveryTaskDescription {
};
}

function defaultDeliveryHuntingTask(): DeliveryHuntingTaskDescription {
function defaultDeliveryCustomTask(): DeliveryCustomTaskDescription {
return {
activities: [
{
Expand All @@ -472,9 +471,9 @@ function defaultTaskDescription(taskCategory: string): TaskDescription | undefin
switch (taskCategory) {
case 'delivery':
return defaultDeliveryTask();
case 'delivery_sequential_hunting':
case 'delivery_area_hunting':
return defaultDeliveryHuntingTask();
case 'delivery_sequential_lot_pick_up':
case 'delivery_area_pick_up':
return defaultDeliveryCustomTask();
default:
return undefined;
}
Expand Down Expand Up @@ -688,22 +687,14 @@ export function CreateTaskForm({
onChange={(desc) => handleTaskDescriptionChange('delivery', desc)}
/>
);
case 'delivery_sequential_hunting':
case 'delivery_sequential_lot_pick_up':
case 'delivery_area_pick_up':
return (
<DeliveryHuntingTaskForm
taskDesc={taskRequest.description as DeliveryHuntingTaskDescription}
<DeliveryCustomTaskForm
taskDesc={taskRequest.description as DeliveryCustomTaskDescription}
pickupZones={pickupZones}
dropoffPoints={Object.keys(dropoffPoints)}
onChange={(desc) => handleTaskDescriptionChange('delivery_sequential_hunting', desc)}
/>
);
case 'delivery_area_hunting':
return (
<DeliveryHuntingTaskForm
taskDesc={taskRequest.description as DeliveryHuntingTaskDescription}
pickupZones={pickupZones}
dropoffPoints={Object.keys(dropoffPoints)}
onChange={(desc) => handleTaskDescriptionChange('delivery_area_hunting', desc)}
onChange={(desc) => handleTaskDescriptionChange(taskRequest.category, desc)}
/>
);
default:
Expand Down Expand Up @@ -881,8 +872,8 @@ export function CreateTaskForm({
description: favoriteTask.description,
unix_millis_earliest_start_time: Date.now(),
priority: favoriteTask.priority,
}]
);
},
]);
}}
/>
);
Expand Down Expand Up @@ -915,19 +906,19 @@ export function CreateTaskForm({
Object.keys(dropoffPoints).length === 0
}
>
Delivery
Delivery - 1:1
</MenuItem>
<MenuItem
value="delivery_sequential_hunting"
value="delivery_sequential_lot_pick_up"
disabled={Object.keys(dropoffPoints).length === 0}
>
Delivery - Sequential hunting
Delivery - Sequential lot pick up
</MenuItem>
<MenuItem
value="delivery_area_hunting"
value="delivery_area_pick_up"
disabled={Object.keys(dropoffPoints).length === 0}
>
Delivery - Area hunting
Delivery - Area pick up
</MenuItem>
</TextField>
</Grid>
Expand Down
Loading