2024-06-29 18:43:11 +00:00
|
|
|
import { getAuth } from "@/auth/queries/getauth";
|
2024-06-29 07:02:21 +00:00
|
|
|
import { generatePlaylogId, getSongsWithTitles } from "@/lib/api";
|
2024-06-29 05:22:22 +00:00
|
|
|
import { shareScore } from "../token";
|
2024-06-29 21:49:55 +00:00
|
|
|
import { getDifficultyClass, getDifficultyText } from "@/lib/helpers";
|
2024-06-29 05:22:22 +00:00
|
|
|
|
|
|
|
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) {
|
|
|
|
return <p>{tokenResult.error}</p>;
|
|
|
|
}
|
|
|
|
|
2024-06-29 21:49:55 +00:00
|
|
|
const { user } = await getAuth();
|
2024-06-29 18:43:11 +00:00
|
|
|
|
2024-06-29 21:49:55 +00:00
|
|
|
if (!user?.UserId) {
|
|
|
|
return <p>Error: No user ID found.</p>;
|
2024-06-29 18:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const userId = user?.UserId;
|
2024-06-29 05:22:22 +00:00
|
|
|
const playlogId = parseInt(id);
|
|
|
|
|
|
|
|
const songsData = await getSongsWithTitles(userId);
|
2024-06-29 07:02:21 +00:00
|
|
|
const playlogIds = await generatePlaylogId(playlogId);
|
2024-06-29 05:22:22 +00:00
|
|
|
|
2024-06-29 21:49:55 +00:00
|
|
|
// Filter songsData to match the playlogIds
|
|
|
|
const matchedSongs = songsData.filter((song) => playlogIds.includes(song.id));
|
|
|
|
return (
|
2024-06-30 04:17:28 +00:00
|
|
|
<div className=" h-screen grid w-full gap-4 bg-red-200 grid-cols-8 grid-rows-9 rounded-lg shadow-md">
|
|
|
|
<div className="col-span-2 row-span-2 row-start-2 col-start-2 bg-pink-200 rounded-lg shadow-md flex items-center justify-center">
|
|
|
|
<p>Salmon</p>
|
|
|
|
</div>
|
2024-06-29 05:22:22 +00:00
|
|
|
|
2024-06-30 04:17:28 +00:00
|
|
|
<div className="col-span-4 row-span-4 row-start-2 bg-lime-200 rounded-lg shadow-md flex items-center justify-center">
|
|
|
|
<p>Broccoli</p>
|
|
|
|
</div>
|
2024-06-29 05:22:22 +00:00
|
|
|
|
2024-06-30 04:17:28 +00:00
|
|
|
<div className="col-span-2 col-start-2 row-span-2 bg-yellow-200 rounded-lg shadow-md flex items-center justify-center">
|
|
|
|
<p>Tamago</p>
|
|
|
|
</div>
|
2024-06-29 21:49:55 +00:00
|
|
|
|
2024-06-30 04:17:28 +00:00
|
|
|
<div className="col-span-2 col-start-2 row-span-3 bg-yellow-200 rounded-lg shadow-md flex items-center justify-center">
|
|
|
|
<p>Pork</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="col-span-4 col-start-4 row-span-2 bg-green-200 rounded-lg shadow-md flex items-center justify-center">
|
|
|
|
<p>Edamame</p>
|
|
|
|
</div>
|
2024-06-29 21:49:55 +00:00
|
|
|
</div>
|
2024-06-30 04:17:28 +00:00
|
|
|
// <div className="py-4 px-2 mx-auto max-w-screen-xl sm:py-4 lg:px-6">
|
|
|
|
// <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-5 gap-4 h-full">
|
|
|
|
// {matchedSongs.map((song) => (
|
|
|
|
// <div
|
|
|
|
// key={song.id}
|
|
|
|
// className="bg-slate-500 h-200 w-400 flex justify-center items-center"
|
|
|
|
// >
|
|
|
|
// <div className="text-white text-lg">
|
|
|
|
// <p>{song.title}</p>
|
|
|
|
// <p>Artist: {song.artist}</p>
|
|
|
|
// <p>Genre: {song.genre}</p>
|
|
|
|
// <p>diff: {song.chartlevel}</p>
|
|
|
|
|
|
|
|
// <p>Level: {song.level}</p>
|
|
|
|
|
|
|
|
// <p>Full Combo: {song.isFullCombo ? "Yes" : "No"}</p>
|
|
|
|
// <p>Score: {song.score}</p>
|
|
|
|
|
|
|
|
// <div>
|
|
|
|
// <span
|
|
|
|
// className={`justify-center rounded-sm text-center text-sm font-bold ${getDifficultyClass(
|
|
|
|
// song.chartId
|
|
|
|
// )} text-white`}
|
|
|
|
// >
|
|
|
|
// {getDifficultyText(song.chartId)}
|
|
|
|
// </span>
|
|
|
|
// </div>
|
|
|
|
// </div>
|
|
|
|
// </div>
|
|
|
|
// ))}
|
|
|
|
// </div>
|
2024-06-29 05:22:22 +00:00
|
|
|
);
|
|
|
|
}
|