fp/services/next/app/components/patrons-list.tsx

53 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-01-20 16:16:14 +00:00
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
import 'react-loading-skeleton/dist/skeleton.css';
import { getPatrons } from '../lib/patreon';
import Link from 'next/link'
2024-12-12 07:23:46 +00:00
2024-01-20 16:16:14 +00:00
interface PatronsListProps {
displayStyle: string;
}
export default async function PatronsList({ displayStyle }: PatronsListProps) {
const patrons = await getPatrons()
2024-12-12 07:23:46 +00:00
console.log('patrons list as follows')
console.log(patrons)
2024-07-04 21:20:29 +00:00
2024-08-13 21:18:01 +00:00
if (!patrons || patrons.length === 0) return (
2024-01-20 16:16:14 +00:00
<SkeletonTheme baseColor="#000" highlightColor="#000">
2024-12-12 07:23:46 +00:00
<Skeleton count={3} enableAnimation={false} width={'18em'} />
2024-01-20 16:16:14 +00:00
</SkeletonTheme>
);
2024-07-04 21:20:29 +00:00
2024-01-20 16:16:14 +00:00
if (displayStyle === 'box') {
return (
<div className="columns is-multiline">
{patrons.map((patron) => (
2024-12-12 07:23:46 +00:00
<div key={patron.id} className="column is-full-mobile is-half-tablet is-one-third-desktop">
2024-01-20 16:16:14 +00:00
<div className="box">
<article className="media">
<div className="media-content">
<div className="content">
2024-12-12 07:23:46 +00:00
{patron.full_name && (
2024-01-20 16:16:14 +00:00
<span>
2024-12-12 07:23:46 +00:00
<b>{patron.full_name}</b>
2024-01-20 16:16:14 +00:00
</span>
)}
</div>
</div>
</article>
</div>
</div>
))}
</div>
);
} else if (displayStyle === 'list') {
2024-12-12 07:23:46 +00:00
const patronNames = patrons.map((patron) => patron.full_name.trim()).join(', ');
2024-01-20 16:16:14 +00:00
return <span>{patronNames}</span>;
} else {
return <span></span>; // Handle unsupported display styles or provide a default display style
}
}