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
|
||||
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>
|
||||
|
@ -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 };
|
||||
}
|
||||
|
Reference in New Issue
Block a user