Align admin dates with EAT and refine analytics, payments, and toasts.

Use Africa/Addis_Ababa for display and filters, add payment method and date range controls, and restyle Sonner notifications to match the admin UI.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Yared Yemane 2026-08-04 15:23:15 +03:00
parent 47893a7838
commit 992ca85690
26 changed files with 703 additions and 269 deletions

View File

@ -1,9 +1,9 @@
import { Toaster } from 'sonner' import { Toaster } from "sonner"
import { AppRoutes } from './app/AppRoutes' import { AppRoutes } from "./app/AppRoutes"
import { useTheme } from './contexts/ThemeContext' import { useTheme } from "./contexts/ThemeContext"
import { clearTeamSession } from './lib/teamAuthStorage' import { clearTeamSession } from "./lib/teamAuthStorage"
const SESSION_KEY = 'yimaru_session_active' const SESSION_KEY = "yimaru_session_active"
/** /**
* Clear persisted team tokens when this browser tab session is new. * Clear persisted team tokens when this browser tab session is new.
@ -14,7 +14,7 @@ function bootstrapBrowserSession() {
try { try {
if (!sessionStorage.getItem(SESSION_KEY)) { if (!sessionStorage.getItem(SESSION_KEY)) {
clearTeamSession() clearTeamSession()
sessionStorage.setItem(SESSION_KEY, '1') sessionStorage.setItem(SESSION_KEY, "1")
} }
} catch { } catch {
// sessionStorage unavailable (private mode quirks) — leave tokens alone // sessionStorage unavailable (private mode quirks) — leave tokens alone
@ -29,15 +29,26 @@ function AppToaster() {
<Toaster <Toaster
position="top-center" position="top-center"
theme={resolvedTheme} theme={resolvedTheme}
closeButton
expand={false}
visibleToasts={4}
offset={20}
gap={12}
duration={4200}
toastOptions={{ toastOptions={{
className: 'font-sans', classNames: {
style: { toast: "yimaru-toast",
padding: '14px 20px', title: "yimaru-toast__title",
borderRadius: '12px', description: "yimaru-toast__description",
fontSize: '14px', actionButton: "yimaru-toast__action",
cancelButton: "yimaru-toast__cancel",
closeButton: "yimaru-toast__close",
success: "yimaru-toast--success",
error: "yimaru-toast--error",
warning: "yimaru-toast--warning",
info: "yimaru-toast--info",
}, },
}} }}
richColors
/> />
) )
} }

View File

@ -8,23 +8,34 @@ import type {
} from "../types/analytics.types"; } from "../types/analytics.types";
function buildDashboardQueryParams(filters?: DashboardFilters): Record<string, string | number> { function buildDashboardQueryParams(filters?: DashboardFilters): Record<string, string | number> {
const params: Record<string, string | number> = {};
if (filters?.payment_method?.trim()) {
params.payment_method = filters.payment_method.trim().toUpperCase();
}
if (!filters || filters.mode === "all_time") { if (!filters || filters.mode === "all_time") {
return {}; return params;
} }
if (filters.mode === "year" && filters.year != null) { if (filters.mode === "year" && filters.year != null) {
return { year: filters.year }; params.year = filters.year;
return params;
} }
if (filters.mode === "year_month" && filters.year != null && filters.month != null) { if (filters.mode === "year_month" && filters.year != null && filters.month != null) {
return { year: filters.year, month: filters.month }; params.year = filters.year;
params.month = filters.month;
return params;
} }
if (filters.mode === "custom" && filters.from && filters.to) { if (filters.mode === "custom" && filters.from && filters.to) {
return { from: filters.from, to: filters.to }; params.from = filters.from;
params.to = filters.to;
return params;
} }
return {}; return params;
} }
function isRecord(value: unknown): value is Record<string, unknown> { function isRecord(value: unknown): value is Record<string, unknown> {

View File

@ -91,6 +91,10 @@ function buildQueryParams(params: GetPaymentsParams): Record<string, string | nu
if (params.plan_category?.trim()) query.plan_category = params.plan_category.trim() if (params.plan_category?.trim()) query.plan_category = params.plan_category.trim()
if (params.currency?.trim()) query.currency = params.currency.trim() if (params.currency?.trim()) query.currency = params.currency.trim()
if (params.reference?.trim()) query.reference = params.reference.trim() if (params.reference?.trim()) query.reference = params.reference.trim()
if (params.created_from?.trim()) query.created_from = params.created_from.trim()
if (params.created_to?.trim()) query.created_to = params.created_to.trim()
if (params.paid_from?.trim()) query.paid_from = params.paid_from.trim()
if (params.paid_to?.trim()) query.paid_to = params.paid_to.trim()
return query return query
} }
@ -107,6 +111,10 @@ export function paymentsFilterParams(
if (params.plan_category?.trim()) next.plan_category = params.plan_category.trim() if (params.plan_category?.trim()) next.plan_category = params.plan_category.trim()
if (params.currency?.trim()) next.currency = params.currency.trim() if (params.currency?.trim()) next.currency = params.currency.trim()
if (params.reference?.trim()) next.reference = params.reference.trim() if (params.reference?.trim()) next.reference = params.reference.trim()
if (params.created_from?.trim()) next.created_from = params.created_from.trim()
if (params.created_to?.trim()) next.created_to = params.created_to.trim()
if (params.paid_from?.trim()) next.paid_from = params.paid_from.trim()
if (params.paid_to?.trim()) next.paid_to = params.paid_to.trim()
return next return next
} }

View File

@ -3,6 +3,8 @@ import { ChevronDown } from "lucide-react"
import { cn } from "../../lib/utils" import { cn } from "../../lib/utils"
import { Input } from "../ui/input" import { Input } from "../ui/input"
import { Button } from "../ui/button" import { Button } from "../ui/button"
import { Select } from "../ui/select"
import { formatPaymentMethod } from "../../lib/payments"
import type { DashboardFilters } from "../../types/analytics.types" import type { DashboardFilters } from "../../types/analytics.types"
const MONTH_LABELS = [ const MONTH_LABELS = [
@ -22,6 +24,14 @@ const MONTH_LABELS = [
const MIN_SELECTABLE_YEAR = 2000 const MIN_SELECTABLE_YEAR = 2000
export const ANALYTICS_PAYMENT_METHOD_OPTIONS = [
{ value: "", label: "All methods" },
{ value: "CHAPA", label: "Chapa" },
{ value: "ARIFPAY", label: "Arifpay" },
{ value: "ADMIN_GRANT", label: "Admin grant" },
{ value: "ADMIN_EXTEND", label: "Admin extend" },
] as const
export function getYearOptions(): number[] { export function getYearOptions(): number[] {
const currentYear = new Date().getFullYear() const currentYear = new Date().getFullYear()
const years: number[] = [] const years: number[] = []
@ -31,20 +41,38 @@ export function getYearOptions(): number[] {
return years return years
} }
function withPaymentMethod(base: DashboardFilters, paymentMethod?: string): DashboardFilters {
const next = { ...base }
if (paymentMethod?.trim()) {
next.payment_method = paymentMethod.trim().toUpperCase()
} else {
delete next.payment_method
}
return next
}
export function getDashboardFilterLabel(filters: DashboardFilters): string { export function getDashboardFilterLabel(filters: DashboardFilters): string {
let rangeLabel = "All Time"
if (filters.mode === "year" && filters.year != null) { if (filters.mode === "year" && filters.year != null) {
return String(filters.year) rangeLabel = String(filters.year)
} else if (filters.mode === "year_month" && filters.year != null && filters.month != null) {
rangeLabel = `${MONTH_LABELS[filters.month - 1]} ${filters.year}`
} else if (filters.mode === "custom" && filters.from && filters.to) {
const opts: Intl.DateTimeFormatOptions = {
month: "short",
day: "numeric",
year: "numeric",
timeZone: "UTC",
} }
if (filters.mode === "year_month" && filters.year != null && filters.month != null) { const from = new Date(`${filters.from}T00:00:00Z`)
return `${MONTH_LABELS[filters.month - 1]} ${filters.year}` const to = new Date(`${filters.to}T00:00:00Z`)
rangeLabel = `${from.toLocaleDateString("en-US", opts)} – ${to.toLocaleDateString("en-US", opts)}`
} }
if (filters.mode === "custom" && filters.from && filters.to) {
const from = new Date(`${filters.from}T00:00:00`) if (!filters.payment_method) {
const to = new Date(`${filters.to}T00:00:00`) return rangeLabel
const opts: Intl.DateTimeFormatOptions = { month: "short", day: "numeric", year: "numeric" }
return `${from.toLocaleDateString("en-US", opts)} – ${to.toLocaleDateString("en-US", opts)}`
} }
return "All Time" return `${rangeLabel} · ${formatPaymentMethod(filters.payment_method)}`
} }
type AnalyticsTimeRangeFilterProps = { type AnalyticsTimeRangeFilterProps = {
@ -64,6 +92,7 @@ export function AnalyticsTimeRangeFilter({ value, onChange, className }: Analyti
const containerRef = useRef<HTMLDivElement>(null) const containerRef = useRef<HTMLDivElement>(null)
const years = getYearOptions() const years = getYearOptions()
const paymentMethod = value.payment_method ?? ""
useEffect(() => { useEffect(() => {
if (value.year != null) { if (value.year != null) {
@ -92,29 +121,47 @@ export function AnalyticsTimeRangeFilter({ value, onChange, className }: Analyti
}, [open]) }, [open])
const selectAllTime = () => { const selectAllTime = () => {
onChange({ mode: "all_time" }) onChange(withPaymentMethod({ mode: "all_time" }, paymentMethod))
setOpen(false) setOpen(false)
} }
const selectYear = (year: number) => { const selectYear = (year: number) => {
setContextYear(year) setContextYear(year)
onChange({ mode: "year", year }) onChange(withPaymentMethod({ mode: "year", year }, paymentMethod))
setOpen(false) setOpen(false)
} }
const selectMonth = (month: number) => { const selectMonth = (month: number) => {
onChange({ mode: "year_month", year: contextYear, month }) onChange(withPaymentMethod({ mode: "year_month", year: contextYear, month }, paymentMethod))
setOpen(false) setOpen(false)
} }
const applyCustomRange = () => { const applyCustomRange = () => {
if (!customFrom || !customTo) return if (!customFrom || !customTo) return
onChange({ mode: "custom", from: customFrom, to: customTo }) onChange(withPaymentMethod({ mode: "custom", from: customFrom, to: customTo }, paymentMethod))
setOpen(false) setOpen(false)
} }
const selectPaymentMethod = (nextMethod: string) => {
onChange(withPaymentMethod({ ...value }, nextMethod))
}
return ( return (
<div ref={containerRef} className={cn("relative", className)}> <div className={cn("flex flex-wrap items-center gap-2", className)}>
<Select
value={paymentMethod}
onChange={(e) => selectPaymentMethod(e.target.value)}
className="h-9 w-[150px] rounded-lg border-grayScale-200 py-1 text-sm font-medium"
aria-label="Payment method filter"
>
{ANALYTICS_PAYMENT_METHOD_OPTIONS.map((option) => (
<option key={option.value || "all"} value={option.value}>
{option.label}
</option>
))}
</Select>
<div ref={containerRef} className="relative">
<button <button
type="button" type="button"
onClick={() => setOpen((prev) => !prev)} onClick={() => setOpen((prev) => !prev)}
@ -268,5 +315,6 @@ export function AnalyticsTimeRangeFilter({ value, onChange, className }: Analyti
</div> </div>
)} )}
</div> </div>
</div>
) )
} }

View File

@ -11,7 +11,7 @@ import { aggregateRevenueByMonth, formatRevenueAxisTick } from "../../lib/analyt
import type { DateRevenue } from "../../types/analytics.types" import type { DateRevenue } from "../../types/analytics.types"
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg"
export function RevenueTrendCard() { export function RevenueTrendCard({ paymentMethod }: { paymentMethod?: string }) {
const currentYear = new Date().getFullYear() const currentYear = new Date().getFullYear()
const [year, setYear] = useState(currentYear) const [year, setYear] = useState(currentYear)
const [totalRevenue, setTotalRevenue] = useState(0) const [totalRevenue, setTotalRevenue] = useState(0)
@ -26,7 +26,11 @@ export function RevenueTrendCard() {
const fetchRevenueTrend = async () => { const fetchRevenueTrend = async () => {
setLoading(true) setLoading(true)
try { try {
const res = await getDashboard({ mode: "year", year }) const res = await getDashboard({
mode: "year",
year,
...(paymentMethod ? { payment_method: paymentMethod } : {}),
})
if (cancelled) return if (cancelled) return
setTotalRevenue(res.data.payments.total_revenue) setTotalRevenue(res.data.payments.total_revenue)
setDailyRevenue(res.data.payments.revenue_last_30_days) setDailyRevenue(res.data.payments.revenue_last_30_days)
@ -44,7 +48,7 @@ export function RevenueTrendCard() {
return () => { return () => {
cancelled = true cancelled = true
} }
}, [year]) }, [year, paymentMethod])
const chartData = useMemo( const chartData = useMemo(
() => aggregateRevenueByMonth(dailyRevenue, year), () => aggregateRevenueByMonth(dailyRevenue, year),

View File

@ -175,4 +175,141 @@
.scrollbar-none::-webkit-scrollbar { .scrollbar-none::-webkit-scrollbar {
display: none; display: none;
} }
/* Sonner toast — polished admin notifications */
[data-sonner-toaster] {
--width: min(420px, calc(100vw - 2rem));
font-family: inherit;
}
[data-sonner-toaster][data-y-position="top"] {
top: 1.25rem;
}
.yimaru-toast[data-sonner-toast] {
--yimaru-toast-accent: #9e2891;
width: var(--width);
display: flex;
align-items: flex-start;
gap: 0.75rem;
padding: 0.875rem 1rem 0.875rem 1rem;
border-radius: 0.75rem;
border: 1px solid var(--gs-200);
border-left: 3px solid var(--yimaru-toast-accent);
background: var(--gs-50);
color: hsl(var(--foreground));
box-shadow:
0 1px 2px rgba(15, 23, 42, 0.04),
0 12px 32px rgba(15, 23, 42, 0.1);
font-size: 0.875rem;
line-height: 1.4;
letter-spacing: -0.01em;
}
html.dark .yimaru-toast[data-sonner-toast] {
box-shadow:
0 1px 2px rgba(0, 0, 0, 0.25),
0 16px 40px rgba(0, 0, 0, 0.45);
}
.yimaru-toast[data-sonner-toast] [data-icon] {
margin-top: 0.1rem;
width: 1.125rem;
height: 1.125rem;
flex-shrink: 0;
color: var(--yimaru-toast-accent);
}
.yimaru-toast[data-sonner-toast] [data-icon] svg {
width: 1.125rem;
height: 1.125rem;
}
.yimaru-toast[data-sonner-toast] [data-content] {
flex: 1;
min-width: 0;
gap: 0.2rem;
}
.yimaru-toast__title {
font-size: 0.875rem;
font-weight: 600;
color: hsl(var(--foreground));
letter-spacing: -0.015em;
}
.yimaru-toast__description {
font-size: 0.8125rem;
font-weight: 400;
color: var(--gs-500);
line-height: 1.45;
}
.yimaru-toast__close {
position: absolute !important;
top: 0.55rem !important;
right: 0.55rem !important;
left: auto !important;
transform: none !important;
width: 1.5rem !important;
height: 1.5rem !important;
border-radius: 0.375rem !important;
border: 1px solid transparent !important;
background: transparent !important;
color: var(--gs-400) !important;
opacity: 0.85;
transition:
background-color 0.15s ease,
color 0.15s ease,
border-color 0.15s ease;
}
.yimaru-toast__close:hover {
background: var(--gs-100) !important;
border-color: var(--gs-200) !important;
color: var(--gs-600) !important;
opacity: 1;
}
.yimaru-toast__action {
margin-top: 0.35rem;
height: 1.75rem;
padding: 0 0.75rem;
border-radius: 0.375rem;
background: #9e2891;
color: #fff;
font-size: 0.75rem;
font-weight: 600;
}
.yimaru-toast__cancel {
margin-top: 0.35rem;
height: 1.75rem;
padding: 0 0.75rem;
border-radius: 0.375rem;
background: var(--gs-100);
color: var(--gs-600);
font-size: 0.75rem;
font-weight: 500;
}
.yimaru-toast--success {
--yimaru-toast-accent: #059669;
}
.yimaru-toast--error {
--yimaru-toast-accent: #dc2626;
}
.yimaru-toast--warning {
--yimaru-toast-accent: #d97706;
}
.yimaru-toast--info {
--yimaru-toast-accent: #9e2891;
}
.yimaru-toast[data-sonner-toast][data-styled="true"] {
padding-right: 2.25rem;
}
} }

View File

@ -1,5 +1,6 @@
import { getTeamMemberById } from "../api/team.api" import { getTeamMemberById } from "../api/team.api"
import { getUserById } from "../api/users.api" import { getUserById } from "../api/users.api"
import { formatAppDate } from "./datetime"
import { TEAM_ROLE_OPTIONS, formatTeamRoleLabel } from "./teamRoles" import { TEAM_ROLE_OPTIONS, formatTeamRoleLabel } from "./teamRoles"
import type { TeamMember, TeamMemberDetail } from "../types/team.types" import type { TeamMember, TeamMemberDetail } from "../types/team.types"
import type { UserProfileData } from "../types/user.types" import type { UserProfileData } from "../types/user.types"
@ -149,11 +150,5 @@ export async function fetchActorProfile(
} }
export function formatActorDate(iso: string): string { export function formatActorDate(iso: string): string {
const d = new Date(iso) return formatAppDate(iso, iso)
if (Number.isNaN(d.getTime())) return iso
return d.toLocaleDateString(undefined, {
year: "numeric",
month: "short",
day: "numeric",
})
} }

View File

@ -1,4 +1,10 @@
import type { ActivityLog, ActivityLogActorKind } from "../types/activity-log.types" import type { ActivityLog, ActivityLogActorKind } from "../types/activity-log.types"
import {
formatAppDate,
formatAppTime,
toAppDayEndISO,
toAppDayStartISO,
} from "./datetime"
export type ActorDisplay = { export type ActorDisplay = {
name: string name: string
@ -355,19 +361,11 @@ export function activityLogResourcePath(
} }
export function formatActivityDate(dateStr: string): string { export function formatActivityDate(dateStr: string): string {
return new Date(dateStr).toLocaleDateString(undefined, { return formatAppDate(dateStr, "—")
year: "numeric",
month: "short",
day: "numeric",
})
} }
export function formatActivityTime(dateStr: string): string { export function formatActivityTime(dateStr: string): string {
return new Date(dateStr).toLocaleTimeString(undefined, { return formatAppTime(dateStr, "—")
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
})
} }
export function getRelativeActivityTime(dateStr: string): string { export function getRelativeActivityTime(dateStr: string): string {
@ -386,9 +384,9 @@ export function getRelativeActivityTime(dateStr: string): string {
} }
export function toRfc3339StartOfDay(dateValue: string): string { export function toRfc3339StartOfDay(dateValue: string): string {
return new Date(`${dateValue}T00:00:00`).toISOString() return toAppDayStartISO(dateValue)
} }
export function toRfc3339EndOfDay(dateValue: string): string { export function toRfc3339EndOfDay(dateValue: string): string {
return new Date(`${dateValue}T23:59:59.999`).toISOString() return toAppDayEndISO(dateValue)
} }

View File

@ -121,9 +121,56 @@ const MONTH_SHORT = [
"Dec", "Dec",
] as const ] as const
/** Calendar Y-M-D from an analytics series date (API encodes civil days as UTC midnight). */
export function analyticsSeriesYmd(dateStr: string): string | null {
const match = /^(\d{4}-\d{2}-\d{2})/.exec(String(dateStr ?? "").trim())
return match ? match[1] : null
}
/**
* Format a daily analytics series date for charts.
* Uses the civil YYYY-MM-DD from the API — never the browser local timezone —
* so EAT buckets stay aligned with payments/Chapa.
*/
export function formatAnalyticsSeriesDate(dateStr: string): string {
const ymd = analyticsSeriesYmd(dateStr)
if (ymd) {
const [year, month, day] = ymd.split("-").map(Number)
const d = new Date(Date.UTC(year, month - 1, day))
return d.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
timeZone: "UTC",
})
}
const d = new Date(dateStr)
if (Number.isNaN(d.getTime())) return String(dateStr)
return d.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
timeZone: "UTC",
})
}
function formatShortDate(iso: string) { function formatShortDate(iso: string) {
const ymd = analyticsSeriesYmd(iso)
if (ymd) {
const [year, month, day] = ymd.split("-").map(Number)
const d = new Date(Date.UTC(year, month - 1, day))
return d.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
timeZone: "UTC",
})
}
const d = new Date(iso) const d = new Date(iso)
return d.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" }) return d.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
timeZone: "UTC",
})
} }
function formatBreakdownLabel(label: string) { function formatBreakdownLabel(label: string) {
@ -154,8 +201,14 @@ export function aggregateRevenueByMonth(daily: DateRevenue[], year: number): Mon
})) }))
for (const { date, revenue } of daily) { for (const { date, revenue } of daily) {
const parsed = new Date(date) const ymd = analyticsSeriesYmd(date)
if (parsed.getUTCFullYear() !== year) continue const parsed = ymd
? (() => {
const [year, month, day] = ymd.split("-").map(Number)
return new Date(Date.UTC(year, month - 1, day))
})()
: new Date(date)
if (Number.isNaN(parsed.getTime()) || parsed.getUTCFullYear() !== year) continue
monthly[parsed.getUTCMonth()].revenue += revenue monthly[parsed.getUTCMonth()].revenue += revenue
} }

View File

@ -4,6 +4,7 @@ import type {
AppVersion, AppVersion,
AppVersionStatus, AppVersionStatus,
} from "../types/app-version.types" } from "../types/app-version.types"
import { formatAppDateTime } from "./datetime"
export const APP_PLATFORMS: { value: AppPlatform; label: string }[] = [ export const APP_PLATFORMS: { value: AppPlatform; label: string }[] = [
{ value: "ANDROID", label: "Android" }, { value: "ANDROID", label: "Android" },
@ -65,13 +66,7 @@ export function formatAppVersionCreatedAt(raw: string): string {
const datePart = raw.split(" ")[0] const datePart = raw.split(" ")[0]
return datePart || raw return datePart || raw
} }
return d.toLocaleString(undefined, { return formatAppDateTime(normalized)
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
})
} }
export function versionLabel(version: Pick<AppVersion, "version_name" | "version_code">): string { export function versionLabel(version: Pick<AppVersion, "version_name" | "version_code">): string {

View File

@ -1,6 +1,7 @@
import type { GetUsersParams } from "../api/users.api" import type { GetUsersParams } from "../api/users.api"
import { buildUsersListQuery } from "../api/users.api" import { buildUsersListQuery } from "../api/users.api"
import { paymentsFilterParams } from "../api/payments.api" import { paymentsFilterParams } from "../api/payments.api"
import { nextCalendarDay } from "./payments"
import type { ActivityLogFilters } from "../types/activity-log.types" import type { ActivityLogFilters } from "../types/activity-log.types"
import type { QueryParams } from "./csv-export" import type { QueryParams } from "./csv-export"
@ -10,13 +11,21 @@ export function paymentListFiltersToExportQuery(filters: {
planCategory?: string planCategory?: string
currency?: string currency?: string
reference?: string reference?: string
/** Inclusive YYYY-MM-DD; mapped to created_from. */
dateFrom?: string
/** Inclusive YYYY-MM-DD; mapped to exclusive created_to. */
dateTo?: string
}): QueryParams { }): QueryParams {
const dateFrom = filters.dateFrom?.trim()
const dateTo = filters.dateTo?.trim()
return paymentsFilterParams({ return paymentsFilterParams({
...(filters.status ? { status: filters.status } : {}), ...(filters.status ? { status: filters.status } : {}),
...(filters.provider ? { provider: filters.provider } : {}), ...(filters.provider ? { provider: filters.provider } : {}),
...(filters.planCategory ? { plan_category: filters.planCategory } : {}), ...(filters.planCategory ? { plan_category: filters.planCategory } : {}),
...(filters.currency ? { currency: filters.currency } : {}), ...(filters.currency ? { currency: filters.currency } : {}),
...(filters.reference ? { reference: filters.reference } : {}), ...(filters.reference ? { reference: filters.reference } : {}),
...(dateFrom ? { created_from: dateFrom } : {}),
...(dateTo ? { created_to: nextCalendarDay(dateTo) } : {}),
}) })
} }

96
src/lib/datetime.ts Normal file
View File

@ -0,0 +1,96 @@
/** Default business timezone for Yimaru (East Africa Time, UTC+3, no DST). */
export const APP_TIMEZONE = "Africa/Addis_Ababa"
export const APP_TIMEZONE_LABEL = "EAT"
/** Fixed offset used when building RFC3339 bounds from calendar days. */
export const APP_TIMEZONE_OFFSET = "+03:00"
export function isValidDateInput(value: string | null | undefined): value is string {
return Boolean(value && /^\d{4}-\d{2}-\d{2}/.test(value.trim()))
}
/** Calendar YYYY-MM-DD of an instant in the app timezone. */
export function toAppCalendarDate(iso: string | Date): string | null {
const d = typeof iso === "string" ? new Date(iso) : iso
if (Number.isNaN(d.getTime())) return null
return new Intl.DateTimeFormat("en-CA", {
timeZone: APP_TIMEZONE,
year: "numeric",
month: "2-digit",
day: "2-digit",
}).format(d)
}
export function formatAppDate(
iso: string | null | undefined,
emptyLabel = "—",
): string {
if (!iso) return emptyLabel
const d = new Date(iso)
if (Number.isNaN(d.getTime())) return emptyLabel
return d.toLocaleDateString("en-GB", {
timeZone: APP_TIMEZONE,
year: "numeric",
month: "short",
day: "numeric",
})
}
export function formatAppDateTime(
iso: string | null | undefined,
emptyLabel = "—",
): string {
if (!iso) return emptyLabel
const d = new Date(iso)
if (Number.isNaN(d.getTime())) return emptyLabel
return d.toLocaleString("en-GB", {
timeZone: APP_TIMEZONE,
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
hour12: false,
})
}
export function formatAppTime(
iso: string | null | undefined,
emptyLabel = "—",
): string {
if (!iso) return emptyLabel
const d = new Date(iso)
if (Number.isNaN(d.getTime())) return emptyLabel
return d.toLocaleTimeString("en-GB", {
timeZone: APP_TIMEZONE,
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
})
}
/** Midnight EAT for a YYYY-MM-DD calendar day, as RFC3339. */
export function toAppDayStartISO(ymd: string): string {
const day = ymd.trim().slice(0, 10)
return `${day}T00:00:00${APP_TIMEZONE_OFFSET}`
}
/** End of EAT calendar day (inclusive-style), as RFC3339. */
export function toAppDayEndISO(ymd: string): string {
const day = ymd.trim().slice(0, 10)
return `${day}T23:59:59.999${APP_TIMEZONE_OFFSET}`
}
/** Next calendar day (UTC date arithmetic on Y-M-D components). */
export function nextAppCalendarDay(ymd: string): string {
const [year, month, day] = ymd.trim().slice(0, 10).split("-").map(Number)
if (!year || !month || !day) return ymd
const dt = new Date(Date.UTC(year, month - 1, day))
dt.setUTCDate(dt.getUTCDate() + 1)
return dt.toISOString().slice(0, 10)
}
/** Exclusive upper bound: next EAT midnight after ymd. */
export function toAppNextDayStartISO(ymd: string): string {
return toAppDayStartISO(nextAppCalendarDay(ymd))
}

View File

@ -1,3 +1,5 @@
import { formatAppDateTime } from "./datetime"
const SAMPLE_VALUES: Record<string, string> = { const SAMPLE_VALUES: Record<string, string> = {
OTP: "123456", OTP: "123456",
FirstName: "Alex", FirstName: "Alex",
@ -42,10 +44,7 @@ export function formatEmailTemplateDate(raw: string | null | undefined) {
if (Number.isNaN(parsed.getTime())) { if (Number.isNaN(parsed.getTime())) {
return text.split(" +")[0]?.trim() || text return text.split(" +")[0]?.trim() || text
} }
return parsed.toLocaleString(undefined, { return formatAppDateTime(text)
dateStyle: "medium",
timeStyle: "short",
})
} }
export function emailTemplateStatusBadgeVariant(status: string) { export function emailTemplateStatusBadgeVariant(status: string) {

View File

@ -1,4 +1,5 @@
import type { FAQ, FAQStatus } from "../types/faq.types" import type { FAQ, FAQStatus } from "../types/faq.types"
import { formatAppDateTime } from "./datetime"
export function faqStatusBadgeVariant(status: string): "success" | "secondary" { export function faqStatusBadgeVariant(status: string): "success" | "secondary" {
const normalized = status.toUpperCase() const normalized = status.toUpperCase()
@ -22,10 +23,7 @@ export function formatFaqDate(raw: string | null | undefined): string {
if (Number.isNaN(parsed.getTime())) { if (Number.isNaN(parsed.getTime())) {
return text.split(" +")[0]?.trim() || text return text.split(" +")[0]?.trim() || text
} }
return parsed.toLocaleString(undefined, { return formatAppDateTime(text)
dateStyle: "medium",
timeStyle: "short",
})
} }
export function deriveFaqCategories(faqs: FAQ[]): string[] { export function deriveFaqCategories(faqs: FAQ[]): string[] {

View File

@ -8,6 +8,7 @@ import type {
} from "../types/notification.types" } from "../types/notification.types"
import { getUsers } from "../api/users.api" import { getUsers } from "../api/users.api"
import { getTeamMembers } from "../api/team.api" import { getTeamMembers } from "../api/team.api"
import { formatAppDateTime } from "./datetime"
import { TEAM_ROLE_OPTIONS } from "./teamRoles" import { TEAM_ROLE_OPTIONS } from "./teamRoles"
export const PLATFORM_ROLES: { value: PlatformRole; label: string }[] = [ export const PLATFORM_ROLES: { value: PlatformRole; label: string }[] = [
@ -122,13 +123,7 @@ export function formatScheduledAtLabel(value: string): string {
if (!value) return "Set date & time" if (!value) return "Set date & time"
const parsed = new Date(value) const parsed = new Date(value)
if (Number.isNaN(parsed.getTime())) return value if (Number.isNaN(parsed.getTime())) return value
return parsed.toLocaleString("en-US", { return formatAppDateTime(value)
month: "short",
day: "numeric",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
})
} }
export function scheduledStatusBadgeVariant( export function scheduledStatusBadgeVariant(

View File

@ -10,6 +10,7 @@ import {
Video, Video,
ShieldAlert, ShieldAlert,
} from "lucide-react" } from "lucide-react"
import { formatAppDate, formatAppDateTime } from "./datetime"
export const NOTIFICATION_TYPE_CONFIG: Record< export const NOTIFICATION_TYPE_CONFIG: Record<
string, string,
@ -67,11 +68,7 @@ export function formatNotificationTimestamp(ts: string) {
if (diffHr < 24) return `${diffHr}h ago` if (diffHr < 24) return `${diffHr}h ago`
if (diffDay < 7) return `${diffDay}d ago` if (diffDay < 7) return `${diffDay}d ago`
return date.toLocaleDateString("en-US", { return formatAppDate(ts)
month: "short",
day: "numeric",
year: date.getFullYear() !== now.getFullYear() ? "numeric" : undefined,
})
} }
export function formatNotificationTypeLabel(type: string) { export function formatNotificationTypeLabel(type: string) {
@ -82,15 +79,7 @@ export function formatNotificationTypeLabel(type: string) {
} }
export function formatNotificationDateTime(ts: string) { export function formatNotificationDateTime(ts: string) {
const date = new Date(ts) return formatAppDateTime(ts, "unassigned")
if (Number.isNaN(date.getTime())) return "unassigned"
return date.toLocaleString(undefined, {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
})
} }
export function isMeaningfulExpiry(expires: string) { export function isMeaningfulExpiry(expires: string) {

View File

@ -1,4 +1,10 @@
import { formatPlanCategory } from "./subscriptionPlans" import { formatPlanCategory } from "./subscriptionPlans"
import {
APP_TIMEZONE,
formatAppDateTime,
nextAppCalendarDay,
toAppCalendarDate,
} from "./datetime"
import type { Payment } from "../types/payment.types" import type { Payment } from "../types/payment.types"
export function formatPaymentAmount(payment: Pick<Payment, "amount" | "currency">): string { export function formatPaymentAmount(payment: Pick<Payment, "amount" | "currency">): string {
@ -9,17 +15,39 @@ export function formatPaymentAmount(payment: Pick<Payment, "amount" | "currency"
return `${formatted} ${payment.currency || "ETB"}` return `${formatted} ${payment.currency || "ETB"}`
} }
/** @deprecated Prefer APP_TIMEZONE from datetime.ts */
export const PAYMENT_DATE_TIMEZONE = APP_TIMEZONE
export function formatPaymentDate(iso: string | null | undefined): string { export function formatPaymentDate(iso: string | null | undefined): string {
if (!iso) return "unassigned" return formatAppDateTime(iso, "unassigned")
const d = new Date(iso) }
if (Number.isNaN(d.getTime())) return iso
return d.toLocaleString(undefined, { /** YYYY-MM-DD of paid_at (or created_at if unpaid) in EAT. */
year: "numeric", export function paymentEventDateEAT(payment: Pick<Payment, "paid_at" | "created_at">): string | null {
month: "short", const raw = payment.paid_at || payment.created_at
day: "numeric", if (!raw) return null
hour: "2-digit", return toAppCalendarDate(raw)
minute: "2-digit", }
})
/** Inclusive YYYY-MM-DD range against the payment event date in EAT. */
export function paymentMatchesDateRange(
payment: Pick<Payment, "paid_at" | "created_at">,
from?: string,
to?: string,
): boolean {
const fromDay = from?.trim()
const toDay = to?.trim()
if (!fromDay && !toDay) return true
const day = paymentEventDateEAT(payment)
if (!day) return false
if (fromDay && day < fromDay) return false
if (toDay && day > toDay) return false
return true
}
/** Next calendar day as YYYY-MM-DD (for exclusive API upper bounds). */
export function nextCalendarDay(ymd: string): string {
return nextAppCalendarDay(ymd)
} }
export function formatPaymentStatus(status: string): string { export function formatPaymentStatus(status: string): string {

View File

@ -2,6 +2,7 @@ import type {
GetPersonasResponse, GetPersonasResponse,
PersonaListItem, PersonaListItem,
} from "../types/persona.types" } from "../types/persona.types"
import { formatAppDate } from "./datetime"
import amanuelAvatar from "../assets/personas/amanuel.png" import amanuelAvatar from "../assets/personas/amanuel.png"
import aseffaAvatar from "../assets/personas/aseffa.png" import aseffaAvatar from "../assets/personas/aseffa.png"
import bethelAvatar from "../assets/personas/bethel.png" import bethelAvatar from "../assets/personas/bethel.png"
@ -91,13 +92,7 @@ export function mapPersonaToCard(persona: PersonaListItem): PersonaCardModel {
export function formatPersonaDate(dateStr: string | null | undefined): string { export function formatPersonaDate(dateStr: string | null | undefined): string {
if (!dateStr?.trim()) return "unassigned" if (!dateStr?.trim()) return "unassigned"
const d = new Date(dateStr) return formatAppDate(dateStr, dateStr)
if (Number.isNaN(d.getTime())) return dateStr
return d.toLocaleDateString(undefined, {
year: "numeric",
month: "short",
day: "numeric",
})
} }
export function personaStatusLabel(isActive: boolean): string { export function personaStatusLabel(isActive: boolean): string {

View File

@ -1,4 +1,5 @@
import type { RatingTargetType } from "../types/ratings.types" import type { RatingTargetType } from "../types/ratings.types"
import { formatAppDate, formatAppDateTime } from "./datetime"
export function formatAverageStars(value: number): string { export function formatAverageStars(value: number): string {
if (!Number.isFinite(value) || value <= 0) return "0.0" if (!Number.isFinite(value) || value <= 0) return "0.0"
@ -6,25 +7,11 @@ export function formatAverageStars(value: number): string {
} }
export function formatRatingDate(dateStr: string): string { export function formatRatingDate(dateStr: string): string {
const d = new Date(dateStr) return formatAppDate(dateStr, dateStr || "unassigned")
if (Number.isNaN(d.getTime())) return dateStr || "unassigned"
return d.toLocaleDateString(undefined, {
year: "numeric",
month: "short",
day: "numeric",
})
} }
export function formatRatingDateTime(dateStr: string): string { export function formatRatingDateTime(dateStr: string): string {
const d = new Date(dateStr) return formatAppDateTime(dateStr, dateStr || "unassigned")
if (Number.isNaN(d.getTime())) return dateStr || "unassigned"
return d.toLocaleString(undefined, {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
})
} }
export function targetTypeLabel(type: RatingTargetType): string { export function targetTypeLabel(type: RatingTargetType): string {

View File

@ -4,6 +4,7 @@ import type {
SubscriptionPlanDurationUnit, SubscriptionPlanDurationUnit,
UpdateSubscriptionPlanPayload, UpdateSubscriptionPlanPayload,
} from "../types/subscription.types" } from "../types/subscription.types"
import { formatAppDate } from "./datetime"
export const SUBSCRIPTION_PLAN_CATEGORIES: { export const SUBSCRIPTION_PLAN_CATEGORIES: {
value: SubscriptionPlanCategory value: SubscriptionPlanCategory
@ -78,13 +79,7 @@ export function formatPlanCategory(category: string): string {
} }
export function formatPlanCreatedAt(iso: string): string { export function formatPlanCreatedAt(iso: string): string {
const d = new Date(iso) return formatAppDate(iso, iso)
if (Number.isNaN(d.getTime())) return iso
return d.toLocaleDateString(undefined, {
year: "numeric",
month: "short",
day: "numeric",
})
} }
export function planToUpdatePayload( export function planToUpdatePayload(

View File

@ -1,4 +1,5 @@
import type { VerifyInvitationData } from "../types/teamInvitation.types" import type { VerifyInvitationData } from "../types/teamInvitation.types"
import { formatAppDateTime } from "./datetime"
export function formatTeamRoleLabel(role: string | undefined): string { export function formatTeamRoleLabel(role: string | undefined): string {
if (!role) return "unassigned" if (!role) return "unassigned"
@ -9,7 +10,7 @@ export function formatInvitationExpiry(raw: string | undefined): string | null {
if (!raw) return null if (!raw) return null
const d = new Date(raw) const d = new Date(raw)
if (Number.isNaN(d.getTime())) return raw if (Number.isNaN(d.getTime())) return raw
return d.toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" }) return formatAppDateTime(raw)
} }
/** User-facing title when verify returns valid: false. */ /** User-facing title when verify returns valid: false. */

View File

@ -48,6 +48,7 @@ import { useEffect, useState, type ReactNode } from "react"
import { Link } from "react-router-dom" import { Link } from "react-router-dom"
import { AnalyticsTimeRangeFilter, getDashboardFilterLabel } from "../components/analytics/AnalyticsTimeRangeFilter" import { AnalyticsTimeRangeFilter, getDashboardFilterLabel } from "../components/analytics/AnalyticsTimeRangeFilter"
import { import {
formatAnalyticsSeriesDate,
getPrimaryQuestionTypeSummary, getPrimaryQuestionTypeSummary,
getSeriesPeriodLabel, getSeriesPeriodLabel,
getSubscriptionMetrics, getSubscriptionMetrics,
@ -76,8 +77,7 @@ function DashboardSectionTitle({ children }: { children: ReactNode }) {
} }
function formatDate(dateStr: string) { function formatDate(dateStr: string) {
const d = new Date(dateStr) return formatAnalyticsSeriesDate(dateStr)
return d.toLocaleDateString("en-US", { month: "short", day: "numeric" })
} }
const DEFAULT_FILTERS: DashboardFilters = { mode: "all_time" } const DEFAULT_FILTERS: DashboardFilters = { mode: "all_time" }
@ -465,7 +465,7 @@ export function DashboardPage() {
<section className="space-y-4"> <section className="space-y-4">
<DashboardSectionTitle>Revenue &amp; subscriptions</DashboardSectionTitle> <DashboardSectionTitle>Revenue &amp; subscriptions</DashboardSectionTitle>
<div className="grid gap-4"> <div className="grid gap-4">
<RevenueTrendCard /> <RevenueTrendCard paymentMethod={filters.payment_method} />
<div className="grid gap-4 lg:grid-cols-2"> <div className="grid gap-4 lg:grid-cols-2">
<ActivePlansBreakdownCard <ActivePlansBreakdownCard

View File

@ -68,6 +68,7 @@ import {
formatPercentRate, formatPercentRate,
buildSubscriptionStatusPie, buildSubscriptionStatusPie,
aggregateRevenueByMonth, aggregateRevenueByMonth,
formatAnalyticsSeriesDate,
formatRevenueAxisTick, formatRevenueAxisTick,
} from "../../lib/analytics" } from "../../lib/analytics"
import type { DashboardData, DashboardFilters, LabelCount } from "../../types/analytics.types" import type { DashboardData, DashboardFilters, LabelCount } from "../../types/analytics.types"
@ -75,8 +76,7 @@ import type { DashboardData, DashboardFilters, LabelCount } from "../../types/an
const PIE_COLORS = ["#9E2891", "#FFD23F", "#1DE9B6", "#C26FC0", "#6366F1", "#F97316", "#14B8A6", "#EF4444", "#8B5CF6", "#EC4899", "#06B6D4", "#84CC16"] const PIE_COLORS = ["#9E2891", "#FFD23F", "#1DE9B6", "#C26FC0", "#6366F1", "#F97316", "#14B8A6", "#EF4444", "#8B5CF6", "#EC4899", "#06B6D4", "#84CC16"]
function formatDate(dateStr: string) { function formatDate(dateStr: string) {
const d = new Date(dateStr) return formatAnalyticsSeriesDate(dateStr)
return d.toLocaleDateString("en-US", { month: "short", day: "numeric" })
} }
function formatNumber(n: number) { function formatNumber(n: number) {

View File

@ -48,6 +48,7 @@ import {
formatPaymentStatus, formatPaymentStatus,
computePaymentAggregateStats, computePaymentAggregateStats,
paymentCustomerName, paymentCustomerName,
paymentMatchesDateRange,
paymentStatusBadgeVariant, paymentStatusBadgeVariant,
type PaymentAggregateStats, type PaymentAggregateStats,
} from "../../lib/payments" } from "../../lib/payments"
@ -82,6 +83,8 @@ type PaymentListFilters = {
provider: PaymentProvider | "" provider: PaymentProvider | ""
planCategory: PaymentPlanCategory | "" planCategory: PaymentPlanCategory | ""
currency: string currency: string
dateFrom: string
dateTo: string
} }
function paymentMatchesSearch(payment: Payment, query: string): boolean { function paymentMatchesSearch(payment: Payment, query: string): boolean {
@ -143,6 +146,8 @@ export function PaymentsPage() {
const [providerFilter, setProviderFilter] = useState<PaymentProvider | "">("") const [providerFilter, setProviderFilter] = useState<PaymentProvider | "">("")
const [planCategoryFilter, setPlanCategoryFilter] = useState<PaymentPlanCategory | "">("") const [planCategoryFilter, setPlanCategoryFilter] = useState<PaymentPlanCategory | "">("")
const [currencyFilter, setCurrencyFilter] = useState("") const [currencyFilter, setCurrencyFilter] = useState("")
const [dateFrom, setDateFrom] = useState("")
const [dateTo, setDateTo] = useState("")
const [selected, setSelected] = useState<Payment | null>(null) const [selected, setSelected] = useState<Payment | null>(null)
const listFilters: PaymentListFilters = { const listFilters: PaymentListFilters = {
@ -150,10 +155,20 @@ export function PaymentsPage() {
provider: providerFilter, provider: providerFilter,
planCategory: planCategoryFilter, planCategory: planCategoryFilter,
currency: currencyFilter, currency: currencyFilter,
dateFrom,
dateTo,
} }
const exportParams = useMemo( const exportParams = useMemo(
() => paymentListFiltersToExportQuery(listFilters), () =>
paymentListFiltersToExportQuery({
status: listFilters.status || undefined,
provider: listFilters.provider || undefined,
planCategory: listFilters.planCategory || undefined,
currency: listFilters.currency || undefined,
dateFrom: listFilters.dateFrom || undefined,
dateTo: listFilters.dateTo || undefined,
}),
[listFilters], [listFilters],
) )
@ -162,6 +177,8 @@ export function PaymentsPage() {
{ value: providerFilter }, { value: providerFilter },
{ value: planCategoryFilter }, { value: planCategoryFilter },
{ value: currencyFilter }, { value: currencyFilter },
{ value: dateFrom },
{ value: dateTo },
]) ])
const hasActiveFilters = activeFilterCount > 0 || Boolean(searchQuery.trim()) const hasActiveFilters = activeFilterCount > 0 || Boolean(searchQuery.trim())
@ -188,7 +205,16 @@ export function PaymentsPage() {
useEffect(() => { useEffect(() => {
setPage(1) setPage(1)
}, [searchQuery, statusFilter, providerFilter, planCategoryFilter, currencyFilter, pageSize]) }, [
searchQuery,
statusFilter,
providerFilter,
planCategoryFilter,
currencyFilter,
dateFrom,
dateTo,
pageSize,
])
const filteredPayments = useMemo(() => { const filteredPayments = useMemo(() => {
return payments.filter((payment) => { return payments.filter((payment) => {
@ -206,6 +232,7 @@ export function PaymentsPage() {
) { ) {
return false return false
} }
if (!paymentMatchesDateRange(payment, dateFrom, dateTo)) return false
return paymentMatchesSearch(payment, searchQuery) return paymentMatchesSearch(payment, searchQuery)
}) })
}, [ }, [
@ -214,6 +241,8 @@ export function PaymentsPage() {
providerFilter, providerFilter,
planCategoryFilter, planCategoryFilter,
currencyFilter, currencyFilter,
dateFrom,
dateTo,
searchQuery, searchQuery,
]) ])
@ -250,6 +279,8 @@ export function PaymentsPage() {
setProviderFilter("") setProviderFilter("")
setPlanCategoryFilter("") setPlanCategoryFilter("")
setCurrencyFilter("") setCurrencyFilter("")
setDateFrom("")
setDateTo("")
setSearchQuery("") setSearchQuery("")
setPage(1) setPage(1)
} }
@ -438,6 +469,45 @@ export function PaymentsPage() {
))} ))}
</Select> </Select>
</div> </div>
<div className="flex flex-wrap items-end gap-3">
<div className="space-y-1.5">
<label
htmlFor="payments-date-from"
className="text-[11px] font-bold uppercase tracking-wider text-grayScale-400"
>
From
</label>
<Input
id="payments-date-from"
type="date"
value={dateFrom}
max={dateTo || undefined}
onChange={(e) => setDateFrom(e.target.value)}
disabled={loading}
className="h-9 rounded-[6px] text-sm"
/>
</div>
<div className="space-y-1.5">
<label
htmlFor="payments-date-to"
className="text-[11px] font-bold uppercase tracking-wider text-grayScale-400"
>
To
</label>
<Input
id="payments-date-to"
type="date"
value={dateTo}
min={dateFrom || undefined}
onChange={(e) => setDateTo(e.target.value)}
disabled={loading}
className="h-9 rounded-[6px] text-sm"
/>
</div>
<p className="pb-2 text-[11px] text-grayScale-400">
Dates use EAT (Africa/Addis_Ababa)
</p>
</div>
</AdminFiltersPanel> </AdminFiltersPanel>
{loading ? ( {loading ? (

View File

@ -180,6 +180,7 @@ export type DashboardDateFilterMode = "all_time" | "year" | "year_month" | "cust
export interface DashboardDateFilter { export interface DashboardDateFilter {
mode: DashboardDateFilterMode mode: DashboardDateFilterMode
timezone?: string
year?: number year?: number
month?: number month?: number
from?: string from?: string
@ -189,6 +190,7 @@ export interface DashboardDateFilter {
series_start?: string series_start?: string
series_end?: string series_end?: string
ref_date?: string ref_date?: string
payment_method?: string
} }
export type DashboardFilterMode = DashboardDateFilterMode export type DashboardFilterMode = DashboardDateFilterMode
@ -199,6 +201,8 @@ export interface DashboardFilters {
month?: number month?: number
from?: string from?: string
to?: string to?: string
/** Optional payment/revenue filter (e.g. CHAPA, ARIFPAY, ADMIN_GRANT). */
payment_method?: string
} }
export interface DashboardData { export interface DashboardData {

View File

@ -63,6 +63,14 @@ export interface GetPaymentsParams {
currency?: string currency?: string
/** Partial match on session_id, nonce, or transaction_id. */ /** Partial match on session_id, nonce, or transaction_id. */
reference?: string reference?: string
/** Inclusive lower bound on created_at (RFC3339 or YYYY-MM-DD). */
created_from?: string
/** Exclusive upper bound on created_at (RFC3339 or YYYY-MM-DD). */
created_to?: string
/** Inclusive lower bound on paid_at (RFC3339 or YYYY-MM-DD). */
paid_from?: string
/** Exclusive upper bound on paid_at (RFC3339 or YYYY-MM-DD). */
paid_to?: string
limit?: number limit?: number
offset?: number offset?: number
} }