updated share page ui and table types
This commit is contained in:
@ -16,37 +16,33 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { generateShareToken } from "@/app/(sharing)/[token]/token";
|
||||
export type Song = {
|
||||
title: string;
|
||||
artist: string;
|
||||
score?: number | null;
|
||||
userPlayDate: string | null;
|
||||
isFullCombo: boolean | null;
|
||||
isAllJustice: boolean | null;
|
||||
id: number;
|
||||
};
|
||||
|
||||
export const columns: ColumnDef<Song>[] = [
|
||||
import { chuni_score_playlog } from "@/prisma/schemas/artemis/generated/artemis";
|
||||
import { chuni_static_music } from "@/prisma/schemas/artemis/generated/artemis";
|
||||
|
||||
export const columns: ColumnDef<chuni_score_playlog & chuni_static_music>[] = [
|
||||
{
|
||||
accessorKey: "title",
|
||||
header: "Title",
|
||||
cell: ({ row }) => (
|
||||
<div>
|
||||
<div className="font-medium ">
|
||||
<div className="font-medium">
|
||||
{row.original.title}
|
||||
<span className="space-x-2 pl-2">
|
||||
{row.original.isFullCombo && (
|
||||
<Badge className="rounded-sm">Full Combo</Badge>
|
||||
)}
|
||||
{row.original.isAllJustice && (
|
||||
<Badge className="rounded-sm bg-yellow-500 text-black">
|
||||
<Badge className="rounded-sm bg-yellow-500 text-black">
|
||||
All Justice
|
||||
</Badge>
|
||||
)}
|
||||
{row.original.isNewRecord && (
|
||||
<Badge className="rounded-sm bg-pink-400 text-white">New!!</Badge>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="text-sm text-muted-foreground truncate inline-block w-[200px] ">
|
||||
<div className="text-sm text-muted-foreground truncate inline-block w-[200px]">
|
||||
{row.original.artist}
|
||||
</div>
|
||||
</div>
|
||||
@ -68,14 +64,13 @@ export const columns: ColumnDef<Song>[] = [
|
||||
const song = row.original;
|
||||
const [error, setError] = useState<string>("");
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
|
||||
const handleGenerateShareToken = async () => {
|
||||
const { token, error } = await generateShareToken(row.original.id);
|
||||
if (error) {
|
||||
setError(error);
|
||||
} else {
|
||||
const newTab = window.open(`/${token}/${row.original.id}`, '_blank');
|
||||
const newTab = window.open(`/${token}/${row.original.id}`, "_blank");
|
||||
if (newTab) {
|
||||
newTab.focus();
|
||||
} else {
|
||||
@ -96,7 +91,9 @@ export const columns: ColumnDef<Song>[] = [
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuLabel>Actions</DropdownMenuLabel>
|
||||
<DropdownMenuItem
|
||||
onClick={() => navigator.clipboard.writeText(song.title)}
|
||||
onClick={() =>
|
||||
song.title && navigator.clipboard.writeText(song.title)
|
||||
}
|
||||
>
|
||||
Copy song title
|
||||
</DropdownMenuItem>
|
||||
|
Reference in New Issue
Block a user