add contacts scroller
This commit is contained in:
parent
b418790ae4
commit
fbc682b41f
@ -1,3 +1,14 @@
|
||||
export default function AddOrdersPage() {
|
||||
return 'Add Orders';
|
||||
import { Container } from '@/components/layout';
|
||||
import { PageHeader } from '@/components/navigation';
|
||||
import { OrderForm } from '@/components/orders';
|
||||
|
||||
export default async function AddOrdersPage() {
|
||||
return (
|
||||
<>
|
||||
<PageHeader title="Новая запись" />
|
||||
<Container className="px-0">
|
||||
<OrderForm />
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
64
apps/web/components/orders/components/contacts-scroller.tsx
Normal file
64
apps/web/components/orders/components/contacts-scroller.tsx
Normal file
@ -0,0 +1,64 @@
|
||||
'use client';
|
||||
import { LoadingSpinner } from '../../common/spinner';
|
||||
import { useCustomerContacts } from '@/hooks/contacts';
|
||||
// eslint-disable-next-line import/extensions
|
||||
import AvatarPlaceholder from '@/public/avatar/avatar_placeholder.png';
|
||||
import { Label } from '@repo/ui/components/ui/label';
|
||||
import { cn } from '@repo/ui/lib/utils';
|
||||
import Image from 'next/image';
|
||||
import { useState } from 'react';
|
||||
|
||||
export function ContactsScroller() {
|
||||
const [selected, setSelected] = useState<null | string>(null);
|
||||
const { contacts, isLoading } = useCustomerContacts();
|
||||
|
||||
if (isLoading) return <LoadingSpinner />;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col rounded-lg bg-transparent px-4">
|
||||
<div className="relative w-full overflow-x-auto pb-2">
|
||||
<div className="flex w-max space-x-4 px-4">
|
||||
{contacts.map((contact) => {
|
||||
if (!contact) return null;
|
||||
|
||||
return (
|
||||
<Label
|
||||
className="flex cursor-pointer flex-col items-center"
|
||||
key={contact?.documentId}
|
||||
onClick={() => setSelected(contact?.documentId)}
|
||||
>
|
||||
<input
|
||||
checked={selected === contact?.documentId}
|
||||
className="hidden"
|
||||
name="user"
|
||||
onChange={() => setSelected(contact?.documentId)}
|
||||
type="radio"
|
||||
value={contact?.documentId}
|
||||
/>
|
||||
<div
|
||||
className={cn(
|
||||
'w-20 h-20 rounded-full border-2 transition-all duration-75',
|
||||
selected === contact?.documentId ? 'border-primary' : 'border-transparent',
|
||||
)}
|
||||
>
|
||||
<div className="size-full border-4 border-transparent">
|
||||
<Image
|
||||
alt={contact?.name}
|
||||
className="size-full rounded-full object-cover"
|
||||
height={80}
|
||||
src={contact?.photoUrl || AvatarPlaceholder}
|
||||
width={80}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<span className="mt-2 max-w-20 break-words text-center text-sm font-medium">
|
||||
{contact?.name}
|
||||
</span>
|
||||
</Label>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
1
apps/web/components/orders/components/index.ts
Normal file
1
apps/web/components/orders/components/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './contacts-scroller';
|
||||
1
apps/web/components/orders/index.ts
Normal file
1
apps/web/components/orders/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './order-form';
|
||||
9
apps/web/components/orders/order-form.tsx
Normal file
9
apps/web/components/orders/order-form.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import { ContactsScroller } from './components';
|
||||
|
||||
export function OrderForm() {
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<ContactsScroller />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
BIN
apps/web/public/avatar/avatar_placeholder.png
Normal file
BIN
apps/web/public/avatar/avatar_placeholder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Loading…
x
Reference in New Issue
Block a user