feat(service-select): share services list for all

enhance service card display with duration formatting and improve layout
This commit is contained in:
vchikalkin 2025-07-03 16:35:04 +03:00
parent e2d92ade16
commit b53a276540

View File

@ -5,19 +5,10 @@ import { useServicesQuery } from '@/hooks/api/services';
import { useOrderStore } from '@/stores/order'; import { useOrderStore } from '@/stores/order';
import { type ServiceFieldsFragment } from '@repo/graphql/types'; import { type ServiceFieldsFragment } from '@repo/graphql/types';
import { cn } from '@repo/ui/lib/utils'; import { cn } from '@repo/ui/lib/utils';
import { formatTime } from '@repo/utils/datetime-format';
export function ServiceSelect() { export function ServiceSelect() {
const masterId = useOrderStore((store) => store.masterId); const { data: { services } = {} } = useServicesQuery({});
const { data: { services } = {} } = useServicesQuery({
filters: {
master: {
documentId: {
eq: masterId,
},
},
},
});
if (!services?.length) return <DataNotFound title="Услуги не найдены" />; if (!services?.length) return <DataNotFound title="Услуги не найдены" />;
@ -28,7 +19,7 @@ export function ServiceSelect() {
); );
} }
function ServiceCard({ documentId, name }: Readonly<ServiceFieldsFragment>) { function ServiceCard({ documentId, duration, name }: Readonly<ServiceFieldsFragment>) {
const serviceId = useOrderStore((store) => store.serviceId); const serviceId = useOrderStore((store) => store.serviceId);
const setServiceId = useOrderStore((store) => store.setServiceId); const setServiceId = useOrderStore((store) => store.setServiceId);
@ -53,9 +44,23 @@ function ServiceCard({ documentId, name }: Readonly<ServiceFieldsFragment>) {
type="radio" type="radio"
value={documentId} value={documentId}
/> />
<div className="flex flex-col gap-2"> <div className="flex w-full items-center justify-between gap-2">
{name} <span className="text-base font-semibold text-foreground">{name}</span>
{/* <span className={cn('text-xs font-normal', 'text-muted-foreground')} /> */} <span
className={cn(
'inline-flex items-center gap-1 px-4 p-2 rounded-full bg-secondary dark:bg-background text-primary text-xs font-medium',
)}
>
<svg
className="size-4 opacity-70"
fill="currentColor"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M8 1.5a6.5 6.5 0 1 0 0 13a6.5 6.5 0 0 0 0-13ZM2.5 8a5.5 5.5 0 1 1 11 0a5.5 5.5 0 0 1-11 0Zm6-2.75a.5.5 0 0 0-1 0v3c0 .28.22.5.5.5h2a.5.5 0 0 0 0-1H8.5V5.25Z" />
</svg>
{formatTime(duration).user()}
</span>
</div> </div>
</label> </label>
); );