diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..55712c1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} \ No newline at end of file diff --git a/app/(authenticated)/chunithm/page.tsx b/app/(authenticated)/chunithm/page.tsx index a398590..46d00a8 100644 --- a/app/(authenticated)/chunithm/page.tsx +++ b/app/(authenticated)/chunithm/page.tsx @@ -1,11 +1,9 @@ -import ChunithmData from "@/components/scoreplaylog/page"; -import React from "react"; +import ChunithmScorePlaylog from "@/components/scoreplaylog/page"; -const ChunithmPage = async () => { +const ChunithmPage = () => { return ( -
- -
+ + ); }; diff --git a/auth/components/signup/signup.tsx b/auth/components/signup/signup.tsx index 45768dc..43c2514 100644 --- a/auth/components/signup/signup.tsx +++ b/auth/components/signup/signup.tsx @@ -11,13 +11,11 @@ import { CardTitle, } from "@/components/ui/card"; import { Label } from "@/components/ui/label"; -import { toast, useToast } from "@/components/ui/use-toast"; +import { toast } from "@/components/ui/use-toast"; import { signUp } from "./action"; -import { useState } from "react"; export default function SignUpForm() { - const [error, setError] = useState(""); const submit = async (data: FormData) => { const { error } = await signUp(data); diff --git a/bun.lockb b/bun.lockb index 5d77caf..e99746a 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/scoreplaylog/colums.tsx b/components/scoreplaylog/colums.tsx index ab1f0ef..1b30b6a 100644 --- a/components/scoreplaylog/colums.tsx +++ b/components/scoreplaylog/colums.tsx @@ -68,13 +68,20 @@ export const columns: ColumnDef[] = [ const song = row.original; const [error, setError] = useState(""); const router = useRouter(); - + + const handleGenerateShareToken = async () => { const { token, error } = await generateShareToken(row.original.id); if (error) { setError(error); } else { - router.push(`/${token}/${row.original.id}`); + const newTab = window.open(`/${token}/${row.original.id}`, '_blank'); + if (newTab) { + newTab.focus(); + } else { + // Handle popup blocker or inability to open new tab + router.push(`/${token}/${row.original.id}`); + } } }; @@ -95,7 +102,7 @@ export const columns: ColumnDef[] = [ - View details + Share Song diff --git a/components/scoreplaylog/page.tsx b/components/scoreplaylog/page.tsx index 0ce63a2..3f52c5e 100644 --- a/components/scoreplaylog/page.tsx +++ b/components/scoreplaylog/page.tsx @@ -1,20 +1,28 @@ import { DataTable } from "./data-table"; import { getSongsWithTitles } from "@/lib/api"; -import { Song, columns } from "./colums"; -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { getAuth } from "@/auth/queries/getauth"; +import { z } from "zod"; +import { columns } from "./colums"; -const ChunithmData = async () => { +const userSchema = z.object({ + UserId: z.number() +}); + +const ChunithmScorePlaylog = async () => { const { user } = await getAuth(); - let songs: Song[] = []; - if (user?.UserId !== undefined) { - songs = await getSongsWithTitles(user.UserId); - } else { - return { - error: "no user id ", - }; + const TypedUser = userSchema.safeParse(user); + + if (!TypedUser.success) { + return ( +
+

Failed to load user data

+
+ ); } + + const songs = await getSongsWithTitles(TypedUser.data.UserId); + return (
@@ -22,4 +30,4 @@ const ChunithmData = async () => { ); }; -export default ChunithmData; +export default ChunithmScorePlaylog; diff --git a/package.json b/package.json index 8fd6284..bb8dd73 100644 --- a/package.json +++ b/package.json @@ -85,13 +85,12 @@ "zustand": "^4.5.2" }, "devDependencies": { - "typescript": "^5.5.2", "@types/node": "^20.14.8", - "@types/react": "^18", "@types/react-dom": "^18", + "eslint": "^8", + "eslint-config-next": "14.2.4", "postcss": "^8", "tailwindcss": "^3.4.1", - "eslint": "^8", - "eslint-config-next": "14.2.4" + "typescript": "^5.5.2" } }