removed song sharing expiration countdown

This commit is contained in:
Polaris 2024-07-28 01:24:54 -04:00
parent d01a88a645
commit aabbef26bf
3 changed files with 42 additions and 47 deletions

View File

@ -39,77 +39,74 @@ export default async function Share({
// Filter songsData to match the playlogIds
const chunithm: chunithm[] = songsData.filter((song) =>
playlogIds.includes(song.id)
playlogIds.includes(song.id),
);
return (
<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="flex flex-col items-center justify-center space-y-4 p-4 dark:text-black">
<div className="w-full rounded-sm bg-white p-4 dark:text-black">
{chunithm.map((song) => (
<div key={song.id} className="w-full">
<span className="text-black text-center font-bold text-xl pr-2">
{song.isNewRecord && "NEW RECORD!!"}
</span>
<span className="text-black text-center font-bold text-xl">
<span className="text-center text-xl font-bold text-black">
Song: {song.title}
</span>
</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) => (
<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}
</span>
</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) => (
<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()}
</span>
</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) => (
<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)}
</span>
</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) => (
<div key={song.id} className="w-full">
<span className="text-black text-center font-bold text-xl">
{song.isFullCombo && "FULL COMBO"}
<span className="pr-2 text-center text-xl font-bold text-black">
{song.isFullCombo && "FULL COMBO!"}
</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}
</span>
</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) => (
<div key={song.id} className="w-full">
<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}
</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}
</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}
</span>
</div>

View File

@ -8,8 +8,8 @@ import { redirect } from "next/navigation";
export async function generateShareToken(id: number): Promise<{
token?: string;
id?: string;
error?: string;
id?: string;
error?: string;
}> {
const { user } = await getAuth();
@ -24,10 +24,10 @@ export async function generateShareToken(id: number): Promise<{
// generate token logic
const token = await daphnis.linkSharingToken.create({
data: {
playlogId: id, // sets the playlog id
id: randomUUID(), // generates a random primary id for the share token
userId: user.id, // attaches the userid from daphnis
token: gernatetoken, // makes an expirable token thats added to the token column
playlogId: id, // sets the playlog id
id: randomUUID(), // generates a random primary id for the share token
userId: user.id, // attaches the userid from daphnis
token: gernatetoken, // makes an expirable token thats added to the token column
createdAt: new Date(), // created at date
},
});
@ -49,21 +49,21 @@ export async function shareScore(token: string) {
}
// Check if token has expired
const tokenAge =
new Date().getTime() - new Date(PublicPage.createdAt).getTime();
const tokenAgeLimit = 1000 * 60 * 60 * 24; // 1 day in milliseconds
// const tokenAge =
// new Date().getTime() - new Date(PublicPage.createdAt).getTime();
// const tokenAgeLimit = 1000 * 60 * 60 * 24; // 1 day in milliseconds
if (tokenAge > tokenAgeLimit) {
await daphnis.linkSharingToken.update({
where: {
token,
},
data: {
tokenExpiredAt: new Date(),
},
});
redirect("/");
}
// if (tokenAge > tokenAgeLimit) {
// await daphnis.linkSharingToken.update({
// where: {
// token,
// },
// data: {
// tokenExpiredAt: new Date(),
// },
// });
// redirect("/");
// }
return { success: true };
}

View File

@ -33,14 +33,14 @@ export const columns: ColumnDef<chunithm>[] = [
const jacketPath = row.original.jacketPath?.replace(".dds", ".png");
const [isLoading, setIsLoading] = useState(true);
return (
<div className="font-medium w-[300px] truncate flex items-center">
<div className="flex w-[300px] items-center truncate font-medium">
{!jacketPath ? (
<Skeleton className="w-8 h-8 inline-block mr-2" />
<Skeleton className="mr-2 inline-block h-8 w-8" />
) : (
<img
src={`/jacketArt/${jacketPath}`}
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>
@ -149,10 +149,8 @@ export const columns: ColumnDef<chunithm>[] = [
{
id: "actions",
header: () => <div className="text-left pl-2">More</div>,
header: () => <div className="pl-2 text-left">More</div>,
cell: ({ row }) => {
const song = row.original;
// eslint-disable-next-line react-hooks/rules-of-hooks
const [error, setError] = useState<string>("");
// eslint-disable-next-line react-hooks/rules-of-hooks
const router = useRouter();