Merge branch 'el-ui' into main.
Prefer el-ui changes when resolving conflicts.
This commit is contained in:
commit
7e4c3fd3b9
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -27,3 +27,4 @@ dist-ssr
|
||||||
*.sw?
|
*.sw?
|
||||||
AGENTS.md
|
AGENTS.md
|
||||||
design-system.md
|
design-system.md
|
||||||
|
.opencode/
|
||||||
|
|
|
||||||
|
|
@ -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}
|
||||||
|
|
|
||||||
|
|
@ -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">
|
||||||
|
<DialogTitle className="text-base font-bold leading-snug text-grayScale-900">
|
||||||
{getNotificationTitle(notification) || "Notification"}
|
{getNotificationTitle(notification) || "Notification"}
|
||||||
</span>
|
|
||||||
</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">
|
||||||
|
{notification.delivery_channel}
|
||||||
|
</span>
|
||||||
|
<span className="text-grayScale-200">·</span>
|
||||||
|
<span>
|
||||||
{formatNotificationTimestamp(notification.timestamp)}
|
{formatNotificationTimestamp(notification.timestamp)}
|
||||||
</DialogDescription>
|
</span>
|
||||||
</DialogHeader>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="space-y-4">
|
{/* Tabs */}
|
||||||
{notification.image ? (
|
<div className="flex border-b border-grayScale-100 px-6">
|
||||||
<div className="overflow-hidden rounded-lg border border-grayScale-200 bg-grayScale-50">
|
{[
|
||||||
|
{ key: "details" as const, label: "Details" },
|
||||||
|
{ key: "preview" as const, label: "Preview" },
|
||||||
|
].map((t) => (
|
||||||
|
<button
|
||||||
|
key={t.key}
|
||||||
|
type="button"
|
||||||
|
onClick={() => setTab(t.key)}
|
||||||
|
className={cn(
|
||||||
|
"relative px-3 pb-2.5 text-xs font-semibold transition-colors",
|
||||||
|
tab === t.key
|
||||||
|
? "text-brand-600"
|
||||||
|
: "text-grayScale-400 hover:text-grayScale-600",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{t.label}
|
||||||
|
{tab === t.key && (
|
||||||
|
<span className="absolute inset-x-0 bottom-0 h-[2px] rounded-full bg-brand-500" />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Tab content */}
|
||||||
|
<div className="px-6 pb-8 pt-5">
|
||||||
|
{tab === "details" ? (
|
||||||
|
<DetailsTab notification={notification} onDelete={onDelete} />
|
||||||
|
) : (
|
||||||
|
<PreviewTab
|
||||||
|
notification={notification}
|
||||||
|
config={config}
|
||||||
|
Icon={Icon}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DetailsTab({
|
||||||
|
notification,
|
||||||
|
onDelete,
|
||||||
|
}: {
|
||||||
|
notification: Notification;
|
||||||
|
onDelete?: () => void;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="space-y-5">
|
||||||
|
{/* Message */}
|
||||||
|
|
||||||
|
{/* Image */}
|
||||||
|
{notification.image && (
|
||||||
|
<div className="overflow-hidden rounded-xl">
|
||||||
<img
|
<img
|
||||||
src={notification.image}
|
src={notification.image}
|
||||||
alt=""
|
alt=""
|
||||||
className="max-h-48 w-full object-cover"
|
className="max-h-48 w-full object-cover"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
)}
|
||||||
|
|
||||||
<div className="rounded-lg bg-grayScale-50 p-3">
|
{/* Metadata */}
|
||||||
<p className="text-sm leading-relaxed text-grayScale-600">
|
<div className="space-y-0 divide-y divide-grayScale-100">
|
||||||
{getNotificationMessage(notification) || "No message content."}
|
{[
|
||||||
</p>
|
{ 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>
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-3 text-xs text-grayScale-500 sm:grid-cols-2">
|
{/* Tags */}
|
||||||
<div>
|
{notification.payload.tags && notification.payload.tags.length > 0 && (
|
||||||
<p className="text-grayScale-400">Type</p>
|
<div className="flex flex-wrap gap-1.5">
|
||||||
<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) => (
|
{notification.payload.tags.map((tag) => (
|
||||||
<Badge key={tag} variant="secondary" className="text-[10px]">
|
<Badge
|
||||||
|
key={tag}
|
||||||
|
variant="secondary"
|
||||||
|
className="text-[10px] px-2 py-0.5"
|
||||||
|
>
|
||||||
{tag}
|
{tag}
|
||||||
</Badge>
|
</Badge>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
)}
|
||||||
</div>
|
|
||||||
|
|
||||||
{onDelete ? (
|
{/* Actions */}
|
||||||
<DialogFooter className="gap-2 sm:gap-2">
|
{onDelete && (
|
||||||
<Button variant="destructive" onClick={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
|
Delete notification
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</div>
|
||||||
) : null}
|
)}
|
||||||
</>
|
</div>
|
||||||
) : null}
|
);
|
||||||
</DialogContent>
|
}
|
||||||
</Dialog>
|
|
||||||
)
|
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>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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" />
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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,167 +245,198 @@ 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="pb-1">
|
<div className="space-y-2">
|
||||||
<h2 className="text-2xl font-semibold text-grayScale-800">{fullName}</h2>
|
<h2 className="text-lg font-semibold text-grayScale-900">
|
||||||
<p className="text-sm text-grayScale-500">{displayValue(profile.job_title)}</p>
|
{fullName}
|
||||||
</div>
|
</h2>
|
||||||
</div>
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
<div className="flex flex-wrap gap-2 pb-1">
|
<Badge
|
||||||
<Badge variant={isActive ? "default" : "secondary"}>
|
variant="outline"
|
||||||
{formatStatusLabel(profile.status)}
|
className="rounded-full border-grayScale-200 px-3 py-0.5 text-[11px] font-medium text-grayScale-600"
|
||||||
|
>
|
||||||
|
{formatRoleLabel(profile.team_role)}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Badge variant={profile.email_verified ? "default" : "outline"}>
|
{profile.job_title?.trim() && (
|
||||||
{profile.email_verified ? "Email verified" : "Email not verified"}
|
<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>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{profile.bio?.trim() ? (
|
</div>
|
||||||
<p className="mt-4 text-sm leading-relaxed text-grayScale-600">{profile.bio.trim()}</p>
|
<Button
|
||||||
) : null}
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="h-8 gap-1.5 rounded-lg text-xs font-medium text-grayScale-500"
|
||||||
|
onClick={startEditing}
|
||||||
|
>
|
||||||
|
<Pencil className="h-3.5 w-3.5" />
|
||||||
|
Edit
|
||||||
|
</Button>
|
||||||
</CardContent>
|
</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
|
||||||
|
label="Job Title"
|
||||||
|
value={displayValue(profile.job_title)}
|
||||||
|
/>
|
||||||
|
<FieldGroup
|
||||||
|
label="Work Phone"
|
||||||
|
value={displayValue(profile.work_phone)}
|
||||||
|
/>
|
||||||
|
<FieldGroup label="Member ID" value={String(profile.id)} mono />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3 text-sm text-grayScale-700">
|
</SectionCard>
|
||||||
<Phone className="h-4 w-4 text-brand-600" />
|
|
||||||
<span>{displayValue(profile.phone_number)}</span>
|
|
||||||
</div>
|
|
||||||
{profile.work_phone?.trim() ? (
|
|
||||||
<div className="flex items-center gap-3 text-sm text-grayScale-700">
|
|
||||||
<Phone className="h-4 w-4 text-brand-600" />
|
|
||||||
<span>
|
|
||||||
<span className="text-grayScale-500">Work: </span>
|
|
||||||
{profile.work_phone.trim()}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<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"
|
|
||||||
value={profile.email_verified ? "Verified" : "Not verified"}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-start gap-3">
|
</SectionCard>
|
||||||
<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="min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5">
|
||||||
<div className="grid gap-4 sm:grid-cols-2">
|
<div className="grid gap-4 sm:grid-cols-2">
|
||||||
<div className="space-y-1.5">
|
<div>
|
||||||
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-first-name">
|
<label
|
||||||
First name
|
className="mb-1.5 block text-xs font-medium text-grayScale-600"
|
||||||
|
htmlFor="profile-first-name"
|
||||||
|
>
|
||||||
|
First name <span className="text-brand-500">*</span>
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
id="profile-first-name"
|
id="profile-first-name"
|
||||||
value={editForm.first_name}
|
value={editForm.first_name}
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setEditForm((prev) => ({ ...prev, first_name: e.target.value }))
|
setEditForm((prev) => ({
|
||||||
|
...prev,
|
||||||
|
first_name: e.target.value,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
<div>
|
||||||
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-last-name">
|
<label
|
||||||
Last name
|
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>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
id="profile-last-name"
|
id="profile-last-name"
|
||||||
value={editForm.last_name}
|
value={editForm.last_name}
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setEditForm((prev) => ({ ...prev, last_name: e.target.value }))
|
setEditForm((prev) => ({
|
||||||
|
...prev,
|
||||||
|
last_name: e.target.value,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
</div>
|
||||||
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-phone">
|
|
||||||
|
<div className="grid gap-4 sm:grid-cols-2">
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
className="mb-1.5 block text-xs font-medium text-grayScale-600"
|
||||||
|
htmlFor="profile-phone"
|
||||||
|
>
|
||||||
Phone number
|
Phone number
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
|
|
@ -392,12 +444,18 @@ export function ProfilePage() {
|
||||||
value={editForm.phone_number}
|
value={editForm.phone_number}
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setEditForm((prev) => ({ ...prev, phone_number: e.target.value }))
|
setEditForm((prev) => ({
|
||||||
|
...prev,
|
||||||
|
phone_number: e.target.value,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
<div>
|
||||||
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-work-phone">
|
<label
|
||||||
|
className="mb-1.5 block text-xs font-medium text-grayScale-600"
|
||||||
|
htmlFor="profile-work-phone"
|
||||||
|
>
|
||||||
Work phone
|
Work phone
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
|
|
@ -405,12 +463,21 @@ export function ProfilePage() {
|
||||||
value={editForm.work_phone}
|
value={editForm.work_phone}
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setEditForm((prev) => ({ ...prev, work_phone: e.target.value }))
|
setEditForm((prev) => ({
|
||||||
|
...prev,
|
||||||
|
work_phone: e.target.value,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
</div>
|
||||||
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-department">
|
|
||||||
|
<div className="grid gap-4 sm:grid-cols-2">
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
className="mb-1.5 block text-xs font-medium text-grayScale-600"
|
||||||
|
htmlFor="profile-department"
|
||||||
|
>
|
||||||
Department
|
Department
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
|
|
@ -418,12 +485,18 @@ export function ProfilePage() {
|
||||||
value={editForm.department}
|
value={editForm.department}
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setEditForm((prev) => ({ ...prev, department: e.target.value }))
|
setEditForm((prev) => ({
|
||||||
|
...prev,
|
||||||
|
department: e.target.value,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
<div>
|
||||||
<label className="text-sm font-medium text-grayScale-700" htmlFor="profile-job-title">
|
<label
|
||||||
|
className="mb-1.5 block text-xs font-medium text-grayScale-600"
|
||||||
|
htmlFor="profile-job-title"
|
||||||
|
>
|
||||||
Job title
|
Job title
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
|
|
@ -431,17 +504,27 @@ export function ProfilePage() {
|
||||||
value={editForm.job_title}
|
value={editForm.job_title}
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setEditForm((prev) => ({ ...prev, job_title: e.target.value }))
|
setEditForm((prev) => ({
|
||||||
|
...prev,
|
||||||
|
job_title: e.target.value,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5 sm:col-span-2">
|
|
||||||
<label className="text-sm font-medium text-grayScale-700">Email</label>
|
|
||||||
<Input value={profile.email} disabled />
|
|
||||||
<p className="text-xs text-grayScale-500">Email is managed by your administrator.</p>
|
|
||||||
</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">
|
||||||
|
Email
|
||||||
|
</label>
|
||||||
|
<Input value={profile.email} disabled />
|
||||||
|
<p className="mt-1 text-[11px] text-grayScale-400">
|
||||||
|
Email is managed by your administrator.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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).
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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)}
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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,9 +246,11 @@ 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 justify-between gap-4">
|
||||||
<div className="flex flex-wrap items-center gap-3 text-xs text-grayScale-500">
|
<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}
|
||||||
|
|
@ -301,8 +303,8 @@ export function QuestionTypeDefinitionPracticesDialog({
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
|
) : null}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<DialogTitle className="text-[15px] font-semibold text-grayScale-900">
|
||||||
Delete FAQ?
|
Delete FAQ?
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogDescription className="text-left text-grayScale-600">
|
<DialogDescription className="mt-0.5 text-xs text-grayScale-500">
|
||||||
This permanently removes the FAQ from the help center. This action cannot be undone.
|
This permanently removes the FAQ from the help center.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</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>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -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,31 +35,42 @@ 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 className="space-y-5 overflow-y-auto px-6 py-5">
|
||||||
|
{(showAll || currentStep === 1) && (
|
||||||
|
<>
|
||||||
<div>
|
<div>
|
||||||
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-grayScale-500">
|
<label className="mb-1.5 block text-xs font-medium text-grayScale-600">
|
||||||
Question
|
Question <span className="text-brand-500">*</span>
|
||||||
</p>
|
</label>
|
||||||
<Textarea
|
<Input
|
||||||
value={draft.question}
|
value={draft.question}
|
||||||
onChange={(e) => onChange({ question: e.target.value })}
|
onChange={(e) => onChange({ question: e.target.value })}
|
||||||
placeholder="How do I reset my password?"
|
placeholder="How do I reset my password?"
|
||||||
rows={2}
|
|
||||||
disabled={saving}
|
disabled={saving}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-grayScale-500">
|
<label className="mb-1.5 block text-xs font-medium text-grayScale-600">
|
||||||
Answer
|
Answer <span className="text-brand-500">*</span>
|
||||||
</p>
|
</label>
|
||||||
<Textarea
|
<Textarea
|
||||||
value={draft.answer}
|
value={draft.answer}
|
||||||
onChange={(e) => onChange({ answer: e.target.value })}
|
onChange={(e) => onChange({ answer: e.target.value })}
|
||||||
|
|
@ -68,14 +78,17 @@ export function FaqForm({
|
||||||
rows={6}
|
rows={6}
|
||||||
disabled={saving}
|
disabled={saving}
|
||||||
/>
|
/>
|
||||||
<p className="mt-1 text-xs text-grayScale-400">Plain text only.</p>
|
<p className="mt-1 text-[11px] text-grayScale-400">Plain text only.</p>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="grid gap-5 sm:grid-cols-2">
|
{(showAll || currentStep === 2) && (
|
||||||
|
<>
|
||||||
<div>
|
<div>
|
||||||
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-grayScale-500">
|
<label className="mb-1.5 block text-xs font-medium text-grayScale-600">
|
||||||
Category
|
Category
|
||||||
</p>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
value={draft.category}
|
value={draft.category}
|
||||||
onChange={(e) => onChange({ category: e.target.value })}
|
onChange={(e) => onChange({ category: e.target.value })}
|
||||||
|
|
@ -93,9 +106,9 @@ export function FaqForm({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-grayScale-500">
|
<label className="mb-1.5 block text-xs font-medium text-grayScale-600">
|
||||||
Display order
|
Display order
|
||||||
</p>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
min={0}
|
min={0}
|
||||||
|
|
@ -103,38 +116,96 @@ export function FaqForm({
|
||||||
onChange={(e) => onChange({ display_order: e.target.value })}
|
onChange={(e) => onChange({ display_order: e.target.value })}
|
||||||
disabled={saving}
|
disabled={saving}
|
||||||
/>
|
/>
|
||||||
<p className="mt-1 text-xs text-grayScale-400">
|
<p className="mt-1 text-[11px] text-grayScale-400">
|
||||||
Lower numbers appear first.
|
Lower numbers appear first.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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 className="flex flex-wrap items-center justify-between gap-3 border-t border-grayScale-100 pt-5">
|
<div className="flex shrink-0 items-center justify-between border-t border-grayScale-100 px-6 py-4">
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex 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">
|
||||||
|
{stepped && currentStep === 1 ? (
|
||||||
|
<Button
|
||||||
|
className="bg-brand-500 text-white hover:bg-brand-600"
|
||||||
|
disabled={!canContinue}
|
||||||
|
onClick={() => onStepChange?.(2)}
|
||||||
|
>
|
||||||
|
Continue
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
disabled={saving}
|
disabled={saving}
|
||||||
onClick={onSaveDraft}
|
onClick={onSaveDraft}
|
||||||
>
|
>
|
||||||
{saving && savingAction === "draft" ? "Saving draft…" : "Save as draft"}
|
{saving && savingAction === "draft" ? "Saving…" : "Save as draft"}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
className="bg-brand-500 text-white hover:bg-brand-600"
|
className="bg-brand-500 text-white hover:bg-brand-600"
|
||||||
disabled={saving}
|
disabled={saving}
|
||||||
onClick={onPublish}
|
onClick={onPublish}
|
||||||
>
|
>
|
||||||
{saving && savingAction === "publish" ? "Publishing…" : "Publish FAQ"}
|
{saving && savingAction === "publish" ? "Publishing…" : "Publish"}
|
||||||
</Button>
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -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" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<DialogTitle className="text-[15px] font-semibold text-grayScale-900">
|
||||||
Preview as learner
|
Preview as learner
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription className="mt-0.5 text-xs text-grayScale-500">
|
||||||
Published FAQs from GET /faqs (ACTIVE only, no authentication).
|
Published FAQs from GET /faqs (ACTIVE only, no authentication).
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</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>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { notifyApiError } from "../../lib/apiErrors"
|
import { notifyApiError } from "../../lib/apiErrors"
|
||||||
import { useEffect, useMemo, useState } from "react"
|
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||||
import { Link, useNavigate } from "react-router-dom"
|
import { Link, useNavigate } from "react-router-dom"
|
||||||
import { Bell, CalendarClock, Mail, MailOpen, Megaphone, Search, Smartphone } from "lucide-react"
|
import { Bell, CalendarClock, ChevronDown, ChevronLeft, ChevronRight, Mail, MailOpen, Megaphone, Search, Smartphone, Users } from "lucide-react"
|
||||||
import { toast } from "sonner"
|
import { toast } from "sonner"
|
||||||
import { Card, CardContent } from "../../components/ui/card"
|
import { Card, CardContent } from "../../components/ui/card"
|
||||||
import { Button } from "../../components/ui/button"
|
import { Button } from "../../components/ui/button"
|
||||||
|
|
@ -13,6 +13,7 @@ import { SpinnerIcon } from "../../components/ui/spinner-icon"
|
||||||
import { NotificationSchedulePicker } from "../../components/notifications/NotificationSchedulePicker"
|
import { NotificationSchedulePicker } from "../../components/notifications/NotificationSchedulePicker"
|
||||||
import { EmailComposeFields } from "../../components/notifications/EmailComposeFields"
|
import { EmailComposeFields } from "../../components/notifications/EmailComposeFields"
|
||||||
import { cn } from "../../lib/utils"
|
import { cn } from "../../lib/utils"
|
||||||
|
import { Stepper } from "../../components/ui/stepper"
|
||||||
import {
|
import {
|
||||||
sendBulkEmail,
|
sendBulkEmail,
|
||||||
sendBulkInApp,
|
sendBulkInApp,
|
||||||
|
|
@ -53,6 +54,8 @@ import type { TeamMember } from "../../types/team.types"
|
||||||
|
|
||||||
type SendMode = "now" | "schedule"
|
type SendMode = "now" | "schedule"
|
||||||
|
|
||||||
|
const NOTIFICATION_STEPS = ["Channel", "Content", "Audience", "Preview"]
|
||||||
|
|
||||||
const CHANNELS: {
|
const CHANNELS: {
|
||||||
value: NotificationChannel
|
value: NotificationChannel
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -157,6 +160,7 @@ export function CreateNotificationPage() {
|
||||||
const [emailTemplates, setEmailTemplates] = useState<EmailTemplate[]>([])
|
const [emailTemplates, setEmailTemplates] = useState<EmailTemplate[]>([])
|
||||||
const [emailTemplatesLoading, setEmailTemplatesLoading] = useState(false)
|
const [emailTemplatesLoading, setEmailTemplatesLoading] = useState(false)
|
||||||
const [sendSummary, setSendSummary] = useState<BulkSendSummary | null>(null)
|
const [sendSummary, setSendSummary] = useState<BulkSendSummary | null>(null)
|
||||||
|
const [currentStep, setCurrentStep] = useState(1)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRecipientsLoading(true)
|
setRecipientsLoading(true)
|
||||||
|
|
@ -305,6 +309,52 @@ export function CreateNotificationPage() {
|
||||||
emailTemplateVariables,
|
emailTemplateVariables,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const validateStep = useCallback(
|
||||||
|
(step: number): boolean => {
|
||||||
|
if (step === 2) {
|
||||||
|
if (channel === "email") {
|
||||||
|
const emailError = validateEmailComposeInput({
|
||||||
|
templateSlug: emailTemplateSlug,
|
||||||
|
subject: title,
|
||||||
|
message,
|
||||||
|
htmlBody,
|
||||||
|
template: selectedEmailTemplate,
|
||||||
|
templateVariables: emailTemplateVariables,
|
||||||
|
})
|
||||||
|
if (emailError) {
|
||||||
|
toast.error(emailError)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
} else if (channel !== "sms" && !title.trim()) {
|
||||||
|
toast.error("Title is required")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (channel !== "email" && !message.trim()) {
|
||||||
|
toast.error("Message is required")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (isScheduling && !scheduledAt) {
|
||||||
|
toast.error("Choose a schedule date and time")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (step === 3) {
|
||||||
|
return validateTargeting()
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
[channel, title, message, htmlBody, emailTemplateSlug, emailTemplateVariables, selectedEmailTemplate, isScheduling, scheduledAt],
|
||||||
|
)
|
||||||
|
|
||||||
|
const goNext = useCallback(() => {
|
||||||
|
if (!validateStep(currentStep)) return
|
||||||
|
setCurrentStep((s) => Math.min(s + 1, 4))
|
||||||
|
}, [currentStep, validateStep])
|
||||||
|
|
||||||
|
const goPrev = useCallback(() => {
|
||||||
|
setCurrentStep((s) => Math.max(s - 1, 1))
|
||||||
|
}, [])
|
||||||
|
|
||||||
const validateTargeting = (): boolean => {
|
const validateTargeting = (): boolean => {
|
||||||
if (audienceMode === "platform_role" || audienceMode === "team_role") return true
|
if (audienceMode === "platform_role" || audienceMode === "team_role") return true
|
||||||
if (audienceMode === "platform_selected") {
|
if (audienceMode === "platform_selected") {
|
||||||
|
|
@ -513,47 +563,28 @@ export function CreateNotificationPage() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const activeStep = currentStep
|
||||||
|
const isLastStep = currentStep === 4
|
||||||
|
|
||||||
const previewIcon = CHANNELS.find((c) => c.value === channel)?.icon ?? Bell
|
const previewIcon = CHANNELS.find((c) => c.value === channel)?.icon ?? Bell
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto w-full max-w-5xl space-y-5">
|
<div className="mx-auto w-full max-w-5xl space-y-5">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<nav className="flex items-center gap-1 text-xs text-grayScale-400">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="hover:text-grayScale-600"
|
|
||||||
onClick={() => navigate("/dashboard")}
|
|
||||||
>
|
|
||||||
Dashboard
|
|
||||||
</button>
|
|
||||||
<span>/</span>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="hover:text-grayScale-600"
|
|
||||||
onClick={() => navigate("/notifications")}
|
|
||||||
>
|
|
||||||
Notifications
|
|
||||||
</button>
|
|
||||||
<span>/</span>
|
|
||||||
<span className="text-grayScale-500">Send</span>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||||
|
<div className="flex items-start gap-3">
|
||||||
|
<div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-brand-100/60 text-brand-600">
|
||||||
|
<Megaphone className="h-5 w-5" />
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-xs font-semibold uppercase tracking-[0.16em] text-grayScale-400">
|
<h1 className="text-2xl font-semibold tracking-tight text-grayScale-900">
|
||||||
Notifications
|
|
||||||
</p>
|
|
||||||
<h1 className="mt-1 flex items-center gap-2 text-2xl font-semibold tracking-tight text-grayScale-700">
|
|
||||||
Send notification
|
Send notification
|
||||||
<span className="inline-flex h-7 items-center gap-1 rounded-full bg-brand-500/90 px-2 text-[11px] font-medium text-white">
|
|
||||||
<Megaphone className="h-3.5 w-3.5" />
|
|
||||||
Composer
|
|
||||||
</span>
|
|
||||||
</h1>
|
</h1>
|
||||||
<p className="mt-1 text-xs text-grayScale-400">
|
<p className="mt-0.5 text-xs text-grayScale-400">
|
||||||
Send or schedule bulk SMS, email, push, or in-app notifications.
|
Send or schedule bulk SMS, email, push, or in-app notifications.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
<Button variant="outline" size="sm" asChild>
|
<Button variant="outline" size="sm" asChild>
|
||||||
<Link to="/notifications/scheduled">Scheduled jobs</Link>
|
<Link to="/notifications/scheduled">Scheduled jobs</Link>
|
||||||
|
|
@ -574,83 +605,78 @@ export function CreateNotificationPage() {
|
||||||
<BulkSendSummaryPanel summary={sendSummary} onDismiss={() => setSendSummary(null)} />
|
<BulkSendSummaryPanel summary={sendSummary} onDismiss={() => setSendSummary(null)} />
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
<div className="rounded-2xl border border-grayScale-100 bg-white px-6 py-5 shadow-sm">
|
||||||
|
<Stepper steps={NOTIFICATION_STEPS} currentStep={activeStep} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onSubmit={handleSubmit}
|
onSubmit={(e) => {
|
||||||
className="grid gap-4 md:grid-cols-[minmax(0,1.5fr)_minmax(0,1.1fr)]"
|
e.preventDefault()
|
||||||
|
if (!isLastStep) {
|
||||||
|
goNext()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
void handleSubmit(e)
|
||||||
|
}}
|
||||||
|
className="space-y-5"
|
||||||
>
|
>
|
||||||
<div className="space-y-4">
|
{/* Step 1: Channel & Delivery */}
|
||||||
<Card className="border border-grayScale-100 shadow-none">
|
{currentStep === 1 && (
|
||||||
<CardContent className="space-y-4 p-4">
|
<div className="rounded-2xl border border-grayScale-100 bg-white p-5 shadow-sm">
|
||||||
<div className="grid gap-3 sm:grid-cols-2">
|
<div className="mb-4 flex items-center gap-2">
|
||||||
|
<span className="flex h-6 w-6 items-center justify-center rounded-full bg-brand-500 text-[11px] font-bold text-white">1</span>
|
||||||
|
<p className="text-sm font-semibold text-grayScale-800">Channel & delivery</p>
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-4 sm:grid-cols-2">
|
||||||
<div>
|
<div>
|
||||||
<p className="mb-2 text-xs font-semibold uppercase tracking-[0.14em] text-grayScale-400">
|
<label className="mb-1.5 block text-xs font-semibold uppercase tracking-[0.14em] text-grayScale-400">
|
||||||
Channel
|
Channel
|
||||||
</p>
|
</label>
|
||||||
<div className="flex flex-wrap gap-1 rounded-full border border-grayScale-200 bg-grayScale-50 p-0.5 text-xs font-medium">
|
<div className="relative">
|
||||||
{CHANNELS.map(({ value, label, icon: Icon }) => (
|
<select
|
||||||
<button
|
value={channel}
|
||||||
key={value}
|
onChange={(e) => {
|
||||||
type="button"
|
const v = e.target.value as NotificationChannel
|
||||||
onClick={() => {
|
setChannel(v)
|
||||||
setChannel(value)
|
if (!isAudienceModeValidForChannel(audienceMode, v)) {
|
||||||
if (!isAudienceModeValidForChannel(audienceMode, value)) {
|
|
||||||
setAudienceMode("platform_role")
|
setAudienceMode("platform_role")
|
||||||
}
|
}
|
||||||
if (value === "sms") setTitle("")
|
if (v === "sms") setTitle("")
|
||||||
}}
|
}}
|
||||||
className={cn(
|
className="h-10 w-full appearance-none rounded-lg border border-grayScale-200 bg-white pl-3 pr-9 text-sm font-medium text-grayScale-700 transition-colors focus:border-brand-400 focus:outline-none focus:ring-2 focus:ring-brand-200"
|
||||||
"flex items-center gap-1 rounded-full px-3 py-1.5 transition-colors",
|
|
||||||
channel === value
|
|
||||||
? "bg-brand-500 text-white shadow-sm"
|
|
||||||
: "text-grayScale-500 hover:text-grayScale-700",
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
<Icon className="h-3.5 w-3.5" />
|
{CHANNELS.map((c) => (
|
||||||
{label}
|
<option key={c.value} value={c.value}>{c.label}</option>
|
||||||
</button>
|
|
||||||
))}
|
))}
|
||||||
|
</select>
|
||||||
|
<ChevronDown className="pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-grayScale-400" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p className="mb-2 text-xs font-semibold uppercase tracking-[0.14em] text-grayScale-400">
|
<label className="mb-1.5 block text-xs font-semibold uppercase tracking-[0.14em] text-grayScale-400">
|
||||||
Delivery
|
Delivery
|
||||||
</p>
|
</label>
|
||||||
<div className="inline-flex rounded-full border border-grayScale-200 bg-grayScale-50 p-0.5 text-xs font-medium">
|
<div className="relative">
|
||||||
<button
|
<select
|
||||||
type="button"
|
value={sendMode}
|
||||||
onClick={() => {
|
onChange={(e) => {
|
||||||
setSendMode("now")
|
const v = e.target.value as SendMode
|
||||||
setScheduledAt("")
|
setSendMode(v)
|
||||||
|
if (v === "now") setScheduledAt("")
|
||||||
}}
|
}}
|
||||||
className={cn(
|
className="h-10 w-full appearance-none rounded-lg border border-grayScale-200 bg-white pl-3 pr-9 text-sm font-medium text-grayScale-700 transition-colors focus:border-brand-400 focus:outline-none focus:ring-2 focus:ring-brand-200"
|
||||||
"flex items-center gap-1 rounded-full px-3 py-1.5 transition-colors",
|
|
||||||
sendMode === "now"
|
|
||||||
? "bg-brand-500 text-white shadow-sm"
|
|
||||||
: "text-grayScale-500 hover:text-grayScale-700",
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
Send now
|
<option value="now">Send now</option>
|
||||||
</button>
|
<option value="schedule">Schedule</option>
|
||||||
<button
|
</select>
|
||||||
type="button"
|
<ChevronDown className="pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-grayScale-400" />
|
||||||
onClick={() => setSendMode("schedule")}
|
|
||||||
className={cn(
|
|
||||||
"flex items-center gap-1 rounded-full px-3 py-1.5 transition-colors",
|
|
||||||
sendMode === "schedule"
|
|
||||||
? "bg-brand-500 text-white shadow-sm"
|
|
||||||
: "text-grayScale-500 hover:text-grayScale-700",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<CalendarClock className="h-3.5 w-3.5" />
|
|
||||||
Schedule
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isScheduling && (
|
{isScheduling && (
|
||||||
<div>
|
<div className="mt-4 border-t border-grayScale-100 pt-4">
|
||||||
<label className="mb-1 block text-xs font-medium text-grayScale-500">
|
<label className="mb-1 block text-xs font-medium text-grayScale-500">
|
||||||
Scheduled at (UTC)
|
Scheduled at (UTC)
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -660,7 +686,16 @@ export function CreateNotificationPage() {
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Step 2: Content */}
|
||||||
|
{currentStep === 2 && (
|
||||||
|
<div className="rounded-2xl border border-grayScale-100 bg-white p-5 shadow-sm">
|
||||||
|
<div className="mb-4 flex items-center gap-2">
|
||||||
|
<span className="flex h-6 w-6 items-center justify-center rounded-full bg-brand-500 text-[11px] font-bold text-white">2</span>
|
||||||
|
<p className="text-sm font-semibold text-grayScale-800">Content</p>
|
||||||
|
</div>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{channel === "email" ? (
|
{channel === "email" ? (
|
||||||
<EmailComposeFields
|
<EmailComposeFields
|
||||||
|
|
@ -746,13 +781,10 @@ export function CreateNotificationPage() {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
{supportsAttachment && (
|
{supportsAttachment && (
|
||||||
<Card className="border border-grayScale-100 shadow-none">
|
<div className="mt-4 border-t border-grayScale-100 pt-4">
|
||||||
<CardContent className="space-y-2 p-4">
|
<p className="mb-2 block text-xs font-medium text-grayScale-500">
|
||||||
<p className="mb-1 block text-xs font-medium text-grayScale-500">
|
|
||||||
{channel === "push" ? "Image (push only)" : "Attachment (email only)"}
|
{channel === "push" ? "Image (push only)" : "Attachment (email only)"}
|
||||||
</p>
|
</p>
|
||||||
<FileUpload
|
<FileUpload
|
||||||
|
|
@ -767,42 +799,20 @@ export function CreateNotificationPage() {
|
||||||
}
|
}
|
||||||
className="min-h-[110px] rounded-lg border-2 border-dashed border-grayScale-300 transition-colors hover:border-brand-400 hover:bg-brand-50/30"
|
className="min-h-[110px] rounded-lg border-2 border-dashed border-grayScale-300 transition-colors hover:border-brand-400 hover:bg-brand-50/30"
|
||||||
/>
|
/>
|
||||||
</CardContent>
|
</div>
|
||||||
</Card>
|
)}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center justify-between gap-3 pt-1">
|
{/* Step 3: Audience */}
|
||||||
<p className="text-[11px] text-grayScale-400">
|
{currentStep === 3 && (
|
||||||
{isScheduling
|
<div className="rounded-2xl border border-grayScale-100 bg-white p-5 shadow-sm">
|
||||||
? "Creates a scheduled job processed by the backend worker."
|
<div className="mb-4 flex items-center gap-2">
|
||||||
: "Delivers immediately with sent/failed counts returned."}
|
<span className="flex h-6 w-6 items-center justify-center rounded-full bg-brand-500 text-[11px] font-bold text-white">3</span>
|
||||||
</p>
|
<p className="text-sm font-semibold text-grayScale-800">Audience</p>
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Button type="button" variant="outline" size="sm" onClick={resetForm} disabled={sending}>
|
|
||||||
Clear
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
size="sm"
|
|
||||||
disabled={sending || (channel === "email" ? !emailContentReady : !message.trim())}
|
|
||||||
>
|
|
||||||
{sending ? (
|
|
||||||
<>
|
|
||||||
<SpinnerIcon className="mr-2 h-3.5 w-3.5" alt="" />
|
|
||||||
{isScheduling ? "Scheduling…" : "Sending…"}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<MailOpen className="mr-2 h-3.5 w-3.5" />
|
|
||||||
{isScheduling ? "Schedule notification" : "Send notification"}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
className={cn(
|
className={cn(
|
||||||
"border shadow-none",
|
"border shadow-none",
|
||||||
|
|
@ -813,20 +823,25 @@ export function CreateNotificationPage() {
|
||||||
: "border-grayScale-100",
|
: "border-grayScale-100",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<CardContent className="space-y-3 p-4">
|
<CardContent className="space-y-3 p-5">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<div className="grid h-7 w-7 place-items-center rounded-md bg-brand-100/60 text-brand-600">
|
||||||
|
<Users className="h-3.5 w-3.5" />
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-xs font-semibold text-grayScale-600">Platform recipients</p>
|
<p className="text-xs font-semibold text-grayScale-700">Platform recipients</p>
|
||||||
<p className="text-[10px] text-grayScale-400">Learners and platform users</p>
|
<p className="text-[10px] text-grayScale-400">Learners and platform users</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="inline-flex flex-wrap gap-1 rounded-full border border-grayScale-200 bg-grayScale-50 p-0.5 text-xs font-medium">
|
</div>
|
||||||
|
<div className="inline-flex flex-wrap gap-1.5 text-xs font-medium">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setAudienceMode("platform_role")}
|
onClick={() => setAudienceMode("platform_role")}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-full px-3 py-1.5 transition-colors",
|
"rounded-lg px-3 py-2 transition-all",
|
||||||
audienceMode === "platform_role"
|
audienceMode === "platform_role"
|
||||||
? "bg-brand-500 text-white shadow-sm"
|
? "bg-brand-500 text-white shadow-sm"
|
||||||
: "text-grayScale-500 hover:text-grayScale-700",
|
: "border border-grayScale-200 bg-white text-grayScale-500 hover:border-grayScale-300 hover:text-grayScale-700",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
Platform role
|
Platform role
|
||||||
|
|
@ -838,10 +853,10 @@ export function CreateNotificationPage() {
|
||||||
setUserSearchQuery("")
|
setUserSearchQuery("")
|
||||||
}}
|
}}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-full px-3 py-1.5 transition-colors",
|
"rounded-lg px-3 py-2 transition-all",
|
||||||
audienceMode === "platform_selected"
|
audienceMode === "platform_selected"
|
||||||
? "bg-brand-500 text-white shadow-sm"
|
? "bg-brand-500 text-white shadow-sm"
|
||||||
: "text-grayScale-500 hover:text-grayScale-700",
|
: "border border-grayScale-200 bg-white text-grayScale-500 hover:border-grayScale-300 hover:text-grayScale-700",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
Platform users
|
Platform users
|
||||||
|
|
@ -851,10 +866,10 @@ export function CreateNotificationPage() {
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setAudienceMode("direct")}
|
onClick={() => setAudienceMode("direct")}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-full px-3 py-1.5 transition-colors",
|
"rounded-lg px-3 py-2 transition-all",
|
||||||
audienceMode === "direct"
|
audienceMode === "direct"
|
||||||
? "bg-brand-500 text-white shadow-sm"
|
? "bg-brand-500 text-white shadow-sm"
|
||||||
: "text-grayScale-500 hover:text-grayScale-700",
|
: "border border-grayScale-200 bg-white text-grayScale-500 hover:border-grayScale-300 hover:text-grayScale-700",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
Direct {channel === "sms" ? "phones" : "emails"}
|
Direct {channel === "sms" ? "phones" : "emails"}
|
||||||
|
|
@ -1021,20 +1036,25 @@ export function CreateNotificationPage() {
|
||||||
: "border-grayScale-100",
|
: "border-grayScale-100",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<CardContent className="space-y-3 p-4">
|
<CardContent className="space-y-3 p-5">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<div className="grid h-7 w-7 place-items-center rounded-md bg-brand-100/60 text-brand-600">
|
||||||
|
<Users className="h-3.5 w-3.5" />
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-xs font-semibold text-grayScale-600">Team recipients</p>
|
<p className="text-xs font-semibold text-grayScale-700">Team recipients</p>
|
||||||
<p className="text-[10px] text-grayScale-400">Staff and team members</p>
|
<p className="text-[10px] text-grayScale-400">Staff and team members</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="inline-flex flex-wrap gap-1 rounded-full border border-grayScale-200 bg-grayScale-50 p-0.5 text-xs font-medium">
|
</div>
|
||||||
|
<div className="inline-flex flex-wrap gap-1.5 text-xs font-medium">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setAudienceMode("team_role")}
|
onClick={() => setAudienceMode("team_role")}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-full px-3 py-1.5 transition-colors",
|
"rounded-lg px-3 py-2 transition-all",
|
||||||
audienceMode === "team_role"
|
audienceMode === "team_role"
|
||||||
? "bg-brand-500 text-white shadow-sm"
|
? "bg-brand-500 text-white shadow-sm"
|
||||||
: "text-grayScale-500 hover:text-grayScale-700",
|
: "border border-grayScale-200 bg-white text-grayScale-500 hover:border-grayScale-300 hover:text-grayScale-700",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
Team role
|
Team role
|
||||||
|
|
@ -1046,10 +1066,10 @@ export function CreateNotificationPage() {
|
||||||
setTeamSearchQuery("")
|
setTeamSearchQuery("")
|
||||||
}}
|
}}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-full px-3 py-1.5 transition-colors",
|
"rounded-lg px-3 py-2 transition-all",
|
||||||
audienceMode === "team_selected"
|
audienceMode === "team_selected"
|
||||||
? "bg-brand-500 text-white shadow-sm"
|
? "bg-brand-500 text-white shadow-sm"
|
||||||
: "text-grayScale-500 hover:text-grayScale-700",
|
: "border border-grayScale-200 bg-white text-grayScale-500 hover:border-grayScale-300 hover:text-grayScale-700",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
Team members
|
Team members
|
||||||
|
|
@ -1177,11 +1197,18 @@ export function CreateNotificationPage() {
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<Card className="border border-dashed border-grayScale-200 bg-grayScale-50/40 shadow-none">
|
{/* Step 4: Preview */}
|
||||||
<CardContent className="space-y-2 p-4">
|
{currentStep === 4 && (
|
||||||
<p className="text-xs font-semibold text-grayScale-600">Preview</p>
|
<div className="rounded-2xl border border-grayScale-100 bg-white p-5 shadow-sm">
|
||||||
<div className="space-y-1 rounded-xl border border-grayScale-200 bg-white p-3 text-xs">
|
<div className="mb-4 flex items-center gap-2">
|
||||||
|
<span className="flex h-6 w-6 items-center justify-center rounded-full bg-brand-500 text-[11px] font-bold text-white">4</span>
|
||||||
|
<p className="text-sm font-semibold text-grayScale-800">Preview</p>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-1 rounded-xl border border-grayScale-200 bg-grayScale-50/50 p-3 text-xs">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="inline-flex h-7 w-7 items-center justify-center rounded-full bg-brand-500/90 text-white">
|
<span className="inline-flex h-7 w-7 items-center justify-center rounded-full bg-brand-500/90 text-white">
|
||||||
{(() => {
|
{(() => {
|
||||||
|
|
@ -1206,7 +1233,7 @@ export function CreateNotificationPage() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-[10px] text-grayScale-400">
|
<p className="mt-2 text-[10px] text-grayScale-400">
|
||||||
Channel: {channel.toUpperCase().replace("_", "-")}
|
Channel: {channel.toUpperCase().replace("_", "-")}
|
||||||
{channel === "email" && emailTemplateSlug
|
{channel === "email" && emailTemplateSlug
|
||||||
? ` · Template: ${emailTemplateSlug}`
|
? ` · Template: ${emailTemplateSlug}`
|
||||||
|
|
@ -1217,8 +1244,56 @@ export function CreateNotificationPage() {
|
||||||
? ` · Scheduled ${formatScheduledAtLabel(scheduledAt)}`
|
? ` · Scheduled ${formatScheduledAtLabel(scheduledAt)}`
|
||||||
: ""}
|
: ""}
|
||||||
</p>
|
</p>
|
||||||
</CardContent>
|
</div>
|
||||||
</Card>
|
)}
|
||||||
|
|
||||||
|
{/* Navigation bar */}
|
||||||
|
<div className="flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-grayScale-100 bg-white px-5 py-4 shadow-sm">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
{currentStep > 1 && (
|
||||||
|
<Button type="button" variant="outline" size="sm" onClick={goPrev} disabled={sending}>
|
||||||
|
<ChevronLeft className="mr-1 h-4 w-4" />
|
||||||
|
Back
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button type="button" variant="ghost" size="sm" onClick={resetForm} disabled={sending}>
|
||||||
|
Clear
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<p className="text-[11px] text-grayScale-400">
|
||||||
|
{isLastStep
|
||||||
|
? isScheduling
|
||||||
|
? "Creates a scheduled job processed by the backend worker."
|
||||||
|
: "Delivers immediately with sent/failed counts returned."
|
||||||
|
: "Step " + currentStep + " of 4"}
|
||||||
|
</p>
|
||||||
|
{isLastStep ? (
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
size="sm"
|
||||||
|
className="bg-brand-600 hover:bg-brand-500"
|
||||||
|
disabled={sending || (channel === "email" ? !emailContentReady : !message.trim())}
|
||||||
|
>
|
||||||
|
{sending ? (
|
||||||
|
<>
|
||||||
|
<SpinnerIcon className="mr-2 h-3.5 w-3.5" alt="" />
|
||||||
|
{isScheduling ? "Scheduling…" : "Sending…"}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<MailOpen className="mr-2 h-3.5 w-3.5" />
|
||||||
|
{isScheduling ? "Schedule notification" : "Send notification"}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button type="submit" size="sm" className="bg-brand-600 hover:bg-brand-500">
|
||||||
|
Continue
|
||||||
|
<ChevronRight className="ml-1 h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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}
|
||||||
|
|
|
||||||
|
|
@ -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,62 +515,72 @@ 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">
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-8 w-8 rounded-[6px] p-0 text-grayScale-500 hover:text-brand-600"
|
className="h-7 w-7 rounded-[6px] p-0 text-grayScale-400 hover:text-grayScale-700"
|
||||||
aria-label="View payment details"
|
|
||||||
onClick={() => setSelected(payment)}
|
|
||||||
>
|
>
|
||||||
<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>
|
||||||
|
<DropdownMenuItem
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
copyText(
|
copyText(
|
||||||
payment.transaction_id || payment.session_id,
|
payment.transaction_id || payment.session_id,
|
||||||
|
|
@ -568,8 +588,11 @@ export function PaymentsPage() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Copy className="h-4 w-4" />
|
<Copy className="mr-2 h-3.5 w-3.5" />
|
||||||
</Button>
|
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}
|
)}>
|
||||||
|
<CreditCard className="h-6 w-6" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="min-w-0 flex-1 pt-0.5">
|
||||||
|
<DialogTitle className="text-base font-bold leading-snug text-grayScale-900">
|
||||||
|
Payment #{selected.id}
|
||||||
|
</DialogTitle>
|
||||||
|
<div className="mt-1.5 flex items-center gap-1.5 text-xs text-grayScale-400">
|
||||||
|
<Badge variant={paymentStatusBadgeVariant(selected.status)} className="text-[10px]">
|
||||||
|
{formatPaymentStatus(selected.status)}
|
||||||
|
</Badge>
|
||||||
|
<span>·</span>
|
||||||
|
<span>{formatPaymentAmount(selected)}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Body */}
|
||||||
|
<div className="px-6 pb-8 pt-1">
|
||||||
|
{/* Amount highlight */}
|
||||||
|
<div className="rounded-xl bg-grayScale-50/70 px-4 py-4 text-center">
|
||||||
|
<p className="text-[11px] font-bold uppercase tracking-wider text-grayScale-300">Amount</p>
|
||||||
|
<p className="mt-1 text-2xl font-bold text-grayScale-900">
|
||||||
|
{formatPaymentAmount(selected)}
|
||||||
|
</p>
|
||||||
|
<p className="mt-0.5 text-xs text-grayScale-400">
|
||||||
|
{formatPaymentMethod(selected.payment_method)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Metadata */}
|
||||||
|
<div className="mt-5 space-y-0 divide-y divide-grayScale-100">
|
||||||
|
{[
|
||||||
|
{ k: "Customer", v: paymentCustomerName(selected) },
|
||||||
|
{ k: "Email", v: selected.user_email || "—" },
|
||||||
|
{ k: "Plan", v: selected.plan_name || `Plan #${selected.plan_id}` },
|
||||||
|
{ k: "Category", v: formatPaymentPlanCategory(selected.plan_category) },
|
||||||
|
{ k: "Transaction", v: selected.transaction_id || "—", mono: true },
|
||||||
|
{ k: "Session", v: selected.session_id || "—", mono: true },
|
||||||
|
{ k: "Subscription", v: `#${selected.subscription_id}` },
|
||||||
|
{ k: "Paid", v: formatPaymentDate(selected.paid_at ?? selected.created_at) },
|
||||||
|
...(selected.expires_at ? [{ k: "Expires", v: formatPaymentDate(selected.expires_at) }] : []),
|
||||||
|
].map((row) => (
|
||||||
|
<div key={row.k} className="flex items-baseline justify-between gap-4 py-2.5 first:pt-0 last:pb-0">
|
||||||
|
<span className="text-xs text-grayScale-400">{row.k}</span>
|
||||||
|
{row.k === "Customer" ? (
|
||||||
|
<span className="text-xs font-medium text-grayScale-600">
|
||||||
|
<Link to={`/users/${selected.user_id}`} className="text-brand-500 hover:text-brand-600">
|
||||||
|
{row.v}
|
||||||
</Link>
|
</Link>
|
||||||
}
|
</span>
|
||||||
/>
|
) : (
|
||||||
<Detail label="Plan" value={selected.plan_name || `Plan #${selected.plan_id}`} />
|
<span className={cn("text-xs font-medium text-grayScale-600", row.mono && "font-mono text-[11px]")}>
|
||||||
<Detail
|
{row.v}
|
||||||
label="Category"
|
</span>
|
||||||
value={formatPaymentPlanCategory(selected.plan_category)}
|
)}
|
||||||
/>
|
</div>
|
||||||
<Detail label="Method" value={formatPaymentMethod(selected.payment_method)} />
|
))}
|
||||||
<Detail label="Status" value={formatPaymentStatus(selected.status)} />
|
</div>
|
||||||
<Detail label="Transaction ID" value={selected.transaction_id || "—"} mono />
|
|
||||||
<Detail label="Session ID" value={selected.session_id || "—"} mono />
|
{/* Actions */}
|
||||||
<Detail label="Subscription" value={`#${selected.subscription_id}`} />
|
{selected.payment_url && (
|
||||||
<Detail label="Paid at" value={formatPaymentDate(selected.paid_at)} />
|
<div className="mt-5 border-t border-grayScale-100 pt-4">
|
||||||
<Detail label="Expires at" value={formatPaymentDate(selected.expires_at)} />
|
<Button size="sm" className="h-9 rounded-lg bg-brand-600 px-4 text-xs font-medium text-white hover:bg-brand-500" asChild>
|
||||||
<Detail label="Created" value={formatPaymentDate(selected.created_at)} />
|
<a href={selected.payment_url} target="_blank" rel="noopener noreferrer">
|
||||||
<Detail label="Updated" value={formatPaymentDate(selected.updated_at)} />
|
<ExternalLink className="mr-1.5 h-3.5 w-3.5" />
|
||||||
</dl>
|
Open checkout
|
||||||
{selected.payment_url ? (
|
|
||||||
<a
|
|
||||||
href={selected.payment_url}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="inline-flex text-sm font-semibold text-brand-500 hover:text-brand-600"
|
|
||||||
>
|
|
||||||
Open checkout URL
|
|
||||||
</a>
|
</a>
|
||||||
) : null}
|
</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>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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]"
|
||||||
|
|
|
||||||
|
|
@ -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]"
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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 ? (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user