components/orders: remove nested components dirs
This commit is contained in:
parent
4160ed4540
commit
1b99f7f18d
@ -1,11 +1,19 @@
|
||||
'use client';
|
||||
|
||||
import { LoadingSpinner } from '@/components/common/spinner';
|
||||
import { CardSectionHeader } from '@/components/ui';
|
||||
import { ContactsFilterProvider } from '@/context/contacts-filter';
|
||||
import { useCustomerContacts } from '@/hooks/api/contacts';
|
||||
// eslint-disable-next-line import/extensions
|
||||
import AvatarPlaceholder from '@/public/avatar/avatar_placeholder.png';
|
||||
import { useOrderStore } from '@/stores/order';
|
||||
import { withContext } from '@/utils/context';
|
||||
import { type CustomerFieldsFragment } from '@repo/graphql/types';
|
||||
import { Card } from '@repo/ui/components/ui/card';
|
||||
import { Label } from '@repo/ui/components/ui/label';
|
||||
import { cn } from '@repo/ui/lib/utils';
|
||||
import Image from 'next/image';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
type ContactsGridProps = {
|
||||
readonly contacts: CustomerFieldsFragment[];
|
||||
@ -77,3 +85,45 @@ export function ContactsGridBase({ contacts, onSelect, selected, title }: Contac
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export const MastersGrid = withContext(ContactsFilterProvider)(function () {
|
||||
const { contacts, isLoading, setFilter } = useCustomerContacts();
|
||||
const masterId = useOrderStore((store) => store.masterId);
|
||||
const setMasterId = useOrderStore((store) => store.setMasterId);
|
||||
|
||||
useEffect(() => {
|
||||
setFilter('masters');
|
||||
}, [setFilter]);
|
||||
|
||||
if (isLoading) return <LoadingSpinner />;
|
||||
|
||||
return (
|
||||
<ContactsGridBase
|
||||
contacts={contacts}
|
||||
onSelect={(contactId) => setMasterId(contactId)}
|
||||
selected={masterId}
|
||||
title="Мастера"
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export const ClientsGrid = withContext(ContactsFilterProvider)(function () {
|
||||
const { contacts, isLoading, setFilter } = useCustomerContacts();
|
||||
const clientId = useOrderStore((store) => store.clientId);
|
||||
const setClientId = useOrderStore((store) => store.setClientId);
|
||||
|
||||
useEffect(() => {
|
||||
setFilter('clients');
|
||||
}, [setFilter]);
|
||||
|
||||
if (isLoading) return <LoadingSpinner />;
|
||||
|
||||
return (
|
||||
<ContactsGridBase
|
||||
contacts={contacts}
|
||||
onSelect={(contactId) => setClientId(contactId)}
|
||||
selected={clientId}
|
||||
title="Клиенты"
|
||||
/>
|
||||
);
|
||||
});
|
||||
@ -1 +0,0 @@
|
||||
export * from './contacts-grid-base';
|
||||
@ -1,51 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { ContactsGridBase } from './components';
|
||||
import { LoadingSpinner } from '@/components/common/spinner';
|
||||
import { ContactsFilterProvider } from '@/context/contacts-filter';
|
||||
import { useCustomerContacts } from '@/hooks/api/contacts';
|
||||
import { useOrderStore } from '@/stores/order';
|
||||
import { withContext } from '@/utils/context';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export const MastersGrid = withContext(ContactsFilterProvider)(function () {
|
||||
const { contacts, isLoading, setFilter } = useCustomerContacts();
|
||||
const masterId = useOrderStore((store) => store.masterId);
|
||||
const setMasterId = useOrderStore((store) => store.setMasterId);
|
||||
|
||||
useEffect(() => {
|
||||
setFilter('masters');
|
||||
}, [setFilter]);
|
||||
|
||||
if (isLoading) return <LoadingSpinner />;
|
||||
|
||||
return (
|
||||
<ContactsGridBase
|
||||
contacts={contacts}
|
||||
onSelect={(contactId) => setMasterId(contactId)}
|
||||
selected={masterId}
|
||||
title="Мастера"
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export const ClientsGrid = withContext(ContactsFilterProvider)(function () {
|
||||
const { contacts, isLoading, setFilter } = useCustomerContacts();
|
||||
const clientId = useOrderStore((store) => store.clientId);
|
||||
const setClientId = useOrderStore((store) => store.setClientId);
|
||||
|
||||
useEffect(() => {
|
||||
setFilter('clients');
|
||||
}, [setFilter]);
|
||||
|
||||
if (isLoading) return <LoadingSpinner />;
|
||||
|
||||
return (
|
||||
<ContactsGridBase
|
||||
contacts={contacts}
|
||||
onSelect={(contactId) => setClientId(contactId)}
|
||||
selected={clientId}
|
||||
title="Клиенты"
|
||||
/>
|
||||
);
|
||||
});
|
||||
@ -3,6 +3,40 @@
|
||||
import { useAvailableTimeSlotsQuery } from '@/hooks/api/slots';
|
||||
import { useOrderStore } from '@/stores/order';
|
||||
import { Button } from '@repo/ui/components/ui/button';
|
||||
import { Calendar } from '@repo/ui/components/ui/calendar';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export function DateSelect() {
|
||||
const selectedDate = useOrderStore((store) => store.date);
|
||||
const setDate = useOrderStore((store) => store.setDate);
|
||||
const setTime = useOrderStore((store) => store.setTime);
|
||||
const setSlot = useOrderStore((store) => store.setSlotId);
|
||||
|
||||
return (
|
||||
<Calendar
|
||||
className="bg-background"
|
||||
disabled={(date) => {
|
||||
return dayjs().isAfter(dayjs(date), 'day');
|
||||
}}
|
||||
mode="single"
|
||||
onSelect={(date) => {
|
||||
if (date) setDate(date);
|
||||
setTime(null);
|
||||
setSlot(null);
|
||||
}}
|
||||
selected={selectedDate}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function DateTimeSelect() {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<DateSelect />
|
||||
<TimeSelect />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function TimeSelect() {
|
||||
const masterId = useOrderStore((store) => store.masterId);
|
||||
@ -1,28 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { useOrderStore } from '@/stores/order';
|
||||
import { Calendar } from '@repo/ui/components/ui/calendar';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export function DateSelect() {
|
||||
const selectedDate = useOrderStore((store) => store.date);
|
||||
const setDate = useOrderStore((store) => store.setDate);
|
||||
const setTime = useOrderStore((store) => store.setTime);
|
||||
const setSlot = useOrderStore((store) => store.setSlotId);
|
||||
|
||||
return (
|
||||
<Calendar
|
||||
className="bg-background"
|
||||
disabled={(date) => {
|
||||
return dayjs().isAfter(dayjs(date), 'day');
|
||||
}}
|
||||
mode="single"
|
||||
onSelect={(date) => {
|
||||
if (date) setDate(date);
|
||||
setTime(null);
|
||||
setSlot(null);
|
||||
}}
|
||||
selected={selectedDate}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
import { DateSelect } from './components/date-select';
|
||||
import { TimeSelect } from './components/time-select';
|
||||
|
||||
export function DateTimeSelect() {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<DateSelect />
|
||||
<TimeSelect />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -5,3 +5,4 @@ export * from './next-button';
|
||||
export * from './order-card';
|
||||
export * from './result';
|
||||
export * from './service-select';
|
||||
export * from './submit-button';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user