From 4ed010056a20d04da7864540bc729e2839dc2bcd Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Mon, 23 Jun 2025 20:55:07 +0300 Subject: [PATCH] slot page: replace buttons with floating panel --- .../schedule/slots/[documentId]/page.tsx | 2 +- apps/web/components/orders/index.ts | 1 + apps/web/components/schedule/slot-buttons.tsx | 39 ++------ apps/web/components/shared/action-panel.tsx | 91 +++++++++++++++++++ 4 files changed, 102 insertions(+), 31 deletions(-) create mode 100644 apps/web/components/shared/action-panel.tsx diff --git a/apps/web/app/(main)/profile/schedule/slots/[documentId]/page.tsx b/apps/web/app/(main)/profile/schedule/slots/[documentId]/page.tsx index 6529c27..29f3467 100644 --- a/apps/web/app/(main)/profile/schedule/slots/[documentId]/page.tsx +++ b/apps/web/app/(main)/profile/schedule/slots/[documentId]/page.tsx @@ -23,8 +23,8 @@ export default async function SlotPage(props: Readonly) { - + ); diff --git a/apps/web/components/orders/index.ts b/apps/web/components/orders/index.ts index 8caaa9e..094008c 100644 --- a/apps/web/components/orders/index.ts +++ b/apps/web/components/orders/index.ts @@ -1,3 +1,4 @@ +export * from '../shared/action-panel'; export * from './order-contacts'; export * from './order-datetime'; export * from './order-form'; diff --git a/apps/web/components/schedule/slot-buttons.tsx b/apps/web/components/schedule/slot-buttons.tsx index 587a3b2..c2f4044 100644 --- a/apps/web/components/schedule/slot-buttons.tsx +++ b/apps/web/components/schedule/slot-buttons.tsx @@ -1,11 +1,10 @@ -/* eslint-disable react/jsx-no-bind */ /* eslint-disable canonical/id-match */ 'use client'; +import FloatingActionPanel from '../shared/action-panel'; import { type SlotComponentProps } from './types'; import { useSlotDelete, useSlotMutation, useSlotQuery } from '@/hooks/api/slots'; import { Enum_Slot_State } from '@repo/graphql/types'; -import { Button } from '@repo/ui/components/ui/button'; import { useRouter } from 'next/navigation'; export function SlotButtons({ documentId }: Readonly) { @@ -38,33 +37,13 @@ export function SlotButtons({ documentId }: Readonly) { const hasOrders = Boolean(slot?.orders.length); return ( -
- {isOpened && ( - - )} - {isClosed && ( - - )} - -
+ handleDeleteSlot()} + onToggle={() => { + if (isOpened) handleCloseSlot(); + if (isClosed) handleOpenSlot(); + }} + /> ); } diff --git a/apps/web/components/shared/action-panel.tsx b/apps/web/components/shared/action-panel.tsx new file mode 100644 index 0000000..1494b12 --- /dev/null +++ b/apps/web/components/shared/action-panel.tsx @@ -0,0 +1,91 @@ +'use client'; + +import { Button } from '@repo/ui/components/ui/button'; +import { Card } from '@repo/ui/components/ui/card'; +import { Ban, Check, Lock, Trash2, Unlock } from 'lucide-react'; + +type FloatingActionPanelProps = { + readonly isOpen?: boolean; + readonly onCancel?: () => void; + readonly onConfirm?: () => void; + readonly onDelete?: () => void; + readonly onToggle?: () => void; +}; + +export default function FloatingActionPanel({ + isOpen, + onCancel, + onConfirm, + onDelete, + onToggle, +}: FloatingActionPanelProps) { + return ( + +
+ {/* Кнопка закрыть/открыть */} + {onToggle && ( + + )} + + {/* Кнопка удалить */} + {onDelete && ( + + )} + + {/* Кнопка отменить */} + {onCancel && ( + + )} + + {/* Кнопка подтверд��ть */} + {onConfirm && ( + + )} +
+
+ ); +}