refactor(order-buttons, action-panel): streamline button handlers and add return functionality
This commit is contained in:
parent
d587ea23b6
commit
f6354d41f6
@ -52,19 +52,12 @@ export function OrderButtons({ documentId }: Readonly<OrderComponentProps>) {
|
||||
<FloatingActionPanel
|
||||
isLoading={isPending}
|
||||
onCancel={
|
||||
isCancelled || (!isMaster && isCancelling) || isCompleted ? undefined : () => handleCancel()
|
||||
}
|
||||
onComplete={isApproved && isMaster ? handleOnComplete : undefined}
|
||||
onConfirm={
|
||||
!isMaster ||
|
||||
isApproved ||
|
||||
(!isMaster && isCancelled) ||
|
||||
(!isMaster && isCancelling) ||
|
||||
isCompleted
|
||||
? undefined
|
||||
: () => handleApprove()
|
||||
isCancelled || (!isMaster && isCancelling) || isCompleted ? undefined : handleCancel
|
||||
}
|
||||
onComplete={isMaster && isApproved ? handleOnComplete : undefined}
|
||||
onConfirm={isMaster && !isApproved ? handleApprove : undefined}
|
||||
onRepeat={isCancelled || isCompleted ? handleOnRepeat : undefined}
|
||||
onReturn={isMaster && isCancelled ? handleApprove : undefined}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
import { Button } from '@repo/ui/components/ui/button';
|
||||
import { Card } from '@repo/ui/components/ui/card';
|
||||
import { Ban, Check, Lock, RotateCcw, Trash2, Unlock } from 'lucide-react';
|
||||
import { Ban, Check, Lock, RotateCcw, Trash2, Undo, Unlock } from 'lucide-react';
|
||||
|
||||
type FloatingActionPanelProps = {
|
||||
readonly isLoading?: boolean;
|
||||
@ -12,6 +12,7 @@ type FloatingActionPanelProps = {
|
||||
readonly onConfirm?: () => void;
|
||||
readonly onDelete?: () => void;
|
||||
readonly onRepeat?: () => void;
|
||||
readonly onReturn?: () => void;
|
||||
readonly onToggle?: () => void;
|
||||
};
|
||||
|
||||
@ -23,10 +24,12 @@ export default function FloatingActionPanel({
|
||||
onConfirm,
|
||||
onDelete,
|
||||
onRepeat,
|
||||
onReturn,
|
||||
onToggle,
|
||||
}: FloatingActionPanelProps) {
|
||||
// Если не переданы обработчики, скрываем панель
|
||||
if (!onCancel && !onConfirm && !onDelete && !onComplete && !onRepeat && !onToggle) return null;
|
||||
if (!onCancel && !onConfirm && !onDelete && !onComplete && !onRepeat && !onToggle && !onReturn)
|
||||
return null;
|
||||
|
||||
return (
|
||||
<Card className="fixed inset-x-4 bottom-4 z-50 rounded-3xl border-0 bg-background/95 p-4 shadow-2xl backdrop-blur-sm dark:bg-primary/5 md:bottom-6 md:left-auto md:right-6 md:p-6">
|
||||
@ -124,6 +127,19 @@ export default function FloatingActionPanel({
|
||||
<span>Подтвердить</span>
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* Кнопка вернуть */}
|
||||
{onReturn && (
|
||||
<Button
|
||||
className="w-full rounded-2xl bg-blue-400 text-sm text-white transition-all duration-200 hover:bg-blue-500 dark:bg-blue-500 dark:hover:bg-blue-600 sm:w-auto"
|
||||
disabled={isLoading}
|
||||
onClick={onReturn}
|
||||
size="sm"
|
||||
>
|
||||
<Undo className="mr-2 size-4" />
|
||||
<span>Вернуть</span>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user