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
Merge requests
!11
cleanup merges
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
cleanup merges
tweeting
into
main
Overview
0
Commits
1
Pipelines
1
Changes
7
Merged
Yusuf Akgül
requested to merge
tweeting
into
main
1 year ago
Overview
0
Commits
1
Pipelines
1
Changes
7
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
a3f893e5
1 commit,
1 year ago
7 files
+
120
−
140
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
app/(content)/(home)/home/page.tsx
+
69
−
78
Options
import
LikeButton
from
"
@/components/
L
ike
B
utton
"
;
import
LikeButton
from
"
@/components/
l
ike
-b
utton
"
;
import
PostMessageForm
from
"
@/components/post-messages
"
;
import
{
prisma
}
from
"
@/prisma/db
"
;
import
{
Prisma
}
from
"
@prisma/client
"
type
likeType
=
Prisma
.
LikeUncheckedCreateInput
import
{
Prisma
}
from
"
@prisma/client
"
;
type
messageType
=
Prisma
.
MessageUncheckedCreateInput
type
messageItemProps
=
{
msg
:
messageType
;
};
msg
:
messageType
;
};
export
default
async
function
HomePage
()
{
let
messages
=
null
try
{
messages
=
await
prisma
.
message
.
findMany
({
orderBy
:{
sentAt
:
"
desc
"
}
})
}
catch
(
error
)
{
console
.
log
(
"
the database is not running, try: 'npx prisma migrate dev --name init' if you want to use the database
"
)
}
let
messages
=
null
try
{
messages
=
await
prisma
.
message
.
findMany
({
orderBy
:
{
sentAt
:
"
desc
"
}
})
return
(
<
div
>
<
h1
>
Home WIP
</
h1
>
<
p
>
This will be where all messages show up.
</
p
>
<
p
>
Needs a reload after posting!!
</
p
>
{
/* <PostMessageForm data={messages}></PostMessageForm> */
}
<
PostMessageForm
data
=
{
messages
}
/>
{
messages
?
<>
{
messages
.
map
((
msg
)
=>
(
<
MessageItem
msg
=
{
msg
}
key
=
{
msg
.
id
}
/>
))
}
</>
:
<
p
>
no messages / no database
</
p
>
}
</
div
>
)
}
catch
(
error
)
{
console
.
log
(
"
the database is not running, try: 'npx prisma migrate dev --name init' if you want to use the database
"
)
}
return
(
<
div
>
<
h1
>
Home WIP
</
h1
>
<
p
>
This will be where all messages show up.
</
p
>
<
p
>
Needs a reload after posting!!
</
p
>
<
PostMessageForm
data
=
{
messages
}
/>
{
messages
?
<>
{
messages
.
map
((
msg
)
=>
(
<
MessageItem
msg
=
{
msg
}
key
=
{
msg
.
id
}
/>
))
}
</>
:
<
p
>
no messages / no database
</
p
>
}
</
div
>
)
}
const
MessageItem
=
({
msg
}:
messageItemProps
)
=>
{
if
(
!
msg
.
id
){
return
<
div
></
div
>
}
return
(
<
div
className
=
"flex border-b border-gray-200 py-4"
>
<
div
className
=
"flex-shrink-0"
>
<
div
className
=
"h-10 w-10 rounded-full bg-gray-300"
></
div
>
{
/* Profile picture */
}
</
div
>
<
div
className
=
"ml-4 flex flex-col"
>
<
div
>
<
div
className
=
"flex items-center"
>
<
span
className
=
"font-bold mr-2"
>
{
msg
.
author
}
</
span
>
<
span
className
=
"text-gray-500 text-sm"
>
{
formatDate
(
new
Date
(
msg
.
sentAt
!
))
}
</
span
>
</
div
>
<
div
className
=
"text-gray-800"
>
{
msg
.
content
}
</
div
>
const
MessageItem
=
({
msg
}:
messageItemProps
)
=>
{
if
(
!
msg
.
id
)
{
return
<
div
></
div
>
}
return
(
<
div
className
=
"flex border-b border-gray-200 py-4"
>
<
div
className
=
"flex-shrink-0"
>
<
div
className
=
"h-10 w-10 rounded-full bg-gray-300"
></
div
>
{
/* Profile picture */
}
</
div
>
<
div
className
=
"ml-4 flex flex-col"
>
<
div
>
<
div
className
=
"flex items-center"
>
<
span
className
=
"font-bold mr-2"
>
{
msg
.
author
}
</
span
>
<
span
className
=
"text-gray-500 text-sm"
>
{
formatDate
(
new
Date
(
msg
.
sentAt
!
))
}
</
span
>
</
div
>
<
div
className
=
"mt-4"
>
<
div
className
=
"flex items-center"
>
<
div
className
=
"bg-gray-200 rounded-lg py-10 px-20 mr-2"
>
{
/* potential Image */
}
</
div
>
<
div
className
=
"text-gray-800"
>
{
msg
.
content
}
</
div
>
</
div
>
<
div
className
=
"mt-4"
>
<
div
className
=
"flex items-center"
>
<
div
className
=
"bg-gray-200 rounded-lg py-10 px-20 mr-2"
>
{
/* potential Image */
}
</
div
>
</
div
>
<
LikeButton
data
=
{
{
postId
:
msg
.
id
,
author
:
msg
.
author
}
}
/>
<
span
className
=
"text-gray-600"
>
Like Count:
{
msg
.
likeCount
}
|
<
span
className
=
"text-gray-600"
>
ReplyButton (Number of Replies)
</
span
></
span
>
</
div
>
<
LikeButton
data
=
{
{
postId
:
msg
.
id
,
author
:
msg
.
author
}
}
/>
<
span
className
=
"text-gray-600"
>
Like Count:
{
msg
.
likeCount
}
|
<
span
className
=
"text-gray-600"
>
ReplyButton (Number of Replies)
</
span
></
span
>
</
div
>
);
};
</
div
>
);
};
function
formatDate
(
date
:
Date
){
return
date
.
toLocaleDateString
(
"
en-US
"
,
{
day
:
"
numeric
"
,
month
:
"
short
"
,
year
:
"
numeric
"
});
function
formatDate
(
date
:
Date
)
{
return
date
.
toLocaleDateString
(
"
en-US
"
,
{
day
:
"
numeric
"
,
month
:
"
short
"
,
year
:
"
numeric
"
});
}
\ No newline at end of file
Loading