11'use client' ;
22
3- import { useRouter , useParams } from 'next/navigation' ;
4- import { Button } from '@/components/common/Button' ;
3+ import { BOTS } from '@chatsift/core' ;
4+ import Link from 'next/link' ;
5+ import { notFound , useParams } from 'next/navigation' ;
6+ import { Breadcrumb } from '@/components/common/Breadcrumb' ;
57import { GuildIcon } from '@/components/common/GuildIcon' ;
68import { Heading } from '@/components/common/Heading' ;
79import { Skeleton } from '@/components/common/Skeleton' ;
8- import { SvgAMA } from '@/components/icons/SvgAMA' ;
910import { client } from '@/data/client' ;
11+ import { Bots } from '@/utils/bots' ;
12+ import { cn } from '@/utils/util' ;
1013
1114export default function GuildPage ( ) {
1215 const params = useParams < { id : string } > ( ) ;
13- const router = useRouter ( ) ;
1416 const { data : me , isLoading } = client . auth . useMe ( ) ;
1517
1618 const guild = me ?. guilds . find ( ( g ) => g . id === params . id ) ;
@@ -20,54 +22,57 @@ export default function GuildPage() {
2022 }
2123
2224 if ( ! guild ) {
23- return (
24- < div className = "flex flex-col gap-4" >
25- < p className = "text-lg text-secondary dark:text-secondary-dark" > Guild not found</ p >
26- </ div >
27- ) ;
25+ return notFound ( ) ;
2826 }
2927
3028 return (
3129 < div className = "space-y-8" >
32- < div className = "flex flex-row flex-grow gap-72" >
33- < div className = "space-y-2 w-64" >
34- < Button
35- className = "flex items-center gap-2 text-lg text-secondary hover:text-primary dark:text-secondary-dark dark:hover:text-primary-dark"
36- onPress = { ( ) => router . replace ( '/dashboard' ) }
37- >
38- ← Servers
39- </ Button >
40-
41- < Heading title = "Server Settings" />
42- </ div >
43- </ div >
30+ < Breadcrumb
31+ segments = { [
32+ { label : 'Servers' , href : '/dashboard' } ,
33+ { label : guild . name , highlight : true } ,
34+ ] }
35+ />
4436
45- < div className = "flex h-36 w-full flex-col gap-3 rounded-lg border-[1px] border-on-secondary bg-[#FFFFFF] p-4 dark:border-on-secondary-dark dark:bg-[#1C1C21]" >
46- < GuildIcon data = { guild } hasBots = { guild . bots . length > 0 } />
47- < div className = "flex flex-col gap-1" >
48- < p className = "w-full overflow-hidden overflow-ellipsis whitespace-nowrap text-lg font-medium text-primary dark:text-primary-dark" >
37+ { /* TODO: Show member counts maybe */ }
38+ < div className = "flex w-full flex-col gap-3 rounded-lg border-[1px] border-on-secondary bg-card p-4 dark:border-on-secondary-dark dark:bg-card-dark" >
39+ < div className = "flex flex-row gap-4" >
40+ < GuildIcon data = { guild } disableLink hasBots = { guild . bots . length > 0 } />
41+ < p className = "content-center w-full overflow-hidden overflow-ellipsis whitespace-nowrap text-lg font-medium text-primary dark:text-primary-dark" >
4942 { guild . name }
5043 </ p >
51- < p className = "text-base text-secondary dark:text-secondary-dark" > { guild . bots . length } bot(s) active</ p >
5244 </ div >
45+
46+ < p className = "text-base text-secondary dark:text-secondary-dark" > { guild . bots . length } bot(s) active</ p >
5347 </ div >
5448
55- { /* Bot navigation section */ }
5649 < div className = "space-y-4" >
57- < Heading subtitle = "Configure your bots" title = "Bots" />
50+ < Heading subtitle = "Configure the bots installed in your server " title = "Bots" />
5851 < div className = "flex flex-col gap-3" >
59- { guild . bots . includes ( 'AMA' ) && (
60- < a
61- className = "flex items-center gap-4 rounded-lg border-[1px] border-on-secondary bg-[#FFFFFF] p-4 hover:bg-on-tertiary dark:border-on-secondary-dark dark:bg-[#1C1C21] dark:hover:bg-on-tertiary-dark"
62- href = { `/dashboard/${ guild . id } /ama` }
63- >
64- < SvgAMA height = { 32 } width = { 32 } />
65- < div className = "flex flex-col" >
66- < p className = "text-lg font-medium text-primary dark:text-primary-dark" > AMA</ p >
67- < p className = "text-sm text-secondary dark:text-secondary-dark" > Configure AMA bot settings</ p >
68- </ div >
69- </ a >
70- ) }
52+ { BOTS . map ( ( bot , index ) => {
53+ const { Icon } = Bots [ bot ] ;
54+ const hasIt = guild . bots . includes ( bot ) ;
55+
56+ return (
57+ < Link
58+ className = { cn (
59+ 'flex items-center gap-4 rounded-lg border-[1px] border-on-secondary bg-card p-4 hover:bg-on-tertiary dark:border-on-secondary-dark dark:bg-card-dark dark:hover:bg-on-tertiary-dark' ,
60+ ! hasIt && 'opacity-50 hover:opacity-75' ,
61+ ) }
62+ href = { hasIt ? `/dashboard/${ guild . id } /ama` : `/invites/${ bot . toLowerCase ( ) } ` }
63+ key = { index }
64+ prefetch
65+ >
66+ < Icon height = { 32 } width = { 32 } />
67+ < div className = "flex flex-col" >
68+ < p className = "text-lg font-medium text-primary dark:text-primary-dark" > { bot } </ p >
69+ < p className = "text-sm text-secondary dark:text-secondary-dark" >
70+ { hasIt ? `Configure ${ bot } bot settings` : `Invite ${ bot } to your server` }
71+ </ p >
72+ </ div >
73+ </ Link >
74+ ) ;
75+ } ) }
7176 </ div >
7277 </ div >
7378 </ div >
0 commit comments