Skip to content

Commit

Permalink
Remove cart ID fields in double compose delivery form
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth committed Jul 10, 2024
1 parent 090dd9b commit 1490593
Showing 1 changed file with 7 additions and 101 deletions.
108 changes: 7 additions & 101 deletions packages/react-components/lib/tasks/types/delivery-custom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,12 @@ export function makeDoubleComposeDeliveryTaskBookingLabel(

const pickups = `${firstPickupDescription.pickup_lot}(1), ${secondPickupDescription.pickup_lot}(2)`;
const dropoffs = `${task_description.phases[1].activity.description.activities[0].description}(1), ${task_description.phases[4].activity.description.activities[0].description}(2)`;
const cartIds = `${firstPickupDescription.pickup_lot}(1), ${secondPickupDescription.cart_id}(2)`;

return {
description: {
task_definition_id: task_description.category,
pickup: pickups,
destination: dropoffs,
cart_id: cartIds,
},
};
}
Expand Down Expand Up @@ -244,19 +242,15 @@ export function makeDoubleComposeDeliveryTaskShortDescription(
try {
const firstGoToPickup: GoToPlaceActivity = desc.phases[0].activity.description.activities[0];
const firstPickup: LotPickupActivity = desc.phases[0].activity.description.activities[1];

Check warning on line 244 in packages/react-components/lib/tasks/types/delivery-custom.tsx

View workflow job for this annotation

GitHub Actions / Unit Tests

'firstPickup' is assigned a value but never used
const firstCartId = firstPickup.description.description.cart_id;
const firstGoToDropoff: GoToPlaceActivity = desc.phases[1].activity.description.activities[0];

const secondGoToPickup: GoToPlaceActivity = desc.phases[3].activity.description.activities[0];
const secondPickup: LotPickupActivity = desc.phases[3].activity.description.activities[1];

Check warning on line 248 in packages/react-components/lib/tasks/types/delivery-custom.tsx

View workflow job for this annotation

GitHub Actions / Unit Tests

'secondPickup' is assigned a value but never used
const secondCartId = secondPickup.description.description.cart_id;
const secondGoToDropoff: GoToPlaceActivity = desc.phases[4].activity.description.activities[0];

return `[${
taskDisplayName ?? DeliveryPickupTaskDefinition.taskDisplayName
}] payload [${firstCartId}] from [${firstGoToPickup.description}] to [${
firstGoToDropoff.description
}], then payload [${secondCartId}] from [${secondGoToPickup.description}] to [${
return `[${taskDisplayName ?? DeliveryPickupTaskDefinition.taskDisplayName}] from [${
firstGoToPickup.description
}] to [${firstGoToDropoff.description}], then from [${secondGoToPickup.description}] to [${
secondGoToDropoff.description
}]`;
} catch (e) {
Expand Down Expand Up @@ -348,14 +342,12 @@ const isDoubleComposeDeliveryTaskDescriptionValid = (
firstGoToPickup.description.length > 0 &&
Object.keys(pickupPoints).includes(firstGoToPickup.description) &&
pickupPoints[firstGoToPickup.description] === firstPickup.description.description.pickup_lot &&
firstPickup.description.description.cart_id.length > 0 &&
firstGoToDropoff.description.length > 0 &&
Object.keys(dropoffPoints).includes(firstGoToDropoff.description) &&
secondGoToPickup.description.length > 0 &&
Object.keys(pickupPoints).includes(secondGoToPickup.description) &&
pickupPoints[secondGoToPickup.description] ===
secondPickup.description.description.pickup_lot &&
secondPickup.description.description.cart_id.length > 0 &&
secondGoToDropoff.description.length > 0 &&
Object.keys(dropoffPoints).includes(secondGoToDropoff.description)
);
Expand Down Expand Up @@ -630,7 +622,7 @@ export function DoubleComposeDeliveryTaskForm({

return (
<Grid container spacing={theme.spacing(2)} justifyContent="left" alignItems="center">
<Grid item xs={5}>
<Grid item xs={6}>
<Autocomplete
id="first-pickup-location"
freeSolo
Expand Down Expand Up @@ -679,7 +671,7 @@ export function DoubleComposeDeliveryTaskForm({
)}
/>
</Grid>
<Grid item xs={5}>
<Grid item xs={6}>
<Autocomplete
id="first-dropoff-location"
freeSolo
Expand Down Expand Up @@ -720,50 +712,7 @@ export function DoubleComposeDeliveryTaskForm({
)}
/>
</Grid>
<Grid item xs={2}>
<Autocomplete
id="first-cart-id"
freeSolo
fullWidth
options={cartIds}
value={
taskDesc.phases[0].activity.description.activities[1].description.description.cart_id
}
getOptionLabel={(option) => option}
onInputChange={(_ev, newValue) => {
const newTaskDesc = { ...taskDesc };
newTaskDesc.phases[0] = cartPickupPhaseInsertCartId(newTaskDesc.phases[0], newValue);
onInputChange(newTaskDesc);
}}
onBlur={(ev) => {
const newTaskDesc = { ...taskDesc };
newTaskDesc.phases[0] = cartPickupPhaseInsertCartId(
newTaskDesc.phases[0],
(ev.target as HTMLInputElement).value,
);
onInputChange(newTaskDesc);
}}
sx={{
'& .MuiOutlinedInput-root': {
height: isScreenHeightLessThan800 ? '3rem' : '3.5rem',
fontSize: isScreenHeightLessThan800 ? 14 : 20,
},
}}
renderInput={(params) => (
<TextField
{...params}
label="Cart ID (1)"
required
InputLabelProps={{ style: { fontSize: isScreenHeightLessThan800 ? 14 : 20 } }}
error={
taskDesc.phases[0].activity.description.activities[1].description.description
.cart_id.length === 0
}
/>
)}
/>
</Grid>
<Grid item xs={5}>
<Grid item xs={6}>
<Autocomplete
id="second-pickup-location"
freeSolo
Expand Down Expand Up @@ -812,7 +761,7 @@ export function DoubleComposeDeliveryTaskForm({
)}
/>
</Grid>
<Grid item xs={5}>
<Grid item xs={6}>
<Autocomplete
id="second-dropoff-location"
freeSolo
Expand Down Expand Up @@ -853,49 +802,6 @@ export function DoubleComposeDeliveryTaskForm({
)}
/>
</Grid>
<Grid item xs={2}>
<Autocomplete
id="second-cart-id"
freeSolo
fullWidth
options={cartIds}
value={
taskDesc.phases[3].activity.description.activities[1].description.description.cart_id
}
getOptionLabel={(option) => option}
onInputChange={(_ev, newValue) => {
const newTaskDesc = { ...taskDesc };
newTaskDesc.phases[3] = cartPickupPhaseInsertCartId(newTaskDesc.phases[3], newValue);
onInputChange(newTaskDesc);
}}
onBlur={(ev) => {
const newTaskDesc = { ...taskDesc };
newTaskDesc.phases[3] = cartPickupPhaseInsertCartId(
newTaskDesc.phases[3],
(ev.target as HTMLInputElement).value,
);
onInputChange(newTaskDesc);
}}
sx={{
'& .MuiOutlinedInput-root': {
height: isScreenHeightLessThan800 ? '3rem' : '3.5rem',
fontSize: isScreenHeightLessThan800 ? 14 : 20,
},
}}
renderInput={(params) => (
<TextField
{...params}
label="Cart ID (2)"
required
InputLabelProps={{ style: { fontSize: isScreenHeightLessThan800 ? 14 : 20 } }}
error={
taskDesc.phases[3].activity.description.activities[1].description.description
.cart_id.length === 0
}
/>
)}
/>
</Grid>
</Grid>
);
}
Expand Down

0 comments on commit 1490593

Please sign in to comment.