42 lines
989 B
TypeScript
42 lines
989 B
TypeScript
'use client';
|
||
|
||
import { useServiceCreate } from '@/hooks/api/services';
|
||
import { Button } from '@repo/ui/components/ui/button';
|
||
import { PlusSquare } from 'lucide-react';
|
||
import { useRouter } from 'next/navigation';
|
||
|
||
export function ServicesAddButton() {
|
||
const { isPending, mutateAsync: createService } = useServiceCreate();
|
||
|
||
const router = useRouter();
|
||
|
||
const handleOnClick = async () => {
|
||
const response = await createService({
|
||
data: {
|
||
name: 'Новая услуга',
|
||
},
|
||
});
|
||
|
||
const documentId = response?.createService?.documentId;
|
||
|
||
if (documentId) {
|
||
router.push(`/profile/services/${documentId}`);
|
||
}
|
||
};
|
||
|
||
return (
|
||
<div className="grid place-items-center">
|
||
<Button
|
||
className="rounded-full"
|
||
disabled={isPending}
|
||
onClick={handleOnClick}
|
||
type="button"
|
||
variant="outline"
|
||
>
|
||
<PlusSquare className="mr-1 size-4" />
|
||
Добавить
|
||
</Button>
|
||
</div>
|
||
);
|
||
}
|