The weeb for the next gen discord boat - Wamellow wamellow.com
bot discord
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix `useSearchParams` suspense

Luna 58625c22 60adeea1

+116 -95
+40 -33
app/dashboard/[guildId]/layout.tsx
··· 4 4 import Image from "next/image"; 5 5 import Link from "next/link"; 6 6 import { useParams, usePathname } from "next/navigation"; 7 - import { useEffect, useState } from "react"; 8 - import { HiArrowNarrowLeft, HiChartBar, HiCode, HiCursorClick, HiHome, HiShare, HiStar, HiUserAdd, HiUsers, HiViewGridAdd } from "react-icons/hi"; 7 + import { Suspense, useEffect, useState } from "react"; 8 + import { HiArrowNarrowLeft, HiChartBar, HiCode, HiCursorClick, HiEye, HiHome, HiShare, HiStar, HiUserAdd, HiUsers, HiViewGridAdd } from "react-icons/hi"; 9 9 10 10 import { guildStore } from "@/common/guilds"; 11 11 import { webStore } from "@/common/webstore"; ··· 208 208 209 209 </div> 210 210 211 - <ListTab 212 - tabs={[ 213 - { 214 - name: "Overview", 215 - value: "/", 216 - icon: <HiHome /> 217 - }, 218 - { 219 - name: "Leaderboards", 220 - value: "/leaderboards", 221 - icon: <HiChartBar /> 222 - }, 223 - { 224 - name: "Greetings", 225 - value: "/greeting", 226 - icon: <HiUserAdd /> 227 - }, 228 - { 229 - name: "Starboard", 230 - value: "/starboard", 231 - icon: <HiStar /> 232 - }, 233 - { 234 - name: "Custom Commands", 235 - value: "/custom-commands", 236 - icon: <HiCode /> 237 - } 238 - ]} 239 - url={`/dashboard/${params.guildId}`} 240 - disabled={!guild?.id || !!error} 241 - /> 211 + <Suspense> 212 + <ListTab 213 + tabs={[ 214 + { 215 + name: "Overview", 216 + value: "/", 217 + icon: <HiHome /> 218 + }, 219 + { 220 + name: "Leaderboards", 221 + value: "/leaderboards", 222 + icon: <HiChartBar /> 223 + }, 224 + { 225 + name: "Greetings", 226 + value: "/greeting", 227 + icon: <HiUserAdd /> 228 + }, 229 + { 230 + name: "Starboard", 231 + value: "/starboard", 232 + icon: <HiStar /> 233 + }, 234 + { 235 + name: "Custom Commands", 236 + value: "/custom-commands", 237 + icon: <HiCode /> 238 + }, 239 + { 240 + name: "NSFW Image Moderation", 241 + value: "/nsfw-image-scanning", 242 + icon: <HiEye /> 243 + } 244 + ]} 245 + url={`/dashboard/${params.guildId}`} 246 + disabled={!guild?.id || !!error} 247 + /> 248 + </Suspense> 242 249 243 250 {error ? 244 251 <ScreenMessage
+28 -16
app/dashboard/page.tsx
··· 30 30 const [search, setSearch] = useState<string>(""); 31 31 const [display, setDisplay] = useState<"LIST" | "GRID">("GRID"); 32 32 33 - const searchParams = useSearchParams(); 34 - 35 33 function filter(guild: UserGuild) { 36 34 if (!search) return true; 37 35 ··· 190 188 <div className="ml-3 text-sm relative bottom-1"> 191 189 <div className="text-lg dark:text-neutral-200 font-medium text-neutral-800 mb-1">{truncate(guild.name, 20)}</div> 192 190 <span className="flex gap-2"> 193 - <Button 194 - as={Link} 195 - href={`/dashboard/${guild.id}${searchParams.get("to") ? `/${searchParams.get("to")}` : ""}`} 196 - className="default dark:bg-neutral-500/40 hover:dark:bg-neutral-500/20 bg-neutral-400/40 hover:bg-neutral-400/20 text-sm h-9" 197 - > 198 - Manage 199 - </Button> 200 - <Button 201 - as={Link} 202 - href={`/leaderboard/${guild.id}`} 203 - className="default dark:bg-neutral-500/40 hover:dark:bg-neutral-500/20 bg-neutral-400/40 hover:bg-neutral-400/20 text-sm h-9 opacity-0 group-hover/card:opacity-100" 204 - > 205 - Leaderboard 206 - </Button> 191 + <ManageButton guildId={guild.id} /> 192 + <LeaderboardButton guildId={guild.id} /> 207 193 </span> 208 194 </div> 209 195 ··· 248 234 } 249 235 250 236 </div> 237 + ); 238 + } 239 + 240 + function ManageButton({ guildId }: { guildId: string }) { 241 + const searchParams = useSearchParams(); 242 + 243 + return ( 244 + <Button 245 + as={Link} 246 + href={`/dashboard/${guildId}${searchParams.get("to") ? `/${searchParams.get("to")}` : ""}`} 247 + className="default dark:bg-neutral-500/40 hover:dark:bg-neutral-500/20 bg-neutral-400/40 hover:bg-neutral-400/20 text-sm h-9" 248 + > 249 + Manage 250 + </Button> 251 + ); 252 + } 253 + 254 + function LeaderboardButton({ guildId }: { guildId: string }) { 255 + return ( 256 + <Button 257 + as={Link} 258 + href={`/leaderboard/${guildId}`} 259 + className="default dark:bg-neutral-500/40 hover:dark:bg-neutral-500/20 bg-neutral-400/40 hover:bg-neutral-400/20 text-sm h-9 opacity-0 group-hover/card:opacity-100" 260 + > 261 + Leaderboard 262 + </Button> 251 263 ); 252 264 }
+7 -7
app/profile/analytics/page.tsx
··· 8 8 import Box from "@/components/box"; 9 9 import { StatsBar } from "@/components/counter"; 10 10 import { ScreenMessage } from "@/components/screen-message"; 11 - import { Nekostic, RouteErrorResponse } from "@/typings"; 11 + import { NekosticResponse, RouteErrorResponse } from "@/typings"; 12 12 import { convertMonthToName } from "@/utils/time"; 13 13 14 14 interface CalcUses { ··· 24 24 25 25 export default function Home() { 26 26 const [error, setError] = useState<string>(); 27 - const [data, setData] = useState<Nekostic[]>(); 27 + const [data, setData] = useState<NekosticResponse[]>(); 28 28 29 29 useEffect(() => { 30 30 ··· 34 34 } 35 35 }) 36 36 .then(async (res) => { 37 - const response = await res.json() as Nekostic[]; 37 + const response = await res.json() as NekosticResponse[]; 38 38 if (!response) return; 39 39 40 40 switch (res.status) { ··· 111 111 ); 112 112 } 113 113 114 - function ChartArea(options: { name: string; data: Nekostic[]; dataKey: keyof Nekostic }) { 114 + function ChartArea(options: { name: string; data: NekosticResponse[]; dataKey: keyof NekosticResponse }) { 115 115 return ( 116 116 <Box none className="dark:bg-wamellow bg-wamellow-100 w-full rounded-md"> 117 117 ··· 144 144 ); 145 145 } 146 146 147 - function ChartBar(options: { name: string; data: Nekostic[]; dataKey: keyof CalcNames }) { 147 + function ChartBar(options: { name: string; data: NekosticResponse[]; dataKey: keyof CalcNames }) { 148 148 return ( 149 149 <Box none className="dark:bg-wamellow bg-wamellow-100 w-full rounded-md"> 150 150 ··· 206 206 }; 207 207 } 208 208 209 - function calcUses(data: Nekostic[]): CalcUses[] { 209 + function calcUses(data: NekosticResponse[]): CalcUses[] { 210 210 const snapshotData: SnapshotData = {}; 211 211 212 212 for (const item of data) { ··· 224 224 })); 225 225 } 226 226 227 - function calcNameOccurrences(data: Nekostic[]): CalcNames[] { 227 + function calcNameOccurrences(data: NekosticResponse[]): CalcNames[] { 228 228 const nameOccurrences: Record<string, number> = {}; 229 229 230 230 for (const item of data) {
+40 -38
app/profile/layout.tsx
··· 2 2 3 3 import { Skeleton } from "@nextui-org/react"; 4 4 import Image from "next/image"; 5 - import { useEffect, useState } from "react"; 5 + import { Suspense, useEffect, useState } from "react"; 6 6 import CountUp from "react-countup"; 7 7 import { HiChartPie, HiHome, HiMusicNote, HiPhotograph, HiTranslate } from "react-icons/hi"; 8 8 ··· 109 109 </div> 110 110 </div> 111 111 112 - <ListTab 113 - tabs={[ 114 - { 115 - name: "Overview", 116 - value: "/", 117 - icon: <HiHome /> 118 - }, 119 - { 120 - name: "Rank", 121 - value: "/rank", 122 - icon: <HiPhotograph /> 123 - }, 124 - { 125 - name: "Text to Speech", 126 - value: "/text-to-speech", 127 - icon: <HiTranslate /> 128 - }, 129 - { 130 - name: "Spotify", 131 - value: "/spotify", 132 - icon: <HiMusicNote /> 133 - }, 134 - ...(user?.HELLO_AND_WELCOME_TO_THE_DEV_TOOLS__PLEASE_GO_AWAY ? 135 - [ 136 - { 137 - name: "Analytics", 138 - value: "/analytics", 139 - icon: <HiChartPie /> 140 - } 141 - ] 142 - : 143 - [] 144 - ) 145 - ]} 146 - url={"/profile"} 147 - disabled={!user?.id || !!error} 148 - /> 112 + <Suspense> 113 + <ListTab 114 + tabs={[ 115 + { 116 + name: "Overview", 117 + value: "/", 118 + icon: <HiHome /> 119 + }, 120 + { 121 + name: "Rank", 122 + value: "/rank", 123 + icon: <HiPhotograph /> 124 + }, 125 + { 126 + name: "Text to Speech", 127 + value: "/text-to-speech", 128 + icon: <HiTranslate /> 129 + }, 130 + { 131 + name: "Spotify", 132 + value: "/spotify", 133 + icon: <HiMusicNote /> 134 + }, 135 + ...(user?.HELLO_AND_WELCOME_TO_THE_DEV_TOOLS__PLEASE_GO_AWAY ? 136 + [ 137 + { 138 + name: "Analytics", 139 + value: "/analytics", 140 + icon: <HiChartPie /> 141 + } 142 + ] 143 + : 144 + [] 145 + ) 146 + ]} 147 + url={"/profile"} 148 + disabled={!user?.id || !!error} 149 + /> 150 + </Suspense> 149 151 150 152 {error ? 151 153 <ScreenMessage
+1 -1
typings.ts
··· 353 353 content: string[]; 354 354 } 355 355 356 - export interface Nekostic { 356 + export interface NekosticResponse { 357 357 event: string; 358 358 name: string; 359 359 uses: number