fix: restrict agreed/driver_assigned status buttons, show hints instead

This commit is contained in:
root 2026-05-27 12:26:21 +00:00
parent 0f32d6d73a
commit a8d54699ff
1 changed files with 41 additions and 29 deletions

View File

@ -821,20 +821,27 @@ 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) => {
const isCurrent = (order.deliveryStatus || order.delivery_status) === statusOption.value;
const isClickable = statusOption.manual !== false && !isCurrent;
return (
<div key={statusOption.value} className="relative group">
<Button <Button
key={statusOption.value} variant={isCurrent ? "primary" : "secondary"}
variant={
(order.deliveryStatus || order.delivery_status) === statusOption.value ? "primary" : "secondary"}
onClick={() => { onClick={() => {
if (!isClickable) {
setFormMessage(statusOption.hint || "");
return;
}
setFormMessage("");
onChangeDeliveryStatus({ onChangeDeliveryStatus({
orderGroupId: order.id, orderGroupId: order.id,
status: statusOption.value, status: statusOption.value,
@ -850,8 +857,13 @@ export const OrderDetailPanel = ({
> >
{statusOption.label} {statusOption.label}
</Button> </Button>
))}
</div> </div>
);
})}
</div>
{formMessage ? (
<p className="text-sm text-[var(--color-warning)]">{formMessage}</p>
) : null}
</Panel> </Panel>
) : null} ) : null}