Skip to content

Commit

Permalink
Double compose delivery task (#963)
Browse files Browse the repository at this point in the history
* Hammer/demo tasks (#925)

* Moved custom deliveries to separate file naively and import naively

Signed-off-by: Aaron Chong <[email protected]>

* Moved patrol

Signed-off-by: Aaron Chong <[email protected]>

* Moved custom-compose

Signed-off-by: Aaron Chong <[email protected]>

* Added clean and delivery

Signed-off-by: Aaron Chong <[email protected]>

* Added delivery, renamed to SimpleDelivery

Signed-off-by: Aaron Chong <[email protected]>

* Clean task added

Signed-off-by: Aaron Chong <[email protected]>

* Moved delivery-custom tests, added return type for forms

Signed-off-by: Aaron Chong <[email protected]>

* Configurable supported tasks and name remapping

Signed-off-by: Aaron Chong <[email protected]>

* Changed directory to types, since it doesn't just handle descriptions

Signed-off-by: Aaron Chong <[email protected]>

* Fix test imports

Signed-off-by: Aaron Chong <[email protected]>

* Using temporary task definition

Signed-off-by: Aaron Chong <[email protected]>

* Refactoring new rename changes

Signed-off-by: Aaron Chong <[email protected]>

* Clean up

Signed-off-by: Aaron Chong <[email protected]>

* Removed problematic and unsused component and test

Signed-off-by: Aaron Chong <[email protected]>

* Lint

Signed-off-by: Aaron Chong <[email protected]>

* Updating pnpm version in github workflow

Signed-off-by: Aaron Chong <[email protected]>

* Reverting update to pnpm version

Signed-off-by: Aaron Chong <[email protected]>

* Fix build now that we use key value strings for labels

Signed-off-by: Aaron Chong <[email protected]>

* Refactored last parts of hard coding categories and rendering forms

Signed-off-by: Aaron Chong <[email protected]>

* Refactor callback names and error handling for misconfigs

Signed-off-by: Aaron Chong <[email protected]>

* Display error as well

Signed-off-by: Aaron Chong <[email protected]>

* Fixed more checks and failures

Signed-off-by: Aaron Chong <[email protected]>

* Split configuration and definition, only handle configurations in resource manager level

Signed-off-by: Aaron Chong <[email protected]>

* Lint

Signed-off-by: Aaron Chong <[email protected]>

* Not using object as a type

Signed-off-by: Aaron Chong <[email protected]>

* Address feedback

Signed-off-by: Aaron Chong <[email protected]>

* Render using validTasks instead

Signed-off-by: Aaron Chong <[email protected]>

* Use useMemo

Signed-off-by: Aaron Chong <[email protected]>

---------

Signed-off-by: Aaron Chong <[email protected]>

* First iteration of double compose delivery task

Signed-off-by: Aaron Chong <[email protected]>

* Lint and fix dispatck task insert emergency lots workaround

Signed-off-by: Aaron Chong <[email protected]>

* Fix favorite task confirmation text field, add more tests

Signed-off-by: Aaron Chong <[email protected]>

* Revert addition of double compose delivery to resource manager

Signed-off-by: Aaron Chong <[email protected]>

* Small UI tweaks to form field widths

Signed-off-by: Aaron Chong <[email protected]>

* Fix tests, grid containers for warn time

Signed-off-by: Aaron Chong <[email protected]>

* Address feedback

Signed-off-by: Aaron Chong <[email protected]>

---------

Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth authored Jul 4, 2024
1 parent 24a2c5c commit 3649b5e
Show file tree
Hide file tree
Showing 6 changed files with 1,323 additions and 450 deletions.
66 changes: 37 additions & 29 deletions packages/api-server/api_server/routes/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,36 +251,44 @@ async def post_dispatch_task(
request.request.category == "compose"
and request.request.description is not None
and "phases" in request.request.description
and len(request.request.description["phases"]) == 3
and "on_cancel" in request.request.description["phases"][1]
):
cancellation_lots = await cancellation_lots_from_building_map(logger)
if len(cancellation_lots) != 0:
# Populate them in the correct form
go_to_one_of_the_places_activity = {
"category": "go_to_place",
"description": {
"one_of": [{"waypoint": name} for name in cancellation_lots],
"constraints": [{"category": "prefer_same_map", "description": ""}],
},
}
delivery_dropoff_activity = {
"category": "perform_action",
"description": {
"unix_millis_action_duration_estimate": 60000,
"category": "delivery_dropoff",
"description": {},
},
}
on_cancel_dropoff = {
"category": "sequence",
"description": [
go_to_one_of_the_places_activity,
delivery_dropoff_activity,
],
}
# Add into task request
request.request.description["phases"][1]["on_cancel"] = [on_cancel_dropoff]
cancellation_lots = None
for i in range(len(request.request.description["phases"])):
if "on_cancel" not in request.request.description["phases"][i]:
continue

if cancellation_lots is None:
cancellation_lots = await cancellation_lots_from_building_map(logger)

if len(cancellation_lots) != 0:
# Populate them in the correct form
go_to_one_of_the_places_activity = {
"category": "go_to_place",
"description": {
"one_of": [{"waypoint": name} for name in cancellation_lots],
"constraints": [
{"category": "prefer_same_map", "description": ""}
],
},
}
delivery_dropoff_activity = {
"category": "perform_action",
"description": {
"unix_millis_action_duration_estimate": 60000,
"category": "delivery_dropoff",
"description": {},
},
}
on_cancel_dropoff = {
"category": "sequence",
"description": [
go_to_one_of_the_places_activity,
delivery_dropoff_activity,
],
}
request.request.description["phases"][i]["on_cancel"] = [
on_cancel_dropoff
]

resp = mdl.TaskDispatchResponse.parse_raw(
await tasks_service().call(request.json(exclude_none=True))
Expand Down
40 changes: 37 additions & 3 deletions packages/react-components/lib/tasks/create-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ import {
DeliveryPickupTaskDefinition,
DeliverySequentialLotPickupTaskDefinition,
DeliveryAreaPickupTaskDefinition,
DoubleComposeDeliveryTaskDescription,
DoubleComposeDeliveryTaskDefinition,
makeDoubleComposeDeliveryTaskBookingLabel,
DoubleComposeDeliveryTaskForm,
} from './types/delivery-custom';
import {
makePatrolTaskBookingLabel,
Expand All @@ -89,6 +93,7 @@ export interface TaskDefinition {
export type TaskDescription =
| DeliveryPickupTaskDescription
| DeliveryCustomTaskDescription
| DoubleComposeDeliveryTaskDescription
| PatrolTaskDescription
| DeliveryTaskDescription
| ComposeCleanTaskDescription;
Expand Down Expand Up @@ -585,6 +590,27 @@ export function CreateTaskForm({
onValidate={onValidate}
/>
);
case DoubleComposeDeliveryTaskDefinition.taskDefinitionId:
return (
<DoubleComposeDeliveryTaskForm
taskDesc={taskRequest.description as DoubleComposeDeliveryTaskDescription}
pickupPoints={pickupPoints}
cartIds={cartIds}
dropoffPoints={dropoffPoints}
onChange={(desc: DoubleComposeDeliveryTaskDescription) => {
desc.category = taskRequest.description.category;
desc.phases[0].activity.description.activities[1].description.category =
taskRequest.description.category;
desc.phases[3].activity.description.activities[1].description.category =
taskRequest.description.category;
handleTaskDescriptionChange(
DoubleComposeDeliveryTaskDefinition.requestCategory,
desc,
);
}}
onValidate={onValidate}
/>
);
case CustomComposeTaskDefinition.taskDefinitionId:
return (
<CustomComposeTaskForm
Expand Down Expand Up @@ -659,6 +685,9 @@ export function CreateTaskForm({
case DeliveryAreaPickupTaskDefinition.taskDefinitionId:
requestBookingLabel = makeDeliveryCustomTaskBookingLabel(request.description);
break;
case DoubleComposeDeliveryTaskDefinition.taskDefinitionId:
requestBookingLabel = makeDoubleComposeDeliveryTaskBookingLabel(request.description);
break;
case PatrolTaskDefinition.taskDefinitionId:
requestBookingLabel = makePatrolTaskBookingLabel(request.description);
break;
Expand Down Expand Up @@ -893,12 +922,18 @@ export function CreateTaskForm({
fontSize: isScreenHeightLessThan800 ? '0.8rem' : '1.15',
},
}}
fullWidth
/>
)}
disabled
/>
</Grid>
<Grid item xs={1}>
<Grid
container
xs={isScreenHeightLessThan800 ? 6 : 5}
justifyContent="flex-end"
alignItems="flex-end"
>
<Checkbox
checked={warnTime !== null}
onChange={handleWarnTimeCheckboxChange}
Expand All @@ -907,8 +942,6 @@ export function CreateTaskForm({
'& .MuiSvgIcon-root': { fontSize: isScreenHeightLessThan800 ? 22 : 32 },
}}
/>
</Grid>
<Grid item xs={isScreenHeightLessThan800 ? 5 : 4}>
<DateTimePicker
disabled={warnTime === null}
inputFormat={'MM/dd/yyyy HH:mm'}
Expand Down Expand Up @@ -1026,6 +1059,7 @@ export function CreateTaskForm({
}
helperText="Required"
error={favoriteTaskTitleError}
fullWidth
/>
)}
{callToDeleteFavoriteTask && (
Expand Down
Loading

0 comments on commit 3649b5e

Please sign in to comment.