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? *.sw?
AGENTS.md AGENTS.md
design-system.md design-system.md
.opencode/

View File

@ -70,7 +70,7 @@ export function NotificationDeleteDialog({
<p className="text-xs text-grayScale-500">#{notification.id}</p> <p className="text-xs text-grayScale-500">#{notification.id}</p>
</div> </div>
) : null} ) : 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 <Button
variant="outline" variant="outline"
disabled={deleting} disabled={deleting}

View File

@ -1,34 +1,35 @@
import { Badge } from "../ui/badge" import { useState } from "react";
import { Button } from "../ui/button" import { Bell } from "lucide-react";
import { import { Badge } from "../ui/badge";
Dialog, import { Button } from "../ui/button";
DialogContent, import { Dialog, DialogContent, DialogTitle } from "../ui/dialog";
DialogDescription, import { SpinnerIcon } from "../ui/spinner-icon";
DialogFooter,
DialogHeader,
DialogTitle,
} from "../ui/dialog"
import { SpinnerIcon } from "../ui/spinner-icon"
import { import {
DEFAULT_NOTIFICATION_TYPE_CONFIG, DEFAULT_NOTIFICATION_TYPE_CONFIG,
formatNotificationDateTime, formatNotificationDateTime,
formatNotificationTimestamp, formatNotificationTimestamp,
formatNotificationTypeLabel, formatNotificationTypeLabel,
getNotificationLevelBadge,
isMeaningfulExpiry, isMeaningfulExpiry,
NOTIFICATION_TYPE_CONFIG, NOTIFICATION_TYPE_CONFIG,
} from "../../lib/notificationDisplay" } from "../../lib/notificationDisplay";
import { getNotificationMessage, getNotificationTitle, type Notification } from "../../types/notification.types" import {
getNotificationMessage,
getNotificationTitle,
type Notification,
} from "../../types/notification.types";
import { cn } from "../../lib/utils";
type NotificationDetailDialogProps = { type NotificationDetailDialogProps = {
open: boolean open: boolean;
onOpenChange: (open: boolean) => void onOpenChange: (open: boolean) => void;
notification: Notification | null notification: Notification | null;
loading?: boolean loading?: boolean;
error?: boolean error?: boolean;
onRetry?: () => void onRetry?: () => void;
onDelete?: () => void onDelete?: () => void;
} };
type Tab = "details" | "preview";
export function NotificationDetailDialog({ export function NotificationDetailDialog({
open, open,
@ -39,142 +40,258 @@ export function NotificationDetailDialog({
onRetry, onRetry,
onDelete, onDelete,
}: NotificationDetailDialogProps) { }: NotificationDetailDialogProps) {
const [tab, setTab] = useState<Tab>("details");
const config = notification const config = notification
? NOTIFICATION_TYPE_CONFIG[notification.type] ?? DEFAULT_NOTIFICATION_TYPE_CONFIG ? (NOTIFICATION_TYPE_CONFIG[notification.type] ??
: DEFAULT_NOTIFICATION_TYPE_CONFIG DEFAULT_NOTIFICATION_TYPE_CONFIG)
const Icon = config.icon : DEFAULT_NOTIFICATION_TYPE_CONFIG;
const Icon = config.icon;
return ( return (
<Dialog open={open} onOpenChange={onOpenChange}> <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 ? ( {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" /> <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> </div>
) : error ? ( ) : error ? (
<div className="flex flex-col items-center justify-center gap-3 py-12 text-center"> <div className="flex flex-col items-center justify-center gap-4 py-20 text-center">
<p className="text-sm font-medium text-grayScale-700">Could not load notification</p> <div className="grid h-14 w-14 place-items-center rounded-2xl bg-grayScale-100">
{onRetry ? ( <Bell className="h-7 w-7 text-grayScale-300" />
<Button variant="outline" size="sm" onClick={onRetry}> </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 Try again
</Button> </Button>
) : null} )}
</div> </div>
) : notification ? ( ) : notification ? (
<> <>
<DialogHeader> {/* Hero header */}
<DialogTitle className="flex items-center gap-2"> <div className="relative px-6 pt-6 pb-4 pr-14">
<span <div
className={`inline-flex h-8 w-8 items-center justify-center rounded-lg ${config.bg} ${config.color}`} 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" /> <Icon className="h-6 w-6" />
</span> </div>
<span className="truncate text-base"> <div className="min-w-0 flex-1 pt-0.5">
{getNotificationTitle(notification) || "Notification"} <DialogTitle className="text-base font-bold leading-snug text-grayScale-900">
</span> {getNotificationTitle(notification) || "Notification"}
</DialogTitle> </DialogTitle>
<DialogDescription> <div className="mt-1.5 flex items-center gap-1.5 text-xs text-grayScale-400">
Sent via {notification.delivery_channel || "in-app"} ·{" "} <span className="capitalize">
{formatNotificationTimestamp(notification.timestamp)} {notification.delivery_channel}
</DialogDescription> </span>
</DialogHeader> <span className="text-grayScale-200">·</span>
<span>
<div className="space-y-4"> {formatNotificationTimestamp(notification.timestamp)}
{notification.image ? ( </span>
<div className="overflow-hidden rounded-lg border border-grayScale-200 bg-grayScale-50"> </div>
<img
src={notification.image}
alt=""
className="max-h-48 w-full object-cover"
/>
</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>
<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> </div>
{onDelete ? ( {/* Tabs */}
<DialogFooter className="gap-2 sm:gap-2"> <div className="flex border-b border-grayScale-100 px-6">
<Button variant="destructive" onClick={onDelete}> {[
Delete notification { key: "details" as const, label: "Details" },
</Button> { key: "preview" as const, label: "Preview" },
</DialogFooter> ].map((t) => (
) : null} <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} ) : null}
</DialogContent> </DialogContent>
</Dialog> </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} onClick={onClose}
className={({ isActive }) => className={({ isActive }) =>
cn( 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", 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", "hover:bg-grayScale-100 hover:text-brand-600 dark:text-grayScale-400 dark:hover:bg-white/5 dark:hover:text-brand-400",
isActive && 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} title={isCollapsed ? entry.label : undefined}
@ -370,13 +371,24 @@ export function Sidebar({
<span <span
className={cn( 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", "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" /> <Icon className="h-4 w-4" />
</span> </span>
{!isCollapsed && ( {!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 { 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 { NavLink, useLocation } from "react-router-dom";
import { cn } from "../../lib/utils"; import { cn } from "../../lib/utils";
@ -34,7 +40,9 @@ export function SidebarNavGroup({
const location = useLocation(); const location = useLocation();
const panelId = useId(); const panelId = useId();
const paths = activePaths?.length ? activePaths : [basePath]; 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); const [expanded, setExpanded] = useState(isSectionActive);
useEffect(() => { useEffect(() => {
@ -51,10 +59,10 @@ export function SidebarNavGroup({
onClick={onNavigate} onClick={onNavigate}
className={({ isActive }) => className={({ isActive }) =>
cn( 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", "hover:bg-grayScale-100 hover:text-brand-600 dark:text-grayScale-400 dark:hover:bg-white/5 dark:hover:text-brand-400",
isActive && 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} title={label}
@ -63,7 +71,8 @@ export function SidebarNavGroup({
<span <span
className={cn( 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", "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" /> <Icon className="h-4 w-4" />
@ -82,20 +91,29 @@ export function SidebarNavGroup({
aria-controls={panelId} aria-controls={panelId}
onClick={() => setExpanded((open) => !open)} onClick={() => setExpanded((open) => !open)}
className={cn( 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", "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 <span
className={cn( 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", "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" /> <Icon className="h-4 w-4" />
</span> </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} {trailing}
<ChevronDown <ChevronDown
className={cn( className={cn(
@ -103,6 +121,9 @@ export function SidebarNavGroup({
expanded && "rotate-180", 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> </button>
<div <div
@ -124,7 +145,7 @@ export function SidebarNavGroup({
cn( cn(
"block rounded-lg px-3 py-1.5 text-sm font-medium transition", "block rounded-lg px-3 py-1.5 text-sm font-medium transition",
isActive 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", : "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} {...props}
> >
{children} {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"> <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-5 w-5" /> <X className="h-4 w-4" />
<span className="sr-only">Close</span> <span className="sr-only">Close</span>
</DialogPrimitive.Close> </DialogPrimitive.Close>
</DialogPrimitive.Content> </DialogPrimitive.Content>

View File

@ -112,9 +112,7 @@
:is( :is(
.bg-brand-50, .bg-brand-50,
.bg-brand-500, .bg-brand-500,
.bg-brand-600, .bg-brand-600
[class*="bg-brand-500/"],
[class*="bg-brand-600/"]
) { ) {
@apply text-white; @apply text-white;
} }
@ -122,9 +120,7 @@
:is( :is(
.bg-brand-50, .bg-brand-50,
.bg-brand-500, .bg-brand-500,
.bg-brand-600, .bg-brand-600
[class*="bg-brand-500/"],
[class*="bg-brand-600/"]
) )
:is(.text-brand-500, .text-brand-600, .text-brand-700, .text-brand-800) { :is(.text-brand-500, .text-brand-600, .text-brand-700, .text-brand-800) {
@apply text-white; @apply text-white;
@ -133,9 +129,7 @@
:is( :is(
.bg-brand-50, .bg-brand-50,
.bg-brand-500, .bg-brand-500,
.bg-brand-600, .bg-brand-600
[class*="bg-brand-500/"],
[class*="bg-brand-600/"]
) )
svg:not([class*="text-"]) { svg:not([class*="text-"]) {
@apply text-white; @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 { import {
BadgeCheck, Card,
CalendarDays, CardContent,
Clock3, CardHeader,
Mail, CardTitle,
Phone, } from "../components/ui/card";
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"
import { import {
Dialog, Dialog,
DialogContent, DialogContent,
DialogFooter, DialogDescription,
DialogHeader,
DialogTitle, DialogTitle,
} from "../components/ui/dialog" } from "../components/ui/dialog";
import { Input } from "../components/ui/input" import { Input } from "../components/ui/input";
import { SpinnerIcon } from "../components/ui/spinner-icon" import { SpinnerIcon } from "../components/ui/spinner-icon";
import { Textarea } from "../components/ui/textarea" import { Textarea } from "../components/ui/textarea";
import { cn } from "../lib/utils" import { cn } from "../lib/utils";
import type { TeamMeProfile } from "../types/team.types" import type { TeamMeProfile } from "../types/team.types";
import { ProfileAvatarUpload } from "../components/profile/ProfileAvatarUpload" import { ProfileAvatarUpload } from "../components/profile/ProfileAvatarUpload";
import { PersonaProfilePictureUploadField } from "./personas/components/PersonaProfilePictureUploadField" import { PersonaProfilePictureUploadField } from "./personas/components/PersonaProfilePictureUploadField";
function formatDate(dateStr: string | null | undefined): string { function formatDate(dateStr: string | null | undefined): string {
if (!dateStr) return "—" if (!dateStr) return "—";
const date = new Date(dateStr) const date = new Date(dateStr);
if (Number.isNaN(date.getTime())) return dateStr if (Number.isNaN(date.getTime())) return dateStr;
return date.toLocaleDateString(undefined, { return date.toLocaleDateString(undefined, {
year: "numeric", year: "numeric",
month: "long", month: "long",
day: "numeric", day: "numeric",
}) });
} }
function formatDateTime(dateStr: string | null | undefined): string { function formatDateTime(dateStr: string | null | undefined): string {
if (!dateStr) return "—" if (!dateStr) return "—";
const date = new Date(dateStr) const date = new Date(dateStr);
if (Number.isNaN(date.getTime())) return dateStr if (Number.isNaN(date.getTime())) return dateStr;
return date.toLocaleString(undefined, { return date.toLocaleString(undefined, {
year: "numeric", year: "numeric",
month: "short", month: "short",
day: "numeric", day: "numeric",
hour: "2-digit", hour: "2-digit",
minute: "2-digit", minute: "2-digit",
}) });
} }
function formatRoleLabel(role: string): string { function formatRoleLabel(role: string): string {
const value = role.trim() const value = role.trim();
if (!value) return "—" if (!value) return "—";
return value return value
.split("_") .split("_")
.map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()) .map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
.join(" ") .join(" ");
}
function formatStatusLabel(status: string): string {
const value = status.trim()
if (!value) return "—"
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase()
} }
function displayValue(value: string | null | undefined): string { function displayValue(value: string | null | undefined): string {
const trimmed = value?.trim() const trimmed = value?.trim();
return trimmed ? trimmed : "—" return trimmed ? trimmed : "—";
} }
function ReadOnlyField({ label, value }: { label: string; value: string }) { function FieldGroup({
label,
value,
mono,
}: {
label: string;
value: string;
mono?: boolean;
}) {
return ( return (
<div> <div className="space-y-1.5">
<p className="mb-1 text-xs font-medium text-grayScale-500">{label}</p> <p className="text-xs font-medium text-grayScale-400">{label}</p>
<p className="text-sm font-medium text-grayScale-700">{value}</p> <p
className={cn(
"text-sm font-medium text-grayScale-900",
mono && "font-mono text-xs",
)}
>
{value}
</p>
</div> </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() { function LoadingSkeleton() {
return ( 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-8 w-48 animate-pulse rounded-lg bg-grayScale-100" />
<div className="h-40 animate-pulse rounded-2xl bg-grayScale-100" /> <div className="h-28 animate-pulse rounded-xl bg-grayScale-100" />
<div className="grid gap-6 md:grid-cols-2"> <div className="h-48 animate-pulse rounded-xl bg-grayScale-100" />
{[1, 2].map((item) => ( <div className="h-48 animate-pulse rounded-xl bg-grayScale-100" />
<div key={item} className="h-56 animate-pulse rounded-2xl bg-grayScale-100" />
))}
</div>
</div> </div>
) );
} }
type EditFormState = { type EditFormState = {
first_name: string first_name: string;
last_name: string last_name: string;
phone_number: string phone_number: string;
department: string department: string;
job_title: string job_title: string;
profile_picture_url: string profile_picture_url: string;
bio: string bio: string;
work_phone: string work_phone: string;
} };
function profileToEditForm(profile: TeamMeProfile): EditFormState { function profileToEditForm(profile: TeamMeProfile): EditFormState {
return { return {
@ -117,16 +138,16 @@ function profileToEditForm(profile: TeamMeProfile): EditFormState {
profile_picture_url: profile.profile_picture_url ?? "", profile_picture_url: profile.profile_picture_url ?? "",
bio: profile.bio ?? "", bio: profile.bio ?? "",
work_phone: profile.work_phone ?? "", work_phone: profile.work_phone ?? "",
} };
} }
export function ProfilePage() { export function ProfilePage() {
const [profile, setProfile] = useState<TeamMeProfile | null>(null) const [profile, setProfile] = useState<TeamMeProfile | null>(null);
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null) const [error, setError] = useState<string | null>(null);
const [editing, setEditing] = useState(false) const [editing, setEditing] = useState(false);
const [saving, setSaving] = useState(false) const [saving, setSaving] = useState(false);
const [uploadingPicture, setUploadingPicture] = useState(false) const [uploadingPicture, setUploadingPicture] = useState(false);
const [editForm, setEditForm] = useState<EditFormState>({ const [editForm, setEditForm] = useState<EditFormState>({
first_name: "", first_name: "",
last_name: "", last_name: "",
@ -136,48 +157,48 @@ export function ProfilePage() {
profile_picture_url: "", profile_picture_url: "",
bio: "", bio: "",
work_phone: "", work_phone: "",
}) });
const busy = saving || uploadingPicture const busy = saving || uploadingPicture;
const loadProfile = async () => { const loadProfile = async () => {
setLoading(true) setLoading(true);
setError(null) setError(null);
try { try {
const res = await getTeamMe() const res = await getTeamMe();
setProfile(res.data.data) setProfile(res.data.data);
} catch (err) { } catch (err) {
console.error("Failed to fetch profile", err) console.error("Failed to fetch profile", err);
setProfile(null) setProfile(null);
setError("Failed to load profile. Please try again later.") setError("Failed to load profile. Please try again later.");
} finally { } finally {
setLoading(false) setLoading(false);
} }
} };
useEffect(() => { useEffect(() => {
void loadProfile() void loadProfile();
}, []) }, []);
const startEditing = () => { const startEditing = () => {
if (!profile) return if (!profile) return;
setEditForm(profileToEditForm(profile)) setEditForm(profileToEditForm(profile));
setUploadingPicture(false) setUploadingPicture(false);
setEditing(true) setEditing(true);
} };
const handleSave = async () => { const handleSave = async () => {
if (!profile) return if (!profile) return;
const firstName = editForm.first_name.trim() const firstName = editForm.first_name.trim();
const lastName = editForm.last_name.trim() const lastName = editForm.last_name.trim();
if (!firstName || !lastName) { if (!firstName || !lastName) {
toast.error("First name and last name are required") toast.error("First name and last name are required");
return return;
} }
setSaving(true) setSaving(true);
try { try {
const res = await updateTeamMe({ const res = await updateTeamMe({
first_name: firstName, first_name: firstName,
@ -188,26 +209,26 @@ export function ProfilePage() {
profile_picture_url: editForm.profile_picture_url.trim(), profile_picture_url: editForm.profile_picture_url.trim(),
bio: editForm.bio.trim(), bio: editForm.bio.trim(),
work_phone: editForm.work_phone.trim(), work_phone: editForm.work_phone.trim(),
}) });
setProfile(res.data.data) setProfile(res.data.data);
setEditing(false) setEditing(false);
toast.success(res.data.message || "Profile updated successfully") toast.success(res.data.message || "Profile updated successfully");
} catch (err) { } catch (err) {
console.error("Failed to update profile", err) console.error("Failed to update profile", err);
notifyApiError(err, "Failed to update profile") notifyApiError(err, "Failed to update profile");
} finally { } finally {
setSaving(false) setSaving(false);
} }
} };
if (loading) return <LoadingSkeleton /> if (loading) return <LoadingSkeleton />;
if (error || !profile) { if (error || !profile) {
return ( return (
<div className="mx-auto w-full max-w-5xl py-16"> <div className="mx-auto w-full max-w-3xl py-16">
<Card className="border-dashed"> <Card className="border border-grayScale-100 shadow-none">
<CardContent className="flex flex-col items-center gap-5 p-12"> <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" /> <User className="h-10 w-10 text-grayScale-300" />
</div> </div>
<div className="text-center"> <div className="text-center">
@ -224,224 +245,286 @@ export function ProfilePage() {
</CardContent> </CardContent>
</Card> </Card>
</div> </div>
) );
} }
const fullName = `${profile.first_name} ${profile.last_name}`.trim() const fullName = `${profile.first_name} ${profile.last_name}`.trim();
const initials = `${profile.first_name?.[0] ?? ""}${profile.last_name?.[0] ?? ""}`.toUpperCase() const initials =
const isActive = profile.status.toLowerCase() === "active" `${profile.first_name?.[0] ?? ""}${profile.last_name?.[0] ?? ""}`.toUpperCase();
const handleProfileUpdate = (nextProfile: TeamMeProfile) => { const handleProfileUpdate = (nextProfile: TeamMeProfile) => {
setProfile(nextProfile) setProfile(nextProfile);
setEditForm((prev) => ({ setEditForm((prev) => ({
...prev, ...prev,
profile_picture_url: nextProfile.profile_picture_url ?? "", profile_picture_url: nextProfile.profile_picture_url ?? "",
})) }));
} };
return ( return (
<div className="mx-auto w-full max-w-5xl space-y-6"> <div className="mx-auto w-full max-w-3xl space-y-6">
<div className="flex flex-wrap items-start justify-between gap-4"> <h1 className="text-xl font-semibold tracking-tight text-grayScale-900">
<div> My Profile
<p className="text-sm font-semibold text-grayScale-500">Account</p> </h1>
<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>
<Card className="overflow-hidden border-grayScale-100 shadow-soft"> {/* Hero */}
<div className="h-28 bg-gradient-to-r from-brand-500/20 via-brand-300/20 to-brand-100/40" /> <Card className="border border-grayScale-100 shadow-none">
<CardContent className="relative px-6 pb-6 pt-0"> <CardContent className="flex items-center justify-between px-6 py-6">
<div className="-mt-12 flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between"> <div className="flex items-center gap-5">
<div className="flex items-end gap-4"> <ProfileAvatarUpload
<ProfileAvatarUpload avatarUrl={profile.profile_picture_url}
avatarUrl={profile.profile_picture_url} initials={initials}
initials={initials} onProfileUpdate={handleProfileUpdate}
onProfileUpdate={handleProfileUpdate} />
/> <div className="space-y-2">
<div className="pb-1"> <h2 className="text-lg font-semibold text-grayScale-900">
<h2 className="text-2xl font-semibold text-grayScale-800">{fullName}</h2> {fullName}
<p className="text-sm text-grayScale-500">{displayValue(profile.job_title)}</p> </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> </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> </div>
{profile.bio?.trim() ? ( <Button
<p className="mt-4 text-sm leading-relaxed text-grayScale-600">{profile.bio.trim()}</p> type="button"
) : null} 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> </CardContent>
</Card> </Card>
<div className="grid gap-6 lg:grid-cols-2"> {/* Personal Information */}
<Card className="shadow-soft"> <SectionCard title="Personal Information">
<CardHeader> <div className="grid gap-x-8 gap-y-5 sm:grid-cols-2">
<CardTitle className="text-base">Work details</CardTitle> <FieldGroup label="First Name" value={profile.first_name} />
</CardHeader> <FieldGroup label="Last Name" value={profile.last_name} />
<CardContent className="grid gap-4 sm:grid-cols-2"> <FieldGroup label="Email address" value={profile.email} />
<ReadOnlyField label="Team role" value={formatRoleLabel(profile.team_role)} /> <FieldGroup label="Phone" value={profile.phone_number} />
<ReadOnlyField label="Department" value={displayValue(profile.department)} /> <div className="sm:col-span-2">
<ReadOnlyField label="Job title" value={displayValue(profile.job_title)} /> <FieldGroup label="Bio" value={displayValue(profile.bio)} />
<ReadOnlyField label="Member ID" value={String(profile.id)} /> </div>
</CardContent> </div>
</Card> </SectionCard>
<Card className="shadow-soft"> {/* Work Details */}
<CardHeader> <SectionCard title="Work Details">
<CardTitle className="text-base">Contact</CardTitle> <div className="grid gap-x-8 gap-y-5 sm:grid-cols-2">
</CardHeader> <FieldGroup
<CardContent className="space-y-4"> label="Department"
<div className="flex items-center gap-3 text-sm text-grayScale-700"> value={displayValue(profile.department)}
<Mail className="h-4 w-4 text-brand-600" /> />
<span>{displayValue(profile.email)}</span> <FieldGroup
</div> label="Job Title"
<div className="flex items-center gap-3 text-sm text-grayScale-700"> value={displayValue(profile.job_title)}
<Phone className="h-4 w-4 text-brand-600" /> />
<span>{displayValue(profile.phone_number)}</span> <FieldGroup
</div> label="Work Phone"
{profile.work_phone?.trim() ? ( value={displayValue(profile.work_phone)}
<div className="flex items-center gap-3 text-sm text-grayScale-700"> />
<Phone className="h-4 w-4 text-brand-600" /> <FieldGroup label="Member ID" value={String(profile.id)} mono />
<span> </div>
<span className="text-grayScale-500">Work: </span> </SectionCard>
{profile.work_phone.trim()}
</span>
</div>
) : null}
</CardContent>
</Card>
<Card className="shadow-soft lg:col-span-2"> {/* Account Activity */}
<CardHeader> <SectionCard title="Account Activity">
<CardTitle className="text-base">Account activity</CardTitle> <div className="grid gap-x-8 gap-y-5 sm:grid-cols-2">
</CardHeader> <FieldGroup label="Joined" value={formatDate(profile.created_at)} />
<CardContent className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4"> <FieldGroup
<div className="flex items-start gap-3"> label="Last Login"
<CalendarDays className="mt-0.5 h-4 w-4 text-brand-600" /> value={formatDateTime(profile.last_login)}
<ReadOnlyField label="Joined" value={formatDate(profile.created_at)} /> />
</div> <FieldGroup
<div className="flex items-start gap-3"> label="Email Verified"
<Clock3 className="mt-0.5 h-4 w-4 text-brand-600" /> value={profile.email_verified ? "Yes" : "No"}
<ReadOnlyField label="Last login" value={formatDateTime(profile.last_login)} /> />
</div> <FieldGroup
<div className="flex items-start gap-3"> label="Last Updated"
<BadgeCheck className="mt-0.5 h-4 w-4 text-brand-600" /> value={formatDate(profile.updated_at)}
<ReadOnlyField />
label="Email verification" </div>
value={profile.email_verified ? "Verified" : "Not verified"} </SectionCard>
/>
</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>
{/* Edit dialog */}
<Dialog open={editing} onOpenChange={(open) => !busy && setEditing(open)}> <Dialog open={editing} onOpenChange={(open) => !busy && setEditing(open)}>
<DialogContent className="max-h-[90vh] overflow-y-auto sm:max-w-2xl"> <DialogContent className="flex max-h-[90vh] max-w-lg flex-col overflow-hidden p-0">
<DialogHeader> <div className="flex items-center gap-3 border-b border-grayScale-100 px-6 py-5 pr-14">
<DialogTitle>Edit profile</DialogTitle> <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-[8px] bg-brand-100/60">
</DialogHeader> <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="min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5">
<div className="space-y-1.5"> <div className="grid gap-4 sm:grid-cols-2">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-first-name"> <div>
First name <label
</label> className="mb-1.5 block text-xs font-medium text-grayScale-600"
<Input htmlFor="profile-first-name"
id="profile-first-name" >
value={editForm.first_name} First name <span className="text-brand-500">*</span>
disabled={busy} </label>
onChange={(e) => <Input
setEditForm((prev) => ({ ...prev, first_name: e.target.value })) 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>
<div className="space-y-1.5">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-last-name"> <div className="grid gap-4 sm:grid-cols-2">
Last name <div>
</label> <label
<Input className="mb-1.5 block text-xs font-medium text-grayScale-600"
id="profile-last-name" htmlFor="profile-phone"
value={editForm.last_name} >
disabled={busy} Phone number
onChange={(e) => </label>
setEditForm((prev) => ({ ...prev, last_name: e.target.value })) <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>
<div className="space-y-1.5">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-phone"> <div className="grid gap-4 sm:grid-cols-2">
Phone number <div>
</label> <label
<Input className="mb-1.5 block text-xs font-medium text-grayScale-600"
id="profile-phone" htmlFor="profile-department"
value={editForm.phone_number} >
disabled={busy} Department
onChange={(e) => </label>
setEditForm((prev) => ({ ...prev, phone_number: e.target.value })) <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>
<div className="space-y-1.5">
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-work-phone"> <div>
Work phone <label className="mb-1.5 block text-xs font-medium text-grayScale-600">
Email
</label> </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 /> <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>
<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 Profile picture
</label> </label>
<PersonaProfilePictureUploadField <PersonaProfilePictureUploadField
@ -453,8 +536,12 @@ export function ProfilePage() {
} }
/> />
</div> </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 Bio
</label> </label>
<Textarea <Textarea
@ -463,27 +550,34 @@ export function ProfilePage() {
disabled={busy} disabled={busy}
rows={4} rows={4}
placeholder="A short introduction about your role and background." 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>
</div> </div>
<DialogFooter> <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}> <Button
type="button"
variant="outline"
onClick={() => setEditing(false)}
disabled={busy}
>
Cancel Cancel
</Button> </Button>
<Button <Button
type="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()} onClick={() => void handleSave()}
disabled={busy} disabled={busy}
> >
{saving ? <SpinnerIcon className="mr-2 h-4 w-4" /> : null} {saving ? <SpinnerIcon className="mr-2 h-4 w-4" /> : null}
{saving ? "Saving…" : "Save changes"} {saving ? "Saving…" : "Save changes"}
</Button> </Button>
</DialogFooter> </div>
</DialogContent> </DialogContent>
</Dialog> </Dialog>
</div> </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="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 className="mt-1.5 text-[1.75rem] font-semibold leading-none tracking-tight text-grayScale-800">{value}</div>
</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" /> <Icon className="h-5 w-5" />
</div> </div>
</div> </div>
@ -128,28 +128,22 @@ function BreakdownList({
title, title,
data, data,
total, total,
scrollable,
}: { }: {
title: string title: string
data: LabelCount[] data: LabelCount[]
total?: number 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 computedTotal = total ?? data.reduce((s, d) => s + d.count, 0)
const sorted = [...data].sort((a, b) => b.count - a.count) const sorted = [...data].sort((a, b) => b.count - a.count)
return ( return (
<Card className="shadow-none"> <Card className="shadow-none flex flex-col">
<CardHeader className="pb-2"> <CardHeader className="pb-2">
<CardTitle className="text-sm">{title}</CardTitle> <CardTitle className="text-sm">{title}</CardTitle>
</CardHeader> </CardHeader>
<CardContent className="p-4 pt-0"> <CardContent className="p-4 pt-0 flex-1 flex flex-col">
{sorted.length > 0 ? ( {sorted.length > 0 ? (
<div <div
className={cn( className="space-y-2.5 flex-1 overflow-y-auto overscroll-contain pr-1 max-h-[320px]"
"space-y-2.5",
scrollable && "max-h-64 overflow-y-auto overscroll-contain pr-1",
)}
> >
{sorted.map((item, i) => { {sorted.map((item, i) => {
const pct = computedTotal > 0 ? (item.count / computedTotal) * 100 : 0 const pct = computedTotal > 0 ? (item.count / computedTotal) * 100 : 0
@ -286,7 +280,7 @@ function Section({
onClick={() => setOpen((v) => !v)} 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" 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" /> <Icon className="h-4 w-4" />
</div> </div>
<span className="flex-1 text-sm font-semibold tracking-wide text-grayScale-800">{title}</span> <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"> <p className="mb-3 text-xs font-semibold uppercase tracking-wide text-grayScale-400">
Profile & demographics Profile & demographics
</p> </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 <BreakdownList
title="Education level" title="Learning goal"
data={users.by_education_level ?? []} data={users.by_learning_goal ?? []}
total={users.total_users}
/>
<BreakdownList
title="Language challenge"
data={users.by_language_challange ?? []}
total={users.total_users} total={users.total_users}
/> />
<BreakdownList <BreakdownList
title="Occupation" title="Occupation"
data={users.by_occupation ?? []} data={users.by_occupation ?? []}
total={users.total_users} total={users.total_users}
scrollable
/> />
<BreakdownList <BreakdownList
title="Age group" title="Age group"
@ -710,7 +708,6 @@ export function AnalyticsPage() {
title="Region" title="Region"
data={users.by_region ?? []} data={users.by_region ?? []}
total={users.total_users} total={users.total_users}
scrollable
/> />
<BreakdownList <BreakdownList
title="Account role" title="Account role"

View File

@ -395,7 +395,7 @@ export function CourseCategoryPage() {
: ""} : ""}
</DialogDescription> </DialogDescription>
</DialogHeader> </DialogHeader>
<DialogFooter> <DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button type="button" variant="outline" onClick={() => setDeleteTarget(null)} disabled={deleting}> <Button type="button" variant="outline" onClick={() => setDeleteTarget(null)} disabled={deleting}>
Cancel Cancel
</Button> </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"> <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> <DialogTitle>Edit module</DialogTitle>
<DialogDescription> <DialogDescription>
Update name, description, sort order, and icon (upload or URL). Update name, description, sort order, and icon (upload or URL).

View File

@ -557,7 +557,7 @@ export function CourseManagementPage() {
</DialogTrigger> </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"> <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"> <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"> <DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Create Unit Create Unit
</DialogTitle> </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"> <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"> <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"> <DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Edit Unit Edit Unit
</DialogTitle> </DialogTitle>
@ -1035,7 +1035,7 @@ export function CourseManagementPage() {
> >
<DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden"> <DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden">
<div className="bg-white"> <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"> <DialogTitle className="text-lg font-bold text-grayScale-900">
Delete Unit Delete Unit
</DialogTitle> </DialogTitle>

View File

@ -648,7 +648,7 @@ export function CourseModuleDetailPage() {
</DialogTrigger> </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"> <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"> <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"> <DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Create Lesson Create Lesson
</DialogTitle> </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"> <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"> <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"> <DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Edit Lesson Edit Lesson
</DialogTitle> </DialogTitle>
@ -1113,7 +1113,7 @@ export function CourseModuleDetailPage() {
> >
<DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden"> <DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden">
<div className="bg-white"> <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"> <DialogTitle className="text-lg font-bold text-grayScale-900">
Delete Lesson Delete Lesson
</DialogTitle> </DialogTitle>

View File

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

View File

@ -1302,7 +1302,7 @@ export function HumanLanguageSubModulePage() {
You can reactivate it later by setting status back to active. You can reactivate it later by setting status back to active.
</DialogDescription> </DialogDescription>
</DialogHeader> </DialogHeader>
<DialogFooter> <DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button <Button
type="button" type="button"
variant="outline" 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"> <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> <DialogTitle>Edit program</DialogTitle>
<DialogDescription> <DialogDescription>
Update name, description, sort order, and thumbnail. Upload an 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." ? " The practice will be unlinked until you attach it again. Questions are kept."
: " Other locations are unaffected."} : " Other locations are unaffected."}
</p> </p>
<DialogFooter> <DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button <Button
type="button" type="button"
variant="outline" variant="outline"
@ -754,7 +754,7 @@ export function LessonPracticesPage() {
</span>{" "} </span>{" "}
and all of its questions will be deleted. This cannot be undone. and all of its questions will be deleted. This cannot be undone.
</p> </p>
<DialogFooter> <DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button <Button
type="button" type="button"
variant="outline" variant="outline"

View File

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

View File

@ -1099,7 +1099,7 @@ export function PracticeDetailsPage() {
/> />
</div> </div>
</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}> <Button type="button" variant="outline" onClick={() => setEditOpen(false)} disabled={savePracticeLoading}>
Cancel Cancel
</Button> </Button>
@ -1120,7 +1120,7 @@ export function PracticeDetailsPage() {
This permanently removes the practice for this {parentTabCopy[parentTab].label.toLowerCase()}. The linked This permanently removes the practice for this {parentTabCopy[parentTab].label.toLowerCase()}. The linked
question set may remain unless you remove it separately. question set may remain unless you remove it separately.
</p> </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 <Button
type="button" type="button"
variant="outline" variant="outline"

View File

@ -95,7 +95,7 @@ export function PracticeMembersPage() {
/> />
</div> </div>
</div> </div>
<DialogFooter> <DialogFooter className="border-t border-grayScale-100 px-6 py-4">
<Button variant="outline" onClick={() => setIsModalOpen(false)}> <Button variant="outline" onClick={() => setIsModalOpen(false)}>
Cancel Cancel
</Button> </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"> <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> <DialogTitle>Edit course</DialogTitle>
<DialogDescription> <DialogDescription>
Update name, description, sort order, and thumbnail. Update name, description, sort order, and thumbnail.

View File

@ -517,7 +517,7 @@ export function ProgramDetailPage() {
</DialogTrigger> </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"> <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"> <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"> <DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Create Course Create Course
</DialogTitle> </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"> <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"> <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"> <DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Edit Course Edit Course
</DialogTitle> </DialogTitle>
@ -915,7 +915,7 @@ export function ProgramDetailPage() {
> >
<DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden"> <DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden">
<div className="bg-white"> <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"> <DialogTitle className="text-lg font-bold text-grayScale-900">
Delete Course Delete Course
</DialogTitle> </DialogTitle>

View File

@ -281,7 +281,7 @@ export function QuestionTypeGroupDetailPage() {
group only; other group memberships are unchanged. group only; other group memberships are unchanged.
</DialogDescription> </DialogDescription>
</DialogHeader> </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 <Button
type="button" type="button"
variant="outline" variant="outline"

View File

@ -719,7 +719,7 @@ export function QuestionTypeLibraryPage() {
Definitions will be removed from this group only; other group memberships are unchanged. Definitions will be removed from this group only; other group memberships are unchanged.
</DialogDescription> </DialogDescription>
</DialogHeader> </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 <Button
type="button" type="button"
variant="outline" variant="outline"
@ -768,7 +768,7 @@ export function QuestionTypeLibraryPage() {
</p> </p>
</div> </div>
) : null} ) : 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 <Button
type="button" type="button"
variant="outline" variant="outline"

View File

@ -611,7 +611,7 @@ export function UnitManagementPage() {
</DialogTrigger> </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"> <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"> <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"> <DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Create Modules Create Modules
</DialogTitle> </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"> <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"> <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"> <DialogTitle className="text-[20px] font-bold relative top-2 text-grayScale-900">
Edit Module Edit Module
</DialogTitle> </DialogTitle>
@ -1182,7 +1182,7 @@ export function UnitManagementPage() {
> >
<DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden"> <DialogContent className="max-w-md rounded-[16px] border-none p-0 overflow-hidden">
<div className="bg-white"> <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"> <DialogTitle className="text-lg font-bold text-grayScale-900">
Delete Module Delete Module
</DialogTitle> </DialogTitle>

View File

@ -64,7 +64,7 @@ export function AccessTierConfirmDialog({
{accessTierConfirmDescription(nextTier, contentLabel)} {accessTierConfirmDescription(nextTier, contentLabel)}
</DialogDescription> </DialogDescription>
</DialogHeader> </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 <Button
type="button" type="button"
variant="outline" 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 { useEffect, useState, type FormEvent } from "react";
import { Button } from "../../../components/ui/button"; import { Button } from "../../../components/ui/button";
import { import {
@ -196,7 +196,7 @@ export function AddModuleModal({
onUploadBusyChange={setIconUploadBusy} 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> <DialogClose asChild>
<Button <Button
type="button" type="button"

View File

@ -286,7 +286,7 @@ export function CatalogCoursePracticesPanel({
? " The practice will be unlinked until re-attached." ? " The practice will be unlinked until re-attached."
: " Other locations are unaffected."} : " Other locations are unaffected."}
</p> </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}> <Button variant="outline" onClick={() => setPracticeToUnlink(null)} disabled={unlinking}>
Cancel Cancel
</Button> </Button>
@ -309,7 +309,7 @@ export function CatalogCoursePracticesPanel({
</span>{" "} </span>{" "}
and all of its questions. and all of its questions.
</p> </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}> <Button variant="outline" onClick={() => setPracticeToDelete(null)} disabled={deleting}>
Cancel Cancel
</Button> </Button>

View File

@ -48,7 +48,7 @@ export function PracticeActionChoiceDialog({
return ( return (
<Dialog open={open} onOpenChange={onOpenChange}> <Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-lg rounded-2xl border-grayScale-200 p-0 sm:max-w-lg"> <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"> <DialogTitle className="text-lg font-bold text-grayScale-900">
Add practice Add practice
</DialogTitle> </DialogTitle>

View File

@ -64,7 +64,7 @@ export function PublishStatusConfirmDialog({
{publishStatusConfirmDescription(nextStatus, contentLabel)} {publishStatusConfirmDescription(nextStatus, contentLabel)}
</DialogDescription> </DialogDescription>
</DialogHeader> </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 <Button
type="button" type="button"
variant="outline" variant="outline"

View File

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

View File

@ -161,7 +161,7 @@ export function QuestionTypeGroupFormDialog({
</div> </div>
</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 <Button
type="button" type="button"
variant="outline" variant="outline"

View File

@ -288,7 +288,7 @@ export function UnitPracticesPanel({
? " The practice will be unlinked until re-attached." ? " The practice will be unlinked until re-attached."
: " Other locations are unaffected."} : " Other locations are unaffected."}
</p> </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}> <Button variant="outline" onClick={() => setPracticeToUnlink(null)} disabled={unlinking}>
Cancel Cancel
</Button> </Button>
@ -311,7 +311,7 @@ export function UnitPracticesPanel({
</span>{" "} </span>{" "}
and all of its questions. and all of its questions.
</p> </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}> <Button variant="outline" onClick={() => setPracticeToDelete(null)} disabled={deleting}>
Cancel Cancel
</Button> </Button>

View File

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

View File

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

View File

@ -1,8 +1,6 @@
import { Badge } from "../../../components/ui/badge"
import { Button } from "../../../components/ui/button" import { Button } from "../../../components/ui/button"
import { Input } from "../../../components/ui/input" import { Input } from "../../../components/ui/input"
import { Textarea } from "../../../components/ui/textarea" import { Textarea } from "../../../components/ui/textarea"
import { faqStatusBadgeVariant, faqStatusLabel } from "../../../lib/faqDisplay"
import type { FAQStatus } from "../../../types/faq.types" import type { FAQStatus } from "../../../types/faq.types"
export type FaqFormDraft = { export type FaqFormDraft = {
@ -24,8 +22,9 @@ type FaqFormProps = {
saving: boolean saving: boolean
savingAction?: "draft" | "publish" | null savingAction?: "draft" | "publish" | null
categories: string[] categories: string[]
currentStatus?: FAQStatus currentStep?: number
onChange: (patch: Partial<FaqFormDraft>) => void onChange: (patch: Partial<FaqFormDraft>) => void
onStepChange?: (step: number) => void
onSaveDraft: () => void onSaveDraft: () => void
onPublish: () => void onPublish: () => void
onCancel: () => void onCancel: () => void
@ -36,105 +35,177 @@ export function FaqForm({
saving, saving,
savingAction = null, savingAction = null,
categories, categories,
currentStatus, currentStep = 2,
onChange, onChange,
onStepChange,
onSaveDraft, onSaveDraft,
onPublish, onPublish,
onCancel, onCancel,
}: FaqFormProps) { }: FaqFormProps) {
const stepped = Boolean(onStepChange)
const showAll = !stepped
const canContinue =
currentStep === 1
? draft.question.trim().length > 0 && draft.answer.trim().length > 0
: true
return ( return (
<div className="space-y-5"> <div className="flex max-h-[calc(90vh-140px)] flex-col overflow-hidden">
<div> <div className="space-y-5 overflow-y-auto px-6 py-5">
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-grayScale-500"> {(showAll || currentStep === 1) && (
Question <>
</p> <div>
<Textarea <label className="mb-1.5 block text-xs font-medium text-grayScale-600">
value={draft.question} Question <span className="text-brand-500">*</span>
onChange={(e) => onChange({ question: e.target.value })} </label>
placeholder="How do I reset my password?" <Input
rows={2} value={draft.question}
disabled={saving} 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>
<div> <div className="flex shrink-0 items-center justify-between border-t border-grayScale-100 px-6 py-4">
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-grayScale-500"> <div className="flex items-center gap-2">
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">
<Button variant="outline" disabled={saving} onClick={onCancel}> <Button variant="outline" disabled={saving} onClick={onCancel}>
Cancel Cancel
</Button> </Button>
{currentStatus ? ( {stepped && currentStep === 2 && (
<Badge variant={faqStatusBadgeVariant(currentStatus)}> <Button
Currently {faqStatusLabel(currentStatus)} variant="outline"
</Badge> disabled={saving}
) : null} onClick={() => onStepChange?.(1)}
>
Back
</Button>
)}
</div> </div>
<div className="flex flex-wrap items-center gap-2"> <div className="flex items-center gap-2">
<Button {stepped && currentStep === 1 ? (
variant="outline" <Button
disabled={saving} className="bg-brand-500 text-white hover:bg-brand-600"
onClick={onSaveDraft} disabled={!canContinue}
> onClick={() => onStepChange?.(2)}
{saving && savingAction === "draft" ? "Saving draft…" : "Save as draft"} >
</Button> Continue
<Button </Button>
className="bg-brand-500 text-white hover:bg-brand-600" ) : (
disabled={saving} <>
onClick={onPublish} <Button
> variant="outline"
{saving && savingAction === "publish" ? "Publishing…" : "Publish FAQ"} disabled={saving}
</Button> 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> </div>
</div> </div>

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -364,6 +364,7 @@ export function NotificationsPage() {
try { try {
const resolved = await resolveNotificationDetail(notification) const resolved = await resolveNotificationDetail(notification)
console.log("[NotificationDetail]", resolved)
if (!hasNotificationContent(resolved)) { if (!hasNotificationContent(resolved)) {
setDetailError(true) setDetailError(true)
toast.error("Notification not found") toast.error("Notification not found")
@ -496,7 +497,7 @@ export function NotificationsPage() {
{totalCount.toLocaleString()} {totalCount.toLocaleString()}
</p> </p>
</div> </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" /> <Bell className="h-5 w-5" />
</div> </div>
</CardContent> </CardContent>
@ -509,7 +510,7 @@ export function NotificationsPage() {
{globalUnread.toLocaleString()} {globalUnread.toLocaleString()}
</p> </p>
</div> </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" /> <BellOff className="h-5 w-5" />
</div> </div>
</CardContent> </CardContent>
@ -522,7 +523,7 @@ export function NotificationsPage() {
{Array.from(new Set(notifications.map((n) => n.delivery_channel))).length || "—"} {Array.from(new Set(notifications.map((n) => n.delivery_channel))).length || "—"}
</p> </p>
</div> </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" /> <MailOpen className="h-5 w-5" />
</div> </div>
</CardContent> </CardContent>

View File

@ -74,7 +74,7 @@ export function EmailTemplateDeleteDialog({
</p> </p>
</div> </div>
) : null} ) : 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 <Button
variant="outline" variant="outline"
disabled={deleting} disabled={deleting}

View File

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

View File

@ -315,7 +315,7 @@ export function InviteTeamMemberDialog({
</div> </div>
) : null} ) : 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 <Button
type="button" type="button"
variant="outline" variant="outline"

View File

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

View File

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

View File

@ -72,7 +72,7 @@ export function DeleteAppVersionDialog({
</p> </p>
</div> </div>
) : null} ) : 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 <Button
variant="outline" variant="outline"
className="rounded-[6px]" className="rounded-[6px]"

View File

@ -72,7 +72,7 @@ export function DeleteSubscriptionPlanDialog({
</p> </p>
</div> </div>
) : null} ) : 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 <Button
variant="outline" variant="outline"
className="rounded-[6px]" className="rounded-[6px]"

View File

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

View File

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

View File

@ -1,5 +1,5 @@
import { useMemo, useState } from "react" 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 { AdminFiltersPanel } from "../../components/filters/AdminFiltersPanel"
import { ExportCsvButton } from "../../components/export/ExportCsvButton" import { ExportCsvButton } from "../../components/export/ExportCsvButton"
import { Input } from "../../components/ui/input" import { Input } from "../../components/ui/input"
@ -179,6 +179,34 @@ export function SubscriptionsExportPage() {
</AdminFiltersPanel> </AdminFiltersPanel>
</div> </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"> <p className="text-xs text-grayScale-400">
Subscription exports may contain learner PII and billing data. Restrict access to authorized Subscription exports may contain learner PII and billing data. Restrict access to authorized
staff only. staff only.

View File

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

View File

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