daphnis/app/(sharing)/[token]/[id]/page.tsx
2024-06-29 01:22:22 -04:00

39 lines
886 B
TypeScript

import { SharingPlaylogId, getSongsWithTitles } from "@/lib/api";
import { shareScore } from "../token";
export default async function Share({
params,
}: {
params: { token: string; id: string };
}) {
const { token, id } = params;
// Verify the token
const tokenResult = await shareScore(token);
if (tokenResult.error) {
// Handle error appropriately, e.g., render an error message
return <p>{tokenResult.error}</p>;
}
const userId = 10000;
const playlogId = parseInt(id);
const songsData = await getSongsWithTitles(userId);
const playlogIds = await SharingPlaylogId(playlogId);
const matchingSongs = songsData.filter((song) =>
playlogIds.includes(song.id)
);
const songTitles = matchingSongs.map((song) => song.title);
return (
<ul>
{songTitles.map((title) => (
<li key={title}>{title}</li>
))}
</ul>
);
}