From 46574bcee85c533c611247addf71623ffbb1cbe3 Mon Sep 17 00:00:00 2001 From: Rykkel <220993G@mymail.nyp.edu.sg> Date: Fri, 2 Aug 2024 08:22:53 +0800 Subject: [PATCH] Fix and Updated Post Management --- client/src/pages/CommunityPostManagement.tsx | 111 +++++++++++-------- 1 file changed, 66 insertions(+), 45 deletions(-) diff --git a/client/src/pages/CommunityPostManagement.tsx b/client/src/pages/CommunityPostManagement.tsx index 0e87720..73e2f44 100644 --- a/client/src/pages/CommunityPostManagement.tsx +++ b/client/src/pages/CommunityPostManagement.tsx @@ -123,10 +123,19 @@ export default function CommunityPostManagement() { } }; + // Function to safely render item values + const renderCellValue = (item: any, columnKey: any) => { + const value = getKeyValue(item, columnKey); + if (typeof value === "object" && value !== null) { + return JSON.stringify(value); // Convert object to string + } + return value; + }; + return (
{mergedList.length > 0 && ( -
+

Community Post

@@ -137,51 +146,63 @@ export default function CommunityPostManagement() { {(item) => ( - {(columnKey) => ( - - {columnKey === "profilePicture" ? ( - item.profilePicture ? ( - + {(columnKey) => { + const value = renderCellValue(item, columnKey); + + return ( + + {columnKey === "profilePicture" ? ( + item.profilePicture ? ( + + ) : ( + "No Image" + ) + ) : columnKey === "postImage" ? ( + value ? ( + + ) : ( + "No Image" + ) + ) : columnKey === "actions" ? ( +
+ + + + + + +
) : ( - "No Image" - ) - ) : columnKey === "actions" ? ( -
- - - - - - -
- ) : ( -

- {getKeyValue(item, columnKey)} -

- )} -
- )} +

+ {value} +

+ )} + +
+ ); + }}
)}