daphnis/components/scoreplaylog/page.tsx

30 lines
712 B
TypeScript
Raw Normal View History

2024-06-29 05:22:22 +00:00
import { DataTable } from "./data-table";
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-07-23 20:15:27 +00:00
import { getSongsWithTitles } from "@/app/(sharing)/[token]/[id]/actions";
2024-06-29 05:22:22 +00:00
2024-06-29 19:25:43 +00:00
const userSchema = z.object({
2024-07-01 18:45:16 +00:00
UserId: z.number(),
2024-06-29 19:25:43 +00:00
});
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-07-01 18:45:16 +00:00
return <DataTable columns={columns} data={songs} />;
2024-06-29 05:22:22 +00:00
};
2024-06-29 19:25:43 +00:00
export default ChunithmScorePlaylog;