* add contacts scroller * add service select * add calendar & time picker * context/order: add masterId * Revert "context/order: add masterId" This reverts commit d5d07d7b2f5b6673a621a30b00ad087c60675a3f. * components/order-form: add back button * disable submit button if no customer selected * disable submit button if no service selected * service component: comment span * save selected date to context * fix calendar padding * hooks/slot: rename index -> master * slot list: render immediately * fix step components rendering * add check icon for masters * Revert "add check icon for masters" This reverts commit cc81a9a504918ebbffcca8d035c7c4984f109957. * prepare for split contacts grid into masters/clients grid * create MastersGrid & master-select step * optimize useCustomerContacts * add ClientsGrid & 'client-select' step * add self to masters list & border avatar * context/order: split into files * hooks/profile: allow pass empty args to useProfileQuery/useProfileMutation * context/order: skip client-select in client steps * packages: upgrade next@15.3.0 * .vscode: add launch.json * back-button: fix steps using * contacts: skip client step for client * fix react types * ServiceSelect: fix padding * Revert "contacts: skip client step for client" This reverts commit db9af07dab9df9428561a1952f5a2c91c5b9d88d. * fix steps for client & master * split datetime-select into files * improve useSlots hook * migrate from order context to zustand store * pass order store via context * fix submit button not working * skip master select for master & client select for client * select time feature & get final order values * apps/web: rename actions/service -> actions/services * create order works! * split next-button into two buttons * add result pages (success, error) * packages/graphql: add eslint * merge branch 'refactor-api' (#23) * refactor customer api * refactor slots api * hooks/customers: use invalidateQueries * refactor services api * optimize hooks queryKey * refactor orders api * typo refactor hooks * fix telegramId type (number) * fix bot with new api * rename customers masters & clients query * fix useClientsQuery & useMastersQuery query * new line after 'use client' & 'use server' directives * move getAvailableTimeSlots to server * getAvailableTimeSlots: add filter by orders * take into service duration when computing times * fix GetSlotsOrders order * take into existing orders when computing times * fix build * app/orders: fill page with content * stores/order: split into slices * components/orders: remove nested components dirs * move order store -> orders\order-store * replace ScheduleTimeContext with ScheduleStore * fix slots queries * context: rename contexts properly * finally organized stores & context * move order-card & time-range to @/components/shared * Refactor/components folder structure (#24) * refactor components/navigation * refactor components/orders * refactor components/profile * refactor components/schedule * remove components/common/spinner * add launch.json * add horizontal calendar * remove context/date.tsx * optimize orders list fetching * add numberOfDaysBefore param * fix orders list in slot page * graphql/api: remove throw new Error * horizontal-calendar: switch months by arrow buttons * SlotCard: use SlotComponentProps type * stores/schedule: export useScheduleStore * SlotPage: add page header title * contacts: mark inactive contacts * prefetchQuery customer profile pages * fix create slot * packages: radash -> radashi * fix queries, using formatDate & formatTime on client * graphql: remove rename operations files * fix create order query * fix show actual slot status after slot update * order page * slot page: replace buttons with floating panel * fix blur & colors * fix floating panel overflows content * hide ClientsOrdersList for non masters * hooks/services: rename input -> variables * move OrderCard types close to component * exact types for Slot components & page * app/profile: show shared orders * order-services: fix types * order page: add buttons * order-card: add colors * add order status alert * fix badges & alerts * take into account cancelled and completed orders in the slot list * action panel: hide if no handlers * highlight days with slots in schedule calendar * highlight days in horizontal calendar * remove getSlotsOrders fn * show masters avatar in orders list * fix auth redirects * fix orders list for client * create useIsMaster hook to prevent duplication * order: revert cancel button for master * FloatingActionPanel: block buttons while pending request * hooks: invalidate orders & slots after mutate & delete * order: revert approve button for master * api/orders: protect update order * order-card: show date * order-card: add showDate variables in props * order: add repeat button * disable dashboard button * apps/bot: beautify messages * order: notify to telegram messages * orderUpdate: add status info
116 lines
3.9 KiB
TypeScript
116 lines
3.9 KiB
TypeScript
'use client';
|
||
|
||
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';
|
||
|
||
type FloatingActionPanelProps = {
|
||
readonly isLoading?: boolean;
|
||
readonly isOpen?: boolean;
|
||
readonly onCancel?: () => void;
|
||
readonly onConfirm?: () => void;
|
||
readonly onDelete?: () => void;
|
||
readonly onRepeat?: () => void;
|
||
readonly onToggle?: () => void;
|
||
};
|
||
|
||
export default function FloatingActionPanel({
|
||
isLoading = false,
|
||
isOpen,
|
||
onCancel,
|
||
onConfirm,
|
||
onDelete,
|
||
onRepeat,
|
||
onToggle,
|
||
}: FloatingActionPanelProps) {
|
||
// Если не переданы обработчики, скрываем панель
|
||
if (!onCancel && !onConfirm && !onDelete && !onRepeat && !onToggle) 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">
|
||
<div className="flex flex-col items-center gap-2 sm:flex-row sm:gap-4">
|
||
{/* Кнопка закрыть/открыть */}
|
||
{onToggle && (
|
||
<Button
|
||
className={`
|
||
w-full rounded-2xl text-sm transition-all duration-200 sm:w-auto
|
||
${
|
||
isOpen
|
||
? 'bg-blue-500 text-white hover:bg-blue-600 dark:bg-blue-600 dark:hover:bg-blue-700'
|
||
: 'bg-gray-500 text-white hover:bg-gray-600 dark:bg-gray-600 dark:hover:bg-gray-700'
|
||
}
|
||
`}
|
||
disabled={isLoading}
|
||
onClick={onToggle}
|
||
size="sm"
|
||
>
|
||
{isOpen ? (
|
||
<>
|
||
<Lock className="mr-2 size-4" />
|
||
<span>Закрыть</span>
|
||
</>
|
||
) : (
|
||
<>
|
||
<Unlock className="mr-2 size-4" />
|
||
<span>Открыть</span>
|
||
</>
|
||
)}
|
||
</Button>
|
||
)}
|
||
|
||
{/* Кнопка повторить */}
|
||
{onRepeat && (
|
||
<Button
|
||
className="w-full rounded-2xl bg-purple-500 text-sm text-white transition-all duration-200 hover:bg-purple-600 dark:bg-purple-600 dark:hover:bg-purple-700 sm:w-auto"
|
||
disabled={isLoading}
|
||
onClick={onRepeat}
|
||
size="sm"
|
||
>
|
||
<RotateCcw className="mr-2 size-4" />
|
||
<span>Повторить</span>
|
||
</Button>
|
||
)}
|
||
|
||
{/* Кнопка удалить */}
|
||
{onDelete && (
|
||
<Button
|
||
className="w-full rounded-2xl bg-orange-500 text-sm text-white transition-all duration-200 hover:bg-orange-600 dark:bg-orange-600 dark:hover:bg-orange-700 sm:w-auto"
|
||
disabled={isLoading}
|
||
onClick={onDelete}
|
||
size="sm"
|
||
>
|
||
<Trash2 className="mr-2 size-4" />
|
||
<span>Удалить</span>
|
||
</Button>
|
||
)}
|
||
|
||
{/* Кнопка отменить */}
|
||
{onCancel && (
|
||
<Button
|
||
className="w-full rounded-2xl bg-red-500 text-sm text-white transition-all duration-200 hover:bg-red-600 dark:bg-red-600 dark:hover:bg-red-700 sm:w-auto"
|
||
disabled={isLoading}
|
||
onClick={onCancel}
|
||
size="sm"
|
||
>
|
||
<Ban className="mr-2 size-4" />
|
||
<span>Отменить</span>
|
||
</Button>
|
||
)}
|
||
|
||
{/* Кнопка подтвердить */}
|
||
{onConfirm && (
|
||
<Button
|
||
className="w-full rounded-2xl bg-green-600 text-sm text-white shadow-lg transition-all duration-200 hover:bg-green-700 dark:bg-green-700 dark:hover:bg-green-600 sm:w-auto"
|
||
disabled={isLoading}
|
||
onClick={onConfirm}
|
||
size="sm"
|
||
>
|
||
<Check className="mr-2 size-4" />
|
||
<span>Подтвердить</span>
|
||
</Button>
|
||
)}
|
||
</div>
|
||
</Card>
|
||
);
|
||
}
|