2024-06-29 05:22:22 +00:00
|
|
|
import { DataTable } from "./data-table";
|
|
|
|
import { getSongsWithTitles } from "@/lib/api";
|
2024-06-29 18:43:11 +00:00
|
|
|
import { getAuth } from "@/auth/queries/getauth";
|
2024-06-29 19:25:43 +00:00
|
|
|
import { z } from "zod";
|
|
|
|
import { columns } from "./colums";
|
2024-06-29 05:22:22 +00:00
|
|
|
|
2024-06-29 19:25:43 +00:00
|
|
|
const userSchema = z.object({
|
|
|
|
UserId: z.number()
|
|
|
|
});
|
|
|
|
|
|
|
|
const ChunithmScorePlaylog = async () => {
|
2024-06-29 18:43:11 +00:00
|
|
|
const { user } = await getAuth();
|
2024-06-29 05:22:22 +00:00
|
|
|
|
2024-06-29 19:25:43 +00:00
|
|
|
const TypedUser = userSchema.safeParse(user);
|
|
|
|
|
|
|
|
if (!TypedUser.success) {
|
|
|
|
return (
|
|
|
|
<div className="p-10">
|
|
|
|
<p>Failed to load user data</p>
|
|
|
|
</div>
|
|
|
|
);
|
2024-06-29 18:43:11 +00:00
|
|
|
}
|
2024-06-29 19:25:43 +00:00
|
|
|
|
|
|
|
const songs = await getSongsWithTitles(TypedUser.data.UserId);
|
|
|
|
|
2024-06-29 05:22:22 +00:00
|
|
|
return (
|
2024-06-29 18:43:11 +00:00
|
|
|
<DataTable columns={columns} data={songs} />
|
2024-06-29 19:26:59 +00:00
|
|
|
|
2024-06-29 05:22:22 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-06-29 19:25:43 +00:00
|
|
|
export default ChunithmScorePlaylog;
|