sprint2: frontend permission checks for ContactDetail + ContactsList + Field-Level UI
This commit is contained in:
@@ -12,6 +12,7 @@ import { useUnifiedContact, type UnifiedContact } from '@/api/hooks';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { ChevronLeft } from 'lucide-react';
|
||||
import { PrintButton } from '@/components/common/PrintButton';
|
||||
import { usePermission } from '@/hooks/usePermission';
|
||||
|
||||
export function ContactDetailPage() {
|
||||
const { t } = useTranslation();
|
||||
@@ -19,6 +20,7 @@ export function ContactDetailPage() {
|
||||
const navigate = useNavigate();
|
||||
const { data: contact, isLoading } = useUnifiedContact(id);
|
||||
const openWindow = useWindowStore((s) => s.openWindow);
|
||||
const { hasPermission } = usePermission();
|
||||
|
||||
const handleEdit = () => {
|
||||
if (contact) {
|
||||
@@ -51,13 +53,13 @@ export function ContactDetailPage() {
|
||||
<span>{t('contacts.title')}</span>
|
||||
</button>
|
||||
<div className="flex-1" />
|
||||
<PrintButton targetId="contact-detail" />
|
||||
{hasPermission('contacts:read') && <PrintButton targetId="contact-detail" />}
|
||||
</div>
|
||||
<div className="flex-1 overflow-y-auto" id="contact-detail">
|
||||
<ContactDetail
|
||||
contact={contact ?? null}
|
||||
loading={isLoading}
|
||||
onEdit={handleEdit}
|
||||
onEdit={hasPermission('contacts:write') ? handleEdit : undefined}
|
||||
onDeleted={handleDeleted}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user