- 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.
41 lines
1.1 KiB
TypeScript
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>
|
|
);
|
|
}
|