vchikalkin 5dfef524e2 refactor(contact): remove customer master role checks and simplify contact addition
- Updated the `addContact` function to allow all users to add contacts, removing the previous restriction that only masters could do so.
- Deleted the `become-master` feature and related utility functions, streamlining the codebase.
- Adjusted command settings to reflect the removal of the master role functionality.
- Refactored components and hooks to eliminate dependencies on the master role, enhancing user experience and simplifying logic.
2025-09-08 12:51:35 +03:00

41 lines
1.1 KiB
TypeScript

'use client';
import { useCustomerQuery } from '@/hooks/api/customers';
import { usePushWithData } from '@/hooks/url';
import { CalendarPlus } from 'lucide-react';
type BookButtonProps = {
disabled?: boolean;
label: string;
onBooked?: () => void;
};
export function BookButton({ disabled, label, onBooked }: Readonly<BookButtonProps>) {
const { data: { customer } = {} } = useCustomerQuery();
const masterId = customer?.documentId;
const push = usePushWithData();
const handleBook = () => {
push('/orders/add', {
slot: { master: { documentId: masterId } },
});
onBooked?.();
};
if (!masterId) return null;
return (
<div className="flex flex-col items-center justify-center">
<button
className="flex items-center justify-center gap-2 self-center rounded-xl bg-primary/5 px-6 py-2 font-semibold text-primary shadow-sm transition-colors hover:bg-primary/10"
disabled={disabled}
onClick={handleBook}
type="button"
>
<CalendarPlus className="size-5 text-primary" />
<span>{label}</span>
</button>
</div>
);
}