made playlog table dynamic

This commit is contained in:
polaris 2024-06-29 14:43:11 -04:00
parent 30825e20f1
commit c784e8808e
14 changed files with 218 additions and 46 deletions

View File

@ -1,12 +1,10 @@
import ChunithmData from "@/components/scoreplaylog/page";
import React from "react";
import ChunithmData from "../../../components/scoreplaylog/page";
const ChunithmPage = async () => {
return (
<div>
<div className=" ">
<ChunithmData />
</div>
</div>
);
};

View File

@ -1,3 +1,4 @@
import { getAuth } from "@/auth/queries/getauth";
import { generatePlaylogId, getSongsWithTitles } from "@/lib/api";
import { shareScore } from "../token";
@ -16,7 +17,17 @@ export default async function Share({
return <p>{tokenResult.error}</p>;
}
const userId = 10000;
const { user } = await getAuth();
if (!user?.UserId) {
return {
error:"no user id"
}
}
const userId = user?.UserId;
const playlogId = parseInt(id);
const songsData = await getSongsWithTitles(userId);

View File

@ -67,9 +67,11 @@ const signUp = async (formData: FormData) => {
const hashedPassword = await new Argon2id().hash(formDataRaw.password);
const userId = generateId(15);
const artemisUserId = existingAccessCode.user;
// Create user in the daphnis database
await daphnis.user.create({
data: {
UserId: artemisUserId,
id: userId,
username: formDataRaw.username,
email: formDataRaw.email,

View File

@ -2,28 +2,22 @@ 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";
const ChunithmData = async () => {
const songs: Song[] = await getSongsWithTitles(10000);
const { user } = await getAuth();
let songs: Song[] = [];
if (user?.UserId !== undefined) {
songs = await getSongsWithTitles(user.UserId);
} else {
return {
error: "no user id ",
};
}
return (
<div className="p-10">
<div className="space-y-1 pb-4">
<Tabs defaultValue="playlog">
<TabsList>
<TabsTrigger value="playlog">Playlog</TabsTrigger>
<TabsTrigger value="gambling">Gamble</TabsTrigger>
<TabsTrigger value="character">Customization</TabsTrigger>
</TabsList>
<TabsContent value="playlog">
<DataTable columns={columns} data={songs} />
</TabsContent>
<TabsContent value="character">
Change your password here.
</TabsContent>
</Tabs>
</div>
<div></div>
<DataTable columns={columns} data={songs} />
</div>
);
};

View File

@ -18,6 +18,7 @@ export const lucia = new Lucia(adapter, {
role: attributes.role,
username: attributes.username,
accessCode: attributes.accessCode,
UserId: attributes.UserId
};
},
});
@ -34,4 +35,5 @@ interface DatabaseUserAttributes {
role: string;
username: string;
accessCode: string;
UserId: number;
}

File diff suppressed because one or more lines are too long

View File

@ -123,6 +123,7 @@ exports.Prisma.UserScalarFieldEnum = {
id: 'id',
username: 'username',
accessCode: 'accessCode',
UserId: 'UserId',
hashedPassword: 'hashedPassword',
email: 'email',
role: 'role'

View File

@ -1191,14 +1191,25 @@ export namespace Prisma {
export type AggregateUser = {
_count: UserCountAggregateOutputType | null
_avg: UserAvgAggregateOutputType | null
_sum: UserSumAggregateOutputType | null
_min: UserMinAggregateOutputType | null
_max: UserMaxAggregateOutputType | null
}
export type UserAvgAggregateOutputType = {
UserId: number | null
}
export type UserSumAggregateOutputType = {
UserId: number | null
}
export type UserMinAggregateOutputType = {
id: string | null
username: string | null
accessCode: string | null
UserId: number | null
hashedPassword: string | null
email: string | null
role: $Enums.UserRole | null
@ -1208,6 +1219,7 @@ export namespace Prisma {
id: string | null
username: string | null
accessCode: string | null
UserId: number | null
hashedPassword: string | null
email: string | null
role: $Enums.UserRole | null
@ -1217,6 +1229,7 @@ export namespace Prisma {
id: number
username: number
accessCode: number
UserId: number
hashedPassword: number
email: number
role: number
@ -1224,10 +1237,19 @@ export namespace Prisma {
}
export type UserAvgAggregateInputType = {
UserId?: true
}
export type UserSumAggregateInputType = {
UserId?: true
}
export type UserMinAggregateInputType = {
id?: true
username?: true
accessCode?: true
UserId?: true
hashedPassword?: true
email?: true
role?: true
@ -1237,6 +1259,7 @@ export namespace Prisma {
id?: true
username?: true
accessCode?: true
UserId?: true
hashedPassword?: true
email?: true
role?: true
@ -1246,6 +1269,7 @@ export namespace Prisma {
id?: true
username?: true
accessCode?: true
UserId?: true
hashedPassword?: true
email?: true
role?: true
@ -1287,6 +1311,18 @@ export namespace Prisma {
* Count returned Users
**/
_count?: true | UserCountAggregateInputType
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs}
*
* Select which fields to average
**/
_avg?: UserAvgAggregateInputType
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs}
*
* Select which fields to sum
**/
_sum?: UserSumAggregateInputType
/**
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs}
*
@ -1320,6 +1356,8 @@ export namespace Prisma {
take?: number
skip?: number
_count?: UserCountAggregateInputType | true
_avg?: UserAvgAggregateInputType
_sum?: UserSumAggregateInputType
_min?: UserMinAggregateInputType
_max?: UserMaxAggregateInputType
}
@ -1328,10 +1366,13 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role: $Enums.UserRole
_count: UserCountAggregateOutputType | null
_avg: UserAvgAggregateOutputType | null
_sum: UserSumAggregateOutputType | null
_min: UserMinAggregateOutputType | null
_max: UserMaxAggregateOutputType | null
}
@ -1354,6 +1395,7 @@ export namespace Prisma {
id?: boolean
username?: boolean
accessCode?: boolean
UserId?: boolean
hashedPassword?: boolean
email?: boolean
role?: boolean
@ -1368,6 +1410,7 @@ export namespace Prisma {
id?: boolean
username?: boolean
accessCode?: boolean
UserId?: boolean
hashedPassword?: boolean
email?: boolean
role?: boolean
@ -1391,6 +1434,7 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role: $Enums.UserRole
@ -1795,6 +1839,7 @@ export namespace Prisma {
readonly id: FieldRef<"User", 'String'>
readonly username: FieldRef<"User", 'String'>
readonly accessCode: FieldRef<"User", 'String'>
readonly UserId: FieldRef<"User", 'Int'>
readonly hashedPassword: FieldRef<"User", 'String'>
readonly email: FieldRef<"User", 'String'>
readonly role: FieldRef<"User", 'UserRole'>
@ -4921,6 +4966,7 @@ export namespace Prisma {
id: 'id',
username: 'username',
accessCode: 'accessCode',
UserId: 'UserId',
hashedPassword: 'hashedPassword',
email: 'email',
role: 'role'
@ -4989,6 +5035,13 @@ export namespace Prisma {
/**
* Reference to a field of type 'Int'
*/
export type IntFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Int'>
/**
* Reference to a field of type 'UserRole'
*/
@ -5003,13 +5056,6 @@ export namespace Prisma {
/**
* Reference to a field of type 'Int'
*/
export type IntFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Int'>
/**
* Reference to a field of type 'Float'
*/
@ -5027,6 +5073,7 @@ export namespace Prisma {
id?: StringFilter<"User"> | string
username?: StringFilter<"User"> | string
accessCode?: StringFilter<"User"> | string
UserId?: IntFilter<"User"> | number
hashedPassword?: StringFilter<"User"> | string
email?: StringFilter<"User"> | string
role?: EnumUserRoleFilter<"User"> | $Enums.UserRole
@ -5039,6 +5086,7 @@ export namespace Prisma {
id?: SortOrder
username?: SortOrder
accessCode?: SortOrder
UserId?: SortOrder
hashedPassword?: SortOrder
email?: SortOrder
role?: SortOrder
@ -5051,6 +5099,7 @@ export namespace Prisma {
id?: string
username?: string
accessCode?: string
UserId?: number
email?: string
AND?: UserWhereInput | UserWhereInput[]
OR?: UserWhereInput[]
@ -5060,18 +5109,21 @@ export namespace Prisma {
sessions?: SessionListRelationFilter
PasswordResetToken?: PasswordResetTokenListRelationFilter
LinkSharingToken?: LinkSharingTokenListRelationFilter
}, "id" | "username" | "accessCode" | "email">
}, "id" | "username" | "accessCode" | "UserId" | "email">
export type UserOrderByWithAggregationInput = {
id?: SortOrder
username?: SortOrder
accessCode?: SortOrder
UserId?: SortOrder
hashedPassword?: SortOrder
email?: SortOrder
role?: SortOrder
_count?: UserCountOrderByAggregateInput
_avg?: UserAvgOrderByAggregateInput
_max?: UserMaxOrderByAggregateInput
_min?: UserMinOrderByAggregateInput
_sum?: UserSumOrderByAggregateInput
}
export type UserScalarWhereWithAggregatesInput = {
@ -5081,6 +5133,7 @@ export namespace Prisma {
id?: StringWithAggregatesFilter<"User"> | string
username?: StringWithAggregatesFilter<"User"> | string
accessCode?: StringWithAggregatesFilter<"User"> | string
UserId?: IntWithAggregatesFilter<"User"> | number
hashedPassword?: StringWithAggregatesFilter<"User"> | string
email?: StringWithAggregatesFilter<"User"> | string
role?: EnumUserRoleWithAggregatesFilter<"User"> | $Enums.UserRole
@ -5252,6 +5305,7 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role?: $Enums.UserRole
@ -5264,6 +5318,7 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role?: $Enums.UserRole
@ -5276,6 +5331,7 @@ export namespace Prisma {
id?: StringFieldUpdateOperationsInput | string
username?: StringFieldUpdateOperationsInput | string
accessCode?: StringFieldUpdateOperationsInput | string
UserId?: IntFieldUpdateOperationsInput | number
hashedPassword?: StringFieldUpdateOperationsInput | string
email?: StringFieldUpdateOperationsInput | string
role?: EnumUserRoleFieldUpdateOperationsInput | $Enums.UserRole
@ -5288,6 +5344,7 @@ export namespace Prisma {
id?: StringFieldUpdateOperationsInput | string
username?: StringFieldUpdateOperationsInput | string
accessCode?: StringFieldUpdateOperationsInput | string
UserId?: IntFieldUpdateOperationsInput | number
hashedPassword?: StringFieldUpdateOperationsInput | string
email?: StringFieldUpdateOperationsInput | string
role?: EnumUserRoleFieldUpdateOperationsInput | $Enums.UserRole
@ -5300,6 +5357,7 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role?: $Enums.UserRole
@ -5309,6 +5367,7 @@ export namespace Prisma {
id?: StringFieldUpdateOperationsInput | string
username?: StringFieldUpdateOperationsInput | string
accessCode?: StringFieldUpdateOperationsInput | string
UserId?: IntFieldUpdateOperationsInput | number
hashedPassword?: StringFieldUpdateOperationsInput | string
email?: StringFieldUpdateOperationsInput | string
role?: EnumUserRoleFieldUpdateOperationsInput | $Enums.UserRole
@ -5318,6 +5377,7 @@ export namespace Prisma {
id?: StringFieldUpdateOperationsInput | string
username?: StringFieldUpdateOperationsInput | string
accessCode?: StringFieldUpdateOperationsInput | string
UserId?: IntFieldUpdateOperationsInput | number
hashedPassword?: StringFieldUpdateOperationsInput | string
email?: StringFieldUpdateOperationsInput | string
role?: EnumUserRoleFieldUpdateOperationsInput | $Enums.UserRole
@ -5495,6 +5555,17 @@ export namespace Prisma {
not?: NestedStringFilter<$PrismaModel> | string
}
export type IntFilter<$PrismaModel = never> = {
equals?: number | IntFieldRefInput<$PrismaModel>
in?: number[]
notIn?: number[]
lt?: number | IntFieldRefInput<$PrismaModel>
lte?: number | IntFieldRefInput<$PrismaModel>
gt?: number | IntFieldRefInput<$PrismaModel>
gte?: number | IntFieldRefInput<$PrismaModel>
not?: NestedIntFilter<$PrismaModel> | number
}
export type EnumUserRoleFilter<$PrismaModel = never> = {
equals?: $Enums.UserRole | EnumUserRoleFieldRefInput<$PrismaModel>
in?: $Enums.UserRole[]
@ -5536,15 +5607,21 @@ export namespace Prisma {
id?: SortOrder
username?: SortOrder
accessCode?: SortOrder
UserId?: SortOrder
hashedPassword?: SortOrder
email?: SortOrder
role?: SortOrder
}
export type UserAvgOrderByAggregateInput = {
UserId?: SortOrder
}
export type UserMaxOrderByAggregateInput = {
id?: SortOrder
username?: SortOrder
accessCode?: SortOrder
UserId?: SortOrder
hashedPassword?: SortOrder
email?: SortOrder
role?: SortOrder
@ -5554,11 +5631,16 @@ export namespace Prisma {
id?: SortOrder
username?: SortOrder
accessCode?: SortOrder
UserId?: SortOrder
hashedPassword?: SortOrder
email?: SortOrder
role?: SortOrder
}
export type UserSumOrderByAggregateInput = {
UserId?: SortOrder
}
export type StringWithAggregatesFilter<$PrismaModel = never> = {
equals?: string | StringFieldRefInput<$PrismaModel>
in?: string[]
@ -5576,6 +5658,22 @@ export namespace Prisma {
_max?: NestedStringFilter<$PrismaModel>
}
export type IntWithAggregatesFilter<$PrismaModel = never> = {
equals?: number | IntFieldRefInput<$PrismaModel>
in?: number[]
notIn?: number[]
lt?: number | IntFieldRefInput<$PrismaModel>
lte?: number | IntFieldRefInput<$PrismaModel>
gt?: number | IntFieldRefInput<$PrismaModel>
gte?: number | IntFieldRefInput<$PrismaModel>
not?: NestedIntWithAggregatesFilter<$PrismaModel> | number
_count?: NestedIntFilter<$PrismaModel>
_avg?: NestedFloatFilter<$PrismaModel>
_sum?: NestedIntFilter<$PrismaModel>
_min?: NestedIntFilter<$PrismaModel>
_max?: NestedIntFilter<$PrismaModel>
}
export type EnumUserRoleWithAggregatesFilter<$PrismaModel = never> = {
equals?: $Enums.UserRole | EnumUserRoleFieldRefInput<$PrismaModel>
in?: $Enums.UserRole[]
@ -5796,6 +5894,14 @@ export namespace Prisma {
set?: string
}
export type IntFieldUpdateOperationsInput = {
set?: number
increment?: number
decrement?: number
multiply?: number
divide?: number
}
export type EnumUserRoleFieldUpdateOperationsInput = {
set?: $Enums.UserRole
}
@ -5956,6 +6062,17 @@ export namespace Prisma {
not?: NestedStringFilter<$PrismaModel> | string
}
export type NestedIntFilter<$PrismaModel = never> = {
equals?: number | IntFieldRefInput<$PrismaModel>
in?: number[]
notIn?: number[]
lt?: number | IntFieldRefInput<$PrismaModel>
lte?: number | IntFieldRefInput<$PrismaModel>
gt?: number | IntFieldRefInput<$PrismaModel>
gte?: number | IntFieldRefInput<$PrismaModel>
not?: NestedIntFilter<$PrismaModel> | number
}
export type NestedEnumUserRoleFilter<$PrismaModel = never> = {
equals?: $Enums.UserRole | EnumUserRoleFieldRefInput<$PrismaModel>
in?: $Enums.UserRole[]
@ -5980,7 +6097,7 @@ export namespace Prisma {
_max?: NestedStringFilter<$PrismaModel>
}
export type NestedIntFilter<$PrismaModel = never> = {
export type NestedIntWithAggregatesFilter<$PrismaModel = never> = {
equals?: number | IntFieldRefInput<$PrismaModel>
in?: number[]
notIn?: number[]
@ -5988,7 +6105,23 @@ export namespace Prisma {
lte?: number | IntFieldRefInput<$PrismaModel>
gt?: number | IntFieldRefInput<$PrismaModel>
gte?: number | IntFieldRefInput<$PrismaModel>
not?: NestedIntFilter<$PrismaModel> | number
not?: NestedIntWithAggregatesFilter<$PrismaModel> | number
_count?: NestedIntFilter<$PrismaModel>
_avg?: NestedFloatFilter<$PrismaModel>
_sum?: NestedIntFilter<$PrismaModel>
_min?: NestedIntFilter<$PrismaModel>
_max?: NestedIntFilter<$PrismaModel>
}
export type NestedFloatFilter<$PrismaModel = never> = {
equals?: number | FloatFieldRefInput<$PrismaModel>
in?: number[]
notIn?: number[]
lt?: number | FloatFieldRefInput<$PrismaModel>
lte?: number | FloatFieldRefInput<$PrismaModel>
gt?: number | FloatFieldRefInput<$PrismaModel>
gte?: number | FloatFieldRefInput<$PrismaModel>
not?: NestedFloatFilter<$PrismaModel> | number
}
export type NestedEnumUserRoleWithAggregatesFilter<$PrismaModel = never> = {
@ -6243,6 +6376,7 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role?: $Enums.UserRole
@ -6254,6 +6388,7 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role?: $Enums.UserRole
@ -6281,6 +6416,7 @@ export namespace Prisma {
id?: StringFieldUpdateOperationsInput | string
username?: StringFieldUpdateOperationsInput | string
accessCode?: StringFieldUpdateOperationsInput | string
UserId?: IntFieldUpdateOperationsInput | number
hashedPassword?: StringFieldUpdateOperationsInput | string
email?: StringFieldUpdateOperationsInput | string
role?: EnumUserRoleFieldUpdateOperationsInput | $Enums.UserRole
@ -6292,6 +6428,7 @@ export namespace Prisma {
id?: StringFieldUpdateOperationsInput | string
username?: StringFieldUpdateOperationsInput | string
accessCode?: StringFieldUpdateOperationsInput | string
UserId?: IntFieldUpdateOperationsInput | number
hashedPassword?: StringFieldUpdateOperationsInput | string
email?: StringFieldUpdateOperationsInput | string
role?: EnumUserRoleFieldUpdateOperationsInput | $Enums.UserRole
@ -6303,6 +6440,7 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role?: $Enums.UserRole
@ -6314,6 +6452,7 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role?: $Enums.UserRole
@ -6341,6 +6480,7 @@ export namespace Prisma {
id?: StringFieldUpdateOperationsInput | string
username?: StringFieldUpdateOperationsInput | string
accessCode?: StringFieldUpdateOperationsInput | string
UserId?: IntFieldUpdateOperationsInput | number
hashedPassword?: StringFieldUpdateOperationsInput | string
email?: StringFieldUpdateOperationsInput | string
role?: EnumUserRoleFieldUpdateOperationsInput | $Enums.UserRole
@ -6352,6 +6492,7 @@ export namespace Prisma {
id?: StringFieldUpdateOperationsInput | string
username?: StringFieldUpdateOperationsInput | string
accessCode?: StringFieldUpdateOperationsInput | string
UserId?: IntFieldUpdateOperationsInput | number
hashedPassword?: StringFieldUpdateOperationsInput | string
email?: StringFieldUpdateOperationsInput | string
role?: EnumUserRoleFieldUpdateOperationsInput | $Enums.UserRole
@ -6363,6 +6504,7 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role?: $Enums.UserRole
@ -6374,6 +6516,7 @@ export namespace Prisma {
id: string
username: string
accessCode: string
UserId: number
hashedPassword: string
email: string
role?: $Enums.UserRole
@ -6401,6 +6544,7 @@ export namespace Prisma {
id?: StringFieldUpdateOperationsInput | string
username?: StringFieldUpdateOperationsInput | string
accessCode?: StringFieldUpdateOperationsInput | string
UserId?: IntFieldUpdateOperationsInput | number
hashedPassword?: StringFieldUpdateOperationsInput | string
email?: StringFieldUpdateOperationsInput | string
role?: EnumUserRoleFieldUpdateOperationsInput | $Enums.UserRole
@ -6412,6 +6556,7 @@ export namespace Prisma {
id?: StringFieldUpdateOperationsInput | string
username?: StringFieldUpdateOperationsInput | string
accessCode?: StringFieldUpdateOperationsInput | string
UserId?: IntFieldUpdateOperationsInput | number
hashedPassword?: StringFieldUpdateOperationsInput | string
email?: StringFieldUpdateOperationsInput | string
role?: EnumUserRoleFieldUpdateOperationsInput | $Enums.UserRole

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
{
"name": "prisma-client-aabc54979c11ed9fe0760e616a5aa0e1ec79c6db5c25a69f7c0abd1fa7e08ee5",
"name": "prisma-client-f6d74f5cbba0fb342495169b34c2d2520dafdd4c2c3b6c0b176fbebe191af770",
"main": "index.js",
"types": "index.d.ts",
"browser": "index-browser.js",

View File

@ -20,10 +20,12 @@ enum UserRole {
}
model User {
id String @id
sessions Session[]
username String @unique
accessCode String @unique
id String @id
sessions Session[]
username String @unique
accessCode String @unique
UserId Int @unique
hashedPassword String
email String @unique
role UserRole @default(USER)

View File

@ -123,6 +123,7 @@ exports.Prisma.UserScalarFieldEnum = {
id: 'id',
username: 'username',
accessCode: 'accessCode',
UserId: 'UserId',
hashedPassword: 'hashedPassword',
email: 'email',
role: 'role'

View File

@ -0,0 +1,12 @@
/*
Warnings:
- A unique constraint covering the columns `[UserId]` on the table `User` will be added. If there are existing duplicate values, this will fail.
- Added the required column `UserId` to the `User` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE `User` ADD COLUMN `UserId` INTEGER NOT NULL;
-- CreateIndex
CREATE UNIQUE INDEX `User_UserId_key` ON `User`(`UserId`);

View File

@ -20,10 +20,12 @@ enum UserRole {
}
model User {
id String @id
sessions Session[]
username String @unique
accessCode String @unique
id String @id
sessions Session[]
username String @unique
accessCode String @unique
UserId Int @unique
hashedPassword String
email String @unique
role UserRole @default(USER)