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.

add leaderboard reset button

Luna 1d6b2b4a f278bc31

+85 -6
+9
app/dashboard/[guildId]/leaderboards/page.tsx
··· 176 176 <UpdatingLeaderboardCard guild={guild as Guild} lb={data.updating.find((lb) => lb.type === "invites")} type="invites" /> 177 177 </div> 178 178 179 + 180 + <Section 181 + title="Danger zone" 182 + > 183 + Reset the leaderboard to start fresh. This action cannot be undone. 184 + </Section> 185 + 186 + <ResetLeaderboard guild={guild as Guild} /> 187 + 179 188 </div > 180 189 ); 181 190 }
+72
app/dashboard/[guildId]/leaderboards/reset.component.tsx
··· 1 + import { Button } from "@nextui-org/react"; 2 + import { useState } from "react"; 3 + import { HiTrash, HiUsers } from "react-icons/hi"; 4 + 5 + import { Guild } from "@/common/guilds"; 6 + import ImageReduceMotion from "@/components/image-reduce-motion"; 7 + import Modal from "@/components/modal"; 8 + import Notice, { NoticeType } from "@/components/notice"; 9 + import { intl } from "@/utils/numbers"; 10 + 11 + interface Props { 12 + guild: Guild; 13 + } 14 + 15 + enum ModalType { 16 + Delete = 1, 17 + } 18 + 19 + export default function ResetLeaderboard({ guild }: Props) { 20 + 21 + const [modal, setModal] = useState<ModalType>(); 22 + 23 + return ( 24 + <> 25 + <Button 26 + onClick={() => setModal(ModalType.Delete)} 27 + color="danger" 28 + variant="flat" 29 + startContent={<HiTrash />} 30 + > 31 + Reset Leaderboard 32 + </Button> 33 + 34 + <Modal 35 + title="Reset @everyone's stats" 36 + buttonName="Reset" 37 + variant="danger" 38 + show={modal === ModalType.Delete} 39 + onClose={() => setModal(undefined)} 40 + onSubmit={() => { 41 + return fetch(`${process.env.NEXT_PUBLIC_API}/guilds/${guild.id}/top-members`, { 42 + method: "DELETE", 43 + credentials: "include", 44 + headers: { 45 + "Content-Type": "application/json" 46 + } 47 + }); 48 + }} 49 + > 50 + <Notice 51 + type={NoticeType.Info} 52 + message="Takes a few seconds to apply" 53 + /> 54 + 55 + <div className="flex items-center gap-3"> 56 + <ImageReduceMotion 57 + alt="Guild Icon" 58 + className="rounded-full" 59 + url={`https://cdn.discordapp.com/icons/${guild.id}/${guild.icon}`} 60 + size={56} 61 + /> 62 + 63 + <div className="flex flex-col gap-1"> 64 + <div className="text-xl dark:text-neutral-200 text-neutral-800 font-medium">{guild?.name || "Unknown Server"}</div> 65 + <div className="text-sm font-semibold flex items-center gap-1"> <HiUsers /> {intl.format(guild?.memberCount || 0)}</div> 66 + </div> 67 + </div> 68 + 69 + </Modal> 70 + </> 71 + ); 72 + }
+4 -6
app/dashboard/[guildId]/leaderboards/updating.component.tsx
··· 3 3 import Image from "next/image"; 4 4 import Link from "next/link"; 5 5 import { useCookies } from "next-client-cookies"; 6 - import { FunctionComponent, useState } from "react"; 6 + import { useState } from "react"; 7 7 import { HiExternalLink, HiPencil, HiTrash } from "react-icons/hi"; 8 8 9 9 import { Guild } from "@/common/guilds"; ··· 23 23 Delete = 2 24 24 } 25 25 26 - const UpdatingLeaderboardCard: FunctionComponent<Props> = ({ guild, lb, type }) => { 26 + export default function UpdatingLeaderboardCard({ guild, lb, type }: Props) { 27 27 const cookies = useCookies(); 28 28 29 29 const [leaderboard, setLeaderboard] = useState(lb); 30 - const [modal, setModal] = useState<ModalType | undefined>(undefined); 30 + const [modal, setModal] = useState<ModalType>(); 31 31 32 32 const [channelId, setChannelId] = useState(leaderboard?.channelId); 33 33 const [structure, setStructure] = useState(leaderboard?.structure); ··· 280 280 </div> 281 281 ); 282 282 283 - }; 284 - 285 - export default UpdatingLeaderboardCard; 283 + }