Commit 55c59f6 1 parent 3045548 commit 55c59f6 Copy full SHA for 55c59f6
File tree 7 files changed +41
-39
lines changed
7 files changed +41
-39
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ The architecture of this project revolves around a streamlined development and d
32
32
- [x] Add auth with lucia
33
33
- [x] Workshop creation
34
34
- [x] Edit workshop
35
+ - [x] Complete workshop page
35
36
- [ ] Interactive workshop session(e.g video conferencing, live chat code editor)
36
37
- [x] Delete workshop
37
38
- [x] Participant registration
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export function UserDropdown({ user }: UserDropdownProps) {
38
38
< DropdownMenuTrigger asChild >
39
39
< Button variant = "secondary" className = "size-8 rounded-full" >
40
40
< Avatar className = "size-8" >
41
- < AvatarImage src = { user . image } />
41
+ < AvatarImage src = { user . image } alt = { `@ ${ user . username } ` } />
42
42
< AvatarFallback > { initial } </ AvatarFallback >
43
43
</ Avatar >
44
44
</ Button >
Original file line number Diff line number Diff line change 1
- import { getWorkshopRegistrants } from "@/server/data/workshop"
1
+ import { type getWorkshopRegistrants } from "@/server/data/registration"
2
+ import { Avatar , AvatarFallback , AvatarImage } from "@/components/ui/avatar"
2
3
3
4
interface WorkshopRegistrantsProps {
4
- workshopId : string
5
+ registrants : Awaited < ReturnType < typeof getWorkshopRegistrants > >
5
6
}
6
7
7
- export async function WorkshopRegistrants ( {
8
- workshopId,
9
- } : WorkshopRegistrantsProps ) {
10
- const registrants = await getWorkshopRegistrants ( workshopId )
8
+ export function WorkshopRegistrants ( { registrants } : WorkshopRegistrantsProps ) {
9
+ const displayedRegistrants = registrants . slice ( 0 , 4 )
10
+ const extraRegistrantsCount = registrants . length - displayedRegistrants . length
11
11
12
- if ( ! registrants . length ) {
13
- return
14
- }
12
+ return (
13
+ < div className = "flex -space-x-4 rtl:space-x-reverse" >
14
+ { displayedRegistrants . map ( ( registrant ) => (
15
+ < Avatar key = { registrant . id } >
16
+ < AvatarImage
17
+ src = { registrant . image ?? "" }
18
+ alt = { `@${ registrant . username } ` }
19
+ />
20
+ < AvatarFallback >
21
+ { registrant . username ?. charAt ( 0 ) ?? "R" }
22
+ </ AvatarFallback >
23
+ </ Avatar >
24
+ ) ) }
15
25
16
- if ( registrants . length <= 3 ) {
17
- return < > </ >
18
- }
19
-
20
- return < > </ >
26
+ { extraRegistrantsCount && (
27
+ < div className = "z-50 flex size-10 items-center justify-center rounded-full bg-muted text-xs font-medium text-white" >
28
+ +{ extraRegistrantsCount }
29
+ </ div >
30
+ ) }
31
+ </ div >
32
+ )
21
33
}
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ export default function WorkshopLoading() {
32
32
/>
33
33
< Skeleton className = "h-5 w-10" />
34
34
</ div >
35
+ < div className = "flex -space-x-4 rtl:space-x-reverse" >
36
+ { Array . from ( { length : 4 } ) . map ( ( _ , i ) => (
37
+ < Skeleton key = { i } className = "size-10 rounded-full" />
38
+ ) ) }
39
+ </ div >
35
40
</ div >
36
41
37
42
< Separator />
Original file line number Diff line number Diff line change @@ -5,8 +5,9 @@ import { env } from "@/env"
5
5
import { eq } from "drizzle-orm"
6
6
7
7
import { redirects } from "@/config/constants"
8
+ import { getWorkshopRegistrants } from "@/server/data/registration"
8
9
import { getUserSession } from "@/server/data/user"
9
- import { getWorkshop , getWorkshopRegistrants } from "@/server/data/workshop"
10
+ import { getWorkshop } from "@/server/data/workshop"
10
11
import { db } from "@/server/db"
11
12
import { workshops } from "@/server/db/schema"
12
13
import { getExactScheduled } from "@/utils/format-scheduled-date"
@@ -113,9 +114,7 @@ export default async function WorkshopPage({ params }: WorkshopPageProps) {
113
114
</ p >
114
115
</ div >
115
116
116
- < React . Suspense >
117
- < WorkshopRegistrants workshopId = { workshop . id } />
118
- </ React . Suspense >
117
+ < WorkshopRegistrants registrants = { registrants } />
119
118
</ div >
120
119
121
120
< Separator />
Original file line number Diff line number Diff line change @@ -6,17 +6,18 @@ import { eq } from "drizzle-orm"
6
6
import { db } from "../db"
7
7
import { registrations , users } from "../db/schema"
8
8
9
- export async function getWorkshopRegistrants ( workshopId : string ) {
9
+ export async function getWorkshopRegistrants ( currentWorkshopId : string ) {
10
10
noStore ( )
11
11
try {
12
- await db
12
+ return await db
13
13
. select ( {
14
14
id : users . id ,
15
+ username : users . username ,
15
16
image : users . image ,
16
17
} )
17
18
. from ( registrations )
18
19
. innerJoin ( users , eq ( registrations . registrantId , users . id ) )
19
- . where ( eq ( registrations . workshopId , workshopId ) )
20
+ . where ( eq ( registrations . workshopId , currentWorkshopId ) )
20
21
} catch ( err ) {
21
22
return [ ]
22
23
}
Original file line number Diff line number Diff line change 7
7
import { asc , eq } from "drizzle-orm"
8
8
9
9
import { db } from "../db"
10
- import { registrations , users , workshops } from "../db/schema"
10
+ import { users , workshops } from "../db/schema"
11
11
12
12
export async function getWorkshop ( workshopId : string ) {
13
13
try {
@@ -70,22 +70,6 @@ export async function getWorkshops() {
70
70
}
71
71
}
72
72
73
- export async function getWorkshopRegistrants ( currentWorkshopId : string ) {
74
- noStore ( )
75
- try {
76
- return await db
77
- . select ( {
78
- id : users . id ,
79
- image : users . image ,
80
- } )
81
- . from ( registrations )
82
- . innerJoin ( users , eq ( registrations . registrantId , users . id ) )
83
- . where ( eq ( registrations . workshopId , currentWorkshopId ) )
84
- } catch ( err ) {
85
- return [ ]
86
- }
87
- }
88
-
89
73
export async function getWorkshopOrganizer ( organizerId : string ) {
90
74
return await cache ( async ( ) => {
91
75
return await db . query . users . findFirst ( {
You can’t perform that action at this time.
0 commit comments