File tree Expand file tree Collapse file tree 2 files changed +31
-12
lines changed Expand file tree Collapse file tree 2 files changed +31
-12
lines changed Original file line number Diff line number Diff line change 1+ import { Image } from "@nextui-org/react" ;
2+
3+ export function ServerIcon ( {
4+ guild,
5+ } : {
6+ guild : { name : string ; icon ?: string } ;
7+ } ) {
8+ if ( ! guild . icon ) {
9+ return (
10+ < div className = "w-16 h-16 rounded-large bg-default flex items-center justify-center" >
11+ { guild . name . match ( / [ A - Z ] / g) ?. join ( "" ) }
12+ </ div >
13+ ) ;
14+ }
15+
16+ return (
17+ < Image
18+ alt = { guild . name + " icon" }
19+ className = "text-center"
20+ height = { 64 }
21+ src = {
22+ guild . icon
23+ ? guild . icon + "?size=256"
24+ : "https://cdn.discordapp.com/embed/avatars/0.png"
25+ }
26+ />
27+ ) ;
28+ }
Original file line number Diff line number Diff line change 11import { useRouter } from "next/router" ;
22import { useQuery } from "@tanstack/react-query" ;
3- import { Button , Image } from "@nextui-org/react" ;
3+ import { Button } from "@nextui-org/react" ;
44import Link from "next/link" ;
55
66import DefaultLayout from "@/layouts/default" ;
77import { API_URL , useUser } from "@/lib/queries" ;
88import { subtitle , title } from "@/components/primitives" ;
99import { LoaderIcon } from "@/components/icons" ;
10+ import { ServerIcon } from "@/components/server-icon" ;
1011
1112interface Guild {
1213 id : string ;
@@ -60,17 +61,7 @@ export default function Dashboard() {
6061 className = "bg-gray-800 p-6 rounded-lg flex flex-col justify-center space-y-4 shadow-lg"
6162 >
6263 < div className = "flex flex-col space-y-3 items-center justify-center" >
63- < Image
64- alt = { guild . name + " avatar" }
65- className = "text-center"
66- height = { 64 }
67- src = {
68- guild . icon
69- ? guild . icon +
70- "?size=256"
71- : "https://cdn.discordapp.com/embed/avatars/0.png"
72- }
73- />
64+ < ServerIcon guild = { guild } />
7465 < span className = "text-white text-2xl font-bold text-center" >
7566 { guild . name }
7667 </ span >
You can’t perform that action at this time.
0 commit comments