Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat-HNG-202): user dashboard overview page layout for Team-Starlight #717

Merged
merged 6 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const nextConfig = {
},
],
},
transpilePackages: ["lucide-react"],
};

export default nextConfig;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cookies-next": "^4.2.1",
"date-fns": "^3.6.0",
"framer-motion": "^11.3.8",
"input-otp": "^1.2.4",
"jest-axe": "^9.0.0",
Expand Down
11 changes: 7 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions public/admin-dashboard/icons/arrowUp.svg

This file was deleted.

5 changes: 0 additions & 5 deletions public/admin-dashboard/icons/box.svg

This file was deleted.

4 changes: 0 additions & 4 deletions public/admin-dashboard/icons/dollarSign.svg

This file was deleted.

4 changes: 0 additions & 4 deletions public/admin-dashboard/icons/user.svg

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/dashboard/(admin)/admin/client.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";

import CardComponent from "~/components/adminDashboard/CardComponent";
import { cardData } from "~/components/adminDashboard/cardData";
import { Chart } from "~/components/adminDashboard/Chart";
import { chartConfig, chartData } from "~/components/adminDashboard/chartData";
import { data, gradients } from "~/components/adminDashboard/productData";
import TopProductsComponent from "~/components/adminDashboard/TopProductsComponent";
import CardComponent from "~/components/common/DashboardCard/CardComponent";
import { Card } from "~/components/ui/card";

const Client = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/dashboard/(admin)/admin/products/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import { CirclePlus, Filter } from "lucide-react";

import CardComponent from "~/components/adminDashboard/CardComponent";
import { cardData } from "~/components/adminDashboard/cardData";
import { Button } from "~/components/common/common-button";
import CardComponent from "~/components/common/DashboardCard/CardComponent";
import {
DropdownMenu,
DropdownMenuContent,
Expand Down
10 changes: 6 additions & 4 deletions src/app/dashboard/(admin)/admin/users/data/user-dummy-data.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { LucideIconName } from "~/components/common/lucide-icon";

interface UserCardData {
title: string;
value: number;
description: string;
icon: string;
icon: LucideIconName;
}

interface UserStatusProperties {
Expand All @@ -23,19 +25,19 @@ export const userCardData: UserCardData[] = [
title: "Total Users",
value: 4000,
description: "+10% from last month",
icon: `/admin-dashboard/icons/user.svg`,
icon: "user",
},
{
title: "Active Users",
value: 1500,
description: "+20% from last month",
icon: `/admin-dashboard/icons/box.svg`,
icon: "box",
},
{
title: "Deleted Users",
value: 2500,
description: "+150% from last month",
icon: `/admin-dashboard/icons/arrowUp.svg`,
icon: "arrow-up",
},
];

Expand Down
2 changes: 1 addition & 1 deletion src/app/dashboard/(admin)/admin/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
} from "lucide-react";
import { useState } from "react";

import CardComponent from "~/components/adminDashboard/CardComponent";
import CustomButton from "~/components/common/common-button/common-button";
import CardComponent from "~/components/common/DashboardCard/CardComponent";
import { Button } from "~/components/ui/button";
import {
DropdownMenu,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function DashboardAnalytics() {
return <div>ANALYTICS</div>;
}
40 changes: 40 additions & 0 deletions src/app/dashboard/(user-dashboard)/(user-metrics)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { PropsWithChildren } from "react";

import { DateSelector } from "~/app/dashboard/(user-dashboard)/_components/layout/dateselector";
import { Tablinks } from "~/app/dashboard/(user-dashboard)/_components/layout/tablinks";
import { Button } from "~/components/common/common-button";

const links = [
{
title: "Overview",
href: "/dashboard",
},
{
title: "Analytics",
href: "/dashboard/analytics",
},
{
title: "Reports",
href: "/dashboard/reports",
},
];

export default function UserMetricsLayout({ children }: PropsWithChildren) {
return (
<div className="flex h-full flex-col gap-[37px] bg-background">
<div className="flex flex-wrap items-center justify-between gap-x-6 gap-y-2 pt-6">
<div className="space-y-6">
<h1 className="text-2xl font-semibold lg:text-[30px]">Dashboard</h1>
<Tablinks links={links} />
</div>
<div className="flex flex-wrap items-center gap-2 max-sm:flex-grow max-sm:justify-between">
<DateSelector />
<Button variant="primary" className="h-10">
Download
</Button>
</div>
</div>
<div className="flex-1 pb-9">{children}</div>
</div>
);
}
19 changes: 19 additions & 0 deletions src/app/dashboard/(user-dashboard)/(user-metrics)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { OverviewChart } from "~/app/dashboard/(user-dashboard)/_components/overview-chart";
import { OverviewRevenue } from "~/app/dashboard/(user-dashboard)/_components/overview-revenue";
import { OverviewSales } from "~/app/dashboard/(user-dashboard)/_components/overview-sales";

export default function DashboardOverview() {
return (
<div className="flex flex-col gap-4">
<div>
<OverviewRevenue />
</div>
<div className="flex flex-wrap gap-4">
<OverviewChart className="flex-grow basis-full md:basis-1/2 lg:max-w-[787px]" />
<div className="flex-1 flex-grow md:min-w-[400px]">
<OverviewSales />
</div>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function DashboardReports() {
return <div>REPORTS</div>;
}
87 changes: 87 additions & 0 deletions src/app/dashboard/(user-dashboard)/_components/RecentSales.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React from "react";

import { Card } from "~/components/ui/card";

type ProductData = {
name: string;
amount: string;
email: string;
};

type TopProductsProperties = {
data: ProductData[];
gradients: string[];
noOfSales: number;
};

const RecentSales: React.FC<TopProductsProperties> = ({
data,
gradients,
noOfSales,
}) => {
return (
<Card className="h-full basis-1/2 rounded-xl border border-border bg-white p-3 shadow-spread md:p-5">
<div className="mb-6 flex items-center justify-between">
<div className="flex flex-col items-start">
<h2 className="text-base font-semibold text-[#080808]">
Recent Sales
</h2>
<p className="text-sm font-medium text-[#626262] md:text-sm">
You made {noOfSales} sales this month
</p>
</div>
</div>
<ul className="text-[#0A0A0A]">
{data.map((item, index) => {
let amount = Number(item.amount).toFixed(2);
amount = amount
.replaceAll(
new RegExp(
String.raw`^(\d{` +
(amount.length % 3 ?? 0) +
String.raw`})(\d{3})`,
"g",
),
"$1 $2",
)
.replaceAll(/(\d{3})+?/gi, "$1 ")
.trim();
const separator = ",";
amount = amount.replaceAll(/\s/g, separator);
amount = amount.replace(",.", ".");

return (
<li
key={index}
className="mb-2 flex items-center justify-between py-2"
>
<div className="flex items-center space-x-4">
<div
className="h-10 w-10 rounded-full"
style={{ background: gradients[index % gradients.length] }}
/>
<div>
<p
data-testid={`product-name-${index}`}
className="text-base font-medium"
>
{item.name}
</p>
<p className="text-sm text-neutral-dark-1">{item.email}</p>
</div>
</div>
<p
data-testid={`product-amount-${index}`}
className="text-base font-semibold"
>
+${amount}
</p>
</li>
);
})}
</ul>
</Card>
);
};

export default RecentSales;
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"use client";

import { format, subMonths } from "date-fns";
import { CalendarDaysIcon } from "lucide-react";
import { useState } from "react";
import { DateRange } from "react-day-picker";

import { Button } from "~/components/common/common-button";
import { Calendar } from "~/components/ui/calendar";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "~/components/ui/popover";
import { cn } from "~/lib/utils";

type DateSelectorProperties = {
from?: Date;
to?: Date;
className?: string;
};
export function DateSelector({
from = subMonths(new Date(), 1),
to = new Date(),
className,
}: DateSelectorProperties) {
const [date, setDate] = useState<DateRange | undefined>({
from,
to,
});

return (
<div className={cn("grid gap-2", className)}>
<Popover>
<PopoverTrigger asChild>
<Button
id="date"
variant={"outline"}
className={cn(
"h-10 max-w-[256px] justify-start gap-1 p-2 text-left font-normal",
!date && "text-muted-foreground",
)}
>
<CalendarDaysIcon className="h-6 w-6" />
<span className="truncate">
{date?.from ? (
date.to ? (
<>
{format(date.from, "LLL dd, y")} -{" "}
{format(date.to, "LLL dd, y")}
</>
) : (
format(date.from, "LLL dd, y")
)
) : (
"Pick a date"
)}
</span>
</Button>
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="start">
<Calendar
initialFocus
mode="range"
defaultMonth={date?.from}
selected={date}
onSelect={setDate}
numberOfMonths={2}
/>
</PopoverContent>
</Popover>
</div>
);
}
Loading
Loading