generated from lucien/api-template
add: added cats, admin rights and owner_username display
This commit is contained in:
parent
7dea3612af
commit
0e2139f408
9 changed files with 15 additions and 5 deletions
BIN
front/public/cat.jpg
Normal file
BIN
front/public/cat.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 196 KiB |
|
@ -0,0 +1,3 @@
|
|||
.cat {
|
||||
width: 100px;
|
||||
}
|
|
@ -73,6 +73,10 @@ export default function Channel() {
|
|||
<Link to="/">Home</Link>
|
||||
<h1>Channel {channel.name}</h1>
|
||||
<p>{channel.description}</p>
|
||||
<p>Owner: {channel.owner_username}</p>
|
||||
{channel.name.toLowerCase().includes("cat") && (
|
||||
<img src="cat.jpg" alt="cat" className="cat" />
|
||||
)}
|
||||
{
|
||||
token ? (
|
||||
<form onSubmit={handleSubmit}>
|
||||
|
@ -95,7 +99,7 @@ export default function Channel() {
|
|||
{messages.slice(0, maxMessageToShown).map((message) => (
|
||||
<li key={message.id}>
|
||||
<p>{message.username}: {message.content}</p>
|
||||
{(user?.id === message.user_id || user?.id === channel.owner_id) && (
|
||||
{(user?.id === message.user_id || user?.id === channel.owner_id || user?.admin === 1) && (
|
||||
<button onClick={() => {deleteMessage(message.id)}}>Delete</button>
|
||||
)}
|
||||
</li>
|
||||
|
|
|
@ -52,6 +52,7 @@ export default function Home() {
|
|||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<img src="cat.jpg" alt="cat" className="cat"/>
|
||||
</div>
|
||||
)
|
||||
}
|
|
@ -3,6 +3,7 @@ export type Channel_type ={
|
|||
name: string
|
||||
description: string
|
||||
owner_id: number
|
||||
owner_username: string
|
||||
}
|
||||
|
||||
export type Channels = Channel_type[]
|
||||
|
@ -20,4 +21,5 @@ export type Messages = Message[]
|
|||
export type User = {
|
||||
id: number,
|
||||
username: string
|
||||
admin: number
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue