Vlad Chikalkin 10981e2afb
Issues/66 (#67)
* feat(profile): add 'Услуги' link button to LinksCard for service management

* feat(services): add create and update service functionalities with corresponding API actions and hooks
2025-08-01 19:54:10 +03:00

42 lines
989 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'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>
);
}