Compare commits

...

2 Commits

Author SHA1 Message Date
Hermes a505ce6ca7 merge main (edge function fix) 2026-08-21 14:25:21 +02:00
Hermes dc0f7f51c5 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.
2026-08-21 14:25:16 +02:00
2 changed files with 16 additions and 2 deletions

View File

@ -88,7 +88,7 @@ export const getClientInvitationStateFromOrderGroupStatus = (
deliveryStatus: string | null | undefined, deliveryStatus: string | null | undefined,
invitationState: string | null | undefined, invitationState: string | null | undefined,
): DeliveryInvitationPublicState => { ): DeliveryInvitationPublicState => {
if (deliveryStatus === "agreed") { if (deliveryStatus === "agreed" || deliveryStatus === "driver_assigned") {
return "agreed"; return "agreed";
} }
@ -96,6 +96,10 @@ export const getClientInvitationStateFromOrderGroupStatus = (
return "delivered"; return "delivered";
} }
if (deliveryStatus === "paid_storage") {
return "paid_storage";
}
if (["awaiting_choice", "opened", "reminder_sent"].includes(String(invitationState || ""))) { if (["awaiting_choice", "opened", "reminder_sent"].includes(String(invitationState || ""))) {
return invitationState as DeliveryInvitationPublicState; return invitationState as DeliveryInvitationPublicState;
} }

View File

@ -20,6 +20,14 @@ import {
const MAX_BODY_BYTES = 8 * 1024; 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 = { type ConfirmBody = {
token?: string; token?: string;
deliveryDate?: string; deliveryDate?: string;
@ -191,7 +199,9 @@ Deno.serve(async (request) => {
? "agreed" ? "agreed"
: "requires_address"; : "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( return jsonResponse(
{ {
ok: false, ok: false,