From e47c25fac8bd6cf164aa797b669991957242bba8 Mon Sep 17 00:00:00 2001 From: Tiago Yamamoto Date: Fri, 26 Dec 2025 01:02:16 -0300 Subject: [PATCH] fix(companies): format JSON description in modal - Added formatDescription helper to parse JSON and display as formatted list - Shows tagline, stores, employees, motto etc as labeled fields - Falls back to plain text if not JSON --- frontend/src/app/dashboard/companies/page.tsx | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/dashboard/companies/page.tsx b/frontend/src/app/dashboard/companies/page.tsx index a668132..a234107 100644 --- a/frontend/src/app/dashboard/companies/page.tsx +++ b/frontend/src/app/dashboard/companies/page.tsx @@ -28,6 +28,33 @@ const companyDateFormatter = new Intl.DateTimeFormat("en-US", { timeZone: "UTC", }) +// Helper to format description (handles JSON or plain text) +const formatDescription = (description: string | undefined) => { + if (!description) return null + + try { + const parsed = JSON.parse(description) + if (typeof parsed === 'object' && parsed !== null) { + return ( +
+ {Object.entries(parsed).map(([key, value]) => ( +
+
+ {key.replace(/([A-Z])/g, ' $1').replace(/_/g, ' ')} +
+
{String(value)}
+
+ ))} +
+ ) + } + } catch { + // Not JSON, return as plain text + } + + return

{description}

+} + export default function AdminCompaniesPage() { const router = useRouter() const [companies, setCompanies] = useState([]) @@ -418,7 +445,9 @@ export default function AdminCompaniesPage() { {selectedCompany.description && (
-

{selectedCompany.description}

+
+ {formatDescription(selectedCompany.description)} +
)}