Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
91 lines
2.5 KiB
TypeScript
91 lines
2.5 KiB
TypeScript
'use client'
|
|
|
|
import { AlertCircle, Inbox, RotateCcw } from 'lucide-react'
|
|
import { useEffect, useRef, type ReactNode } from 'react'
|
|
import { Button } from '@/app/components/ui/button'
|
|
import { Skeleton } from '@/app/components/ui/skeleton'
|
|
import { cn } from '@/app/lib/utils'
|
|
import { useT } from '@/app/lib/i18n/MessagesProvider'
|
|
|
|
/**
|
|
* The four required data states from DASHBOARD-STANDARD.md §8. Every data-bound
|
|
* view uses these rather than inventing its own copy.
|
|
*/
|
|
|
|
export function EmptyState({
|
|
title,
|
|
action,
|
|
icon,
|
|
className,
|
|
}: {
|
|
title: string
|
|
/** The corrective action — "No data" without a way forward is not acceptable. */
|
|
action?: ReactNode
|
|
icon?: ReactNode
|
|
className?: string
|
|
}) {
|
|
return (
|
|
<div className={cn('flex flex-col items-center justify-center gap-3 px-6 py-10 text-center', className)}>
|
|
<span className="text-muted-foreground" aria-hidden="true">
|
|
{icon ?? <Inbox className="size-8" />}
|
|
</span>
|
|
<p className="text-sm text-muted-foreground">{title}</p>
|
|
{action}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export function ErrorState({
|
|
message,
|
|
onRetry,
|
|
className,
|
|
}: {
|
|
message: string
|
|
onRetry?: () => void
|
|
className?: string
|
|
}) {
|
|
const t = useT()
|
|
const ref = useRef<HTMLDivElement>(null)
|
|
useEffect(() => {
|
|
ref.current?.scrollIntoView?.({ block: 'nearest' })
|
|
}, [message])
|
|
|
|
return (
|
|
<div
|
|
ref={ref}
|
|
role="alert"
|
|
className={cn(
|
|
'flex flex-col items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/5 p-4',
|
|
className,
|
|
)}
|
|
>
|
|
<div className="flex items-start gap-2">
|
|
<AlertCircle aria-hidden="true" className="mt-0.5 size-4 shrink-0 text-destructive" />
|
|
<p className="text-sm text-foreground">{message}</p>
|
|
</div>
|
|
{onRetry && (
|
|
<Button variant="outline" size="sm" onClick={onRetry} className="h-9">
|
|
<RotateCcw aria-hidden="true" className="size-4" />
|
|
{t("UiRetry")}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export function TableSkeleton({ rows = 5, columns = 4 }: { rows?: number; columns?: number }) {
|
|
const t = useT()
|
|
return (
|
|
<div role="status" className="space-y-3 rounded-xl border bg-card p-3">
|
|
<span className="sr-only">{t("UiLoading")}</span>
|
|
{Array.from({ length: rows }).map((_, r) => (
|
|
<div key={r} className="flex gap-3">
|
|
{Array.from({ length: columns }).map((__, c) => (
|
|
<Skeleton key={c} className="h-4 flex-1" />
|
|
))}
|
|
</div>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|