From 32354276f0e5455a0b42cf0b24fe495badf202eb Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Mon, 1 Jun 2026 12:36:49 -0400 Subject: [PATCH] fix fetch for non existant contract data --- src/components/profile/contract/Contract.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/profile/contract/Contract.tsx b/src/components/profile/contract/Contract.tsx index 2dc1513..d8c7a75 100644 --- a/src/components/profile/contract/Contract.tsx +++ b/src/components/profile/contract/Contract.tsx @@ -62,13 +62,13 @@ export default function Contract({ categoriesData, profileData }: ContractProps) .eq("profile_id", profileId) .order("updated_at", { ascending: false }) .limit(1) - .single(); + .maybeSingle(); if (error) { console.error(error); } else { - setContract(data.data as ContractData); - setLastUpdated(new Date(data.updated_at)); + setContract(data?.data as ContractData); + setLastUpdated(new Date(data?.updated_at)); } })(); }, [profileId]); @@ -150,7 +150,7 @@ function ContractModal({ onSave, featureMap, problemCountByCategory, - profileData + profileData, }: ContractModalProps) { const [isUpdating, setIsUpdating] = useState(false); const [isReadOnly, setIsReadOnly] = useState(false); @@ -158,8 +158,8 @@ function ContractModal({ useEffect(() => { const checkIfReadOnly = async () => { try { - if(profileData && profileData.contract_override === true){ - setIsReadOnly(false) + if (profileData && profileData.contract_override === true) { + setIsReadOnly(false); } else { setIsReadOnly(await fetchContractPerms()); }