fix: restrict agreed/driver_assigned status buttons, show hints instead
This commit is contained in:
parent
0f32d6d73a
commit
a8d54699ff
|
|
@ -821,37 +821,49 @@ export const OrderDetailPanel = ({
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
{[
|
{[
|
||||||
{ value: "pending_confirmation", label: "Ожидает согласования" },
|
{ value: "pending_confirmation", label: "Ожидает согласования", manual: true },
|
||||||
{ value: "agreed", label: "Согласовано" },
|
{ value: "agreed", label: "Согласовано", manual: false, hint: "Согласуйте дату доставки выше" },
|
||||||
{ value: "driver_assigned", label: "Назначен водитель" },
|
{ value: "driver_assigned", label: "Назначен водитель", manual: false, hint: "Назначьте водителя из списка" },
|
||||||
{ value: "loaded", label: "Загружено" },
|
{ value: "loaded", label: "Загружено", manual: true },
|
||||||
{ value: "on_route", label: "В пути" },
|
{ value: "on_route", label: "В пути", manual: true },
|
||||||
{ value: "delivered", label: "Доставлено" },
|
{ value: "delivered", label: "Доставлено", manual: true },
|
||||||
{ value: "problem", label: "Проблема" },
|
{ value: "problem", label: "Проблема", manual: true },
|
||||||
{ value: "cancelled", label: "Отменено" },
|
{ value: "cancelled", label: "Отменено", manual: true },
|
||||||
].map((statusOption) => (
|
].map((statusOption) => {
|
||||||
<Button
|
const isCurrent = (order.deliveryStatus || order.delivery_status) === statusOption.value;
|
||||||
key={statusOption.value}
|
const isClickable = statusOption.manual !== false && !isCurrent;
|
||||||
variant={
|
return (
|
||||||
(order.deliveryStatus || order.delivery_status) === statusOption.value ? "primary" : "secondary"}
|
<div key={statusOption.value} className="relative group">
|
||||||
onClick={() => {
|
<Button
|
||||||
onChangeDeliveryStatus({
|
variant={isCurrent ? "primary" : "secondary"}
|
||||||
orderGroupId: order.id,
|
onClick={() => {
|
||||||
status: statusOption.value,
|
if (!isClickable) {
|
||||||
}).then((response) => {
|
setFormMessage(statusOption.hint || "");
|
||||||
if (!response.success) {
|
return;
|
||||||
setFormMessage(response.error || "Не удалось обновить статус");
|
}
|
||||||
} else {
|
|
||||||
setFormMessage("");
|
setFormMessage("");
|
||||||
}
|
onChangeDeliveryStatus({
|
||||||
});
|
orderGroupId: order.id,
|
||||||
}}
|
status: statusOption.value,
|
||||||
disabled={isSavingDeliveryChoice}
|
}).then((response) => {
|
||||||
>
|
if (!response.success) {
|
||||||
{statusOption.label}
|
setFormMessage(response.error || "Не удалось обновить статус");
|
||||||
</Button>
|
} else {
|
||||||
))}
|
setFormMessage("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
disabled={isSavingDeliveryChoice}
|
||||||
|
>
|
||||||
|
{statusOption.label}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
{formMessage ? (
|
||||||
|
<p className="text-sm text-[var(--color-warning)]">{formMessage}</p>
|
||||||
|
) : null}
|
||||||
</Panel>
|
</Panel>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue