From de91f75203a61e2e7a4ef5c9bdd64c85f9fb65d8 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sun, 6 Nov 2022 01:25:53 -0800 Subject: [PATCH] Fix card keys --- .../virtual-grid/grid-card/default-card.tsx | 206 +++++++++--------- .../virtual-grid/grid-card/poster-card.tsx | 102 +++++---- 2 files changed, 163 insertions(+), 145 deletions(-) diff --git a/src/renderer/components/virtual-grid/grid-card/default-card.tsx b/src/renderer/components/virtual-grid/grid-card/default-card.tsx index 45ed8b0e0..109e1d7fd 100644 --- a/src/renderer/components/virtual-grid/grid-card/default-card.tsx +++ b/src/renderer/components/virtual-grid/grid-card/default-card.tsx @@ -1,9 +1,10 @@ -import styled from '@emotion/styled'; +import React from 'react'; import { Center, Skeleton } from '@mantine/core'; import { RiAlbumFill } from 'react-icons/ri'; import { generatePath, useNavigate } from 'react-router'; import { Link } from 'react-router-dom'; import { ListChildComponentProps } from 'react-window'; +import styled from 'styled-components'; import { Text } from '@/renderer/components/text'; import { GridCardControls } from '@/renderer/components/virtual-grid/grid-card/grid-card-controls'; import { fadeIn } from '@/renderer/styles'; @@ -211,53 +212,59 @@ export const DefaultCard = ({ {cardRows.map((row: CardRow, index: number) => { - if (row.arrayProperty) { - if (row.route) { - return ( - 0}> - {data[row.property].map( - (item: any, itemIndex: number) => ( - <> - {itemIndex > 0 && ( - - , - - )}{' '} - 0} - to={generatePath( - row.route!.route, - row.route!.slugs?.reduce((acc, slug) => { - return { - ...acc, - [slug.slugProperty]: - data[slug.idProperty], - }; - }, {}) - )} - onClick={(e) => e.stopPropagation()} - > - {row.arrayProperty && item[row.arrayProperty]} - - - ) - )} - - ); - } - + if (row.arrayProperty && row.route) { return ( - + 0} + > + {data[row.property].map( + (item: any, itemIndex: number) => ( + + {itemIndex > 0 && ( + + , + + )}{' '} + 0} + component={Link} + overflow="hidden" + to={generatePath( + row.route!.route, + row.route!.slugs?.reduce((acc, slug) => { + return { + ...acc, + [slug.slugProperty]: data[slug.idProperty], + }; + }, {}) + )} + onClick={(e) => e.stopPropagation()} + > + {row.arrayProperty && item[row.arrayProperty]} + + + ) + )} + + ); + } + + if (row.arrayProperty) { + return ( + {data[row.property].map((item: any) => ( - 0}> + 0} + overflow="hidden" + > {row.arrayProperty && item[row.arrayProperty]} ))} @@ -266,10 +273,10 @@ export const DefaultCard = ({ } return ( - + {row.route ? ( ) : ( - 0}> + 0} overflow="hidden"> {data && data[row.property]} )} @@ -334,52 +341,57 @@ export const DefaultCard = ({ {cardRows.map((row: CardRow, index: number) => { - if (row.arrayProperty) { - if (row.route) { - return ( - 0}> - {data[row.property].map( - (item: any, itemIndex: number) => ( - <> - {itemIndex > 0 && ( - - , - - )}{' '} - 0} - to={generatePath( - row.route!.route, - row.route!.slugs?.reduce((acc, slug) => { - return { - ...acc, - [slug.slugProperty]: data[slug.idProperty], - }; - }, {}) - )} - onClick={(e) => e.stopPropagation()} - > - {row.arrayProperty && item[row.arrayProperty]} - - - ) - )} - - ); - } - + if (row.arrayProperty && row.route) { return ( - + 0} + > + {data[row.property].map((item: any, itemIndex: number) => ( + + {itemIndex > 0 && ( + + , + + )}{' '} + 0} + component={Link} + overflow="hidden" + to={generatePath( + row.route!.route, + row.route!.slugs?.reduce((acc, slug) => { + return { + ...acc, + [slug.slugProperty]: data[slug.idProperty], + }; + }, {}) + )} + onClick={(e) => e.stopPropagation()} + > + {row.arrayProperty && item[row.arrayProperty]} + + + ))} + + ); + } + + if (row.arrayProperty) { + return ( + {data[row.property].map((item: any) => ( - 0}> + 0} + overflow="hidden" + > {row.arrayProperty && item[row.arrayProperty]} ))} @@ -388,10 +400,10 @@ export const DefaultCard = ({ } return ( - + {row.route ? ( ) : ( - 0}> + 0} overflow="hidden"> {data && data[row.property]} )} @@ -435,7 +447,7 @@ export const DefaultCard = ({ {cardRows.map((row: CardRow, index: number) => ( {cardRows.map((row: CardRow, index: number) => { - if (row.arrayProperty) { - if (row.route) { - return ( - 0}> - {data[row.property].map( - (item: any, itemIndex: number) => ( - <> - {itemIndex > 0 && ( - - , - - )}{' '} - 0} - to={generatePath( - row.route!.route, - row.route!.slugs?.reduce((acc, slug) => { - return { - ...acc, - [slug.slugProperty]: data[slug.idProperty], - }; - }, {}) - )} - > - {row.arrayProperty && item[row.arrayProperty]} - - - ) - )} - - ); - } - + if (row.arrayProperty && row.route) { return ( - + 0} + > + {data[row.property].map((item: any, itemIndex: number) => ( + + {itemIndex > 0 && ( + + , + + )}{' '} + 0} + component={Link} + overflow="hidden" + to={generatePath( + row.route!.route, + row.route!.slugs?.reduce((acc, slug) => { + return { + ...acc, + [slug.slugProperty]: data[slug.idProperty], + }; + }, {}) + )} + > + {row.arrayProperty && item[row.arrayProperty]} + + + ))} + + ); + } + + if (row.arrayProperty) { + return ( + {data[row.property].map((item: any) => ( - 0}> + 0} + overflow="hidden" + > {row.arrayProperty && item[row.arrayProperty]} ))} @@ -283,10 +289,10 @@ export const PosterCard = ({ } return ( - + {row.route ? ( ) : ( - 0}> + 0} overflow="hidden"> {data && data[row.property]} )} @@ -329,7 +335,7 @@ export const PosterCard = ({ {cardRows.map((row: CardRow, index: number) => (