Merge branch 'el-ui' into main.

Prefer el-ui changes when resolving conflicts.
This commit is contained in:
Yared Yemane 2026-07-13 08:40:28 -07:00
commit 7e4c3fd3b9
52 changed files with 1970 additions and 1495 deletions

1
.gitignore vendored
View File

@ -27,3 +27,4 @@ dist-ssr
*.sw?
AGENTS.md
design-system.md
.opencode/

View File

@ -70,7 +70,7 @@ export function NotificationDeleteDialog({
<p className="text-xs text-grayScale-500">#{notification.id}</p>
</div>
) : null}
<DialogFooter className="gap-2 sm:gap-2">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
variant="outline"
disabled={deleting}

View File

@ -1,34 +1,35 @@
import { Badge } from "../ui/badge"
import { Button } from "../ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "../ui/dialog"
import { SpinnerIcon } from "../ui/spinner-icon"
import { useState } from "react";
import { Bell } from "lucide-react";
import { Badge } from "../ui/badge";
import { Button } from "../ui/button";
import { Dialog, DialogContent, DialogTitle } from "../ui/dialog";
import { SpinnerIcon } from "../ui/spinner-icon";
import {
DEFAULT_NOTIFICATION_TYPE_CONFIG,
formatNotificationDateTime,
formatNotificationTimestamp,
formatNotificationTypeLabel,
getNotificationLevelBadge,
isMeaningfulExpiry,
NOTIFICATION_TYPE_CONFIG,
} from "../../lib/notificationDisplay"
import { getNotificationMessage, getNotificationTitle, type Notification } from "../../types/notification.types"
} from "../../lib/notificationDisplay";
import {
getNotificationMessage,
getNotificationTitle,
type Notification,
} from "../../types/notification.types";
import { cn } from "../../lib/utils";
type NotificationDetailDialogProps = {
open: boolean
onOpenChange: (open: boolean) => void
notification: Notification | null
loading?: boolean
error?: boolean
onRetry?: () => void
onDelete?: () => void
}
open: boolean;
onOpenChange: (open: boolean) => void;
notification: Notification | null;
loading?: boolean;
error?: boolean;
onRetry?: () => void;
onDelete?: () => void;
};
type Tab = "details" | "preview";
export function NotificationDetailDialog({
open,
@ -39,142 +40,258 @@ export function NotificationDetailDialog({
onRetry,
onDelete,
}: NotificationDetailDialogProps) {
const [tab, setTab] = useState<Tab>("details");
const config = notification
? NOTIFICATION_TYPE_CONFIG[notification.type] ?? DEFAULT_NOTIFICATION_TYPE_CONFIG
: DEFAULT_NOTIFICATION_TYPE_CONFIG
const Icon = config.icon
? (NOTIFICATION_TYPE_CONFIG[notification.type] ??
DEFAULT_NOTIFICATION_TYPE_CONFIG)
: DEFAULT_NOTIFICATION_TYPE_CONFIG;
const Icon = config.icon;
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-lg">
<DialogContent className="max-w-lg gap-0 overflow-hidden rounded-2xl border-0 p-0 shadow-[0_25px_60px_-12px_rgba(0,0,0,0.25)]">
{loading ? (
<div className="flex flex-col items-center justify-center gap-3 py-12">
<div className="flex flex-col items-center justify-center gap-3 py-20">
<SpinnerIcon className="h-8 w-8 text-brand-500" />
<p className="text-sm text-grayScale-500">Loading notification…</p>
<p className="text-sm text-grayScale-500">Loading…</p>
</div>
) : error ? (
<div className="flex flex-col items-center justify-center gap-3 py-12 text-center">
<p className="text-sm font-medium text-grayScale-700">Could not load notification</p>
{onRetry ? (
<Button variant="outline" size="sm" onClick={onRetry}>
<div className="flex flex-col items-center justify-center gap-4 py-20 text-center">
<div className="grid h-14 w-14 place-items-center rounded-2xl bg-grayScale-100">
<Bell className="h-7 w-7 text-grayScale-300" />
</div>
<div>
<p className="text-sm font-semibold text-grayScale-700">
Could not load
</p>
<p className="mt-1 text-xs text-grayScale-400">
Content may have been removed.
</p>
</div>
{onRetry && (
<Button
variant="outline"
size="sm"
className="rounded-lg"
onClick={onRetry}
>
Try again
</Button>
) : null}
)}
</div>
) : notification ? (
<>
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<span
className={`inline-flex h-8 w-8 items-center justify-center rounded-lg ${config.bg} ${config.color}`}
{/* Hero header */}
<div className="relative px-6 pt-6 pb-4 pr-14">
<div
className={cn(
"absolute left-6 top-5 h-12 w-12 rounded-2xl opacity-20 blur-xl",
config.bg,
)}
/>
<div className="relative flex items-start gap-3.5">
<div
className={cn(
"grid h-12 w-12 shrink-0 place-items-center rounded-2xl",
config.bg,
config.color,
)}
>
<Icon className="h-4 w-4" />
</span>
<span className="truncate text-base">
{getNotificationTitle(notification) || "Notification"}
</span>
</DialogTitle>
<DialogDescription>
Sent via {notification.delivery_channel || "in-app"} ·{" "}
{formatNotificationTimestamp(notification.timestamp)}
</DialogDescription>
</DialogHeader>
<div className="space-y-4">
{notification.image ? (
<div className="overflow-hidden rounded-lg border border-grayScale-200 bg-grayScale-50">
<img
src={notification.image}
alt=""
className="max-h-48 w-full object-cover"
/>
<Icon className="h-6 w-6" />
</div>
<div className="min-w-0 flex-1 pt-0.5">
<DialogTitle className="text-base font-bold leading-snug text-grayScale-900">
{getNotificationTitle(notification) || "Notification"}
</DialogTitle>
<div className="mt-1.5 flex items-center gap-1.5 text-xs text-grayScale-400">
<span className="capitalize">
{notification.delivery_channel}
</span>
<span className="text-grayScale-200">·</span>
<span>
{formatNotificationTimestamp(notification.timestamp)}
</span>
</div>
</div>
) : null}
<div className="rounded-lg bg-grayScale-50 p-3">
<p className="text-sm leading-relaxed text-grayScale-600">
{getNotificationMessage(notification) || "No message content."}
</p>
</div>
<div className="grid gap-3 text-xs text-grayScale-500 sm:grid-cols-2">
<div>
<p className="text-grayScale-400">Type</p>
<p className="mt-0.5 font-medium text-grayScale-700">
{formatNotificationTypeLabel(notification.type)}
</p>
</div>
<div>
<p className="text-grayScale-400">Level</p>
<div className="mt-0.5">
<Badge variant={getNotificationLevelBadge(notification.level)} className="text-[10px]">
{notification.level || "—"}
</Badge>
</div>
</div>
<div>
<p className="text-grayScale-400">Channel</p>
<p className="mt-0.5 font-medium capitalize text-grayScale-700">
{notification.delivery_channel || "—"}
</p>
</div>
<div>
<p className="text-grayScale-400">Delivery status</p>
<p className="mt-0.5 font-medium text-grayScale-700">
{notification.delivery_status || "—"}
</p>
</div>
<div>
<p className="text-grayScale-400">Read status</p>
<p className="mt-0.5 font-medium text-grayScale-700">
{notification.is_read ? "Read" : "Unread"}
</p>
</div>
{notification.receiver_type ? (
<div>
<p className="text-grayScale-400">Receiver</p>
<p className="mt-0.5 font-medium capitalize text-grayScale-700">
{notification.receiver_type}
</p>
</div>
) : null}
<div className="sm:col-span-2">
<p className="text-grayScale-400">Sent at</p>
<p className="mt-0.5 font-medium text-grayScale-700">
{formatNotificationDateTime(notification.timestamp)}
</p>
</div>
{isMeaningfulExpiry(notification.expires) ? (
<div className="sm:col-span-2">
<p className="text-grayScale-400">Expires</p>
<p className="mt-0.5 font-medium text-grayScale-700">
{formatNotificationDateTime(notification.expires)}
</p>
</div>
) : null}
</div>
{notification.payload.tags && notification.payload.tags.length > 0 ? (
<div className="flex flex-wrap gap-2">
{notification.payload.tags.map((tag) => (
<Badge key={tag} variant="secondary" className="text-[10px]">
{tag}
</Badge>
))}
</div>
) : null}
</div>
{onDelete ? (
<DialogFooter className="gap-2 sm:gap-2">
<Button variant="destructive" onClick={onDelete}>
Delete notification
</Button>
</DialogFooter>
) : null}
{/* Tabs */}
<div className="flex border-b border-grayScale-100 px-6">
{[
{ key: "details" as const, label: "Details" },
{ key: "preview" as const, label: "Preview" },
].map((t) => (
<button
key={t.key}
type="button"
onClick={() => setTab(t.key)}
className={cn(
"relative px-3 pb-2.5 text-xs font-semibold transition-colors",
tab === t.key
? "text-brand-600"
: "text-grayScale-400 hover:text-grayScale-600",
)}
>
{t.label}
{tab === t.key && (
<span className="absolute inset-x-0 bottom-0 h-[2px] rounded-full bg-brand-500" />
)}
</button>
))}
</div>
{/* Tab content */}
<div className="px-6 pb-8 pt-5">
{tab === "details" ? (
<DetailsTab notification={notification} onDelete={onDelete} />
) : (
<PreviewTab
notification={notification}
config={config}
Icon={Icon}
/>
)}
</div>
</>
) : null}
</DialogContent>
</Dialog>
)
);
}
function DetailsTab({
notification,
onDelete,
}: {
notification: Notification;
onDelete?: () => void;
}) {
return (
<div className="space-y-5">
{/* Message */}
{/* Image */}
{notification.image && (
<div className="overflow-hidden rounded-xl">
<img
src={notification.image}
alt=""
className="max-h-48 w-full object-cover"
/>
</div>
)}
{/* Metadata */}
<div className="space-y-0 divide-y divide-grayScale-100">
{[
{ k: "Type", v: formatNotificationTypeLabel(notification.type) },
{ k: "Channel", v: notification.delivery_channel || "—" },
{ k: "Status", v: notification.is_read ? "Read" : "Unread" },
{ k: "Delivery", v: notification.delivery_status || "—" },
...(notification.receiver_type
? [{ k: "Receiver", v: notification.receiver_type }]
: []),
{ k: "Sent", v: formatNotificationDateTime(notification.timestamp) },
...(isMeaningfulExpiry(notification.expires)
? [
{
k: "Expires",
v: formatNotificationDateTime(notification.expires),
},
]
: []),
].map((row) => (
<div
key={row.k}
className="flex items-baseline justify-between py-2.5 first:pt-0 last:pb-0"
>
<span className="text-xs text-grayScale-400">{row.k}</span>
<span className="text-xs font-medium text-grayScale-600">
{row.v}
</span>
</div>
))}
</div>
{/* Tags */}
{notification.payload.tags && notification.payload.tags.length > 0 && (
<div className="flex flex-wrap gap-1.5">
{notification.payload.tags.map((tag) => (
<Badge
key={tag}
variant="secondary"
className="text-[10px] px-2 py-0.5"
>
{tag}
</Badge>
))}
</div>
)}
{/* Actions */}
{onDelete && (
<div className="border-t border-grayScale-100 pt-4">
<Button
size="sm"
className="h-9 rounded-lg bg-destructive px-4 text-xs font-medium text-white hover:bg-destructive/90"
onClick={onDelete}
>
Delete notification
</Button>
</div>
)}
</div>
);
}
function PreviewTab({
notification,
config,
Icon,
}: {
notification: Notification;
config: { bg: string; color: string };
Icon: React.ComponentType<{ className?: string }>;
}) {
const title = getNotificationTitle(notification) || "Notification";
const message = getNotificationMessage(notification) || "";
return (
<div className="space-y-4">
{/* Full content preview */}
<div className="rounded-xl border border-grayScale-100 bg-grayScale-50/50 px-4 py-4">
<p className="text-[11px] font-semibold uppercase tracking-wide text-grayScale-400">
Full content
</p>
<h3 className="mt-2 text-sm font-semibold text-grayScale-900">
{title}
</h3>
{message ? (
<p className="mt-1.5 whitespace-pre-wrap text-xs leading-relaxed text-grayScale-600">
{message}
</p>
) : (
<p className="mt-1.5 text-xs text-grayScale-400 italic">
No message content.
</p>
)}
{notification.payload.tags && notification.payload.tags.length > 0 && (
<div className="mt-3 flex flex-wrap gap-1.5">
{notification.payload.tags.map((tag) => (
<Badge
key={tag}
variant="secondary"
className="text-[10px] px-2 py-0.5"
>
{tag}
</Badge>
))}
</div>
)}
</div>
</div>
);
}

View File

@ -356,11 +356,12 @@ export function Sidebar({
onClick={onClose}
className={({ isActive }) =>
cn(
"group flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium text-grayScale-600 transition",
"relative group flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium text-grayScale-600 transition",
isCollapsed && "justify-center gap-0 p-2",
"hover:bg-grayScale-100 hover:text-brand-600 dark:text-grayScale-400 dark:hover:bg-white/5 dark:hover:text-brand-400",
isActive &&
"bg-brand-500/50 text-brand-600 hover:bg-brand-500/50 hover:text-brand-600 dark:bg-brand-500/30 dark:text-brand-400 dark:hover:bg-brand-500/30 dark:hover:text-brand-400",
"bg-brand-500/10 hover:bg-brand-500/10 dark:bg-brand-500/15 dark:hover:bg-brand-500/15",
isActive ? "text-[#000] dark:text-white" : "",
)
}
title={isCollapsed ? entry.label : undefined}
@ -370,13 +371,24 @@ export function Sidebar({
<span
className={cn(
"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-grayScale-50 text-grayScale-500 transition dark:bg-grayScale-200/10 dark:text-grayScale-400",
isActive && "bg-brand-500/20 text-brand-600 dark:bg-brand-500/20 dark:text-brand-400",
isActive &&
"bg-brand-500 text-white dark:bg-brand-500 dark:text-white",
)}
>
<Icon className="h-4 w-4" />
</span>
{!isCollapsed && (
<span className="truncate">{entry.label}</span>
<span
className={cn(
"truncate",
isActive ? "text-[#000]/80 dark:text-white" : "",
)}
>
{entry.label}
</span>
)}
{isActive && (
<span className="absolute right-1.5 top-1/2 -translate-y-1/2 h-5 w-[3px] rounded-full bg-brand-500" />
)}
</>
)}

View File

@ -1,5 +1,11 @@
import { ChevronDown } from "lucide-react";
import { type ComponentType, type ReactNode, useEffect, useId, useState } from "react";
import {
type ComponentType,
type ReactNode,
useEffect,
useId,
useState,
} from "react";
import { NavLink, useLocation } from "react-router-dom";
import { cn } from "../../lib/utils";
@ -34,7 +40,9 @@ export function SidebarNavGroup({
const location = useLocation();
const panelId = useId();
const paths = activePaths?.length ? activePaths : [basePath];
const isSectionActive = paths.some((path) => location.pathname.startsWith(path));
const isSectionActive = paths.some((path) =>
location.pathname.startsWith(path),
);
const [expanded, setExpanded] = useState(isSectionActive);
useEffect(() => {
@ -51,10 +59,10 @@ export function SidebarNavGroup({
onClick={onNavigate}
className={({ isActive }) =>
cn(
"group flex items-center justify-center rounded-lg p-2 text-sm font-medium text-grayScale-600 transition",
"relative group flex items-center justify-center rounded-lg p-2 text-sm font-medium text-grayScale-600 transition",
"hover:bg-grayScale-100 hover:text-brand-600 dark:text-grayScale-400 dark:hover:bg-white/5 dark:hover:text-brand-400",
isActive &&
"bg-brand-500/50 text-brand-600 hover:bg-brand-500/50 hover:text-brand-600 dark:bg-brand-500/30 dark:text-brand-400 dark:hover:bg-brand-500/30 dark:hover:text-brand-400",
"bg-brand-500/10 text-brand-600 hover:bg-brand-500/10 hover:text-brand-600 dark:bg-brand-500/15 dark:text-brand-400 dark:hover:bg-brand-500/15 dark:hover:text-brand-400",
)
}
title={label}
@ -63,7 +71,8 @@ export function SidebarNavGroup({
<span
className={cn(
"relative flex h-9 w-9 items-center justify-center rounded-lg bg-grayScale-50 text-grayScale-500 transition dark:bg-grayScale-200/10 dark:text-grayScale-400",
isActive && "bg-brand-500/20 text-brand-600 dark:bg-brand-500/20 dark:text-brand-400",
isActive &&
"bg-brand-500 text-white dark:bg-brand-500 dark:text-white",
)}
>
<Icon className="h-4 w-4" />
@ -82,20 +91,29 @@ export function SidebarNavGroup({
aria-controls={panelId}
onClick={() => setExpanded((open) => !open)}
className={cn(
"group flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium text-grayScale-600 transition",
"relative group flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium text-grayScale-600 transition",
"hover:bg-grayScale-100 hover:text-brand-600 dark:text-grayScale-400 dark:hover:bg-white/5 dark:hover:text-brand-400",
isSectionActive && "text-brand-600 dark:text-brand-400",
isSectionActive &&
"bg-brand-500/10 text-black dark:bg-brand-500/15 dark:text-white",
)}
>
<span
className={cn(
"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-grayScale-50 text-grayScale-500 transition dark:bg-grayScale-200/10 dark:text-grayScale-400",
isSectionActive && "bg-brand-500/20 text-brand-600 dark:bg-brand-500/20 dark:text-brand-400",
isSectionActive &&
"bg-brand-500 text-white dark:bg-brand-500 dark:text-white",
)}
>
<Icon className="h-4 w-4" />
</span>
<span className="min-w-0 flex-1 truncate">{label}</span>
<span
className={cn(
"min-w-0 flex-1 truncate",
isSectionActive ? "text-[#000]/80 dark:text-white" : "",
)}
>
{label}
</span>
{trailing}
<ChevronDown
className={cn(
@ -103,6 +121,9 @@ export function SidebarNavGroup({
expanded && "rotate-180",
)}
/>
{isSectionActive && (
<span className="absolute right-1.5 top-1/2 -translate-y-1/2 h-5 w-[3px] rounded-full bg-brand-500" />
)}
</button>
<div
@ -124,7 +145,7 @@ export function SidebarNavGroup({
cn(
"block rounded-lg px-3 py-1.5 text-sm font-medium transition",
isActive
? "bg-brand-500/50 text-brand-600 font-medium hover:bg-brand-500/50 hover:text-brand-600 dark:bg-brand-500/30 dark:text-brand-400 dark:hover:bg-brand-500/30 dark:hover:text-brand-400"
? "bg-brand-500/10 text-black font-medium hover:bg-brand-500/10 hover:text-black dark:bg-brand-500/15 dark:text-white dark:hover:bg-brand-500/15 dark:hover:text-white"
: "text-grayScale-500 hover:bg-grayScale-100 hover:text-brand-600 dark:text-grayScale-400 dark:hover:bg-white/5 dark:hover:text-brand-400",
)
}

View File

@ -38,8 +38,8 @@ const DialogContent = React.forwardRef<
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 z-10 rounded-sm opacity-60 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-5 w-5" />
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-md p-1 opacity-40 transition-opacity hover:opacity-70 disabled:pointer-events-none">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>

View File

@ -112,9 +112,7 @@
:is(
.bg-brand-50,
.bg-brand-500,
.bg-brand-600,
[class*="bg-brand-500/"],
[class*="bg-brand-600/"]
.bg-brand-600
) {
@apply text-white;
}
@ -122,9 +120,7 @@
:is(
.bg-brand-50,
.bg-brand-500,
.bg-brand-600,
[class*="bg-brand-500/"],
[class*="bg-brand-600/"]
.bg-brand-600
)
:is(.text-brand-500, .text-brand-600, .text-brand-700, .text-brand-800) {
@apply text-white;
@ -133,9 +129,7 @@
:is(
.bg-brand-50,
.bg-brand-500,
.bg-brand-600,
[class*="bg-brand-500/"],
[class*="bg-brand-600/"]
.bg-brand-600
)
svg:not([class*="text-"]) {
@apply text-white;

View File

@ -1,111 +1,132 @@
import { useEffect, useState } from "react"
import { useEffect, useState } from "react";
import { Pencil, User } from "lucide-react";
import { toast } from "sonner";
import { notifyApiError } from "../lib/apiErrors";
import { getTeamMe, updateTeamMe } from "../api/team.api";
import { Badge } from "../components/ui/badge";
import { Button } from "../components/ui/button";
import {
BadgeCheck,
CalendarDays,
Clock3,
Mail,
Phone,
Shield,
User,
} from "lucide-react"
import { toast } from "sonner"
import { notifyApiError } from "../lib/apiErrors"
import { getTeamMe, updateTeamMe } from "../api/team.api"
import { Badge } from "../components/ui/badge"
import { Button } from "../components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card"
Card,
CardContent,
CardHeader,
CardTitle,
} from "../components/ui/card";
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogDescription,
DialogTitle,
} from "../components/ui/dialog"
import { Input } from "../components/ui/input"
import { SpinnerIcon } from "../components/ui/spinner-icon"
import { Textarea } from "../components/ui/textarea"
import { cn } from "../lib/utils"
import type { TeamMeProfile } from "../types/team.types"
import { ProfileAvatarUpload } from "../components/profile/ProfileAvatarUpload"
import { PersonaProfilePictureUploadField } from "./personas/components/PersonaProfilePictureUploadField"
} from "../components/ui/dialog";
import { Input } from "../components/ui/input";
import { SpinnerIcon } from "../components/ui/spinner-icon";
import { Textarea } from "../components/ui/textarea";
import { cn } from "../lib/utils";
import type { TeamMeProfile } from "../types/team.types";
import { ProfileAvatarUpload } from "../components/profile/ProfileAvatarUpload";
import { PersonaProfilePictureUploadField } from "./personas/components/PersonaProfilePictureUploadField";
function formatDate(dateStr: string | null | undefined): string {
if (!dateStr) return "—"
const date = new Date(dateStr)
if (Number.isNaN(date.getTime())) return dateStr
if (!dateStr) return "—";
const date = new Date(dateStr);
if (Number.isNaN(date.getTime())) return dateStr;
return date.toLocaleDateString(undefined, {
year: "numeric",
month: "long",
day: "numeric",
})
});
}
function formatDateTime(dateStr: string | null | undefined): string {
if (!dateStr) return "—"
const date = new Date(dateStr)
if (Number.isNaN(date.getTime())) return dateStr
if (!dateStr) return "—";
const date = new Date(dateStr);
if (Number.isNaN(date.getTime())) return dateStr;
return date.toLocaleString(undefined, {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
})
});
}
function formatRoleLabel(role: string): string {
const value = role.trim()
if (!value) return "—"
const value = role.trim();
if (!value) return "—";
return value
.split("_")
.map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
.join(" ")
}
function formatStatusLabel(status: string): string {
const value = status.trim()
if (!value) return "—"
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase()
.join(" ");
}
function displayValue(value: string | null | undefined): string {
const trimmed = value?.trim()
return trimmed ? trimmed : "—"
const trimmed = value?.trim();
return trimmed ? trimmed : "—";
}
function ReadOnlyField({ label, value }: { label: string; value: string }) {
function FieldGroup({
label,
value,
mono,
}: {
label: string;
value: string;
mono?: boolean;
}) {
return (
<div>
<p className="mb-1 text-xs font-medium text-grayScale-500">{label}</p>
<p className="text-sm font-medium text-grayScale-700">{value}</p>
<div className="space-y-1.5">
<p className="text-xs font-medium text-grayScale-400">{label}</p>
<p
className={cn(
"text-sm font-medium text-grayScale-900",
mono && "font-mono text-xs",
)}
>
{value}
</p>
</div>
)
);
}
function SectionCard({
title,
children,
}: {
title: string;
children: React.ReactNode;
}) {
return (
<Card className="border border-grayScale-100 shadow-none">
<CardHeader className="pb-3">
<CardTitle className="text-[15px] font-semibold text-grayScale-900">
{title}
</CardTitle>
</CardHeader>
<CardContent className="pt-0">{children}</CardContent>
</Card>
);
}
function LoadingSkeleton() {
return (
<div className="mx-auto w-full max-w-5xl space-y-6 py-8">
<div className="mx-auto w-full max-w-3xl space-y-6 py-8">
<div className="h-8 w-48 animate-pulse rounded-lg bg-grayScale-100" />
<div className="h-40 animate-pulse rounded-2xl bg-grayScale-100" />
<div className="grid gap-6 md:grid-cols-2">
{[1, 2].map((item) => (
<div key={item} className="h-56 animate-pulse rounded-2xl bg-grayScale-100" />
))}
</div>
<div className="h-28 animate-pulse rounded-xl bg-grayScale-100" />
<div className="h-48 animate-pulse rounded-xl bg-grayScale-100" />
<div className="h-48 animate-pulse rounded-xl bg-grayScale-100" />
</div>
)
);
}
type EditFormState = {
first_name: string
last_name: string
phone_number: string
department: string
job_title: string
profile_picture_url: string
bio: string
work_phone: string
}
first_name: string;
last_name: string;
phone_number: string;
department: string;
job_title: string;
profile_picture_url: string;
bio: string;
work_phone: string;
};
function profileToEditForm(profile: TeamMeProfile): EditFormState {
return {
@ -117,16 +138,16 @@ function profileToEditForm(profile: TeamMeProfile): EditFormState {
profile_picture_url: profile.profile_picture_url ?? "",
bio: profile.bio ?? "",
work_phone: profile.work_phone ?? "",
}
};
}
export function ProfilePage() {
const [profile, setProfile] = useState<TeamMeProfile | null>(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(null)
const [editing, setEditing] = useState(false)
const [saving, setSaving] = useState(false)
const [uploadingPicture, setUploadingPicture] = useState(false)
const [profile, setProfile] = useState<TeamMeProfile | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [editing, setEditing] = useState(false);
const [saving, setSaving] = useState(false);
const [uploadingPicture, setUploadingPicture] = useState(false);
const [editForm, setEditForm] = useState<EditFormState>({
first_name: "",
last_name: "",
@ -136,48 +157,48 @@ export function ProfilePage() {
profile_picture_url: "",
bio: "",
work_phone: "",
})
});
const busy = saving || uploadingPicture
const busy = saving || uploadingPicture;
const loadProfile = async () => {
setLoading(true)
setError(null)
setLoading(true);
setError(null);
try {
const res = await getTeamMe()
setProfile(res.data.data)
const res = await getTeamMe();
setProfile(res.data.data);
} catch (err) {
console.error("Failed to fetch profile", err)
setProfile(null)
setError("Failed to load profile. Please try again later.")
console.error("Failed to fetch profile", err);
setProfile(null);
setError("Failed to load profile. Please try again later.");
} finally {
setLoading(false)
setLoading(false);
}
}
};
useEffect(() => {
void loadProfile()
}, [])
void loadProfile();
}, []);
const startEditing = () => {
if (!profile) return
setEditForm(profileToEditForm(profile))
setUploadingPicture(false)
setEditing(true)
}
if (!profile) return;
setEditForm(profileToEditForm(profile));
setUploadingPicture(false);
setEditing(true);
};
const handleSave = async () => {
if (!profile) return
if (!profile) return;
const firstName = editForm.first_name.trim()
const lastName = editForm.last_name.trim()
const firstName = editForm.first_name.trim();
const lastName = editForm.last_name.trim();
if (!firstName || !lastName) {
toast.error("First name and last name are required")
return
toast.error("First name and last name are required");
return;
}
setSaving(true)
setSaving(true);
try {
const res = await updateTeamMe({
first_name: firstName,
@ -188,26 +209,26 @@ export function ProfilePage() {
profile_picture_url: editForm.profile_picture_url.trim(),
bio: editForm.bio.trim(),
work_phone: editForm.work_phone.trim(),
})
setProfile(res.data.data)
setEditing(false)
toast.success(res.data.message || "Profile updated successfully")
});
setProfile(res.data.data);
setEditing(false);
toast.success(res.data.message || "Profile updated successfully");
} catch (err) {
console.error("Failed to update profile", err)
notifyApiError(err, "Failed to update profile")
console.error("Failed to update profile", err);
notifyApiError(err, "Failed to update profile");
} finally {
setSaving(false)
setSaving(false);
}
}
};
if (loading) return <LoadingSkeleton />
if (loading) return <LoadingSkeleton />;
if (error || !profile) {
return (
<div className="mx-auto w-full max-w-5xl py-16">
<Card className="border-dashed">
<div className="mx-auto w-full max-w-3xl py-16">
<Card className="border border-grayScale-100 shadow-none">
<CardContent className="flex flex-col items-center gap-5 p-12">
<div className="flex h-20 w-20 items-center justify-center rounded-full bg-grayScale-100">
<div className="flex h-20 w-20 items-center justify-center rounded-full bg-grayScale-50">
<User className="h-10 w-10 text-grayScale-300" />
</div>
<div className="text-center">
@ -224,224 +245,286 @@ export function ProfilePage() {
</CardContent>
</Card>
</div>
)
);
}
const fullName = `${profile.first_name} ${profile.last_name}`.trim()
const initials = `${profile.first_name?.[0] ?? ""}${profile.last_name?.[0] ?? ""}`.toUpperCase()
const isActive = profile.status.toLowerCase() === "active"
const fullName = `${profile.first_name} ${profile.last_name}`.trim();
const initials =
`${profile.first_name?.[0] ?? ""}${profile.last_name?.[0] ?? ""}`.toUpperCase();
const handleProfileUpdate = (nextProfile: TeamMeProfile) => {
setProfile(nextProfile)
setProfile(nextProfile);
setEditForm((prev) => ({
...prev,
profile_picture_url: nextProfile.profile_picture_url ?? "",
}))
}
}));
};
return (
<div className="mx-auto w-full max-w-5xl space-y-6">
<div className="flex flex-wrap items-start justify-between gap-4">
<div>
<p className="text-sm font-semibold text-grayScale-500">Account</p>
<h1 className="text-2xl font-semibold tracking-tight text-grayScale-800">My profile</h1>
<p className="mt-1 text-sm text-grayScale-500">
Your team account details from the admin directory.
</p>
</div>
<Button className="bg-brand-500 text-white hover:bg-brand-600" onClick={startEditing}>
Edit profile
</Button>
</div>
<div className="mx-auto w-full max-w-3xl space-y-6">
<h1 className="text-xl font-semibold tracking-tight text-grayScale-900">
My Profile
</h1>
<Card className="overflow-hidden border-grayScale-100 shadow-soft">
<div className="h-28 bg-gradient-to-r from-brand-500/20 via-brand-300/20 to-brand-100/40" />
<CardContent className="relative px-6 pb-6 pt-0">
<div className="-mt-12 flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between">
<div className="flex items-end gap-4">
<ProfileAvatarUpload
avatarUrl={profile.profile_picture_url}
initials={initials}
onProfileUpdate={handleProfileUpdate}
/>
<div className="pb-1">
<h2 className="text-2xl font-semibold text-grayScale-800">{fullName}</h2>
<p className="text-sm text-grayScale-500">{displayValue(profile.job_title)}</p>
{/* Hero */}
<Card className="border border-grayScale-100 shadow-none">
<CardContent className="flex items-center justify-between px-6 py-6">
<div className="flex items-center gap-5">
<ProfileAvatarUpload
avatarUrl={profile.profile_picture_url}
initials={initials}
onProfileUpdate={handleProfileUpdate}
/>
<div className="space-y-2">
<h2 className="text-lg font-semibold text-grayScale-900">
{fullName}
</h2>
<div className="flex flex-wrap items-center gap-2">
<Badge
variant="outline"
className="rounded-full border-grayScale-200 px-3 py-0.5 text-[11px] font-medium text-grayScale-600"
>
{formatRoleLabel(profile.team_role)}
</Badge>
{profile.job_title?.trim() && (
<Badge
variant="outline"
className="rounded-full border-grayScale-200 px-3 py-0.5 text-[11px] font-medium text-grayScale-600"
>
{profile.job_title}
</Badge>
)}
<Badge
variant="outline"
className={cn(
"rounded-full px-3 py-0.5 text-[11px] font-medium",
profile.email_verified
? "border-green-200 text-green-600"
: "border-grayScale-200 text-grayScale-500",
)}
>
{profile.email_verified ? "Verified" : "Unverified"}
</Badge>
</div>
</div>
<div className="flex flex-wrap gap-2 pb-1">
<Badge variant={isActive ? "default" : "secondary"}>
{formatStatusLabel(profile.status)}
</Badge>
<Badge variant={profile.email_verified ? "default" : "outline"}>
{profile.email_verified ? "Email verified" : "Email not verified"}
</Badge>
</div>
</div>
{profile.bio?.trim() ? (
<p className="mt-4 text-sm leading-relaxed text-grayScale-600">{profile.bio.trim()}</p>
) : null}
<Button
type="button"
variant="outline"
size="sm"
className="h-8 gap-1.5 rounded-lg text-xs font-medium text-grayScale-500"
onClick={startEditing}
>
<Pencil className="h-3.5 w-3.5" />
Edit
</Button>
</CardContent>
</Card>
<div className="grid gap-6 lg:grid-cols-2">
<Card className="shadow-soft">
<CardHeader>
<CardTitle className="text-base">Work details</CardTitle>
</CardHeader>
<CardContent className="grid gap-4 sm:grid-cols-2">
<ReadOnlyField label="Team role" value={formatRoleLabel(profile.team_role)} />
<ReadOnlyField label="Department" value={displayValue(profile.department)} />
<ReadOnlyField label="Job title" value={displayValue(profile.job_title)} />
<ReadOnlyField label="Member ID" value={String(profile.id)} />
</CardContent>
</Card>
{/* Personal Information */}
<SectionCard title="Personal Information">
<div className="grid gap-x-8 gap-y-5 sm:grid-cols-2">
<FieldGroup label="First Name" value={profile.first_name} />
<FieldGroup label="Last Name" value={profile.last_name} />
<FieldGroup label="Email address" value={profile.email} />
<FieldGroup label="Phone" value={profile.phone_number} />
<div className="sm:col-span-2">
<FieldGroup label="Bio" value={displayValue(profile.bio)} />
</div>
</div>
</SectionCard>
<Card className="shadow-soft">
<CardHeader>
<CardTitle className="text-base">Contact</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="flex items-center gap-3 text-sm text-grayScale-700">
<Mail className="h-4 w-4 text-brand-600" />
<span>{displayValue(profile.email)}</span>
</div>
<div className="flex items-center gap-3 text-sm text-grayScale-700">
<Phone className="h-4 w-4 text-brand-600" />
<span>{displayValue(profile.phone_number)}</span>
</div>
{profile.work_phone?.trim() ? (
<div className="flex items-center gap-3 text-sm text-grayScale-700">
<Phone className="h-4 w-4 text-brand-600" />
<span>
<span className="text-grayScale-500">Work: </span>
{profile.work_phone.trim()}
</span>
</div>
) : null}
</CardContent>
</Card>
{/* Work Details */}
<SectionCard title="Work Details">
<div className="grid gap-x-8 gap-y-5 sm:grid-cols-2">
<FieldGroup
label="Department"
value={displayValue(profile.department)}
/>
<FieldGroup
label="Job Title"
value={displayValue(profile.job_title)}
/>
<FieldGroup
label="Work Phone"
value={displayValue(profile.work_phone)}
/>
<FieldGroup label="Member ID" value={String(profile.id)} mono />
</div>
</SectionCard>
<Card className="shadow-soft lg:col-span-2">
<CardHeader>
<CardTitle className="text-base">Account activity</CardTitle>
</CardHeader>
<CardContent className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
<div className="flex items-start gap-3">
<CalendarDays className="mt-0.5 h-4 w-4 text-brand-600" />
<ReadOnlyField label="Joined" value={formatDate(profile.created_at)} />
</div>
<div className="flex items-start gap-3">
<Clock3 className="mt-0.5 h-4 w-4 text-brand-600" />
<ReadOnlyField label="Last login" value={formatDateTime(profile.last_login)} />
</div>
<div className="flex items-start gap-3">
<BadgeCheck className="mt-0.5 h-4 w-4 text-brand-600" />
<ReadOnlyField
label="Email verification"
value={profile.email_verified ? "Verified" : "Not verified"}
/>
</div>
<div className="flex items-start gap-3">
<Shield className="mt-0.5 h-4 w-4 text-brand-600" />
<ReadOnlyField label="Last updated" value={formatDate(profile.updated_at)} />
</div>
</CardContent>
</Card>
</div>
{/* Account Activity */}
<SectionCard title="Account Activity">
<div className="grid gap-x-8 gap-y-5 sm:grid-cols-2">
<FieldGroup label="Joined" value={formatDate(profile.created_at)} />
<FieldGroup
label="Last Login"
value={formatDateTime(profile.last_login)}
/>
<FieldGroup
label="Email Verified"
value={profile.email_verified ? "Yes" : "No"}
/>
<FieldGroup
label="Last Updated"
value={formatDate(profile.updated_at)}
/>
</div>
</SectionCard>
{/* Edit dialog */}
<Dialog open={editing} onOpenChange={(open) => !busy && setEditing(open)}>
<DialogContent className="max-h-[90vh] overflow-y-auto sm:max-w-2xl">
<DialogHeader>
<DialogTitle>Edit profile</DialogTitle>
</DialogHeader>
<DialogContent className="flex max-h-[90vh] max-w-lg flex-col overflow-hidden p-0">
<div className="flex items-center gap-3 border-b border-grayScale-100 px-6 py-5 pr-14">
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-[8px] bg-brand-100/60">
<User className="h-5 w-5 text-brand-600" />
</div>
<div>
<DialogTitle className="text-[15px] font-semibold text-grayScale-900">
Edit profile
</DialogTitle>
<DialogDescription className="mt-0.5 text-xs text-grayScale-500">
Update your personal and work information.
</DialogDescription>
</div>
</div>
<div className="grid gap-4 sm:grid-cols-2">
<div className="space-y-1.5">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-first-name">
First name
</label>
<Input
id="profile-first-name"
value={editForm.first_name}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({ ...prev, first_name: e.target.value }))
}
/>
<div className="min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5">
<div className="grid gap-4 sm:grid-cols-2">
<div>
<label
className="mb-1.5 block text-xs font-medium text-grayScale-600"
htmlFor="profile-first-name"
>
First name <span className="text-brand-500">*</span>
</label>
<Input
id="profile-first-name"
value={editForm.first_name}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({
...prev,
first_name: e.target.value,
}))
}
/>
</div>
<div>
<label
className="mb-1.5 block text-xs font-medium text-grayScale-600"
htmlFor="profile-last-name"
>
Last name <span className="text-brand-500">*</span>
</label>
<Input
id="profile-last-name"
value={editForm.last_name}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({
...prev,
last_name: e.target.value,
}))
}
/>
</div>
</div>
<div className="space-y-1.5">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-last-name">
Last name
</label>
<Input
id="profile-last-name"
value={editForm.last_name}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({ ...prev, last_name: e.target.value }))
}
/>
<div className="grid gap-4 sm:grid-cols-2">
<div>
<label
className="mb-1.5 block text-xs font-medium text-grayScale-600"
htmlFor="profile-phone"
>
Phone number
</label>
<Input
id="profile-phone"
value={editForm.phone_number}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({
...prev,
phone_number: e.target.value,
}))
}
/>
</div>
<div>
<label
className="mb-1.5 block text-xs font-medium text-grayScale-600"
htmlFor="profile-work-phone"
>
Work phone
</label>
<Input
id="profile-work-phone"
value={editForm.work_phone}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({
...prev,
work_phone: e.target.value,
}))
}
/>
</div>
</div>
<div className="space-y-1.5">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-phone">
Phone number
</label>
<Input
id="profile-phone"
value={editForm.phone_number}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({ ...prev, phone_number: e.target.value }))
}
/>
<div className="grid gap-4 sm:grid-cols-2">
<div>
<label
className="mb-1.5 block text-xs font-medium text-grayScale-600"
htmlFor="profile-department"
>
Department
</label>
<Input
id="profile-department"
value={editForm.department}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({
...prev,
department: e.target.value,
}))
}
/>
</div>
<div>
<label
className="mb-1.5 block text-xs font-medium text-grayScale-600"
htmlFor="profile-job-title"
>
Job title
</label>
<Input
id="profile-job-title"
value={editForm.job_title}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({
...prev,
job_title: e.target.value,
}))
}
/>
</div>
</div>
<div className="space-y-1.5">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-work-phone">
Work phone
<div>
<label className="mb-1.5 block text-xs font-medium text-grayScale-600">
Email
</label>
<Input
id="profile-work-phone"
value={editForm.work_phone}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({ ...prev, work_phone: e.target.value }))
}
/>
</div>
<div className="space-y-1.5">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-department">
Department
</label>
<Input
id="profile-department"
value={editForm.department}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({ ...prev, department: e.target.value }))
}
/>
</div>
<div className="space-y-1.5">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-job-title">
Job title
</label>
<Input
id="profile-job-title"
value={editForm.job_title}
disabled={busy}
onChange={(e) =>
setEditForm((prev) => ({ ...prev, job_title: e.target.value }))
}
/>
</div>
<div className="space-y-1.5 sm:col-span-2">
<label className="text-sm font-medium text-grayScale-700">Email</label>
<Input value={profile.email} disabled />
<p className="text-xs text-grayScale-500">Email is managed by your administrator.</p>
<p className="mt-1 text-[11px] text-grayScale-400">
Email is managed by your administrator.
</p>
</div>
<div className="space-y-1.5 sm:col-span-2">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-picture">
<div>
<label className="mb-1.5 block text-xs font-medium text-grayScale-600">
Profile picture
</label>
<PersonaProfilePictureUploadField
@ -453,8 +536,12 @@ export function ProfilePage() {
}
/>
</div>
<div className="space-y-1.5 sm:col-span-2">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-bio">
<div>
<label
className="mb-1.5 block text-xs font-medium text-grayScale-600"
htmlFor="profile-bio"
>
Bio
</label>
<Textarea
@ -463,27 +550,34 @@ export function ProfilePage() {
disabled={busy}
rows={4}
placeholder="A short introduction about your role and background."
onChange={(e) => setEditForm((prev) => ({ ...prev, bio: e.target.value }))}
onChange={(e) =>
setEditForm((prev) => ({ ...prev, bio: e.target.value }))
}
/>
</div>
</div>
<DialogFooter>
<Button type="button" variant="outline" onClick={() => setEditing(false)} disabled={busy}>
<div className="flex shrink-0 items-center justify-end gap-2 border-t border-grayScale-100 px-6 pb-6 pt-4 pr-6">
<Button
type="button"
variant="outline"
onClick={() => setEditing(false)}
disabled={busy}
>
Cancel
</Button>
<Button
type="button"
className={cn("bg-brand-500 text-white hover:bg-brand-600")}
className="bg-brand-500 text-white hover:bg-brand-600"
onClick={() => void handleSave()}
disabled={busy}
>
{saving ? <SpinnerIcon className="mr-2 h-4 w-4" /> : null}
{saving ? "Saving…" : "Save changes"}
</Button>
</DialogFooter>
</div>
</DialogContent>
</Dialog>
</div>
)
);
}

View File

@ -101,7 +101,7 @@ function KpiCard({
<div className="text-xs font-semibold uppercase tracking-wide text-grayScale-400">{label}</div>
<div className="mt-1.5 text-[1.75rem] font-semibold leading-none tracking-tight text-grayScale-800">{value}</div>
</div>
<div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-gradient-to-br from-brand-50 to-brand-100 text-brand-600 ring-1 ring-brand-100">
<div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-brand-100/60 text-brand-600">
<Icon className="h-5 w-5" />
</div>
</div>
@ -128,28 +128,22 @@ function BreakdownList({
title,
data,
total,
scrollable,
}: {
title: string
data: LabelCount[]
total?: number
/** Enable vertical scroll for long breakdowns (e.g. occupation). */
scrollable?: boolean
}) {
const computedTotal = total ?? data.reduce((s, d) => s + d.count, 0)
const sorted = [...data].sort((a, b) => b.count - a.count)
return (
<Card className="shadow-none">
<Card className="shadow-none flex flex-col">
<CardHeader className="pb-2">
<CardTitle className="text-sm">{title}</CardTitle>
</CardHeader>
<CardContent className="p-4 pt-0">
<CardContent className="p-4 pt-0 flex-1 flex flex-col">
{sorted.length > 0 ? (
<div
className={cn(
"space-y-2.5",
scrollable && "max-h-64 overflow-y-auto overscroll-contain pr-1",
)}
className="space-y-2.5 flex-1 overflow-y-auto overscroll-contain pr-1 max-h-[320px]"
>
{sorted.map((item, i) => {
const pct = computedTotal > 0 ? (item.count / computedTotal) * 100 : 0
@ -286,7 +280,7 @@ function Section({
onClick={() => setOpen((v) => !v)}
className="flex w-full items-center gap-3 px-6 py-4 text-left transition-colors hover:bg-grayScale-50/80"
>
<div className="grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-gradient-to-br from-brand-50 to-brand-100 text-brand-600 ring-1 ring-brand-100">
<div className="grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-brand-100/60 text-brand-600">
<Icon className="h-4 w-4" />
</div>
<span className="flex-1 text-sm font-semibold tracking-wide text-grayScale-800">{title}</span>
@ -684,17 +678,21 @@ export function AnalyticsPage() {
<p className="mb-3 text-xs font-semibold uppercase tracking-wide text-grayScale-400">
Profile & demographics
</p>
<div className="grid items-start gap-4 sm:grid-cols-2 lg:grid-cols-3">
<div className="grid items-stretch gap-4 sm:grid-cols-2 lg:grid-cols-3">
<BreakdownList
title="Education level"
data={users.by_education_level ?? []}
title="Learning goal"
data={users.by_learning_goal ?? []}
total={users.total_users}
/>
<BreakdownList
title="Language challenge"
data={users.by_language_challange ?? []}
total={users.total_users}
/>
<BreakdownList
title="Occupation"
data={users.by_occupation ?? []}
total={users.total_users}
scrollable
/>
<BreakdownList
title="Age group"
@ -710,7 +708,6 @@ export function AnalyticsPage() {
title="Region"
data={users.by_region ?? []}
total={users.total_users}
scrollable
/>
<BreakdownList
title="Account role"

View File

@ -395,7 +395,7 @@ export function CourseCategoryPage() {
: ""}
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button type="button" variant="outline" onClick={() => setDeleteTarget(null)} disabled={deleting}>
Cancel
</Button>

View File

@ -603,7 +603,7 @@ export function CourseDetailPage() {
}}
>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-lg flex-col gap-0 overflow-hidden p-0">
<DialogHeader className="shrink-0 space-y-1.5 border-b border-grayScale-100 px-6 pb-4 pt-6 pr-12">
<DialogHeader className="shrink-0 space-y-1.5 border-b border-grayScale-100 px-6 pb-4 pt-6 pr-14">
<DialogTitle>Edit module</DialogTitle>
<DialogDescription>
Update name, description, sort order, and icon (upload or URL).

View File

@ -557,7 +557,7 @@ export function CourseManagementPage() {
</DialogTrigger>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-[600px] flex-col gap-0 overflow-hidden rounded-[16px] border-none p-0">
<div className="flex min-h-0 flex-1 flex-col bg-white">
<DialogHeader className="shrink-0 px-8 py-6 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogHeader className="shrink-0 px-8 py-6 pr-14 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Create Unit
</DialogTitle>
@ -910,7 +910,7 @@ export function CourseManagementPage() {
>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-[600px] flex-col gap-0 overflow-hidden rounded-[16px] border-none p-0">
<div className="flex min-h-0 flex-1 flex-col bg-white">
<DialogHeader className="shrink-0 px-8 py-6 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogHeader className="shrink-0 px-8 py-6 pr-14 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Edit Unit
</DialogTitle>
@ -1035,7 +1035,7 @@ export function CourseManagementPage() {
>
<DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden">
<div className="bg-white">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 sm:px-6">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 pr-14 sm:px-6">
<DialogTitle className="text-lg font-bold text-grayScale-900">
Delete Unit
</DialogTitle>

View File

@ -648,7 +648,7 @@ export function CourseModuleDetailPage() {
</DialogTrigger>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-[600px] flex-col gap-0 overflow-hidden rounded-[16px] border-none p-0">
<div className="flex min-h-0 flex-1 flex-col bg-white">
<DialogHeader className="shrink-0 px-8 py-6 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogHeader className="shrink-0 px-8 py-6 pr-14 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Create Lesson
</DialogTitle>
@ -941,7 +941,7 @@ export function CourseModuleDetailPage() {
>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-[600px] flex-col gap-0 overflow-hidden rounded-[16px] border-none p-0">
<div className="flex min-h-0 flex-1 flex-col bg-white">
<DialogHeader className="shrink-0 px-8 py-6 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogHeader className="shrink-0 px-8 py-6 pr-14 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Edit Lesson
</DialogTitle>
@ -1113,7 +1113,7 @@ export function CourseModuleDetailPage() {
>
<DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden">
<div className="bg-white">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 sm:px-6">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 pr-14 sm:px-6">
<DialogTitle className="text-lg font-bold text-grayScale-900">
Delete Lesson
</DialogTitle>

View File

@ -1120,7 +1120,7 @@ export function HumanLanguageHierarchyPage() {
</div>
</div>
<DialogFooter className="mt-2">
<DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button
type="button"
variant="outline"
@ -1225,7 +1225,7 @@ export function HumanLanguageHierarchyPage() {
</div>
</div>
<DialogFooter className="mt-2">
<DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button
type="button"
variant="outline"
@ -1266,7 +1266,7 @@ export function HumanLanguageHierarchyPage() {
<span className="font-medium text-grayScale-700">{deleteModuleTarget?.levelTitle ?? "this level"}</span>.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button
type="button"
variant="outline"

View File

@ -1302,7 +1302,7 @@ export function HumanLanguageSubModulePage() {
You can reactivate it later by setting status back to active.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button
type="button"
variant="outline"

View File

@ -761,7 +761,7 @@ export function LearnEnglishPage() {
}}
>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-lg flex-col gap-0 overflow-hidden p-0">
<DialogHeader className="shrink-0 space-y-1.5 border-b border-grayScale-100 px-6 pb-4 pt-6 pr-12">
<DialogHeader className="shrink-0 space-y-1.5 border-b border-grayScale-100 px-6 pb-4 pt-6 pr-14">
<DialogTitle>Edit program</DialogTitle>
<DialogDescription>
Update name, description, sort order, and thumbnail. Upload an

View File

@ -718,7 +718,7 @@ export function LessonPracticesPage() {
? " The practice will be unlinked until you attach it again. Questions are kept."
: " Other locations are unaffected."}
</p>
<DialogFooter>
<DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button
type="button"
variant="outline"
@ -754,7 +754,7 @@ export function LessonPracticesPage() {
</span>{" "}
and all of its questions will be deleted. This cannot be undone.
</p>
<DialogFooter>
<DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button
type="button"
variant="outline"

View File

@ -841,7 +841,7 @@ export function ModuleDetailPage() {
/>
</div>
</div>
<DialogFooter>
<DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button
type="button"
variant="outline"
@ -946,7 +946,7 @@ export function ModuleDetailPage() {
: " Other locations are unaffected."}
</DialogDescription>
</DialogHeader>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
variant="outline"
onClick={() => setPracticeToUnlink(null)}

View File

@ -1099,7 +1099,7 @@ export function PracticeDetailsPage() {
/>
</div>
</div>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button type="button" variant="outline" onClick={() => setEditOpen(false)} disabled={savePracticeLoading}>
Cancel
</Button>
@ -1120,7 +1120,7 @@ export function PracticeDetailsPage() {
This permanently removes the practice for this {parentTabCopy[parentTab].label.toLowerCase()}. The linked
question set may remain unless you remove it separately.
</p>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
type="button"
variant="outline"

View File

@ -95,7 +95,7 @@ export function PracticeMembersPage() {
/>
</div>
</div>
<DialogFooter>
<DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button variant="outline" onClick={() => setIsModalOpen(false)}>
Cancel
</Button>

View File

@ -824,7 +824,7 @@ export function ProgramCoursesPage() {
}}
>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-lg flex-col gap-0 overflow-hidden p-0">
<DialogHeader className="shrink-0 space-y-1.5 border-b border-grayScale-100 px-6 pb-4 pt-6 pr-12">
<DialogHeader className="shrink-0 space-y-1.5 border-b border-grayScale-100 px-6 pb-4 pt-6 pr-14">
<DialogTitle>Edit course</DialogTitle>
<DialogDescription>
Update name, description, sort order, and thumbnail.

View File

@ -517,7 +517,7 @@ export function ProgramDetailPage() {
</DialogTrigger>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-[600px] flex-col gap-0 overflow-hidden rounded-[16px] border-none p-0">
<div className="flex min-h-0 flex-1 flex-col bg-white">
<DialogHeader className="shrink-0 border-b border-grayScale-200 px-8 py-6 flex flex-row items-center justify-between">
<DialogHeader className="shrink-0 border-b border-grayScale-200 px-8 py-6 pr-14 flex flex-row items-center justify-between">
<DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Create Course
</DialogTitle>
@ -807,7 +807,7 @@ export function ProgramDetailPage() {
>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-[600px] flex-col gap-0 overflow-hidden rounded-[16px] border-none p-0">
<div className="flex min-h-0 flex-1 flex-col bg-white">
<DialogHeader className="shrink-0 border-b border-grayScale-200 px-8 py-6 flex flex-row items-center justify-between">
<DialogHeader className="shrink-0 border-b border-grayScale-200 px-8 py-6 pr-14 flex flex-row items-center justify-between">
<DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Edit Course
</DialogTitle>
@ -915,7 +915,7 @@ export function ProgramDetailPage() {
>
<DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden">
<div className="bg-white">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 sm:px-6">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 pr-14 sm:px-6">
<DialogTitle className="text-lg font-bold text-grayScale-900">
Delete Course
</DialogTitle>

View File

@ -281,7 +281,7 @@ export function QuestionTypeGroupDetailPage() {
group only; other group memberships are unchanged.
</DialogDescription>
</DialogHeader>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
type="button"
variant="outline"

View File

@ -719,7 +719,7 @@ export function QuestionTypeLibraryPage() {
Definitions will be removed from this group only; other group memberships are unchanged.
</DialogDescription>
</DialogHeader>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
type="button"
variant="outline"
@ -768,7 +768,7 @@ export function QuestionTypeLibraryPage() {
</p>
</div>
) : null}
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
type="button"
variant="outline"

View File

@ -611,7 +611,7 @@ export function UnitManagementPage() {
</DialogTrigger>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-[600px] flex-col gap-0 overflow-hidden rounded-[16px] border-none p-0">
<div className="flex min-h-0 flex-1 flex-col bg-white">
<DialogHeader className="px-8 py-6 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogHeader className="px-8 py-6 pr-14 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Create Modules
</DialogTitle>
@ -1014,7 +1014,7 @@ export function UnitManagementPage() {
>
<DialogContent className="flex max-h-[min(90vh,calc(100dvh-2rem))] max-w-[600px] flex-col gap-0 overflow-hidden rounded-[16px] border-none p-0">
<div className="flex min-h-0 flex-1 flex-col bg-white">
<DialogHeader className="px-8 py-6 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogHeader className="px-8 py-6 pr-14 border-b border-grayScale-200 flex flex-row items-center justify-between">
<DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Edit Module
</DialogTitle>
@ -1182,7 +1182,7 @@ export function UnitManagementPage() {
>
<DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden">
<div className="bg-white">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 sm:px-6">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 pr-14 sm:px-6">
<DialogTitle className="text-lg font-bold text-grayScale-900">
Delete Module
</DialogTitle>

View File

@ -64,7 +64,7 @@ export function AccessTierConfirmDialog({
{accessTierConfirmDescription(nextTier, contentLabel)}
</DialogDescription>
</DialogHeader>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
type="button"
variant="outline"

View File

@ -1,4 +1,4 @@
import { notifyApiError } from "../../../lib/apiErrors"
import { notifyApiError } from "../../../lib/apiErrors";
import { useEffect, useState, type FormEvent } from "react";
import { Button } from "../../../components/ui/button";
import {
@ -196,7 +196,7 @@ export function AddModuleModal({
onUploadBusyChange={setIconUploadBusy}
/>
<div className="flex justify-end gap-3 pt-4">
<div className="flex justify-end gap-3 border-t border-grayScale-100 pt-4 pb-6">
<DialogClose asChild>
<Button
type="button"

View File

@ -286,7 +286,7 @@ export function CatalogCoursePracticesPanel({
? " The practice will be unlinked until re-attached."
: " Other locations are unaffected."}
</p>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button variant="outline" onClick={() => setPracticeToUnlink(null)} disabled={unlinking}>
Cancel
</Button>
@ -309,7 +309,7 @@ export function CatalogCoursePracticesPanel({
</span>{" "}
and all of its questions.
</p>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button variant="outline" onClick={() => setPracticeToDelete(null)} disabled={deleting}>
Cancel
</Button>

View File

@ -48,7 +48,7 @@ export function PracticeActionChoiceDialog({
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-lg rounded-2xl border-grayScale-200 p-0 sm:max-w-lg">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 sm:px-6 text-left">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 pr-14 sm:px-6 text-left">
<DialogTitle className="text-lg font-bold text-grayScale-900">
Add practice
</DialogTitle>

View File

@ -64,7 +64,7 @@ export function PublishStatusConfirmDialog({
{publishStatusConfirmDescription(nextStatus, contentLabel)}
</DialogDescription>
</DialogHeader>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
type="button"
variant="outline"

View File

@ -127,8 +127,8 @@ export function QuestionTypeDefinitionPracticesDialog({
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-h-[90vh] max-w-3xl overflow-hidden rounded-2xl border-grayScale-200 p-0 sm:max-w-3xl">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 sm:px-6 text-left">
<DialogContent className="flex max-h-[90vh] max-w-3xl flex-col overflow-hidden rounded-2xl border-grayScale-200 p-0 sm:max-w-3xl">
<DialogHeader className="shrink-0 border-b border-grayScale-100 px-4 py-4 pr-14 sm:px-6 text-left">
<DialogTitle className="flex items-center gap-2 text-lg font-bold text-grayScale-900">
<GraduationCap className="h-5 w-5 text-brand-600 shrink-0" aria-hidden />
Practices using this definition
@ -157,7 +157,7 @@ export function QuestionTypeDefinitionPracticesDialog({
) : null}
</DialogHeader>
<div className="flex max-h-[calc(90vh-8rem)] flex-col">
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
{loading ? (
<div className="flex flex-col items-center justify-center gap-3 px-6 py-16">
<SpinnerIcon className="h-8 w-8 text-brand-500" />
@ -246,10 +246,12 @@ export function QuestionTypeDefinitionPracticesDialog({
)})}
</ul>
)}
</div>
{!loading && totalCount > 0 ? (
<div className="flex flex-wrap items-center justify-between gap-4 border-t border-grayScale-100 bg-grayScale-50/60 px-6 py-4">
<div className="flex flex-wrap items-center gap-3 text-xs text-grayScale-500">
{!loading && totalCount > 0 ? (
<div className="shrink-0 border-t border-grayScale-200 bg-grayScale-50/80 px-6 py-4">
<div className="flex flex-wrap items-center justify-between gap-4">
<div className="flex flex-wrap items-center gap-3 text-xs text-grayScale-500">
<span>
Showing {pageStart}–{pageEnd} of {totalCount}
</span>
@ -301,8 +303,8 @@ export function QuestionTypeDefinitionPracticesDialog({
</Button>
</div>
</div>
) : null}
</div>
</div>
) : null}
</DialogContent>
</Dialog>
)

View File

@ -161,7 +161,7 @@ export function QuestionTypeGroupFormDialog({
</div>
</div>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
type="button"
variant="outline"

View File

@ -288,7 +288,7 @@ export function UnitPracticesPanel({
? " The practice will be unlinked until re-attached."
: " Other locations are unaffected."}
</p>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button variant="outline" onClick={() => setPracticeToUnlink(null)} disabled={unlinking}>
Cancel
</Button>
@ -311,7 +311,7 @@ export function UnitPracticesPanel({
</span>{" "}
and all of its questions.
</p>
<DialogFooter className="gap-2 sm:gap-0">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button variant="outline" onClick={() => setPracticeToDelete(null)} disabled={deleting}>
Cancel
</Button>

View File

@ -1,31 +1,33 @@
import { useEffect, useState } from "react"
import { Plus } from "lucide-react"
import { toast } from "sonner"
import { createFAQ } from "../../../api/faq.api"
import { useEffect, useState } from "react";
import { Plus } from "lucide-react";
import { toast } from "sonner";
import { createFAQ } from "../../../api/faq.api";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "../../../components/ui/dialog"
import { notifyApiError } from "../../../lib/apiErrors"
} from "../../../components/ui/dialog";
import { Stepper } from "../../../components/ui/stepper";
import { notifyApiError } from "../../../lib/apiErrors";
import {
draftToCreatePayload,
EMPTY_FAQ_FORM_DRAFT,
FaqForm,
validateFaqDraft,
type FaqFormDraft,
} from "./FaqForm"
import type { FAQStatus } from "../../../types/faq.types"
} from "./FaqForm";
import type { FAQStatus } from "../../../types/faq.types";
const STEPS = ["Question & Answer", "Category & Details"];
type CreateFaqDialogProps = {
open: boolean
onOpenChange: (open: boolean) => void
categories: string[]
suggestedDisplayOrder: number
onCreated?: () => void
}
open: boolean;
onOpenChange: (open: boolean) => void;
categories: string[];
suggestedDisplayOrder: number;
onCreated?: () => void;
};
export function CreateFaqDialog({
open,
@ -34,78 +36,89 @@ export function CreateFaqDialog({
suggestedDisplayOrder,
onCreated,
}: CreateFaqDialogProps) {
const [draft, setDraft] = useState<FaqFormDraft>(EMPTY_FAQ_FORM_DRAFT)
const [saving, setSaving] = useState(false)
const [savingAction, setSavingAction] = useState<"draft" | "publish" | null>(null)
const [draft, setDraft] = useState<FaqFormDraft>(EMPTY_FAQ_FORM_DRAFT);
const [saving, setSaving] = useState(false);
const [savingAction, setSavingAction] = useState<"draft" | "publish" | null>(
null,
);
const [currentStep, setCurrentStep] = useState(1);
useEffect(() => {
if (open) {
setDraft({
...EMPTY_FAQ_FORM_DRAFT,
display_order: String(suggestedDisplayOrder),
})
setSavingAction(null)
});
setSavingAction(null);
setCurrentStep(1);
}
}, [open, suggestedDisplayOrder])
}, [open, suggestedDisplayOrder]);
const handleOpenChange = (next: boolean) => {
if (!next && !saving) onOpenChange(false)
}
if (!next && !saving) onOpenChange(false);
};
const handleCreate = async (status: FAQStatus) => {
const validationError = validateFaqDraft(draft)
const validationError = validateFaqDraft(draft);
if (validationError) {
toast.error(validationError)
return
toast.error(validationError);
return;
}
setSaving(true)
setSavingAction(status === "ACTIVE" ? "publish" : "draft")
setSaving(true);
setSavingAction(status === "ACTIVE" ? "publish" : "draft");
try {
const response = await createFAQ(draftToCreatePayload(draft, status))
const response = await createFAQ(draftToCreatePayload(draft, status));
if (!response.data) {
throw new Error("Empty create response")
throw new Error("Empty create response");
}
toast.success(
status === "ACTIVE"
? response.message ?? "FAQ published successfully"
: response.message ?? "FAQ saved as draft",
)
onOpenChange(false)
onCreated?.()
? (response.message ?? "FAQ published successfully")
: (response.message ?? "FAQ saved as draft"),
);
onOpenChange(false);
onCreated?.();
} catch (e: unknown) {
console.error(e)
notifyApiError(e, "Failed to create FAQ")
console.error(e);
notifyApiError(e, "Failed to create FAQ");
} finally {
setSaving(false)
setSavingAction(null)
setSaving(false);
setSavingAction(null);
}
}
};
return (
<Dialog open={open} onOpenChange={handleOpenChange}>
<DialogContent className="max-h-[90vh] max-w-lg overflow-y-auto">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<Plus className="h-5 w-5 text-brand-500" />
New FAQ
</DialogTitle>
<DialogDescription>
Add a question and answer for the learner help center.
</DialogDescription>
</DialogHeader>
<DialogContent className="max-h-[90vh] max-w-lg p-0 overflow-hidden">
<div className="flex items-center gap-3 border-b border-grayScale-100 px-6 py-5 pr-14">
<div>
<DialogTitle className="text-[15px] font-semibold text-grayScale-900">
New FAQ
</DialogTitle>
<DialogDescription className="mt-0.5 text-xs text-grayScale-500">
Add a question and answer for the learner help center.
</DialogDescription>
</div>
</div>
<div className="px-6 pt-5">
<Stepper steps={STEPS} currentStep={currentStep} />
</div>
<FaqForm
draft={draft}
saving={saving}
savingAction={savingAction}
categories={categories}
currentStep={currentStep}
onChange={(patch) => setDraft((prev) => ({ ...prev, ...patch }))}
onStepChange={setCurrentStep}
onSaveDraft={() => void handleCreate("INACTIVE")}
onPublish={() => void handleCreate("ACTIVE")}
onCancel={() => onOpenChange(false)}
/>
</DialogContent>
</Dialog>
)
);
}

View File

@ -8,8 +8,6 @@ import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "../../../components/ui/dialog"
import type { FAQ } from "../../../types/faq.types"
@ -52,23 +50,27 @@ export function FaqDeleteDialog({
return (
<Dialog open={open} onOpenChange={handleOpenChange}>
<DialogContent className="max-w-md rounded-2xl border-grayScale-200 sm:max-w-md">
<DialogHeader>
<DialogTitle className="flex items-center gap-2 text-lg font-bold text-grayScale-900">
<Trash2 className="h-5 w-5 shrink-0 text-destructive" aria-hidden />
Delete FAQ?
</DialogTitle>
<DialogDescription className="text-left text-grayScale-600">
This permanently removes the FAQ from the help center. This action cannot be undone.
</DialogDescription>
</DialogHeader>
<DialogContent className="max-w-md overflow-hidden p-0">
<div className="flex items-center gap-3 border-b border-grayScale-100 px-6 py-5 pr-14">
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-[8px] bg-red-50 dark:bg-red-500/10">
<Trash2 className="h-5 w-5 text-red-500" />
</div>
<div>
<DialogTitle className="text-[15px] font-semibold text-grayScale-900">
Delete FAQ?
</DialogTitle>
<DialogDescription className="mt-0.5 text-xs text-grayScale-500">
This permanently removes the FAQ from the help center.
</DialogDescription>
</div>
</div>
{faq ? (
<div className="space-y-1 rounded-xl border border-grayScale-200 bg-grayScale-50 px-4 py-3">
<p className="text-sm font-semibold text-grayScale-900">{faq.question}</p>
<p className="text-xs text-grayScale-500">#{faq.id}</p>
<div className="mx-6 mt-4 rounded-[8px] border border-grayScale-100 bg-grayScale-50 px-4 py-3">
<p className="text-sm font-medium text-grayScale-900">{faq.question}</p>
<p className="mt-0.5 text-[11px] text-grayScale-400">#{faq.id}</p>
</div>
) : null}
<DialogFooter className="gap-2 sm:gap-2">
<div className="flex items-center justify-end gap-2 border-t border-grayScale-100 px-6 py-4">
<Button
variant="outline"
disabled={deleting}
@ -83,7 +85,7 @@ export function FaqDeleteDialog({
>
{deleting ? "Deleting…" : "Delete FAQ"}
</Button>
</DialogFooter>
</div>
</DialogContent>
</Dialog>
)

View File

@ -1,8 +1,6 @@
import { Badge } from "../../../components/ui/badge"
import { Button } from "../../../components/ui/button"
import { Input } from "../../../components/ui/input"
import { Textarea } from "../../../components/ui/textarea"
import { faqStatusBadgeVariant, faqStatusLabel } from "../../../lib/faqDisplay"
import type { FAQStatus } from "../../../types/faq.types"
export type FaqFormDraft = {
@ -24,8 +22,9 @@ type FaqFormProps = {
saving: boolean
savingAction?: "draft" | "publish" | null
categories: string[]
currentStatus?: FAQStatus
currentStep?: number
onChange: (patch: Partial<FaqFormDraft>) => void
onStepChange?: (step: number) => void
onSaveDraft: () => void
onPublish: () => void
onCancel: () => void
@ -36,105 +35,177 @@ export function FaqForm({
saving,
savingAction = null,
categories,
currentStatus,
currentStep = 2,
onChange,
onStepChange,
onSaveDraft,
onPublish,
onCancel,
}: FaqFormProps) {
const stepped = Boolean(onStepChange)
const showAll = !stepped
const canContinue =
currentStep === 1
? draft.question.trim().length > 0 && draft.answer.trim().length > 0
: true
return (
<div className="space-y-5">
<div>
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-grayScale-500">
Question
</p>
<Textarea
value={draft.question}
onChange={(e) => onChange({ question: e.target.value })}
placeholder="How do I reset my password?"
rows={2}
disabled={saving}
/>
<div className="flex max-h-[calc(90vh-140px)] flex-col overflow-hidden">
<div className="space-y-5 overflow-y-auto px-6 py-5">
{(showAll || currentStep === 1) && (
<>
<div>
<label className="mb-1.5 block text-xs font-medium text-grayScale-600">
Question <span className="text-brand-500">*</span>
</label>
<Input
value={draft.question}
onChange={(e) => onChange({ question: e.target.value })}
placeholder="How do I reset my password?"
disabled={saving}
/>
</div>
<div>
<label className="mb-1.5 block text-xs font-medium text-grayScale-600">
Answer <span className="text-brand-500">*</span>
</label>
<Textarea
value={draft.answer}
onChange={(e) => onChange({ answer: e.target.value })}
placeholder="Go to login and click 'Forgot Password'."
rows={6}
disabled={saving}
/>
<p className="mt-1 text-[11px] text-grayScale-400">Plain text only.</p>
</div>
</>
)}
{(showAll || currentStep === 2) && (
<>
<div>
<label className="mb-1.5 block text-xs font-medium text-grayScale-600">
Category
</label>
<Input
value={draft.category}
onChange={(e) => onChange({ category: e.target.value })}
placeholder="Account"
list="faq-category-suggestions"
disabled={saving}
/>
{categories.length > 0 ? (
<datalist id="faq-category-suggestions">
{categories.map((category) => (
<option key={category} value={category} />
))}
</datalist>
) : null}
</div>
<div>
<label className="mb-1.5 block text-xs font-medium text-grayScale-600">
Display order
</label>
<Input
type="number"
min={0}
value={draft.display_order}
onChange={(e) => onChange({ display_order: e.target.value })}
disabled={saving}
/>
<p className="mt-1 text-[11px] text-grayScale-400">
Lower numbers appear first.
</p>
</div>
{showAll && (
<div className="rounded-[8px] border border-grayScale-100 bg-grayScale-50/70 px-4 py-3.5">
<p className="text-[11px] font-semibold uppercase tracking-wide text-grayScale-400">
Preview
</p>
<p className="mt-2 text-sm font-medium text-grayScale-900">
{draft.question || "—"}
</p>
<p className="mt-1 whitespace-pre-wrap text-xs leading-relaxed text-grayScale-600">
{draft.answer || "—"}
</p>
{(draft.category || draft.display_order) && (
<div className="mt-2.5 flex items-center gap-2 text-[11px] text-grayScale-400">
{draft.category && <span>Category: {draft.category}</span>}
{draft.display_order && <span>Order: {draft.display_order}</span>}
</div>
)}
</div>
)}
</>
)}
{stepped && currentStep === 2 && (
<div className="rounded-[8px] border border-grayScale-100 bg-grayScale-50/70 px-4 py-3.5">
<p className="text-[11px] font-semibold uppercase tracking-wide text-grayScale-400">
Preview
</p>
<p className="mt-2 text-sm font-medium text-grayScale-900">
{draft.question || "—"}
</p>
<p className="mt-1 whitespace-pre-wrap text-xs leading-relaxed text-grayScale-600">
{draft.answer || "—"}
</p>
{(draft.category || draft.display_order) && (
<div className="mt-2.5 flex items-center gap-2 text-[11px] text-grayScale-400">
{draft.category && <span>Category: {draft.category}</span>}
{draft.display_order && <span>Order: {draft.display_order}</span>}
</div>
)}
</div>
)}
</div>
<div>
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-grayScale-500">
Answer
</p>
<Textarea
value={draft.answer}
onChange={(e) => onChange({ answer: e.target.value })}
placeholder="Go to login and click 'Forgot Password'."
rows={6}
disabled={saving}
/>
<p className="mt-1 text-xs text-grayScale-400">Plain text only.</p>
</div>
<div className="grid gap-5 sm:grid-cols-2">
<div>
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-grayScale-500">
Category
</p>
<Input
value={draft.category}
onChange={(e) => onChange({ category: e.target.value })}
placeholder="Account"
list="faq-category-suggestions"
disabled={saving}
/>
{categories.length > 0 ? (
<datalist id="faq-category-suggestions">
{categories.map((category) => (
<option key={category} value={category} />
))}
</datalist>
) : null}
</div>
<div>
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-grayScale-500">
Display order
</p>
<Input
type="number"
min={0}
value={draft.display_order}
onChange={(e) => onChange({ display_order: e.target.value })}
disabled={saving}
/>
<p className="mt-1 text-xs text-grayScale-400">
Lower numbers appear first.
</p>
</div>
</div>
<div className="flex flex-wrap items-center justify-between gap-3 border-t border-grayScale-100 pt-5">
<div className="flex flex-wrap items-center gap-2">
<div className="flex shrink-0 items-center justify-between border-t border-grayScale-100 px-6 py-4">
<div className="flex items-center gap-2">
<Button variant="outline" disabled={saving} onClick={onCancel}>
Cancel
</Button>
{currentStatus ? (
<Badge variant={faqStatusBadgeVariant(currentStatus)}>
Currently {faqStatusLabel(currentStatus)}
</Badge>
) : null}
{stepped && currentStep === 2 && (
<Button
variant="outline"
disabled={saving}
onClick={() => onStepChange?.(1)}
>
Back
</Button>
)}
</div>
<div className="flex flex-wrap items-center gap-2">
<Button
variant="outline"
disabled={saving}
onClick={onSaveDraft}
>
{saving && savingAction === "draft" ? "Saving draft…" : "Save as draft"}
</Button>
<Button
className="bg-brand-500 text-white hover:bg-brand-600"
disabled={saving}
onClick={onPublish}
>
{saving && savingAction === "publish" ? "Publishing…" : "Publish FAQ"}
</Button>
<div className="flex items-center gap-2">
{stepped && currentStep === 1 ? (
<Button
className="bg-brand-500 text-white hover:bg-brand-600"
disabled={!canContinue}
onClick={() => onStepChange?.(2)}
>
Continue
</Button>
) : (
<>
<Button
variant="outline"
disabled={saving}
onClick={onSaveDraft}
>
{saving && savingAction === "draft" ? "Saving…" : "Save as draft"}
</Button>
<Button
className="bg-brand-500 text-white hover:bg-brand-600"
disabled={saving}
onClick={onPublish}
>
{saving && savingAction === "publish" ? "Publishing…" : "Publish"}
</Button>
</>
)}
</div>
</div>
</div>

View File

@ -9,7 +9,6 @@ import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "../../../components/ui/dialog"
import { SpinnerIcon } from "../../../components/ui/spinner-icon"
@ -63,26 +62,30 @@ export function FaqPublicPreviewDialog({
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-h-[85vh] max-w-2xl overflow-hidden">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<Eye className="h-5 w-5 text-brand-500" />
Preview as learner
</DialogTitle>
<DialogDescription>
Published FAQs from GET /faqs (ACTIVE only, no authentication).
</DialogDescription>
</DialogHeader>
<DialogContent className="max-h-[85vh] max-w-2xl overflow-hidden p-0">
<div className="flex items-center gap-3 border-b border-grayScale-100 px-6 py-5 pr-14">
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-[8px] bg-brand-100/60">
<Eye className="h-5 w-5 text-brand-600" />
</div>
<div>
<DialogTitle className="text-[15px] font-semibold text-grayScale-900">
Preview as learner
</DialogTitle>
<DialogDescription className="mt-0.5 text-xs text-grayScale-500">
Published FAQs from GET /faqs (ACTIVE only, no authentication).
</DialogDescription>
</div>
</div>
<div className="flex items-center gap-2">
<label htmlFor="preview-category" className="text-xs font-semibold text-grayScale-500">
<div className="flex items-center gap-2 px-6 pt-4">
<label htmlFor="preview-category" className="text-xs font-medium text-grayScale-600">
Category
</label>
<select
id="preview-category"
value={categoryFilter}
onChange={(e) => setCategoryFilter(e.target.value)}
className="h-9 rounded-lg border border-grayScale-200 bg-white px-3 text-sm"
className="h-8 rounded-lg border border-grayScale-200 bg-white px-3 text-xs dark:border-grayScale-200 dark:bg-grayScale-100 dark:text-grayScale-900"
>
<option value="">All categories</option>
{categories.map((category) => (
@ -96,7 +99,7 @@ export function FaqPublicPreviewDialog({
</Button>
</div>
<div className="max-h-[55vh] space-y-4 overflow-y-auto pr-1">
<div className="max-h-[55vh] space-y-4 overflow-y-auto px-6 py-5">
{loading ? (
<div className="flex justify-center py-12">
<SpinnerIcon className="h-6 w-6" />
@ -118,10 +121,10 @@ export function FaqPublicPreviewDialog({
{rows.map((faq) => (
<div
key={faq.id}
className="rounded-xl border border-grayScale-200 bg-grayScale-50 px-4 py-3"
className="rounded-[8px] border border-grayScale-100 bg-grayScale-50 px-4 py-3"
>
<p className="text-sm font-semibold text-grayScale-900">{faq.question}</p>
<p className="mt-1 whitespace-pre-wrap text-sm text-grayScale-600">
<p className="text-sm font-medium text-grayScale-900">{faq.question}</p>
<p className="mt-1 whitespace-pre-wrap text-xs leading-relaxed text-grayScale-600">
{faq.answer}
</p>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -364,6 +364,7 @@ export function NotificationsPage() {
try {
const resolved = await resolveNotificationDetail(notification)
console.log("[NotificationDetail]", resolved)
if (!hasNotificationContent(resolved)) {
setDetailError(true)
toast.error("Notification not found")
@ -496,7 +497,7 @@ export function NotificationsPage() {
{totalCount.toLocaleString()}
</p>
</div>
<div className="grid h-10 w-10 place-items-center rounded-xl bg-brand-500/90 text-white">
<div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-brand-100/60 text-brand-600">
<Bell className="h-5 w-5" />
</div>
</CardContent>
@ -509,7 +510,7 @@ export function NotificationsPage() {
{globalUnread.toLocaleString()}
</p>
</div>
<div className="grid h-10 w-10 place-items-center rounded-xl bg-amber-50 text-amber-600">
<div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-brand-100/60 text-brand-600">
<BellOff className="h-5 w-5" />
</div>
</CardContent>
@ -522,7 +523,7 @@ export function NotificationsPage() {
{Array.from(new Set(notifications.map((n) => n.delivery_channel))).length || "—"}
</p>
</div>
<div className="grid h-10 w-10 place-items-center rounded-xl bg-grayScale-50 text-grayScale-500">
<div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-brand-100/60 text-brand-600">
<MailOpen className="h-5 w-5" />
</div>
</CardContent>

View File

@ -74,7 +74,7 @@ export function EmailTemplateDeleteDialog({
</p>
</div>
) : null}
<DialogFooter className="gap-2 sm:gap-2">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
variant="outline"
disabled={deleting}

View File

@ -1,5 +1,5 @@
import { notifyApiError } from "../../lib/apiErrors"
import { useCallback, useEffect, useMemo, useState, type ReactNode } from "react"
import { useCallback, useEffect, useMemo, useState } from "react"
import {
ChevronDown,
ChevronLeft,
@ -7,6 +7,7 @@ import {
Copy,
CreditCard,
Eye,
MoreHorizontal,
RefreshCw,
Search,
TrendingUp,
@ -25,8 +26,6 @@ import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/ca
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "../../components/ui/dialog"
import { Input } from "../../components/ui/input"
@ -34,6 +33,12 @@ import { Select } from "../../components/ui/select"
import { SpinnerIcon } from "../../components/ui/spinner-icon"
import { countActiveFilters } from "../../lib/adminFilterUtils"
import { cn } from "../../lib/utils"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "../../components/ui/dropdown-menu"
import {
formatPaymentAmount,
formatPaymentDate,
@ -86,6 +91,11 @@ function copyText(value: string, label: string) {
toast.success(`${label} copied`)
}
const PROVIDER_LOGOS: Record<string, string> = {
CHAPA: "https://avatars.githubusercontent.com/u/72302147?v=4",
ARIFPAY: "https://avatars.githubusercontent.com/u/72302147?v=4",
}
const EMPTY_PAYMENT_STATS: PaymentAggregateStats = {
successfulCount: 0,
totalRevenue: 0,
@ -487,17 +497,17 @@ export function PaymentsPage() {
</div>
) : (
<div className="min-w-0 w-full max-w-full overflow-x-auto rounded-[8px] border border-grayScale-100">
<table className="w-full min-w-[900px] text-left text-sm">
<table className="w-full text-left text-sm">
<thead>
<tr className="border-b border-grayScale-100 bg-grayScale-50/80 text-[11px] font-bold uppercase tracking-wider text-grayScale-400">
<th className="whitespace-nowrap px-3 py-3 sm:px-4">Transaction</th>
<th className="whitespace-nowrap px-3 py-3 sm:px-4">Customer</th>
<th className="whitespace-nowrap px-3 py-3 sm:px-4">Plan</th>
<th className="whitespace-nowrap px-3 py-3 sm:px-4">Amount</th>
<th className="whitespace-nowrap px-3 py-3 sm:px-4">Method</th>
<th className="whitespace-nowrap px-3 py-3 sm:px-4">Status</th>
<th className="whitespace-nowrap px-3 py-3 sm:px-4">Paid</th>
<th className="sticky right-0 z-10 whitespace-nowrap bg-grayScale-50/95 px-3 py-3 text-right sm:px-4">
<th className="whitespace-nowrap px-3 py-2.5 sm:px-4">Transaction</th>
<th className="whitespace-nowrap px-3 py-2.5 sm:px-4">Customer</th>
<th className="whitespace-nowrap px-3 py-2.5 sm:px-4">Plan</th>
<th className="whitespace-nowrap px-3 py-2.5 sm:px-4">Amount</th>
<th className="whitespace-nowrap px-3 py-2.5 sm:px-4">Method</th>
<th className="whitespace-nowrap px-3 py-2.5 sm:px-4">Status</th>
<th className="whitespace-nowrap px-3 py-2.5 sm:px-4">Paid</th>
<th className="whitespace-nowrap px-3 py-2.5 text-right sm:px-4">
Actions
</th>
</tr>
@ -505,71 +515,84 @@ export function PaymentsPage() {
<tbody className="divide-y divide-grayScale-50">
{payments.map((payment) => (
<tr key={payment.id} className="group transition-colors hover:bg-grayScale-50/60">
<td className="whitespace-nowrap px-3 py-3 sm:px-4 sm:py-4">
<td className="whitespace-nowrap px-3 py-2.5 sm:px-4">
<p className="font-semibold text-grayScale-900">#{payment.id}</p>
<p className="mt-0.5 max-w-[160px] truncate font-mono text-[11px] text-grayScale-500">
<p className="mt-0.5 max-w-[140px] truncate font-mono text-[11px] text-grayScale-500">
{payment.transaction_id || payment.session_id || "—"}
</p>
</td>
<td className="px-3 py-3 sm:px-4 sm:py-4">
<p className="font-medium text-grayScale-900">
<td className="px-3 py-2.5 sm:px-4">
<p className="max-w-[150px] truncate font-medium text-grayScale-900">
{paymentCustomerName(payment)}
</p>
<p className="mt-0.5 truncate text-xs text-grayScale-500">
<p className="mt-0.5 max-w-[150px] truncate text-xs text-grayScale-500">
{payment.user_email || `User #${payment.user_id}`}
</p>
</td>
<td className="px-3 py-3 sm:px-4 sm:py-4">
<p className="max-w-[180px] truncate font-medium text-grayScale-800">
<td className="px-3 py-2.5 sm:px-4">
<p className="max-w-[160px] truncate font-medium text-grayScale-800">
{payment.plan_name || `Plan #${payment.plan_id}`}
</p>
{payment.plan_category ? (
<Badge variant="secondary" className="mt-1 text-[10px]">
{payment.plan_category && (
<p className="mt-0.5 truncate text-[11px] text-grayScale-400">
{formatPaymentPlanCategory(payment.plan_category)}
</Badge>
) : null}
</p>
)}
</td>
<td className="whitespace-nowrap px-3 py-3 font-semibold text-grayScale-900 sm:px-4 sm:py-4">
<td className="whitespace-nowrap px-3 py-2.5 font-semibold text-grayScale-900 sm:px-4">
{formatPaymentAmount(payment)}
</td>
<td className="whitespace-nowrap px-3 py-3 sm:px-4 sm:py-4">
<Badge variant="info">{formatPaymentMethod(payment.payment_method)}</Badge>
<td className="whitespace-nowrap px-3 py-2.5 sm:px-4">
<div className="flex items-center gap-1.5">
{PROVIDER_LOGOS[payment.payment_method?.toUpperCase()] && (
<img
src={PROVIDER_LOGOS[payment.payment_method.toUpperCase()]}
alt=""
className="h-4 w-4 rounded-full object-cover"
/>
)}
<Badge variant="info" className="text-[10px]">{formatPaymentMethod(payment.payment_method)}</Badge>
</div>
</td>
<td className="whitespace-nowrap px-3 py-3 sm:px-4 sm:py-4">
<Badge variant={paymentStatusBadgeVariant(payment.status)}>
<td className="whitespace-nowrap px-3 py-2.5 sm:px-4">
<Badge variant={paymentStatusBadgeVariant(payment.status)} className="text-[10px]">
{formatPaymentStatus(payment.status)}
</Badge>
</td>
<td className="whitespace-nowrap px-3 py-3 text-xs text-grayScale-600 sm:px-4 sm:py-4">
<td className="whitespace-nowrap px-3 py-2.5 text-xs text-grayScale-600 sm:px-4">
{formatPaymentDate(payment.paid_at ?? payment.created_at)}
</td>
<td className="sticky right-0 z-10 whitespace-nowrap bg-white px-3 py-3 shadow-[-8px_0_12px_-8px_rgba(0,0,0,0.08)] group-hover:bg-grayScale-50/60 sm:px-4 sm:py-4">
<div className="flex justify-end gap-0.5">
<Button
type="button"
variant="ghost"
size="sm"
className="h-8 w-8 rounded-[6px] p-0 text-grayScale-500 hover:text-brand-600"
aria-label="View payment details"
onClick={() => setSelected(payment)}
>
<Eye className="h-4 w-4" />
</Button>
<Button
type="button"
variant="ghost"
size="sm"
className="h-8 w-8 rounded-[6px] p-0 text-grayScale-500 hover:text-brand-600"
aria-label="Copy transaction ID"
onClick={() =>
copyText(
payment.transaction_id || payment.session_id,
"Transaction ID",
)
}
>
<Copy className="h-4 w-4" />
</Button>
<td className="whitespace-nowrap px-3 py-2.5 sm:px-4">
<div className="flex justify-end">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
type="button"
variant="ghost"
size="sm"
className="h-7 w-7 rounded-[6px] p-0 text-grayScale-400 hover:text-grayScale-700"
>
<MoreHorizontal className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-40">
<DropdownMenuItem onClick={() => setSelected(payment)}>
<Eye className="mr-2 h-3.5 w-3.5" />
View details
</DropdownMenuItem>
<DropdownMenuItem
onClick={() =>
copyText(
payment.transaction_id || payment.session_id,
"Transaction ID",
)
}
>
<Copy className="mr-2 h-3.5 w-3.5" />
Copy transaction ID
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</td>
</tr>
@ -638,54 +661,99 @@ export function PaymentsPage() {
</Card>
<Dialog open={selected != null} onOpenChange={(open) => !open && setSelected(null)}>
<DialogContent className="max-h-[90vh] max-w-lg overflow-y-auto rounded-[12px]">
<DialogContent className="max-w-lg gap-0 overflow-hidden rounded-2xl border-0 p-0 shadow-[0_25px_60px_-12px_rgba(0,0,0,0.25)]">
{selected ? (
<>
<DialogHeader>
<DialogTitle>Payment #{selected.id}</DialogTitle>
<DialogDescription>
{formatPaymentStatus(selected.status)} · {formatPaymentAmount(selected)}
</DialogDescription>
</DialogHeader>
<dl className="grid gap-3 text-sm sm:grid-cols-2">
<Detail label="Customer" value={paymentCustomerName(selected)} />
<Detail label="Email" value={selected.user_email || "—"} />
<Detail
label="User"
value={
<Link
to={`/users/${selected.user_id}`}
className="font-medium text-brand-500 hover:text-brand-600"
>
View user #{selected.user_id}
</Link>
}
/>
<Detail label="Plan" value={selected.plan_name || `Plan #${selected.plan_id}`} />
<Detail
label="Category"
value={formatPaymentPlanCategory(selected.plan_category)}
/>
<Detail label="Method" value={formatPaymentMethod(selected.payment_method)} />
<Detail label="Status" value={formatPaymentStatus(selected.status)} />
<Detail label="Transaction ID" value={selected.transaction_id || "—"} mono />
<Detail label="Session ID" value={selected.session_id || "—"} mono />
<Detail label="Subscription" value={`#${selected.subscription_id}`} />
<Detail label="Paid at" value={formatPaymentDate(selected.paid_at)} />
<Detail label="Expires at" value={formatPaymentDate(selected.expires_at)} />
<Detail label="Created" value={formatPaymentDate(selected.created_at)} />
<Detail label="Updated" value={formatPaymentDate(selected.updated_at)} />
</dl>
{selected.payment_url ? (
<a
href={selected.payment_url}
target="_blank"
rel="noopener noreferrer"
className="inline-flex text-sm font-semibold text-brand-500 hover:text-brand-600"
>
Open checkout URL
</a>
) : null}
{/* Header */}
<div className="px-6 pt-6 pb-5 pr-14">
<div className="flex items-start gap-3.5">
{PROVIDER_LOGOS[selected.payment_method?.toUpperCase()] ? (
<img
src={PROVIDER_LOGOS[selected.payment_method.toUpperCase()]}
alt={formatPaymentMethod(selected.payment_method)}
className="h-12 w-12 shrink-0 rounded-2xl object-cover"
/>
) : (
<div className={cn(
"grid h-12 w-12 shrink-0 place-items-center rounded-2xl",
selected.status === "SUCCESS" ? "bg-green-50 text-green-600"
: selected.status === "FAILED" ? "bg-red-50 text-red-600"
: selected.status === "PENDING" ? "bg-amber-50 text-amber-600"
: "bg-grayScale-100 text-grayScale-500",
)}>
<CreditCard className="h-6 w-6" />
</div>
)}
<div className="min-w-0 flex-1 pt-0.5">
<DialogTitle className="text-base font-bold leading-snug text-grayScale-900">
Payment #{selected.id}
</DialogTitle>
<div className="mt-1.5 flex items-center gap-1.5 text-xs text-grayScale-400">
<Badge variant={paymentStatusBadgeVariant(selected.status)} className="text-[10px]">
{formatPaymentStatus(selected.status)}
</Badge>
<span>·</span>
<span>{formatPaymentAmount(selected)}</span>
</div>
</div>
</div>
</div>
{/* Body */}
<div className="px-6 pb-8 pt-1">
{/* Amount highlight */}
<div className="rounded-xl bg-grayScale-50/70 px-4 py-4 text-center">
<p className="text-[11px] font-bold uppercase tracking-wider text-grayScale-300">Amount</p>
<p className="mt-1 text-2xl font-bold text-grayScale-900">
{formatPaymentAmount(selected)}
</p>
<p className="mt-0.5 text-xs text-grayScale-400">
{formatPaymentMethod(selected.payment_method)}
</p>
</div>
{/* Metadata */}
<div className="mt-5 space-y-0 divide-y divide-grayScale-100">
{[
{ k: "Customer", v: paymentCustomerName(selected) },
{ k: "Email", v: selected.user_email || "—" },
{ k: "Plan", v: selected.plan_name || `Plan #${selected.plan_id}` },
{ k: "Category", v: formatPaymentPlanCategory(selected.plan_category) },
{ k: "Transaction", v: selected.transaction_id || "—", mono: true },
{ k: "Session", v: selected.session_id || "—", mono: true },
{ k: "Subscription", v: `#${selected.subscription_id}` },
{ k: "Paid", v: formatPaymentDate(selected.paid_at ?? selected.created_at) },
...(selected.expires_at ? [{ k: "Expires", v: formatPaymentDate(selected.expires_at) }] : []),
].map((row) => (
<div key={row.k} className="flex items-baseline justify-between gap-4 py-2.5 first:pt-0 last:pb-0">
<span className="text-xs text-grayScale-400">{row.k}</span>
{row.k === "Customer" ? (
<span className="text-xs font-medium text-grayScale-600">
<Link to={`/users/${selected.user_id}`} className="text-brand-500 hover:text-brand-600">
{row.v}
</Link>
</span>
) : (
<span className={cn("text-xs font-medium text-grayScale-600", row.mono && "font-mono text-[11px]")}>
{row.v}
</span>
)}
</div>
))}
</div>
{/* Actions */}
{selected.payment_url && (
<div className="mt-5 border-t border-grayScale-100 pt-4">
<Button size="sm" className="h-9 rounded-lg bg-brand-600 px-4 text-xs font-medium text-white hover:bg-brand-500" asChild>
<a href={selected.payment_url} target="_blank" rel="noopener noreferrer">
<ExternalLink className="mr-1.5 h-3.5 w-3.5" />
Open checkout
</a>
</Button>
</div>
)}
</div>
</>
) : null}
</DialogContent>
@ -722,27 +790,3 @@ function FilterChip({
</button>
)
}
function Detail({
label,
value,
mono,
}: {
label: string
value: ReactNode
mono?: boolean
}) {
return (
<div className="rounded-[8px] border border-grayScale-100 bg-grayScale-50/50 px-3 py-2">
<dt className="text-[10px] font-bold uppercase tracking-wider text-grayScale-400">{label}</dt>
<dd
className={cn(
"mt-0.5 font-medium text-grayScale-800 break-all",
mono && "font-mono text-xs",
)}
>
{value}
</dd>
</div>
)
}

View File

@ -69,7 +69,7 @@ export function PersonaDeleteDialog({
<p className="text-xs text-grayScale-500">#{persona.id}</p>
</div>
) : null}
<DialogFooter className="gap-2 sm:gap-2">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button variant="outline" disabled={deleting} onClick={() => onOpenChange(false)}>
Cancel
</Button>

View File

@ -315,7 +315,7 @@ export function InviteTeamMemberDialog({
</div>
) : null}
<DialogFooter className="gap-2 pt-2 sm:gap-2">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
type="button"
variant="outline"

View File

@ -144,7 +144,7 @@ export function CreateAppVersionDialog({
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-h-[90vh] max-w-lg overflow-y-auto rounded-[12px] border border-grayScale-100 p-0">
<form onSubmit={handleSubmit}>
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 sm:px-6">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 pr-14 sm:px-6">
<DialogTitle className="text-lg font-bold text-grayScale-900">
New app version
</DialogTitle>

View File

@ -125,7 +125,7 @@ export function CreateSubscriptionPlanDialog({
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-h-[90vh] max-w-lg overflow-y-auto rounded-[12px] border border-grayScale-100 p-0">
<form onSubmit={handleSubmit}>
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 sm:px-6">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 pr-14 sm:px-6">
<DialogTitle className="text-lg font-bold text-grayScale-900">
New subscription package
</DialogTitle>

View File

@ -72,7 +72,7 @@ export function DeleteAppVersionDialog({
</p>
</div>
) : null}
<DialogFooter className="gap-2 sm:gap-2">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
variant="outline"
className="rounded-[6px]"

View File

@ -72,7 +72,7 @@ export function DeleteSubscriptionPlanDialog({
</p>
</div>
) : null}
<DialogFooter className="gap-2 sm:gap-2">
<DialogFooter className="gap-2 border-t border-grayScale-100 px-6 py-4 sm:justify-end">
<Button
variant="outline"
className="rounded-[6px]"

View File

@ -136,7 +136,7 @@ export function EditAppVersionDialog({
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-h-[90vh] max-w-lg overflow-y-auto rounded-[12px] border border-grayScale-100 p-0">
<form onSubmit={handleSubmit}>
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 sm:px-6">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 pr-14 sm:px-6">
<DialogTitle className="text-lg font-bold text-grayScale-900">
Edit app version
</DialogTitle>

View File

@ -140,7 +140,7 @@ export function EditSubscriptionPlanDialog({
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-h-[90vh] max-w-lg overflow-y-auto rounded-[12px] border border-grayScale-100 p-0">
<form onSubmit={handleSubmit}>
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 sm:px-6">
<DialogHeader className="border-b border-grayScale-100 px-4 py-4 pr-14 sm:px-6">
<DialogTitle className="text-lg font-bold text-grayScale-900">
Edit subscription package
</DialogTitle>

View File

@ -1,5 +1,5 @@
import { useMemo, useState } from "react"
import { ChevronDown } from "lucide-react"
import { ChevronDown, Download, FileSpreadsheet, Filter } from "lucide-react"
import { AdminFiltersPanel } from "../../components/filters/AdminFiltersPanel"
import { ExportCsvButton } from "../../components/export/ExportCsvButton"
import { Input } from "../../components/ui/input"
@ -179,6 +179,34 @@ export function SubscriptionsExportPage() {
</AdminFiltersPanel>
</div>
{/* Empty state */}
<div className="flex flex-col items-center justify-center rounded-[12px] border border-dashed border-grayScale-200 bg-white py-16 text-center">
<div className="grid h-14 w-14 place-items-center rounded-2xl bg-grayScale-50">
<FileSpreadsheet className="h-7 w-7 text-grayScale-300" />
</div>
<p className="mt-4 text-sm font-semibold text-grayScale-700">Ready to export</p>
<p className="mt-1 max-w-sm text-xs text-grayScale-400">
{activeFilterCount > 0
? `${activeFilterCount} filter${activeFilterCount === 1 ? "" : "s"} applied. Hit export to download matching subscriptions.`
: "Set filters above to narrow down which subscriptions to include, or export everything."}
</p>
{activeFilterCount > 0 ? (
<button
type="button"
onClick={clearFilters}
className="mt-4 flex items-center gap-1.5 rounded-lg border border-grayScale-200 bg-white px-3 py-1.5 text-xs font-medium text-grayScale-600 transition-colors hover:border-grayScale-300 hover:text-grayScale-800"
>
<Filter className="h-3.5 w-3.5" />
Clear filters
</button>
) : (
<div className="mt-4 flex items-center gap-1.5 text-xs text-grayScale-300">
<Download className="h-3.5 w-3.5" />
Exports limited to 50,000 rows
</div>
)}
</div>
<p className="text-xs text-grayScale-400">
Subscription exports may contain learner PII and billing data. Restrict access to authorized
staff only.

View File

@ -124,7 +124,7 @@ export function UserGroupsPage() {
/>
</div>
</div>
<DialogFooter>
<DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button variant="outline" onClick={() => setIsModalOpen(false)}>
Cancel
</Button>

View File

@ -393,14 +393,14 @@ export function UsersListPage() {
{/* Platform-wide user summary (same metrics as former User Management dashboard) */}
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
<Card className="border-none bg-brand-50 shadow-sm">
<Card className="border-none shadow-sm">
<CardContent className="flex items-center gap-4 p-5">
<div className="grid h-12 w-12 shrink-0 place-items-center rounded-xl bg-brand-100 text-brand-600">
<Users className="h-6 w-6" />
<div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-brand-100/60 text-brand-600">
<Users className="h-5 w-5" />
</div>
<div className="min-w-0">
<p className="text-sm font-medium text-white/80">Total Users</p>
<p className="text-2xl font-bold text-white">
<p className="text-sm font-medium text-grayScale-500">Total Users</p>
<p className="text-2xl font-bold text-grayScale-900">
{userSummaryLoading ? (
<SpinnerIcon className="h-5 w-5" />
) : userSummary ? (
@ -413,14 +413,14 @@ export function UsersListPage() {
</CardContent>
</Card>
<Card className="border-none bg-brand-50 shadow-sm">
<Card className="border-none shadow-sm">
<CardContent className="flex items-center gap-4 p-5">
<div className="grid h-12 w-12 shrink-0 place-items-center rounded-xl bg-brand-100 text-brand-600">
<UserCheck className="h-6 w-6" />
<div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-brand-100/60 text-brand-600">
<UserCheck className="h-5 w-5" />
</div>
<div className="min-w-0">
<p className="text-sm font-medium text-white/80">Active Users</p>
<p className="text-2xl font-bold text-white">
<p className="text-sm font-medium text-grayScale-500">Active Users</p>
<p className="text-2xl font-bold text-grayScale-900">
{userSummaryLoading ? (
<SpinnerIcon className="h-5 w-5" />
) : activeUsersTotal !== null ? (
@ -433,14 +433,14 @@ export function UsersListPage() {
</CardContent>
</Card>
<Card className="border-none bg-brand-50 shadow-sm sm:col-span-2 lg:col-span-1">
<Card className="border-none shadow-sm sm:col-span-2 lg:col-span-1">
<CardContent className="flex items-center gap-4 p-5">
<div className="grid h-12 w-12 shrink-0 place-items-center rounded-xl bg-brand-100 text-brand-600">
<TrendingUp className="h-6 w-6" />
<div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-brand-100/60 text-brand-600">
<TrendingUp className="h-5 w-5" />
</div>
<div className="min-w-0">
<p className="text-sm font-medium text-white/80">New This Month</p>
<p className="text-2xl font-bold text-white">
<p className="text-sm font-medium text-grayScale-500">New This Month</p>
<p className="text-2xl font-bold text-grayScale-900">
{userSummaryLoading ? (
<SpinnerIcon className="h-5 w-5" />
) : userSummary ? (