removed song sharing expiration countdown
This commit is contained in:
@ -39,77 +39,74 @@ export default async function Share({
|
|||||||
|
|
||||||
// Filter songsData to match the playlogIds
|
// Filter songsData to match the playlogIds
|
||||||
const chunithm: chunithm[] = songsData.filter((song) =>
|
const chunithm: chunithm[] = songsData.filter((song) =>
|
||||||
playlogIds.includes(song.id)
|
playlogIds.includes(song.id),
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center space-y-4 p-4 dark:text-black">
|
<div className="flex flex-col items-center justify-center space-y-4 p-4 dark:text-black">
|
||||||
<div className="w-full p-4 bg-white dark:text-black rounded-sm">
|
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
|
||||||
{chunithm.map((song) => (
|
{chunithm.map((song) => (
|
||||||
<div key={song.id} className="w-full">
|
<div key={song.id} className="w-full">
|
||||||
<span className="text-black text-center font-bold text-xl pr-2">
|
<span className="text-center text-xl font-bold text-black">
|
||||||
{song.isNewRecord && "NEW RECORD!!"}
|
|
||||||
</span>
|
|
||||||
<span className="text-black text-center font-bold text-xl">
|
|
||||||
Song: {song.title}
|
Song: {song.title}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full p-4 bg-white dark:text-black rounded-sm">
|
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
|
||||||
{chunithm.map((song) => (
|
{chunithm.map((song) => (
|
||||||
<div key={song.id} className="w-full">
|
<div key={song.id} className="w-full">
|
||||||
<span className="text-black text-center font-bold text-xl">
|
<span className="text-center text-xl font-bold text-black">
|
||||||
Artist: {song.artist}
|
Artist: {song.artist}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full p-4 bg-white dark:text-black rounded-sm">
|
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
|
||||||
{chunithm.map((song) => (
|
{chunithm.map((song) => (
|
||||||
<div key={song.id} className="w-full">
|
<div key={song.id} className="w-full">
|
||||||
<span className="text-black text-center font-bold text-xl">
|
<span className="text-center text-xl font-bold text-black">
|
||||||
Score: {song.score?.toLocaleString()}
|
Score: {song.score?.toLocaleString()}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full p-4 bg-white dark:text-black rounded-sm">
|
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
|
||||||
{chunithm.map((song) => (
|
{chunithm.map((song) => (
|
||||||
<div key={song.id} className="w-full">
|
<div key={song.id} className="w-full">
|
||||||
<span className="text-black text-center font-bold text-xl">
|
<span className="text-center text-xl font-bold text-black">
|
||||||
Rank: {getGrade(song.score ?? 0)}
|
Rank: {getGrade(song.score ?? 0)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full p-4 bg-white dark:text-black rounded-sm">
|
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
|
||||||
{chunithm.map((song) => (
|
{chunithm.map((song) => (
|
||||||
<div key={song.id} className="w-full">
|
<div key={song.id} className="w-full">
|
||||||
<span className="text-black text-center font-bold text-xl">
|
<span className="pr-2 text-center text-xl font-bold text-black">
|
||||||
{song.isFullCombo && "FULL COMBO"}
|
{song.isFullCombo && "FULL COMBO!"}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-black text-center font-bold text-xl">
|
<span className="text-center text-xl font-bold text-black">
|
||||||
Max combo: {song.maxCombo}
|
Max combo: {song.maxCombo}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full p-4 bg-white dark:text-black rounded-sm">
|
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
|
||||||
{chunithm.map((song) => (
|
{chunithm.map((song) => (
|
||||||
<div key={song.id} className="w-full">
|
<div key={song.id} className="w-full">
|
||||||
<div className="flex flex-col items-center justify-center">
|
<div className="flex flex-col items-center justify-center">
|
||||||
<span className="text-white rounded-md shadow-[inset_0px_3px_6px_0px_#1a202c] bg-[#58329F] w-full text-center p-2 font-bold text-md">
|
<span className="text-md w-full rounded-md bg-[#58329F] p-2 text-center font-bold text-white shadow-[inset_0px_3px_6px_0px_#1a202c]">
|
||||||
Judge Justice: {song.judgeJustice}
|
Judge Justice: {song.judgeJustice}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-white rounded-md shadow-[inset_0px_3px_6px_0px_#1a202c] bg-[#58329F] w-full text-center p-2 font-bold text-md m-5">
|
<span className="text-md m-5 w-full rounded-md bg-[#58329F] p-2 text-center font-bold text-white shadow-[inset_0px_3px_6px_0px_#1a202c]">
|
||||||
Judge Attack: {song.judgeAttack}
|
Judge Attack: {song.judgeAttack}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-white rounded-md shadow-[inset_0px_3px_6px_0px_#1a202c] bg-[#58329F] w-full text-center p-2 font-bold text-md">
|
<span className="text-md w-full rounded-md bg-[#58329F] p-2 text-center font-bold text-white shadow-[inset_0px_3px_6px_0px_#1a202c]">
|
||||||
Miss: {song.judgeGuilty}
|
Miss: {song.judgeGuilty}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,8 +8,8 @@ import { redirect } from "next/navigation";
|
|||||||
|
|
||||||
export async function generateShareToken(id: number): Promise<{
|
export async function generateShareToken(id: number): Promise<{
|
||||||
token?: string;
|
token?: string;
|
||||||
id?: string;
|
id?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
}> {
|
}> {
|
||||||
const { user } = await getAuth();
|
const { user } = await getAuth();
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ export async function generateShareToken(id: number): Promise<{
|
|||||||
// generate token logic
|
// generate token logic
|
||||||
const token = await daphnis.linkSharingToken.create({
|
const token = await daphnis.linkSharingToken.create({
|
||||||
data: {
|
data: {
|
||||||
playlogId: id, // sets the playlog id
|
playlogId: id, // sets the playlog id
|
||||||
id: randomUUID(), // generates a random primary id for the share token
|
id: randomUUID(), // generates a random primary id for the share token
|
||||||
userId: user.id, // attaches the userid from daphnis
|
userId: user.id, // attaches the userid from daphnis
|
||||||
token: gernatetoken, // makes an expirable token thats added to the token column
|
token: gernatetoken, // makes an expirable token thats added to the token column
|
||||||
createdAt: new Date(), // created at date
|
createdAt: new Date(), // created at date
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -49,21 +49,21 @@ export async function shareScore(token: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if token has expired
|
// Check if token has expired
|
||||||
const tokenAge =
|
// const tokenAge =
|
||||||
new Date().getTime() - new Date(PublicPage.createdAt).getTime();
|
// new Date().getTime() - new Date(PublicPage.createdAt).getTime();
|
||||||
const tokenAgeLimit = 1000 * 60 * 60 * 24; // 1 day in milliseconds
|
// const tokenAgeLimit = 1000 * 60 * 60 * 24; // 1 day in milliseconds
|
||||||
|
|
||||||
if (tokenAge > tokenAgeLimit) {
|
// if (tokenAge > tokenAgeLimit) {
|
||||||
await daphnis.linkSharingToken.update({
|
// await daphnis.linkSharingToken.update({
|
||||||
where: {
|
// where: {
|
||||||
token,
|
// token,
|
||||||
},
|
// },
|
||||||
data: {
|
// data: {
|
||||||
tokenExpiredAt: new Date(),
|
// tokenExpiredAt: new Date(),
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
redirect("/");
|
// redirect("/");
|
||||||
}
|
// }
|
||||||
|
|
||||||
return { success: true };
|
return { success: true };
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,14 @@ export const columns: ColumnDef<chunithm>[] = [
|
|||||||
const jacketPath = row.original.jacketPath?.replace(".dds", ".png");
|
const jacketPath = row.original.jacketPath?.replace(".dds", ".png");
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
return (
|
return (
|
||||||
<div className="font-medium w-[300px] truncate flex items-center">
|
<div className="flex w-[300px] items-center truncate font-medium">
|
||||||
{!jacketPath ? (
|
{!jacketPath ? (
|
||||||
<Skeleton className="w-8 h-8 inline-block mr-2" />
|
<Skeleton className="mr-2 inline-block h-8 w-8" />
|
||||||
) : (
|
) : (
|
||||||
<img
|
<img
|
||||||
src={`/jacketArt/${jacketPath}`}
|
src={`/jacketArt/${jacketPath}`}
|
||||||
alt="Jacket"
|
alt="Jacket"
|
||||||
className="w-8 h-8 inline-block mr-2"
|
className="mr-2 inline-block h-8 w-8"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<span className="truncate">{row.original.title}</span>
|
<span className="truncate">{row.original.title}</span>
|
||||||
@ -149,10 +149,8 @@ export const columns: ColumnDef<chunithm>[] = [
|
|||||||
|
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: "actions",
|
||||||
header: () => <div className="text-left pl-2">More</div>,
|
header: () => <div className="pl-2 text-left">More</div>,
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const song = row.original;
|
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
||||||
const [error, setError] = useState<string>("");
|
const [error, setError] = useState<string>("");
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
Reference in New Issue
Block a user