* feat(profile): add 'Услуги' link button to LinksCard for service management * feat(services): add create and update service functionalities with corresponding API actions and hooks
28 lines
735 B
TypeScript
28 lines
735 B
TypeScript
'use client';
|
|
|
|
import FloatingActionPanel from '@/components/shared/action-panel';
|
|
import { useServiceMutation, useServiceQuery } from '@/hooks/api/services';
|
|
|
|
type Props = {
|
|
serviceId: string;
|
|
};
|
|
|
|
export function ServiceButtons({ serviceId }: Readonly<Props>) {
|
|
const { data: { service } = {}, isPending: isPendingQuery } = useServiceQuery({
|
|
documentId: serviceId,
|
|
});
|
|
const { isPending: isPendingUpdate, mutate: updateService } = useServiceMutation({
|
|
documentId: serviceId,
|
|
});
|
|
|
|
const active = Boolean(service?.active);
|
|
|
|
return (
|
|
<FloatingActionPanel
|
|
isLoading={isPendingQuery || isPendingUpdate}
|
|
isOpen={active}
|
|
onToggle={() => updateService({ data: { active: !active } })}
|
|
/>
|
|
);
|
|
}
|