From 3a5e5b06f34b9f80af19d8b08e660518801856ce Mon Sep 17 00:00:00 2001 From: aatbip Date: Mon, 5 Feb 2024 16:04:43 +0545 Subject: [PATCH] fix bug --- src/app/manage/views/ManagePageContainer.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/manage/views/ManagePageContainer.tsx b/src/app/manage/views/ManagePageContainer.tsx index a30e267..023b3d5 100644 --- a/src/app/manage/views/ManagePageContainer.tsx +++ b/src/app/manage/views/ManagePageContainer.tsx @@ -27,15 +27,16 @@ export const ManagePageContainer = ({ const [allowedCustomField, setAllowedCustomField] = useState(null); - const customFieldsValue: any | null = client.customFields; + const [customFieldsValue, setCustomFieldsValue] = useState(client.customFields); const [profileData, setProfileData] = useState({}); const [originalProfileData, setOriginalProfileData] = useState({}); useMemo(() => { - if (customFieldAccess.length > 0) { - const allowedFields = customFieldAccess.filter((field: any) => field.permission?.length > 0); + if (_customFieldAccess.length > 0) { + const allowedFields = _customFieldAccess.filter((field: any) => field.permission?.length > 0); + console.log(allowedFields); const getSelectedValuesForMultiSelect = (key: string) => { const values = customFieldsValue[key]; if (!values) { @@ -95,6 +96,12 @@ export const ManagePageContainer = ({ const { data } = await res.json(); + const client = await fetch(`/api/client?clientId=${clientId}&token=${token}`); + + const updatedClientData = await client.json(); + + setCustomFieldsValue(updatedClientData.data.customFields); + setCustomFieldAccess(data); setLoading(false);