2022-12-19 15:59:14 -08:00
|
|
|
import React from 'react';
|
|
|
|
|
import type { ICellRendererParams } from '@ag-grid-community/core';
|
|
|
|
|
import { generatePath } from 'react-router';
|
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
import type { AlbumArtist, Artist } from '/@/renderer/api/types';
|
|
|
|
|
import { Text } from '/@/renderer/components/text';
|
|
|
|
|
import { CellContainer } from '/@/renderer/components/virtual-table/cells/generic-cell';
|
|
|
|
|
import { AppRoute } from '/@/renderer/router/routes';
|
2022-12-20 04:25:51 -08:00
|
|
|
import { Skeleton } from '/@/renderer/components/skeleton';
|
2022-12-19 15:59:14 -08:00
|
|
|
|
|
|
|
|
export const AlbumArtistCell = ({ value, data }: ICellRendererParams) => {
|
2022-12-24 18:12:49 -08:00
|
|
|
if (value === undefined) {
|
2022-12-20 04:25:51 -08:00
|
|
|
return (
|
|
|
|
|
<CellContainer position="left">
|
|
|
|
|
<Skeleton
|
|
|
|
|
height="1rem"
|
|
|
|
|
width="80%"
|
|
|
|
|
/>
|
|
|
|
|
</CellContainer>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-19 15:59:14 -08:00
|
|
|
return (
|
|
|
|
|
<CellContainer position="left">
|
|
|
|
|
<Text
|
|
|
|
|
$secondary
|
|
|
|
|
overflow="hidden"
|
2023-01-30 01:05:02 -08:00
|
|
|
size="md"
|
2022-12-19 15:59:14 -08:00
|
|
|
>
|
|
|
|
|
{value?.map((item: Artist | AlbumArtist, index: number) => (
|
|
|
|
|
<React.Fragment key={`row-${item.id}-${data.uniqueId}`}>
|
|
|
|
|
{index > 0 && (
|
|
|
|
|
<Text
|
|
|
|
|
$secondary
|
2023-01-30 01:05:02 -08:00
|
|
|
size="md"
|
2022-12-19 15:59:14 -08:00
|
|
|
style={{ display: 'inline-block' }}
|
|
|
|
|
>
|
|
|
|
|
,
|
|
|
|
|
</Text>
|
|
|
|
|
)}{' '}
|
|
|
|
|
<Text
|
|
|
|
|
$link
|
|
|
|
|
$secondary
|
|
|
|
|
component={Link}
|
|
|
|
|
overflow="hidden"
|
2023-01-30 01:05:02 -08:00
|
|
|
size="md"
|
2023-01-12 12:45:44 -08:00
|
|
|
to={generatePath(AppRoute.LIBRARY_ALBUM_ARTISTS_DETAIL, {
|
2022-12-19 15:59:14 -08:00
|
|
|
albumArtistId: item.id,
|
|
|
|
|
})}
|
|
|
|
|
>
|
|
|
|
|
{item.name || '—'}
|
|
|
|
|
</Text>
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
))}
|
|
|
|
|
</Text>
|
|
|
|
|
</CellContainer>
|
|
|
|
|
);
|
|
|
|
|
};
|