Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
project_ss23_gameunity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Yusuf Akgül
project_ss23_gameunity
Commits
770970ec
Commit
770970ec
authored
1 year ago
by
Caner
Browse files
Options
Downloads
Patches
Plain Diff
gamelist
parent
e355e504
No related branches found
Branches containing commit
No related tags found
1 merge request
!26
Game list
Pipeline
#36988
failed
1 year ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/api/gameList/route.ts
+37
-0
37 additions, 0 deletions
app/api/gameList/route.ts
components/addGameToList.tsx
+36
-0
36 additions, 0 deletions
components/addGameToList.tsx
prisma/schema.prisma
+45
-55
45 additions, 55 deletions
prisma/schema.prisma
with
118 additions
and
55 deletions
app/api/gameList/route.ts
0 → 100644
+
37
−
0
View file @
770970ec
import
{
db
}
from
"
@/lib/db
"
;
import
{
getCurrentUser
}
from
"
@/lib/session
"
;
import
{
revalidatePath
}
from
"
next/cache
"
;
import
{
NextRequest
,
NextResponse
}
from
"
next/server
"
;
export
async
function
PUT
(
req
:
NextRequest
)
{
const
user
=
await
getCurrentUser
();
if
(
!
user
)
{
return
NextResponse
.
json
({
status
:
401
,
message
:
'
Unauthorized
'
});
}
const
userId
=
user
.
id
;
const
content
=
await
req
.
json
()
console
.
log
(
content
);
console
.
log
(
userId
);
try
{
await
db
.
user
.
update
({
where
:{
id
:
userId
},
data
:
{
favGameList
:{
push
:
content
.
gameId
}
}
})
const
path
=
req
.
nextUrl
.
searchParams
.
get
(
'
path
'
)
||
'
/
'
;
revalidatePath
(
path
);
return
NextResponse
.
json
({
status
:
201
,
message
:
'
Game Hinzugefügt
'
})
}
catch
(
error
:
any
)
{
return
NextResponse
.
json
({
status
:
500
,
message
:
error
.
message
})
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
components/addGameToList.tsx
0 → 100644
+
36
−
0
View file @
770970ec
"
use client
"
import
{
Post
,
Prisma
}
from
"
@prisma/client
"
;
import
{
useRouter
}
from
"
next/navigation
"
;
import
{
startTransition
,
useEffect
,
useState
}
from
"
react
"
;
export
default
function
AddGameToList
(
props
:
{
userid
:
string
,
gameId
:
string
})
{
const
router
=
useRouter
();
const
gameId
=
props
.
gameId
let
formData
=
{
gameId
}
async
function
addGame
(
e
:
any
)
{
e
.
preventDefault
()
formData
.
gameId
=
gameId
;
const
response
=
await
fetch
(
'
http://localhost:3000/api/gameList
'
,
{
method
:
'
PUT
'
,
body
:
JSON
.
stringify
(
formData
)
})
startTransition
(()
=>
{
// Refresh the current route and fetch new data from the server without
// losing client-side browser or React state.
router
.
refresh
();
});
return
await
response
.
json
()
}
return
(
<
button
type
=
"submit"
className
=
"mt-2 bg-gray-300 text-gray-800 px-4 py-2 rounded float-right"
>
Post
</
button
>
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
prisma/schema.prisma
+
45
−
55
View file @
770970ec
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
...
...
@@ -16,21 +13,20 @@ model Account {
type String
provider String
providerAccountId String
refresh_token String?
@db.Text
access_token String?
@db.Text
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
@db.Text
id_token String?
session_state String?
createdAt DateTime @default(now()) @map(
name:
"created_at")
updatedAt DateTime @default(now()) @map(
name:
"updated_at")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
refresh_token_expires_in Int?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map(
name:
"accounts")
@@map("accounts")
}
model Session {
...
...
@@ -38,10 +34,9 @@ model Session {
sessionToken String @unique
userId String @unique
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map(name: "sessions")
@@map("sessions")
}
model User {
...
...
@@ -52,20 +47,18 @@ model User {
emailVerified DateTime?
password String?
image String?
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
accounts Account[]
sessions Session[]
Post Post[]
Comment Comment[]
Like Like[]
followers Follows[] @relation("follower")
following Follows[] @relation("following")
@@map(name: "users")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
favGameList Int[]
accounts Account?
Comment Comment[]
following Follows[] @relation("following")
followers Follows[] @relation("follower")
Like Like[]
Post Post[]
sessions Session?
@@map("users")
}
model VerificationToken {
...
...
@@ -74,61 +67,58 @@ model VerificationToken {
expires DateTime
@@unique([identifier, token])
@@map(
name:
"verification_tokens")
@@map("verification_tokens")
}
model Follows {
follower User @relation("following", fields: [followerId], references: [id])
followerId String
following User @relation("follower", fields: [followingId], references: [id])
followingId String
createdAt DateTime @default(now())
follower User @relation("following", fields: [followerId], references: [id])
following User @relation("follower", fields: [followingId], references: [id])
@@id([followerId, followingId])
@@map(
name:
"follows")
@@map("follows")
}
model Post {
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(
name:
"created_at")
updatedAt DateTime @default(now()) @map(
name:
"updated_at")
id String
@id @default(cuid())
createdAt DateTime
@default(now()) @map("created_at")
updatedAt DateTime
@default(now()) @map("updated_at")
userId String
content String
likeCount Int? @default(0)
published Boolean @default(false)
likeCount Int? @default(0)
published Boolean @default(false)
Comment Comment[]
Like Like[]
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
Comment Comment[]
Like Like[]
@@map(name: "posts")
@@map("posts")
}
model Like {
id String @id @default(cuid())
id String
@id @default(cuid())
postId String
commentId String?
userId String
comment Comment? @relation(fields: [commentId], references: [id], onDelete: Cascade)
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
comment Comment? @relation(fields: [commentId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map(name: "likes")
@@map("likes")
}
model Comment {
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(
name:
"created_at")
updatedAt DateTime @default(now()) @map(
name:
"updated_at")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
message String
likeCount Int? @default(0)
postId String
userId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
Like Like[]
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
Like Like[]
@@map(name: "comments")
@@map("comments")
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment