fix(client): allow self-booking in manual-confirmation status
confirm-delivery-choice blocked any order_groups with delivery_status other than 'pending_confirmation', so orders in manual handling (manual_confirmation_required) showed the client a form but rejected the save. Allow booking for manual_confirmation_required so clients can pick date+time until the order is assigned/paid. Surface 'paid_storage' and 'driver_assigned' states to the client view instead of a dead form.
This commit is contained in:
parent
f35a84084b
commit
dc0f7f51c5
|
|
@ -88,7 +88,7 @@ export const getClientInvitationStateFromOrderGroupStatus = (
|
|||
deliveryStatus: string | null | undefined,
|
||||
invitationState: string | null | undefined,
|
||||
): DeliveryInvitationPublicState => {
|
||||
if (deliveryStatus === "agreed") {
|
||||
if (deliveryStatus === "agreed" || deliveryStatus === "driver_assigned") {
|
||||
return "agreed";
|
||||
}
|
||||
|
||||
|
|
@ -96,6 +96,10 @@ export const getClientInvitationStateFromOrderGroupStatus = (
|
|||
return "delivered";
|
||||
}
|
||||
|
||||
if (deliveryStatus === "paid_storage") {
|
||||
return "paid_storage";
|
||||
}
|
||||
|
||||
if (["awaiting_choice", "opened", "reminder_sent"].includes(String(invitationState || ""))) {
|
||||
return invitationState as DeliveryInvitationPublicState;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,14 @@ import {
|
|||
|
||||
const MAX_BODY_BYTES = 8 * 1024;
|
||||
|
||||
// Order groups a client may still self-book (choose delivery date+time) on.
|
||||
// manual_confirmation_required (ручная обработка) stays bookable until the
|
||||
// order leaves these states (date assigned / paid storage / finished).
|
||||
const CLIENT_BOOKABLE_STATUSES = new Set([
|
||||
"pending_confirmation",
|
||||
"manual_confirmation_required",
|
||||
]);
|
||||
|
||||
type ConfirmBody = {
|
||||
token?: string;
|
||||
deliveryDate?: string;
|
||||
|
|
@ -191,7 +199,9 @@ Deno.serve(async (request) => {
|
|||
? "agreed"
|
||||
: "requires_address";
|
||||
|
||||
if (!isActiveInvitationState(invitation.state) || currentGroup.delivery_status !== "pending_confirmation") {
|
||||
const bookingBlocked = !CLIENT_BOOKABLE_STATUSES.has(currentGroup.delivery_status || "");
|
||||
|
||||
if (!isActiveInvitationState(invitation.state) || bookingBlocked) {
|
||||
return jsonResponse(
|
||||
{
|
||||
ok: false,
|
||||
|
|
|
|||
Loading…
Reference in New Issue