Skip to content

Commit

Permalink
Merge branch 'deploy/hammer-humble' into hammer/generic-alerts
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Jul 4, 2024
2 parents c5dc60b + 3649b5e commit 5237e72
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 5237e72

Please sign in to comment.