Skip to content

Commit

Permalink
+feat: stats
Browse files Browse the repository at this point in the history
nicitaacom committed Jul 14, 2024
1 parent 8c1902d commit 5c6546b
Showing 5 changed files with 257 additions and 142 deletions.
34 changes: 34 additions & 0 deletions app/(site)/stats/components/Stats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"use client"

import CountUp from "react-countup"

type StatsResponse = {
stats:
| {
clicks: number
created_at: string
id: string
utm_source: string
}[]
| null
}

export function Stats({ stats }: StatsResponse) {
return (
<ul>
{stats?.map(stat => (
<li className="flex flex-row justify-center items-center" key={stat.id}>
<p>{stat.utm_source} -&nbsp;</p>
<CountUp
className="font-bold text-secondary-foreground"
end={stat.clicks}
duration={4}
delay={0.5}
separator=""
key={stat.id}
/>
</li>
))}
</ul>
)
}
15 changes: 15 additions & 0 deletions app/(site)/stats/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import supabaseAdmin from "@/libs/supabase/supabaseAdmin"
import CountUp from "react-countup"
import { Stats } from "./components/Stats"

export default async function StatsPage() {
const { data: stats } = await supabaseAdmin.from("stats").select("*")

return (
<div
className="w-full py-12 h-[calc(100vh-64px)] overflow-x-hidden overflow-y-auto
text-2xl text-title flex flex-col gap-y-8 justify-between items-center mx-auto">
<Stats stats={stats} />
</div>
)
}
2 changes: 2 additions & 0 deletions app/components/Navbar/components/AvatarDropdown.tsx
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import { BsWindow } from "react-icons/bs"
import { TbWorld } from "react-icons/tb"
import { FiPhoneCall } from "react-icons/fi"
import { IoChatboxEllipsesOutline } from "react-icons/io5"
import { IoIosStats } from "react-icons/io"

import useUserStore from "@/store/user/userStore"
import useDarkMode from "@/store/ui/darkModeStore"
@@ -65,6 +66,7 @@ export function AvatarDropdown({ role, avatarUrlServer }: AvatarDropdownProps) {
href={contact.telegram}
target="_blank"
/>
{role === "SUPPORT" && <DropdownItem label="Stats" icon={IoIosStats} href="/stats" />}
<DropdownItem label="Change language" icon={TbWorld} onClick={openChangeLanguageModal} />
<DropdownItem
className="min-[501px]:hidden"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@
"pusher": "^5.2.0",
"pusher-js": "^8.3.0",
"react": "18.2.0",
"react-countup": "^6.5.3",
"react-dom": "18.2.0",
"react-email": "^2.1.5",
"react-hook-form": "^7.52.1",
347 changes: 205 additions & 142 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

0 comments on commit 5c6546b

Please sign in to comment.