Skip to content

Commit

Permalink
remove empty attributes and captialize values
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed May 16, 2024
1 parent 5d852cf commit 00a7aab
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ const formatValue = (value: unknown, key?: string): ReactNode => {
return value.toLocaleString();
}

if (Object.entries(value).length === 0) {
const entries = Object.entries(value).filter(
([_, value]) => value != null && value !== "",
);

if (entries.length === 0) {
return `No ${key?.replaceAll(/_/g, " ")}`;
}

return Object.entries(value).map(([key, value]) => (
return entries.map(([key, value]) => (
<div className="flex flex-col items-center gap-2 md:flex-row">
<span className="text-xs uppercase text-gray-700">
{key.replaceAll(/_/g, " ")}
</span>
<span className="text-sm font-semibold text-gray-700">
<span className="text-sm font-semibold capitalize text-gray-700">
{formatValue(value, key)}
</span>
</div>
Expand Down

0 comments on commit 00a7aab

Please sign in to comment.