project+setup

This commit is contained in:
kirukib 2025-12-17 14:40:14 +03:00
parent b2ee881f41
commit afccaf9892
46 changed files with 7917 additions and 0 deletions

24
.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

23
eslint.config.js Normal file
View File

@ -0,0 +1,23 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
])

13
index.html Normal file
View File

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>yimaru-admin</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

5889
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

45
package.json Normal file
View File

@ -0,0 +1,45 @@
{
"name": "yimaru-admin",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@fontsource/inter": "^5.2.8",
"@radix-ui/react-avatar": "^1.1.11",
"@radix-ui/react-dropdown-menu": "^2.1.16",
"@radix-ui/react-separator": "^1.1.8",
"@radix-ui/react-slot": "^1.2.4",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^0.561.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-router-dom": "^7.10.1",
"recharts": "^3.6.0",
"tailwind-merge": "^3.4.0",
"zustand": "^5.0.9"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
"@types/node": "^24.10.1",
"@types/react": "^19.2.5",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^5.1.1",
"autoprefixer": "^10.4.23",
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0",
"postcss": "^8.5.6",
"tailwindcss": "^3.4.17",
"typescript": "~5.9.3",
"typescript-eslint": "^8.46.4",
"vite": "^7.2.4"
}
}

6
postcss.config.js Normal file
View File

@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

1
public/vite.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

42
src/App.css Normal file
View File

@ -0,0 +1,42 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}

5
src/App.tsx Normal file
View File

@ -0,0 +1,5 @@
import { AppRoutes } from './app/AppRoutes'
export default function App() {
return <AppRoutes />
}

47
src/app/AppRoutes.tsx Normal file
View File

@ -0,0 +1,47 @@
import { Navigate, Route, Routes } from "react-router-dom"
import { AppLayout } from "../layouts/AppLayout"
import { DashboardPage } from "../pages/DashboardPage"
import { AnalyticsPage } from "../pages/analytics/AnalyticsPage"
import { ContentManagementLayout } from "../pages/content-management/ContentManagementLayout"
import { ContentOverviewPage } from "../pages/content-management/ContentOverviewPage"
import { CoursesPage } from "../pages/content-management/CoursesPage"
import { SpeakingPage } from "../pages/content-management/SpeakingPage"
import { NotFoundPage } from "../pages/NotFoundPage"
import { NotificationsPage } from "../pages/notifications/NotificationsPage"
import { PlaceholderPage } from "../pages/PlaceholderPage"
import { UserDetailPage } from "../pages/user-management/UserDetailPage"
import { UserManagementLayout } from "../pages/user-management/UserManagementLayout"
import { UsersListPage } from "../pages/user-management/UsersListPage"
import { UserLogPage } from "../pages/user-log/UserLogPage"
export function AppRoutes() {
return (
<Routes>
<Route element={<AppLayout />}>
<Route path="/" element={<Navigate to="/dashboard" replace />} />
<Route path="/dashboard" element={<DashboardPage />} />
<Route path="/users" element={<UserManagementLayout />}>
<Route index element={<UsersListPage />} />
<Route path=":id" element={<UserDetailPage />} />
</Route>
<Route path="/content" element={<ContentManagementLayout />}>
<Route index element={<ContentOverviewPage />} />
<Route path="courses" element={<CoursesPage />} />
<Route path="speaking" element={<SpeakingPage />} />
</Route>
<Route path="/notifications" element={<NotificationsPage />} />
<Route path="/user-log" element={<UserLogPage />} />
<Route path="/analytics" element={<AnalyticsPage />} />
<Route path="/team" element={<PlaceholderPage title="Team Management" />} />
<Route path="/profile" element={<PlaceholderPage title="Profile" />} />
</Route>
<Route path="*" element={<NotFoundPage />} />
</Routes>
)
}

1
src/assets/react.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -0,0 +1,15 @@
export function BrandLogo() {
return (
<div className="flex items-center gap-2">
<div className="grid h-9 w-9 place-items-center rounded-lg bg-brand-500 text-white">
<div className="h-4 w-4 rotate-45 rounded-[3px] bg-white/90" />
</div>
<div className="leading-tight">
<div className="text-sm font-semibold text-brand-600">Yimaru</div>
<div className="text-xs font-medium text-brand-400">Academy</div>
</div>
</div>
)
}

View File

@ -0,0 +1,39 @@
import type { LucideIcon } from "lucide-react"
import { cn } from "../../lib/utils"
import { Card, CardContent } from "../ui/card"
export function StatCard({
icon: Icon,
label,
value,
deltaLabel,
deltaPositive,
}: {
icon: LucideIcon
label: string
value: string
deltaLabel: string
deltaPositive: boolean
}) {
return (
<Card className="shadow-none">
<CardContent className="p-4">
<div className="flex items-start justify-between gap-3">
<div>
<div className="text-2xl font-semibold tracking-tight">{value}</div>
<div className="mt-1 text-xs font-medium text-grayScale-500">{label}</div>
</div>
<div className="grid h-10 w-10 place-items-center rounded-xl bg-brand-100 text-brand-600">
<Icon className="h-5 w-5" />
</div>
</div>
<div className={cn("mt-3 text-xs font-medium", deltaPositive ? "text-mint-500" : "text-destructive")}>
{deltaLabel} <span className="text-grayScale-400">vs Last Month</span>
</div>
</CardContent>
</Card>
)
}

View File

@ -0,0 +1,91 @@
import {
BarChart3,
Bell,
BookOpen,
ClipboardList,
LayoutDashboard,
LogOut,
UserCircle2,
Users,
Users2,
} from "lucide-react"
import type { ComponentType } from "react"
import { NavLink } from "react-router-dom"
import { cn } from "../../lib/utils"
import { BrandLogo } from "../brand/BrandLogo"
type NavItem = {
label: string
to: string
icon: ComponentType<{ className?: string }>
}
const navItems: NavItem[] = [
{ label: "Dashboard", to: "/dashboard", icon: LayoutDashboard },
{ label: "User Management", to: "/users", icon: Users },
{ label: "Content Management", to: "/content", icon: BookOpen },
{ label: "Notifications", to: "/notifications", icon: Bell },
{ label: "User Log", to: "/user-log", icon: ClipboardList },
{ label: "Analytics", to: "/analytics", icon: BarChart3 },
{ label: "Team Management", to: "/team", icon: Users2 },
{ label: "Profile", to: "/profile", icon: UserCircle2 },
]
export function Sidebar() {
return (
<aside className="flex w-[264px] flex-col border-r bg-grayScale-50 px-4 py-5">
<div className="px-2">
<BrandLogo />
</div>
<nav className="mt-6 space-y-1">
{navItems.map((item) => {
const Icon = item.icon
return (
<NavLink
key={item.to}
to={item.to}
className={({ isActive }) =>
cn(
"group flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium text-grayScale-600 transition",
"hover:bg-grayScale-100 hover:text-brand-600",
isActive &&
"bg-brand-100/40 text-brand-600 shadow-[0_1px_0_rgba(0,0,0,0.02)] ring-1 ring-brand-100",
)
}
>
{({ isActive }) => (
<>
<span
className={cn(
"grid h-8 w-8 place-items-center rounded-lg bg-grayScale-100 text-grayScale-500 transition group-hover:bg-brand-100 group-hover:text-brand-600",
isActive && "bg-brand-500 text-white",
)}
>
<Icon className="h-4 w-4" />
</span>
<span className="truncate">{item.label}</span>
{isActive ? (
<span className="ml-auto h-6 w-1 rounded-full bg-brand-500" />
) : null}
</>
)}
</NavLink>
)
})}
</nav>
<div className="mt-auto px-2 pt-6">
<button
type="button"
className="flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium text-grayScale-500 hover:bg-grayScale-100 hover:text-brand-600"
>
<LogOut className="h-4 w-4" />
Logout
</button>
</div>
</aside>
)
}

View File

@ -0,0 +1,23 @@
import { Bell } from "lucide-react"
import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"
export function Topbar() {
return (
<header className="sticky top-0 z-10 flex h-16 items-center justify-end gap-3 border-b bg-grayScale-50/85 px-6 backdrop-blur">
<button
type="button"
className="grid h-10 w-10 place-items-center rounded-full border bg-white text-grayScale-500 hover:text-brand-600"
aria-label="Notifications"
>
<Bell className="h-5 w-5" />
</button>
<Avatar className="h-10 w-10 ring-2 ring-brand-100">
<AvatarImage src="" alt="Admin" />
<AvatarFallback className="bg-brand-500 text-white">JA</AvatarFallback>
</Avatar>
</header>
)
}

View File

@ -0,0 +1,38 @@
import * as React from "react"
import * as AvatarPrimitive from "@radix-ui/react-avatar"
import { cn } from "../../lib/utils"
export const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className)}
{...props}
/>
))
Avatar.displayName = AvatarPrimitive.Root.displayName
export const AvatarImage = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Image>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Image ref={ref} className={cn("aspect-square h-full w-full", className)} {...props} />
))
AvatarImage.displayName = AvatarPrimitive.Image.displayName
export const AvatarFallback = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Fallback>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Fallback
ref={ref}
className={cn("flex h-full w-full items-center justify-center rounded-full bg-grayScale-200 text-sm font-semibold", className)}
{...props}
/>
))
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName

View File

@ -0,0 +1,31 @@
import { cva, type VariantProps } from "class-variance-authority"
import * as React from "react"
import { cn } from "../../lib/utils"
const badgeVariants = cva(
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors",
{
variants: {
variant: {
default: "border-transparent bg-brand-500 text-white",
secondary: "border-transparent bg-grayScale-200 text-grayScale-600",
warning: "border-transparent bg-gold-600 text-white",
success: "border-transparent bg-mint-500 text-white",
info: "border-transparent bg-sky-500 text-white",
destructive: "border-transparent bg-destructive text-destructive-foreground",
},
},
defaultVariants: {
variant: "default",
},
},
)
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
export function Badge({ className, variant, ...props }: BadgeProps) {
return <div className={cn(badgeVariants({ variant }), className)} {...props} />
}

View File

@ -0,0 +1,54 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "../../lib/utils"
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-brand-600",
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
outline: "border bg-background hover:bg-grayScale-100",
ghost: "hover:bg-grayScale-100",
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
},
size: {
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 px-6",
icon: "h-10 w-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
},
)
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
}
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
)
},
)
Button.displayName = "Button"
export { buttonVariants }

View File

@ -0,0 +1,49 @@
import * as React from "react"
import { cn } from "../../lib/utils"
export const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("rounded-2xl border bg-card text-card-foreground shadow-soft", className)}
{...props}
/>
),
)
Card.displayName = "Card"
export const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
),
)
CardHeader.displayName = "CardHeader"
export const CardTitle = React.forwardRef<React.ElementRef<"h3">, React.ComponentPropsWithoutRef<"h3">>(
({ className, ...props }, ref) => (
<h3 ref={ref} className={cn("text-base font-semibold leading-none tracking-tight", className)} {...props} />
),
)
CardTitle.displayName = "CardTitle"
export const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
))
CardDescription.displayName = "CardDescription"
export const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />,
)
CardContent.displayName = "CardContent"
export const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
),
)
CardFooter.displayName = "CardFooter"

View File

@ -0,0 +1,151 @@
import * as React from "react"
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
import { Check, ChevronRight, Circle } from "lucide-react"
import { cn } from "../../lib/utils"
export const DropdownMenu = DropdownMenuPrimitive.Root
export const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
export const DropdownMenuGroup = DropdownMenuPrimitive.Group
export const DropdownMenuPortal = DropdownMenuPrimitive.Portal
export const DropdownMenuSub = DropdownMenuPrimitive.Sub
export const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
export const DropdownMenuSubTrigger = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & { inset?: boolean }
>(({ className, inset, children, ...props }, ref) => (
<DropdownMenuPrimitive.SubTrigger
ref={ref}
className={cn(
"flex cursor-default select-none items-center rounded-md px-2 py-1.5 text-sm outline-none focus:bg-grayScale-100 data-[state=open]:bg-grayScale-100",
inset && "pl-8",
className,
)}
{...props}
>
{children}
<ChevronRight className="ml-auto h-4 w-4" />
</DropdownMenuPrimitive.SubTrigger>
))
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName
export const DropdownMenuSubContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
>(({ className, ...props }, ref) => (
<DropdownMenuPrimitive.SubContent
ref={ref}
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-white p-1 text-grayScale-600 shadow-soft",
className,
)}
{...props}
/>
))
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName
export const DropdownMenuContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<DropdownMenuPrimitive.Portal>
<DropdownMenuPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 min-w-[10rem] overflow-hidden rounded-md border bg-white p-1 text-grayScale-600 shadow-soft",
className,
)}
{...props}
/>
</DropdownMenuPrimitive.Portal>
))
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
export const DropdownMenuItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & { inset?: boolean }
>(({ className, inset, ...props }, ref) => (
<DropdownMenuPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-md px-2 py-1.5 text-sm outline-none transition-colors focus:bg-grayScale-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
inset && "pl-8",
className,
)}
{...props}
/>
))
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
export const DropdownMenuCheckboxItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
>(({ className, children, checked, ...props }, ref) => (
<DropdownMenuPrimitive.CheckboxItem
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-md py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-grayScale-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className,
)}
checked={checked}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
<Check className="h-4 w-4" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
</DropdownMenuPrimitive.CheckboxItem>
))
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName
export const DropdownMenuRadioItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
>(({ className, children, ...props }, ref) => (
<DropdownMenuPrimitive.RadioItem
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-md py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-grayScale-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className,
)}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
<Circle className="h-2 w-2 fill-current" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
</DropdownMenuPrimitive.RadioItem>
))
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
export const DropdownMenuLabel = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & { inset?: boolean }
>(({ className, inset, ...props }, ref) => (
<DropdownMenuPrimitive.Label
ref={ref}
className={cn("px-2 py-1.5 text-xs font-semibold text-grayScale-500", inset && "pl-8", className)}
{...props}
/>
))
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
export const DropdownMenuSeparator = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
>(({ className, ...props }, ref) => (
<DropdownMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-grayScale-200", className)} {...props} />
))
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
export const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
return <span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} />
}

View File

@ -0,0 +1,21 @@
import * as React from "react"
import { cn } from "../../lib/utils"
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
export const Input = React.forwardRef<HTMLInputElement, InputProps>(({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"flex h-10 w-full rounded-lg border bg-white px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-grayScale-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
ref={ref}
{...props}
/>
)
})
Input.displayName = "Input"

View File

@ -0,0 +1,20 @@
import * as React from "react"
import * as SeparatorPrimitive from "@radix-ui/react-separator"
import { cn } from "../../lib/utils"
export const Separator = React.forwardRef<
React.ElementRef<typeof SeparatorPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
>(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => (
<SeparatorPrimitive.Root
ref={ref}
decorative={decorative}
orientation={orientation}
className={cn("shrink-0 bg-grayScale-200", orientation === "horizontal" ? "h-px w-full" : "h-full w-px", className)}
{...props}
/>
))
Separator.displayName = SeparatorPrimitive.Root.displayName

View File

@ -0,0 +1,70 @@
import * as React from "react"
import { cn } from "../../lib/utils"
export const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(
({ className, ...props }, ref) => (
<div className="relative w-full overflow-auto">
<table ref={ref} className={cn("w-full caption-bottom text-sm", className)} {...props} />
</div>
),
)
Table.displayName = "Table"
export const TableHeader = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
({ className, ...props }, ref) => (
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
),
)
TableHeader.displayName = "TableHeader"
export const TableBody = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
({ className, ...props }, ref) => (
<tbody ref={ref} className={cn("[&_tr:last-child]:border-0", className)} {...props} />
),
)
TableBody.displayName = "TableBody"
export const TableFooter = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
({ className, ...props }, ref) => (
<tfoot ref={ref} className={cn("border-t bg-grayScale-100 font-medium", className)} {...props} />
),
)
TableFooter.displayName = "TableFooter"
export const TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>(
({ className, ...props }, ref) => (
<tr
ref={ref}
className={cn("border-b transition-colors hover:bg-grayScale-100/70 data-[state=selected]:bg-grayScale-100", className)}
{...props}
/>
),
)
TableRow.displayName = "TableRow"
export const TableHead = React.forwardRef<HTMLTableCellElement, React.ThHTMLAttributes<HTMLTableCellElement>>(
({ className, ...props }, ref) => (
<th
ref={ref}
className={cn("h-11 px-4 text-left align-middle text-xs font-semibold text-grayScale-500 [&:has([role=checkbox])]:pr-0", className)}
{...props}
/>
),
)
TableHead.displayName = "TableHead"
export const TableCell = React.forwardRef<HTMLTableCellElement, React.TdHTMLAttributes<HTMLTableCellElement>>(
({ className, ...props }, ref) => (
<td ref={ref} className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)} {...props} />
),
)
TableCell.displayName = "TableCell"
export const TableCaption = React.forwardRef<HTMLTableCaptionElement, React.HTMLAttributes<HTMLTableCaptionElement>>(
({ className, ...props }, ref) => (
<caption ref={ref} className={cn("mt-4 text-sm text-muted-foreground", className)} {...props} />
),
)
TableCaption.displayName = "TableCaption"

54
src/index.css Normal file
View File

@ -0,0 +1,54 @@
@import "@fontsource/inter/latin.css";
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
/* primary ~= #9E2891 (brand 500) */
--primary: 312 59% 39%;
--primary-foreground: 0 0% 100%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 100%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 312 59% 39%;
--radius: 14px;
}
* {
@apply border-border;
}
html,
body,
#root {
height: 100%;
}
body {
@apply bg-grayScale-100 text-foreground font-sans antialiased;
}
}

19
src/layouts/AppLayout.tsx Normal file
View File

@ -0,0 +1,19 @@
import { Outlet } from "react-router-dom"
import { Sidebar } from "../components/sidebar/Sidebar"
import { Topbar } from "../components/topbar/Topbar"
export function AppLayout() {
return (
<div className="flex h-full bg-grayScale-100">
<Sidebar />
<div className="flex min-w-0 flex-1 flex-col">
<Topbar />
<main className="min-w-0 flex-1 px-6 pb-8 pt-4">
<Outlet />
</main>
</div>
</div>
)
}

8
src/lib/utils.ts Normal file
View File

@ -0,0 +1,8 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}

13
src/main.tsx Normal file
View File

@ -0,0 +1,13 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { BrowserRouter } from 'react-router-dom'
import './index.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</StrictMode>,
)

260
src/pages/DashboardPage.tsx Normal file
View File

@ -0,0 +1,260 @@
import {
Activity,
BadgeCheck,
Coins,
DollarSign,
TrendingUp,
Users,
} from "lucide-react"
import {
Area,
AreaChart,
Bar,
BarChart,
CartesianGrid,
Cell,
Pie,
PieChart,
ResponsiveContainer,
Tooltip,
XAxis,
YAxis,
} from "recharts"
import { StatCard } from "../components/dashboard/StatCard"
import { Button } from "../components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card"
import { cn } from "../lib/utils"
const userGrowth = [
{ month: "Jan", users: 2400 },
{ month: "Feb", users: 2700 },
{ month: "Mar", users: 3100 },
{ month: "Apr", users: 1900 },
{ month: "May", users: 1900 },
{ month: "Jun", users: 2100 },
{ month: "Jul", users: 2050 },
{ month: "Aug", users: 2900 },
{ month: "Sep", users: 2000 },
{ month: "Oct", users: 2050 },
{ month: "Nov", users: 1850 },
{ month: "Dec", users: 1900 },
]
const subscriptionStatus = [
{ name: "Free Plan", value: 3125, color: "#9E2891" },
{ name: "Monthly Plan", value: 5901, color: "#FFD23F" },
{ name: "3-Month Plan", value: 1203, color: "#1DE9B6" },
{ name: "6-Monthly Plan", value: 825, color: "#C26FC0" },
]
const revenueTrend = [
{ month: "Jan", value: 52000 },
{ month: "Feb", value: 30000 },
{ month: "Mar", value: 50000 },
{ month: "Apr", value: 28000 },
{ month: "May", value: 70000 },
{ month: "Jun", value: 76000 },
]
const ranges = ["1D", "1W", "1M", "3M", "6M", "1Y"] as const
export function DashboardPage() {
const activeRange = "1Y"
return (
<div className="mx-auto w-full max-w-6xl">
<div className="mb-2 text-sm font-semibold text-grayScale-500">Dashboard</div>
<div className="mb-5 text-2xl font-semibold tracking-tight">Welcome, Josh</div>
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-6">
<StatCard
icon={Users}
label="Total Users"
value="12,490"
deltaLabel="-15%"
deltaPositive={false}
/>
<StatCard
icon={BadgeCheck}
label="Active Subscribers"
value="3,200"
deltaLabel="+35%"
deltaPositive
/>
<StatCard
icon={Activity}
label="Monthly Active Users"
value="521"
deltaLabel="+41%"
deltaPositive
/>
<StatCard
icon={DollarSign}
label="Total Revenue (ETB)"
value="927,004"
deltaLabel="-20%"
deltaPositive={false}
/>
<StatCard
icon={Coins}
label="Monthly Revenue (ETB)"
value="81,290"
deltaLabel="+35%"
deltaPositive
/>
<StatCard
icon={TrendingUp}
label="Growth Rate"
value="12.5%"
deltaLabel="+5%"
deltaPositive
/>
</div>
<div className="mt-5 grid gap-4">
<Card className="shadow-none">
<CardHeader className="pb-2">
<div className="flex items-center justify-between gap-3">
<div>
<CardTitle>User Growth</CardTitle>
<div className="mt-1 text-2xl font-semibold tracking-tight">5,730</div>
<div className="text-xs font-medium text-mint-500">Last 12 Months +15.2%</div>
</div>
<div className="flex items-center gap-1 rounded-full bg-grayScale-100 p-1">
{ranges.map((r) => (
<button
key={r}
type="button"
className={cn(
"rounded-full px-3 py-1 text-xs font-semibold text-grayScale-500",
r === activeRange && "bg-brand-500 text-white",
)}
>
{r}
</button>
))}
</div>
</div>
</CardHeader>
<CardContent className="h-[280px] p-6 pt-2">
<ResponsiveContainer width="100%" height="100%">
<AreaChart data={userGrowth} margin={{ left: 8, right: 8, top: 8, bottom: 0 }}>
<defs>
<linearGradient id="fillBrand" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="#9E2891" stopOpacity={0.25} />
<stop offset="100%" stopColor="#9E2891" stopOpacity={0.02} />
</linearGradient>
</defs>
<CartesianGrid vertical={false} stroke="#E0E0E0" strokeDasharray="4 4" />
<XAxis dataKey="month" tickLine={false} axisLine={false} fontSize={12} />
<YAxis tickLine={false} axisLine={false} fontSize={12} width={32} />
<Tooltip
contentStyle={{
borderRadius: 12,
border: "1px solid #E0E0E0",
boxShadow: "0 10px 30px rgba(0,0,0,0.08)",
}}
/>
<Area
type="monotone"
dataKey="users"
stroke="#9E2891"
strokeWidth={2}
fill="url(#fillBrand)"
/>
</AreaChart>
</ResponsiveContainer>
</CardContent>
</Card>
<div className="grid gap-4 lg:grid-cols-2">
<Card className="shadow-none">
<CardHeader className="pb-2">
<div className="flex items-center justify-between">
<CardTitle>Subscription Status</CardTitle>
<div className="rounded-full bg-grayScale-100 px-3 py-1 text-xs font-semibold text-grayScale-500">
Weekly
</div>
</div>
</CardHeader>
<CardContent className="grid gap-4 p-6 pt-2 md:grid-cols-2">
<div className="h-[180px]">
<ResponsiveContainer width="100%" height="100%">
<PieChart>
<Pie
data={subscriptionStatus}
dataKey="value"
nameKey="name"
innerRadius={55}
outerRadius={80}
paddingAngle={2}
>
{subscriptionStatus.map((entry) => (
<Cell key={entry.name} fill={entry.color} />
))}
</Pie>
<Tooltip
contentStyle={{
borderRadius: 12,
border: "1px solid #E0E0E0",
boxShadow: "0 10px 30px rgba(0,0,0,0.08)",
}}
/>
</PieChart>
</ResponsiveContainer>
</div>
<div className="space-y-3">
{subscriptionStatus.map((s) => (
<div key={s.name} className="flex items-center justify-between gap-3 text-sm">
<div className="flex items-center gap-2">
<span className="h-2.5 w-2.5 rounded-full" style={{ backgroundColor: s.color }} />
<span className="text-grayScale-600">{s.name}</span>
</div>
<span className="font-semibold text-grayScale-600">{s.value.toLocaleString()} Users</span>
</div>
))}
</div>
</CardContent>
</Card>
<Card className="shadow-none">
<CardHeader className="pb-2">
<div className="flex items-center justify-between">
<div>
<CardTitle>Revenue Trend</CardTitle>
<div className="mt-2 text-2xl font-semibold tracking-tight">ETB 923,417</div>
<div className="text-xs font-medium text-grayScale-500">Last 6 Months (ETB)</div>
</div>
<Button variant="ghost" className="text-brand-600 hover:text-brand-600">
View Report
</Button>
</div>
</CardHeader>
<CardContent className="h-[220px] p-6 pt-2">
<ResponsiveContainer width="100%" height="100%">
<BarChart data={revenueTrend} margin={{ left: 8, right: 8, top: 8 }}>
<CartesianGrid vertical={false} stroke="#E0E0E0" strokeDasharray="4 4" />
<XAxis dataKey="month" tickLine={false} axisLine={false} fontSize={12} />
<YAxis tickLine={false} axisLine={false} fontSize={12} width={42} />
<Tooltip
formatter={(v) => [`${Number(v).toLocaleString()}`, "ETB"]}
contentStyle={{
borderRadius: 12,
border: "1px solid #E0E0E0",
boxShadow: "0 10px 30px rgba(0,0,0,0.08)",
}}
/>
<Bar dataKey="value" radius={[10, 10, 0, 0]} fill="#9E2891" />
</BarChart>
</ResponsiveContainer>
</CardContent>
</Card>
</div>
</div>
</div>
)
}

View File

@ -0,0 +1,23 @@
import { Link } from "react-router-dom"
import { Button } from "../components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card"
export function NotFoundPage() {
return (
<div className="mx-auto w-full max-w-3xl pt-10">
<Card>
<CardHeader>
<CardTitle>Page not found</CardTitle>
</CardHeader>
<CardContent className="flex items-center justify-between gap-3">
<div className="text-sm text-muted-foreground">The page you requested doesnt exist.</div>
<Button asChild>
<Link to="/dashboard">Go to Dashboard</Link>
</Button>
</CardContent>
</Card>
</div>
)
}

View File

@ -0,0 +1,19 @@
import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card"
export function PlaceholderPage({ title }: { title: string }) {
return (
<div className="mx-auto w-full max-w-6xl">
<div className="mb-4 text-sm font-semibold text-grayScale-500">{title}</div>
<Card>
<CardHeader>
<CardTitle>{title}</CardTitle>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">
This section is scaffolded in the sidebar/routes. We can fill it in next.
</CardContent>
</Card>
</div>
)
}

View File

@ -0,0 +1,17 @@
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"
export function AnalyticsPage() {
return (
<div className="mx-auto w-full max-w-6xl">
<div className="mb-4 text-sm font-semibold text-grayScale-500">Analytics</div>
<Card className="shadow-none">
<CardHeader>
<CardTitle>Analytics</CardTitle>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">Analytics module placeholder.</CardContent>
</Card>
</div>
)
}

View File

@ -0,0 +1,39 @@
import { NavLink, Outlet } from "react-router-dom"
import { cn } from "../../lib/utils"
const tabs = [
{ label: "Overview", to: "/content" },
{ label: "Courses", to: "/content/courses" },
{ label: "Speaking", to: "/content/speaking" },
]
export function ContentManagementLayout() {
return (
<div className="mx-auto w-full max-w-6xl">
<div className="mb-4 text-sm font-semibold text-grayScale-500">Content Management</div>
<div className="mb-4 flex items-center gap-2 rounded-xl border bg-white p-1">
{tabs.map((t) => (
<NavLink
key={t.to}
to={t.to}
end={t.to === "/content"}
className={({ isActive }) =>
cn(
"rounded-lg px-4 py-2 text-sm font-semibold text-grayScale-500 transition",
"hover:text-brand-600",
isActive && "bg-brand-500 text-white hover:text-white",
)
}
>
{t.label}
</NavLink>
))}
</div>
<Outlet />
</div>
)
}

View File

@ -0,0 +1,22 @@
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"
export function ContentOverviewPage() {
return (
<div className="grid gap-4 md:grid-cols-2">
<Card className="shadow-none">
<CardHeader>
<CardTitle>Courses</CardTitle>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">Manage courses content (scaffold).</CardContent>
</Card>
<Card className="shadow-none">
<CardHeader>
<CardTitle>Speaking</CardTitle>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">Manage speaking content (scaffold).</CardContent>
</Card>
</div>
)
}

View File

@ -0,0 +1,14 @@
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"
export function CoursesPage() {
return (
<Card className="shadow-none">
<CardHeader>
<CardTitle>Courses</CardTitle>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">Courses module placeholder.</CardContent>
</Card>
)
}

View File

@ -0,0 +1,14 @@
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"
export function SpeakingPage() {
return (
<Card className="shadow-none">
<CardHeader>
<CardTitle>Speaking</CardTitle>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">Speaking module placeholder.</CardContent>
</Card>
)
}

View File

@ -0,0 +1,17 @@
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"
export function NotificationsPage() {
return (
<div className="mx-auto w-full max-w-6xl">
<div className="mb-4 text-sm font-semibold text-grayScale-500">Notifications</div>
<Card className="shadow-none">
<CardHeader>
<CardTitle>Notifications</CardTitle>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">Notifications module placeholder.</CardContent>
</Card>
</div>
)
}

View File

@ -0,0 +1,17 @@
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"
export function UserLogPage() {
return (
<div className="mx-auto w-full max-w-6xl">
<div className="mb-4 text-sm font-semibold text-grayScale-500">User Log</div>
<Card className="shadow-none">
<CardHeader>
<CardTitle>User Log</CardTitle>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">User Log module placeholder.</CardContent>
</Card>
</div>
)
}

View File

@ -0,0 +1,206 @@
import { ArrowLeft } from "lucide-react"
import { Link, useParams } from "react-router-dom"
import { Badge } from "../../components/ui/badge"
import { Button } from "../../components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"
import { Separator } from "../../components/ui/separator"
import { cn } from "../../lib/utils"
import { useUsersStore } from "../../stores/usersStore"
export function UserDetailPage() {
const { id } = useParams()
const user = useUsersStore((s) => (id ? s.getUserById(id) : undefined))
if (!user) {
return (
<div className="mx-auto w-full max-w-3xl">
<div className="mb-4 text-sm font-semibold text-grayScale-500">User Detail</div>
<Card className="shadow-none">
<CardHeader>
<CardTitle>User not found</CardTitle>
</CardHeader>
<CardContent>
<Button asChild>
<Link to="/users">Back to Users</Link>
</Button>
</CardContent>
</Card>
</div>
)
}
return (
<div>
<div className="mb-4 flex items-center gap-3">
<Link
to="/users"
className="inline-flex items-center gap-2 text-sm font-semibold text-grayScale-500 hover:text-brand-600"
>
<ArrowLeft className="h-4 w-4" />
Back to Users
</Link>
</div>
<div className="mb-4 text-sm font-semibold text-grayScale-500">User Detail</div>
<div className="grid gap-4 lg:grid-cols-3">
<div className="space-y-4 lg:col-span-1">
<Card className="shadow-none">
<CardHeader>
<CardTitle>Basic Information</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="flex items-center gap-3">
<div className="h-12 w-12 rounded-full bg-grayScale-200" />
<div className="min-w-0">
<div className="truncate text-sm font-semibold text-grayScale-600">{user.fullName}</div>
<div className="mt-1 flex items-center gap-2 text-xs text-grayScale-500">
<span>ID: {user.id}</span>
<span className="h-1 w-1 rounded-full bg-grayScale-300" />
<span className="inline-flex items-center gap-1">
<span className={cn("h-2 w-2 rounded-full", user.isActive ? "bg-mint-500" : "bg-grayScale-300")} />
{user.isActive ? "Active" : "Inactive"}
</span>
</div>
</div>
</div>
<Separator />
<div className="space-y-3 text-sm">
<div>
<div className="text-xs font-semibold text-grayScale-400">Phone</div>
<div className="font-medium text-grayScale-600">{user.phone}</div>
</div>
<div>
<div className="text-xs font-semibold text-grayScale-400">Email</div>
<div className="font-medium text-grayScale-600">{user.email}</div>
</div>
<div>
<div className="text-xs font-semibold text-grayScale-400">Region</div>
<div className="font-medium text-grayScale-600">{user.region}</div>
</div>
<div>
<div className="text-xs font-semibold text-grayScale-400">Joined Date</div>
<div className="font-medium text-grayScale-600">{user.joinedDate}</div>
</div>
</div>
</CardContent>
</Card>
<Card className="shadow-none">
<CardHeader className="pb-2">
<div className="flex items-center justify-between">
<CardTitle>Subscription</CardTitle>
<Badge className={cn(user.isActive ? "bg-mint-500" : "bg-destructive")}>
{user.isActive ? "Active" : "Inactive"}
</Badge>
</div>
</CardHeader>
<CardContent className="space-y-4">
<div className="space-y-1">
<div className="text-xs font-semibold text-grayScale-400">Current Plan</div>
<div className="text-sm font-semibold text-grayScale-600">{user.currentPlan}</div>
</div>
<div className="space-y-1">
<div className="text-xs font-semibold text-grayScale-400">Expires On</div>
<div className="flex items-center gap-2 text-sm font-semibold text-grayScale-600">
{user.expiresOn}
<span className="rounded-full bg-gold-100 px-2 py-0.5 text-xs font-semibold text-gold-600">
{user.daysLeftLabel}
</span>
</div>
</div>
<Button className="w-full">Extend Subscription</Button>
<div className="grid grid-cols-2 gap-2">
<Button variant="outline" className="w-full">
Mark as Paid
</Button>
<Button variant="outline" className="w-full">
Cancel
</Button>
</div>
</CardContent>
</Card>
</div>
<div className="space-y-4 lg:col-span-2">
<Card className="shadow-none">
<CardHeader>
<CardTitle>Learning Profile</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="grid gap-4 md:grid-cols-2">
<div>
<div className="text-xs font-semibold text-grayScale-400">Education Level</div>
<div className="mt-1 text-sm font-semibold text-grayScale-600">{user.learningProfile.educationLevel}</div>
</div>
<div>
<div className="text-xs font-semibold text-grayScale-400">Age Group</div>
<div className="mt-1 text-sm font-semibold text-grayScale-600">{user.learningProfile.ageGroup}</div>
</div>
</div>
<div className="flex items-center gap-2 text-sm">
<div className="text-xs font-semibold text-grayScale-400">Current Proficiency</div>
<Badge variant="secondary" className="border-brand-200 bg-brand-100/50 text-brand-600">
{user.learningProfile.currentProficiency}
</Badge>
</div>
<div className="grid gap-4 md:grid-cols-2">
<div>
<div className="text-xs font-semibold text-grayScale-400">Preferred Topic</div>
<div className="mt-1 text-sm font-semibold text-grayScale-600">{user.learningProfile.preferredTopic}</div>
</div>
<div>
<div className="text-xs font-semibold text-grayScale-400">Primary Goal</div>
<div className="mt-2 rounded-lg border bg-white px-3 py-2 text-sm text-grayScale-600">
{user.learningProfile.primaryGoal}
</div>
</div>
</div>
<div>
<div className="text-xs font-semibold text-grayScale-400">Challenges</div>
<div className="mt-2 flex flex-wrap gap-2">
{user.learningProfile.challenges.map((c) => (
<Badge key={c} variant="secondary">
{c}
</Badge>
))}
</div>
</div>
</CardContent>
</Card>
<Card className="shadow-none">
<CardHeader>
<CardTitle>Recent Activity</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
{user.recentActivity.map((a) => (
<div key={a.id} className="flex items-start gap-3">
<span
className={cn(
"mt-1 h-2.5 w-2.5 rounded-full",
a.dotColor === "brand" ? "bg-brand-500" : "bg-grayScale-300",
)}
/>
<div className="min-w-0">
<div className="text-sm font-semibold text-grayScale-600">{a.text}</div>
<div className="text-xs text-grayScale-400">{a.time}</div>
</div>
</div>
))}
</CardContent>
</Card>
</div>
</div>
</div>
)
}

View File

@ -0,0 +1,12 @@
import { Outlet } from "react-router-dom"
export function UserManagementLayout() {
return (
<div className="mx-auto w-full max-w-6xl">
<div className="mb-4 text-sm font-semibold text-grayScale-500">User Management</div>
<Outlet />
</div>
)
}

View File

@ -0,0 +1,169 @@
import { Eye, Search } from "lucide-react"
import { useMemo, useState } from "react"
import { Link } from "react-router-dom"
import { Badge } from "../../components/ui/badge"
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"
import { Input } from "../../components/ui/input"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../../components/ui/table"
import { cn } from "../../lib/utils"
import type { SubscriptionType, User } from "../../stores/usersStore"
import { useUsersStore } from "../../stores/usersStore"
function subscriptionVariant(sub: SubscriptionType) {
switch (sub) {
case "Monthly":
return "warning"
case "Free":
return "secondary"
case "Expired":
return "destructive"
case "3-Month":
return "success"
case "6-Month":
return "info"
default:
return "default"
}
}
export function UsersListPage() {
const [page, setPage] = useState(1)
const search = useUsersStore((s) => s.search)
const region = useUsersStore((s) => s.region)
const subscription = useUsersStore((s) => s.subscription)
const allUsers = useUsersStore((s) => s.users)
const setSearch = useUsersStore((s) => s.setSearch)
const setRegion = useUsersStore((s) => s.setRegion)
const setSubscription = useUsersStore((s) => s.setSubscription)
const getFilteredUsers = useUsersStore((s) => s.getFilteredUsers)
const users = getFilteredUsers()
const pageSize = 10
const pageCount = Math.max(1, Math.ceil(users.length / pageSize))
const safePage = Math.min(page, pageCount)
const start = (safePage - 1) * pageSize
const end = safePage * pageSize
const paged = users.slice(start, end)
const regions = useMemo(() => Array.from(new Set(allUsers.map((u) => u.region))).sort(), [allUsers])
return (
<Card className="shadow-none">
<CardHeader className="pb-3">
<CardTitle>User Management</CardTitle>
<div className="mt-3 flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
<div className="relative w-full md:max-w-sm">
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-grayScale-400" />
<Input
placeholder="Search by name, phone number"
className="pl-9"
value={search}
onChange={(e) => setSearch(e.target.value)}
/>
</div>
<div className="flex flex-wrap items-center gap-2">
<select
value={region}
onChange={(e) => setRegion(e.target.value)}
className={cn(
"h-10 rounded-lg border bg-white px-3 text-sm font-medium text-grayScale-600",
"focus:outline-none focus:ring-2 focus:ring-ring",
)}
>
<option value="All">Region</option>
{regions.map((r) => (
<option key={r} value={r}>
{r}
</option>
))}
</select>
<select
value={subscription}
onChange={(e) => setSubscription(e.target.value as SubscriptionType | "All")}
className={cn(
"h-10 rounded-lg border bg-white px-3 text-sm font-medium text-grayScale-600",
"focus:outline-none focus:ring-2 focus:ring-ring",
)}
>
<option value="All">Subscription</option>
<option value="Monthly">Monthly</option>
<option value="Free">Free</option>
<option value="Expired">Expired</option>
<option value="3-Month">3-Month</option>
<option value="6-Month">6-Month</option>
</select>
</div>
</div>
</CardHeader>
<CardContent className="p-0">
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-[40%]">Full Name</TableHead>
<TableHead>Phone Number</TableHead>
<TableHead>Region</TableHead>
<TableHead>Last Active</TableHead>
<TableHead>Subscription</TableHead>
<TableHead className="w-[56px]" />
</TableRow>
</TableHeader>
<TableBody>
{paged.map((u: User) => (
<TableRow key={u.id}>
<TableCell className="font-medium text-grayScale-600">{u.fullName}</TableCell>
<TableCell className="text-grayScale-500">{u.phone}</TableCell>
<TableCell className="text-grayScale-500">{u.region}</TableCell>
<TableCell className="text-grayScale-500">{u.lastActive}</TableCell>
<TableCell>
<Badge variant={subscriptionVariant(u.subscription)}>{u.subscription}</Badge>
</TableCell>
<TableCell className="text-right">
<Link
to={`/users/${u.id}`}
className="inline-flex h-9 w-9 items-center justify-center rounded-lg border bg-white text-grayScale-500 hover:text-brand-600"
aria-label="View user"
>
<Eye className="h-4 w-4" />
</Link>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
<div className="flex flex-wrap items-center justify-between gap-3 border-t px-4 py-3 text-xs text-grayScale-500">
<div className="flex items-center gap-2">
Row Per Page
<span className="rounded-md border bg-white px-2 py-1 font-semibold text-grayScale-600">{pageSize}</span>
Entries
</div>
<div className="flex items-center gap-1">
{[1, 2, 3, 4].map((n) => (
<button
key={n}
type="button"
onClick={() => setPage(n)}
className={cn(
"h-8 w-8 rounded-md border bg-white text-xs font-semibold text-grayScale-500",
n === safePage && "border-brand-200 bg-brand-100/40 text-brand-600",
)}
>
{n}
</button>
))}
<span className="px-2"></span>
<button type="button" className="h-8 w-10 rounded-md border bg-white font-semibold">
15
</button>
</div>
</div>
</CardContent>
</Card>
)
}

142
src/stores/usersStore.ts Normal file
View File

@ -0,0 +1,142 @@
import { create } from "zustand"
export type SubscriptionType = "Monthly" | "Free" | "Expired" | "3-Month" | "6-Month"
export type UserActivity = {
id: string
text: string
time: string
dotColor: "brand" | "muted"
}
export type User = {
id: string
fullName: string
phone: string
region: string
lastActive: string
subscription: SubscriptionType
email: string
joinedDate: string
learningProfile: {
educationLevel: string
ageGroup: string
currentProficiency: string
preferredTopic: string
primaryGoal: string
challenges: string[]
}
currentPlan: string
expiresOn: string
daysLeftLabel: string
isActive: boolean
recentActivity: UserActivity[]
}
const MOCK_USERS: User[] = [
{
id: "u_1001",
fullName: "Richard Wilson",
phone: "(555) 123-4567",
region: "Addis Ababa",
lastActive: "24 Dec 2024",
subscription: "6-Month",
email: "contact@capitalflow.com",
joinedDate: "Oct 12, 2024",
learningProfile: {
educationLevel: "Undergraduate Student",
ageGroup: "18-24 Years",
currentProficiency: "Intermediate (B2)",
preferredTopic: "Business, Travel, Culture",
primaryGoal: "To achieve fluency for business communication in an international company",
challenges: ["Speaking Confidence", "Vocabulary Retention"],
},
currentPlan: "6-Month",
expiresOn: "Nov 13, 2025",
daysLeftLabel: "65 days left",
isActive: true,
recentActivity: [
{ id: "a1", text: "Completed Unit 4: Business Emails", time: "Today, 10:27 AM", dotColor: "brand" },
{ id: "a2", text: "Started new course: Advanced English", time: "Today, 7:20 AM", dotColor: "muted" },
{ id: "a3", text: "Started new course: Advanced English", time: "Today, 7:20 AM", dotColor: "muted" },
],
},
...Array.from({ length: 14 }).map((_, idx) => {
const i = idx + 1
const sub: SubscriptionType[] = ["Monthly", "Free", "Expired", "3-Month", "6-Month"]
const subscription = sub[i % sub.length]!
return {
id: `u_10${10 + i}`,
fullName: "Abebe Kebede",
phone: "+251912345678",
region: "Addis Ababa",
lastActive: "24 Dec 2024",
subscription,
email: "abebe@example.com",
joinedDate: "Sep 02, 2024",
learningProfile: {
educationLevel: "High School",
ageGroup: "18-24 Years",
currentProficiency: "Beginner (A2)",
preferredTopic: "General English",
primaryGoal: "Improve daily conversation skills",
challenges: ["Listening", "Pronunciation"],
},
currentPlan: subscription,
expiresOn: "Nov 13, 2025",
daysLeftLabel: "65 days left",
isActive: subscription !== "Expired",
recentActivity: [
{ id: "a1", text: "Completed Lesson 2", time: "Today, 9:00 AM", dotColor: "brand" },
{ id: "a2", text: "Started new course: English Basics", time: "Yesterday, 7:20 AM", dotColor: "muted" },
],
} satisfies User
}),
]
type UsersState = {
users: User[]
search: string
region: string
subscription: SubscriptionType | "All"
setSearch: (value: string) => void
setRegion: (value: string) => void
setSubscription: (value: UsersState["subscription"]) => void
getUserById: (id: string) => User | undefined
getFilteredUsers: () => User[]
}
export const useUsersStore = create<UsersState>((set, get) => ({
users: MOCK_USERS,
search: "",
region: "All",
subscription: "All",
setSearch: (value) => set({ search: value }),
setRegion: (value) => set({ region: value }),
setSubscription: (value) => set({ subscription: value }),
getUserById: (id) => get().users.find((u) => u.id === id),
getFilteredUsers: () => {
const { users, search, region, subscription } = get()
const q = search.trim().toLowerCase()
return users.filter((u) => {
const matchesQuery =
q.length === 0 ||
u.fullName.toLowerCase().includes(q) ||
u.phone.toLowerCase().includes(q) ||
u.region.toLowerCase().includes(q)
const matchesRegion = region === "All" || u.region === region
const matchesSub = subscription === "All" || u.subscription === subscription
return matchesQuery && matchesRegion && matchesSub
})
},
}))

86
tailwind.config.js Normal file
View File

@ -0,0 +1,86 @@
/** @type {import('tailwindcss').Config} */
export default {
darkMode: ["class"],
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {
fontFamily: {
sans: ["Inter", "ui-sans-serif", "system-ui", "sans-serif"],
},
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
brand: {
50: "#5E1F70",
100: "#E7C5E4",
200: "#D69AD3",
300: "#C26FC0",
400: "#A94EAA",
500: "#9E2891",
600: "#6A1B9A",
},
gold: {
100: "#FFF6CC",
300: "#FFE480",
500: "#FFD23F",
600: "#E6BE2F",
},
mint: {
100: "#D6FCF0",
300: "#7CF3D0",
500: "#1DE9B6",
},
grayScale: {
50: "#FFFFFF",
100: "#F5F5F5",
200: "#E0E0E0",
300: "#BDBDBD",
400: "#9E9E9E",
500: "#757575",
600: "#616161",
},
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
boxShadow: {
soft: "0 8px 24px rgba(0,0,0,0.06)",
},
},
},
plugins: [],
}

28
tsconfig.app.json Normal file
View File

@ -0,0 +1,28 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}

7
tsconfig.json Normal file
View File

@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}

26
tsconfig.node.json Normal file
View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"types": ["node"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}

7
vite.config.ts Normal file
View File

@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
})