Skip to content

Commit

Permalink
feat: handle parsing of pros and cons in array
Browse files Browse the repository at this point in the history
  • Loading branch information
ThianHooi committed Jul 27, 2024
1 parent fa79dc3 commit e1e5ea3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 11 additions & 2 deletions app/modules/dashboard/DataDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ const Title = ({ children }: { children: React.ReactNode }) => (
);

export function DataSheet({ open, onOpenChange, video }: Props) {
const parseProsCons = (prosCons: string | string[] | undefined) => {
if (!prosCons) return null;

if (Array.isArray(prosCons)) {
return prosCons.map((proCon, index) => <li key={index}>{proCon}</li>);
}
return <Markdown>{prosCons}</Markdown>;
};

return (
<Sheet open={open} onOpenChange={onOpenChange}>
<SheetContent className="overflow-y-scroll min-w-[50vw]">
Expand All @@ -44,11 +53,11 @@ export function DataSheet({ open, onOpenChange, video }: Props) {

<div>
<Title>Pros</Title>
<Markdown>{video?.summary?.pros}</Markdown>
{parseProsCons(video?.summary?.pros)}
</div>
<div>
<Title>Cons</Title>
<Markdown>{video?.summary?.cons}</Markdown>
{parseProsCons(video?.summary?.cons)}
</div>

<div>
Expand Down
5 changes: 2 additions & 3 deletions app/modules/dashboard/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import GoogleMapAnchor from './GoogleMapAnchor';

type Summary = {
introduction?: Introduction;
pros?: string;
cons?: string;
pros?: string | string[];
cons?: string | string[];
summary?: string;
};

Expand Down Expand Up @@ -50,7 +50,6 @@ export const columns: ColumnDef<Video>[] = [
header: 'Location',
},
{
accessorKey: 'location',
header: 'Google Maps',
cell: ({ row }) => (
<GoogleMapAnchor
Expand Down

0 comments on commit e1e5ea3

Please sign in to comment.