diff --git a/app/(protected)/admin/users/user-list.tsx b/app/(protected)/admin/users/user-list.tsx index f69f37a..850ee90 100644 --- a/app/(protected)/admin/users/user-list.tsx +++ b/app/(protected)/admin/users/user-list.tsx @@ -205,22 +205,11 @@ export default function UsersList({ user }: UrlListProps) { )) ) : ( - + No users Here don't have any user yet. - {/* { - setcurrentEditUser(null); - setShowForm(false); - setShowForm(!isShowForm); - }} - > - Add user - */} )} diff --git a/app/(protected)/dashboard/records/record-list.tsx b/app/(protected)/dashboard/records/record-list.tsx index 7e7e3d5..b2d8284 100644 --- a/app/(protected)/dashboard/records/record-list.tsx +++ b/app/(protected)/dashboard/records/record-list.tsx @@ -245,23 +245,11 @@ export default function UserRecordsList({ user, action }: RecordListProps) { )) ) : ( - {/* */} + No records You don't have any record yet. Start creating record. - { - setCurrentEditRecord(null); - setShowForm(false); - setFormType("add"); - setShowForm(!isShowForm); - }} - > - Add record - )} diff --git a/app/(protected)/dashboard/urls/meta-chart.tsx b/app/(protected)/dashboard/urls/meta-chart.tsx index f1c30d5..952668d 100644 --- a/app/(protected)/dashboard/urls/meta-chart.tsx +++ b/app/(protected)/dashboard/urls/meta-chart.tsx @@ -140,7 +140,9 @@ export function DailyPVUVChart({ data }: { data: UrlMeta[] }) { const triggers = { [TopoJSONMap.selectors.feature]: (d) => d.id }; const refererStats = generateStatsList(data, "referer"); - const countryStats = generateStatsList(data, "region"); + const cityStats = generateStatsList(data, "city"); + const deviceStats = generateStatsList(data, "device"); + const browserStats = generateStatsList(data, "browser"); return ( @@ -232,8 +234,14 @@ export function DailyPVUVChart({ data }: { data: UrlMeta[] }) { {refererStats.length > 0 && ( )} - {countryStats.length > 0 && ( - + {cityStats.length > 0 && ( + + )} + {browserStats.length > 0 && ( + + )} + {deviceStats.length > 0 && ( + )} @@ -255,10 +263,12 @@ export function StatsList({ data, title }: { data: Stat[]; title: string }) { {isLink(ref.dimension) ? ( - {ref.dimension} + {ref.dimension.startsWith("http") + ? ref.dimension.split("//")[1] + : ref.dimension} ) : ( {ref.dimension} @@ -269,11 +279,9 @@ export function StatsList({ data, title }: { data: Stat[]; title: string }) { - {ref.percentage} - + > ))} diff --git a/app/(protected)/dashboard/urls/url-list.tsx b/app/(protected)/dashboard/urls/url-list.tsx index d362fda..67b8562 100644 --- a/app/(protected)/dashboard/urls/url-list.tsx +++ b/app/(protected)/dashboard/urls/url-list.tsx @@ -263,23 +263,11 @@ export default function UserUrlsList({ user, action }: UrlListProps) { )) ) : ( - {/* */} + No urls You don't have any url yet. Start creating url. - { - setCurrentEditUrl(null); - setShowForm(false); - setFormType("add"); - setShowForm(!isShowForm); - }} - > - Add url - )} diff --git a/components/forms/record-form.tsx b/components/forms/record-form.tsx index 0d88d91..b8b24ef 100644 --- a/components/forms/record-form.tsx +++ b/components/forms/record-form.tsx @@ -327,7 +327,7 @@ export function RecordForm({ diff --git a/components/forms/url-form.tsx b/components/forms/url-form.tsx index e84c884..c60b1d2 100644 --- a/components/forms/url-form.tsx +++ b/components/forms/url-form.tsx @@ -300,7 +300,7 @@ export function UrlForm({ diff --git a/components/forms/user-form.tsx b/components/forms/user-form.tsx index f8d43cb..af58014 100644 --- a/components/forms/user-form.tsx +++ b/components/forms/user-form.tsx @@ -216,7 +216,7 @@ export function UserForm({ diff --git a/components/forms/user-name-form.tsx b/components/forms/user-name-form.tsx index 6af960d..4227779 100644 --- a/components/forms/user-name-form.tsx +++ b/components/forms/user-name-form.tsx @@ -75,7 +75,7 @@ export function UserNameForm({ user }: UserNameFormProps) { /> diff --git a/components/forms/user-role-form.tsx b/components/forms/user-role-form.tsx index cf30e97..d06431c 100644 --- a/components/forms/user-role-form.tsx +++ b/components/forms/user-role-form.tsx @@ -108,7 +108,7 @@ export function UserRoleForm({ user }: UserNameFormProps) { /> diff --git a/components/shared/icons.tsx b/components/shared/icons.tsx index 5996f1d..8c5ea2e 100644 --- a/components/shared/icons.tsx +++ b/components/shared/icons.tsx @@ -10,6 +10,7 @@ import { File, FileText, Flame, + Globe, GlobeLock, HelpCircle, Home, @@ -123,6 +124,7 @@ export const Icons = { users: Users, warning: AlertTriangle, globeLock: GlobeLock, + globe: Globe, link: Link, mail: Mail, }; diff --git a/components/ui/button.tsx b/components/ui/button.tsx index 6dc25c6..a6cc038 100644 --- a/components/ui/button.tsx +++ b/components/ui/button.tsx @@ -19,6 +19,7 @@ const buttonVariants = cva( link: "underline-offset-4 hover:underline text-primary", disable: "border border-input bg-transparent text-neutral-600 cursor-not-allowed", + blue: "bg-bluer text-white hover:bg-blue/90", }, size: { default: "h-10 py-2 px-4", diff --git a/config/dashboard.ts b/config/dashboard.ts index 1dfd40b..d390469 100644 --- a/config/dashboard.ts +++ b/config/dashboard.ts @@ -30,13 +30,13 @@ export const sidebarLinks: SidebarNavItem[] = [ }, { href: "/admin/records", - icon: "lineChart", + icon: "globe", title: "Record List", authorizeOnly: UserRole.ADMIN, }, { href: "/admin/urls", - icon: "post", + icon: "link", title: "URL List", authorizeOnly: UserRole.ADMIN, }, diff --git a/middleware.ts b/middleware.ts index e345b07..86f74ed 100644 --- a/middleware.ts +++ b/middleware.ts @@ -18,18 +18,13 @@ export default auth(async (req) => { const geo = geolocation(req); const userLanguage = req.headers.get("accept-language")?.split(",")[0]; - const ua = req.headers.get("user-agent"); + const ua = req.headers.get("user-agent") || ""; const parser = new UAParser(); parser.setUA(ua); const browser = parser.getBrowser(); const device = parser.getDevice(); - console.log(device, browser); - const referer = req.headers.get("referer") || "(None)"; - // const res1 = await fetch( - // `${siteConfig.url}/api/s?slug=${match[0]}&referer=${referer}&ip=${ip}&city=${geo?.city}®ion=${geo?.region}&country=${geo?.country}&latitude=${geo?.latitude}&longitude=${geo?.longitude}&flag=${geo?.flag}`, - // ); const res = await fetch(`${siteConfig.url}/api/s`, { method: "POST", diff --git a/package.json b/package.json index fd1b588..e6e6dbb 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "@types/node": "^20.14.11", "@types/react": "18.3.3", "@types/react-dom": "18.3.0", + "@types/ua-parser-js": "^0.7.39", "autoprefixer": "^10.4.19", "eslint": "^8.57.0", "eslint-config-next": "14.2.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a98a25d..3ec934c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -264,6 +264,9 @@ importers: '@types/react-dom': specifier: 18.3.0 version: 18.3.0 + '@types/ua-parser-js': + specifier: ^0.7.39 + version: 0.7.39 autoprefixer: specifier: ^10.4.19 version: 10.4.19(postcss@8.4.39) @@ -2813,6 +2816,9 @@ packages: '@types/topojson@3.2.6': resolution: {integrity: sha512-ppfdlxjxofWJ66XdLgIlER/85RvpGyfOf8jrWf+3kVIjEatFxEZYD/Ea83jO672Xu1HRzd/ghwlbcZIUNHTskw==} + '@types/ua-parser-js@0.7.39': + resolution: {integrity: sha512-P/oDfpofrdtF5xw433SPALpdSchtJmY7nsJItf8h3KXqOslkbySh8zq4dSWXH2oTjRvJ5PczVEoCZPow6GicLg==} + '@types/ungap__structured-clone@1.2.0': resolution: {integrity: sha512-ZoaihZNLeZSxESbk9PUAPZOlSpcKx81I1+4emtULDVmBLkYutTcMlCj2K9VNlf9EWODxdO6gkAqEaLorXwZQVA==} @@ -9377,6 +9383,8 @@ snapshots: '@types/topojson-simplify': 3.0.3 '@types/topojson-specification': 1.0.5 + '@types/ua-parser-js@0.7.39': {} + '@types/ungap__structured-clone@1.2.0': {} '@types/unist@2.0.10': {} diff --git a/styles/globals.css b/styles/globals.css index cf526cf..9a96b76 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -24,6 +24,7 @@ --input: 0 0% 89.8%; --ring: 0 0% 3.9%; --radius: 0.5rem; + --blue: 210 100% 50%; --chart-1: 221.2 83.2% 53.3%; --chart-2: 212 95% 68%; @@ -52,6 +53,7 @@ --border: 0 0% 14.9%; --input: 0 0% 14.9%; --ring: 0 0% 83.1%; + --blue: 215 100% 50%; --chart-1: 221.2 83.2% 53.3%; --chart-2: 212 95% 68%; diff --git a/tailwind.config.ts b/tailwind.config.ts index 46fceaa..20aa21d 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -26,6 +26,7 @@ const config = { ring: "hsl(var(--ring))", background: "hsl(var(--background))", foreground: "hsl(var(--foreground))", + bluer: "hsl(var(--blue))", primary: { DEFAULT: "hsl(var(--primary))", foreground: "hsl(var(--primary-foreground))",
{ref.dimension}