diff --git a/apps/web/components/profile/profile-buttons.tsx b/apps/web/components/profile/profile-buttons.tsx index 08720e6..0400f6f 100644 --- a/apps/web/components/profile/profile-buttons.tsx +++ b/apps/web/components/profile/profile-buttons.tsx @@ -1,94 +1,35 @@ +/* eslint-disable canonical/id-match */ 'use client'; import FloatingActionPanel from '@/components/shared/action-panel'; import { useCustomerQuery } from '@/hooks/api/customers'; import { usePushWithData } from '@/hooks/url'; -import { Button } from '@repo/ui/components/ui/button'; -import { - Drawer, - DrawerClose, - DrawerContent, - DrawerDescription, - DrawerFooter, - DrawerHeader, - DrawerTitle, - DrawerTrigger, -} from '@repo/ui/components/ui/drawer'; -import { useState } from 'react'; +import { Enum_Customer_Role } from '@repo/graphql/types'; type QuickAppointmentProps = { readonly telegramId: number; }; export function ProfileButtons({ telegramId }: Readonly) { - const [isPanelOpen, setIsPanelOpen] = useState(false); const push = usePushWithData(); - const { data: { customer: profile } = {} } = useCustomerQuery({ telegramId }); - const { data: { customer: currentUser } = {} } = useCustomerQuery(); + const { data: { customer: profile } = {}, isLoading: isLoadingProfile } = useCustomerQuery({ + telegramId, + }); + const { data: { customer: currentUser } = {}, isLoading: isLoadingCurrentUser } = + useCustomerQuery(); - const handleBookAsClient = () => { - push('/orders/add', { - client: currentUser, - slot: { master: profile }, - }); - }; + const isLoading = isLoadingProfile || isLoadingCurrentUser; - const handleBookAsMaster = () => { - push('/orders/add', { - client: profile, - slot: { master: currentUser }, - }); + const handleBook = () => { + if (profile?.role === Enum_Customer_Role.Client) { + push('/orders/add', { client: profile, slot: { master: currentUser } }); + } else { + push('/orders/add', { client: currentUser, slot: { master: profile } }); + } }; if (!telegramId) return null; - return ( - <> - setIsPanelOpen(true)} /> - - -
- - -
- - Быстрая запись - Выберите действие - -
-
- - - - - - -
-
- - - - - -
-
- - - ); + return ; }