* feat(profile): add 'Услуги' link button to LinksCard for service management * feat(services): add create and update service functionalities with corresponding API actions and hooks
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
'use client';
|
|
|
|
import { TextField, TimeField } from '@/components/shared/data-fields';
|
|
import { useServiceMutation, useServiceQuery } from '@/hooks/api/services';
|
|
import { Card } from '@repo/ui/components/ui/card';
|
|
import { convertTimeString } from '@repo/utils/datetime-format';
|
|
|
|
type Props = {
|
|
serviceId: string;
|
|
};
|
|
|
|
export function ServiceDataCard({ serviceId }: Readonly<Props>) {
|
|
const { data: { service } = {} } = useServiceQuery({ documentId: serviceId });
|
|
const { mutate } = useServiceMutation({ documentId: serviceId });
|
|
|
|
if (!service) return null;
|
|
|
|
return (
|
|
<Card className="p-4">
|
|
<div className="flex flex-col gap-4">
|
|
<TextField
|
|
id="name"
|
|
label="Название"
|
|
onChange={(name) => mutate({ data: { name } })}
|
|
value={service?.name ?? ''}
|
|
/>
|
|
<TimeField
|
|
id="duration"
|
|
label="Длительность"
|
|
onChange={(time) =>
|
|
mutate({
|
|
data: {
|
|
duration: convertTimeString(time).db(),
|
|
},
|
|
})
|
|
}
|
|
value={service?.duration ?? ''}
|
|
/>
|
|
</div>
|
|
</Card>
|
|
);
|
|
}
|