@burdenoff/microfe-billing 2026.530.2 → 2026.530.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billing/BillingAdminRoutes.js +84 -71
- package/dist/billing/BillingAdminRoutes.js.map +1 -1
- package/dist/billing/BillingUserRoutes.js +103 -90
- package/dist/billing/BillingUserRoutes.js.map +1 -1
- package/dist/billing/modules/billing/index.js +2 -1
- package/dist/billing/modules/billing/pages/InvoicesListPage.js +135 -126
- package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/UserRefundsPage.js +417 -0
- package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -0
- package/dist/billing/modules/billing/pages/index.js +1 -0
- package/dist/billing/modules/plans/constants/featuredQuotas.js +37 -0
- package/dist/billing/modules/plans/constants/featuredQuotas.js.map +1 -0
- package/dist/billing/modules/plans/index.js +2 -1
- package/dist/billing/modules/plans/pages/PlanAssignFreePage.js +205 -0
- package/dist/billing/modules/plans/pages/PlanAssignFreePage.js.map +1 -0
- package/dist/billing/modules/plans/pages/PlanCreatePage.js +51 -33
- package/dist/billing/modules/plans/pages/PlanCreatePage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanEditPage.js +78 -60
- package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js +246 -126
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js.map +1 -1
- package/dist/billing/modules/plans/pages/index.js +1 -0
- package/dist/billing/shared/types/graphql.js.map +1 -1
- package/dist/generated/global-operations.js +317 -287
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.js +3 -1
- package/dist/generated/global-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvoicesListPage.js","names":[],"sources":["../../../../../src/billing/modules/billing/pages/InvoicesListPage.tsx"],"sourcesContent":["/**\n * Billing Module - Invoices List Page\n * Displays all invoices for the current tenant\n */\n\nimport { useEffect, useState, useMemo, useRef, type FC } from 'react';\nimport { useSearchParams } from 'react-router-dom';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { usePaginatedInvoices } from '../hooks/useInvoices';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n useGetBillingAccountsByOrgQuery,\n type GetBillingAccountsByOrgQuery,\n} from '../../../../generated/global-operations';\n\ntype BillingAccountItem = GetBillingAccountsByOrgQuery['getBillingAccountsByOrg'][number];\nimport {\n formatCurrency,\n formatDate,\n formatInvoiceStatus,\n formatInvoiceNumber,\n} from '../../../shared/utils/format';\nimport { withBillingAccountId } from '../../../shared/utils/navigation';\nimport { getInvoiceStatusColor, getStatusBadgeClasses } from '../../../shared/utils/status';\nimport type { Invoice, InvoiceStatus } from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\ntype FilterStatus = 'all' | InvoiceStatus;\n\nexport const InvoicesListPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n const [searchParams] = useSearchParams();\n const urlBillingAccountId = searchParams.get('billingAccountId') ?? undefined;\n\n const { data: accountsData } = useGetBillingAccountsByOrgQuery({ fetchPolicy: 'cache-first' });\n const billingAccounts = accountsData?.getBillingAccountsByOrg ?? [];\n\n // undefined = user hasn't explicitly chosen yet → auto-pick default\n // null = user explicitly chose \"All Accounts\"\n // string = user explicitly chose a specific account\n const [explicitAccountId, setExplicitAccountId] = useState<string | null | undefined>(\n urlBillingAccountId\n );\n\n useEffect(() => {\n setExplicitAccountId(urlBillingAccountId);\n }, [urlBillingAccountId]);\n\n const defaultAccountId = useMemo(\n () =>\n (billingAccounts.find((a: BillingAccountItem) => a.isDefault) ?? billingAccounts[0])?.id ??\n undefined,\n [billingAccounts]\n );\n\n // Resolved selection: explicit choice wins; before any choice, use the default\n const selectedAccountId: string | null =\n explicitAccountId !== undefined ? explicitAccountId : (defaultAccountId ?? null);\n\n const [filterStatus, setFilterStatus] = useState<FilterStatus>('all');\n const [searchQuery, setSearchQuery] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n const [page, setPage] = useState(1);\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n debounceTimer.current = setTimeout(() => {\n setDebouncedSearch(searchQuery);\n setPage(1);\n }, 400);\n return () => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n };\n }, [searchQuery]);\n\n const { invoices, totalPages, isLoading, error, refetch } = usePaginatedInvoices({\n billingAccountId: selectedAccountId ?? undefined,\n status: filterStatus !== 'all' ? (filterStatus as InvoiceStatus) : undefined,\n search: debouncedSearch || undefined,\n page,\n pageSize: 20,\n });\n\n // Permission check\n if (!permissions.canViewInvoices) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <div className=\"size-12 mx-auto rounded-full bg-muted flex items-center justify-center\">\n <svg\n className=\"size-6 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-foreground\">\n {tr('billing.accessDenied.title', 'Access Denied')}\n </h2>\n <p className=\"text-sm text-muted-foreground max-w-sm\">\n {tr('billing.invoices.noViewPermission', \"You don't have permission to view invoices.\")}\n </p>\n </div>\n </div>\n );\n }\n\n // Loading state\n if (isLoading && invoices.length === 0) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-48 bg-muted animate-pulse rounded\" />\n <div className=\"space-y-3\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"border border-border rounded-lg p-4\">\n <div className=\"flex items-center gap-4\">\n <div className=\"size-10 bg-muted animate-pulse rounded\" />\n <div className=\"flex-1 space-y-2\">\n <div className=\"h-4 w-32 bg-muted animate-pulse rounded\" />\n <div className=\"h-3 w-48 bg-muted animate-pulse rounded\" />\n </div>\n </div>\n </div>\n ))}\n </div>\n </div>\n );\n }\n\n // Error state\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-4\">\n <div className=\"size-12 mx-auto rounded-full bg-destructive/10 flex items-center justify-center\">\n <svg\n className=\"size-6 text-destructive\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-foreground\">\n {tr('billing.invoices.failedToLoad', 'Failed to load invoices')}\n </h2>\n <p className=\"text-sm text-muted-foreground\">{error.message}</p>\n <button\n type=\"button\"\n onClick={() => refetch()}\n className=\"px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors\"\n >\n Try Again\n </button>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n {/* Header */}\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between\">\n <div>\n <h1 className=\"text-2xl font-bold text-foreground\">\n {tr('billing.invoices.title', 'Invoices')}\n </h1>\n <p className=\"text-sm text-muted-foreground mt-1\">\n {tr('billing.invoices.subtitle', 'View and manage your billing invoices')}\n </p>\n </div>\n {billingAccounts.length > 1 && (\n <div className=\"flex items-center gap-2\">\n <label className=\"text-sm text-muted-foreground whitespace-nowrap\">\n Billing Account\n </label>\n <select\n value={selectedAccountId ?? ''}\n onChange={(e) => setExplicitAccountId(e.target.value || null)}\n className=\"text-sm border border-border rounded-md bg-background text-foreground px-3 py-2 focus:outline-none focus:ring-2 focus:ring-primary\"\n >\n <option value=\"\">All Accounts</option>\n {billingAccounts.map((account: BillingAccountItem) => (\n <option key={account.id ?? ''} value={account.id ?? ''}>\n {account.name ?? account.email ?? account.id}\n {account.isDefault ? ' (Default)' : ''}\n </option>\n ))}\n </select>\n </div>\n )}\n </div>\n\n {/* Filters */}\n <div className=\"flex flex-wrap items-center gap-4 pb-4 border-b border-border\">\n {/* Status Filter */}\n <div className=\"inline-flex rounded-lg border border-border p-1 bg-muted/50 flex-wrap\">\n {(['all', 'OPEN', 'PAID', 'DRAFT', 'VOID'] as FilterStatus[]).map((status) => (\n <button\n type=\"button\"\n key={status}\n onClick={() => {\n setFilterStatus(status);\n setPage(1);\n }}\n className={`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${\n filterStatus === status\n ? 'bg-background text-foreground shadow-sm'\n : 'text-muted-foreground hover:text-foreground'\n }`}\n >\n {status === 'all' ? 'All' : formatInvoiceStatus(status as InvoiceStatus)}\n </button>\n ))}\n </div>\n\n {/* Search */}\n <div className=\"relative flex-1 min-w-0 w-full sm:max-w-md\">\n <svg\n className=\"absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z\"\n />\n </svg>\n <input\n type=\"text\"\n placeholder={tr('billing.invoices.searchPlaceholder', 'Search by invoice number...')}\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n className=\"w-full pl-[3.25rem] pr-4 py-2 text-sm border border-border rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n </div>\n </div>\n\n {/* Invoices Table */}\n {!isLoading && invoices.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg\">\n <div className=\"size-12 rounded-full bg-muted flex items-center justify-center mb-4\">\n <svg\n className=\"size-6 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z\"\n />\n </svg>\n </div>\n <h3 className=\"text-lg font-medium text-foreground\">\n {tr('billing.invoices.noInvoicesFound', 'No invoices found')}\n </h3>\n <p className=\"text-sm text-muted-foreground mt-1\">\n {filterStatus !== 'all' || debouncedSearch\n ? tr('billing.invoices.noInvoicesFiltered', 'No invoices match your filters.')\n : tr('billing.invoices.noInvoicesYet', \"You don't have any invoices yet.\")}\n </p>\n </div>\n ) : (\n <>\n <div className=\"border border-border rounded-lg overflow-hidden\">\n <table className=\"w-full\">\n <thead className=\"bg-muted/50\">\n <tr>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground\">\n Invoice\n </th>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground\">\n Status\n </th>\n {!selectedAccountId && billingAccounts.length > 1 && (\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden lg:table-cell\">\n Account\n </th>\n )}\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden sm:table-cell\">\n Date\n </th>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden md:table-cell\">\n Due Date\n </th>\n <th className=\"text-right px-4 py-3 text-sm font-medium text-muted-foreground\">\n Amount\n </th>\n <th className=\"text-right px-4 py-3 text-sm font-medium text-muted-foreground\">\n Actions\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border\">\n {invoices.map((invoice) => (\n <InvoiceRow\n key={invoice.id}\n invoice={invoice}\n onView={() =>\n navigateTo(\n withBillingAccountId(`/invoices/${invoice.id}`, invoice.billingAccountId)\n )\n }\n canPay={permissions.canPayInvoice}\n canVoid={permissions.canVoidInvoice}\n showAccount={!selectedAccountId && billingAccounts.length > 1}\n accountName={\n billingAccounts.find(\n (a: BillingAccountItem) => a.id === invoice.billingAccountId\n )?.name ?? null\n }\n />\n ))}\n </tbody>\n </table>\n </div>\n\n {totalPages > 1 && (\n <div className=\"flex items-center justify-between pt-2\">\n <p className=\"text-sm text-muted-foreground\">\n Page {page} of {totalPages}\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setPage((p) => Math.max(1, p - 1))}\n disabled={page <= 1}\n className=\"px-3 py-1.5 text-sm font-medium border border-border rounded-md bg-background text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n Previous\n </button>\n <button\n type=\"button\"\n onClick={() => setPage((p) => Math.min(totalPages, p + 1))}\n disabled={page >= totalPages}\n className=\"px-3 py-1.5 text-sm font-medium border border-border rounded-md bg-background text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n Next\n </button>\n </div>\n </div>\n )}\n </>\n )}\n </div>\n );\n};\n\n// ============================================================================\n// Invoice Row Component\n// ============================================================================\n\ninterface InvoiceRowProps {\n invoice: Invoice;\n onView: () => void;\n canPay: boolean;\n canVoid: boolean;\n showAccount?: boolean;\n accountName?: string | null;\n}\n\nconst InvoiceRow: FC<InvoiceRowProps> = ({\n invoice,\n onView,\n canPay,\n canVoid,\n showAccount = false,\n accountName,\n}) => {\n const statusColor = getInvoiceStatusColor(invoice.status);\n const isOpen = invoice.status === ('OPEN' as InvoiceStatus);\n const isDraft = invoice.status === ('DRAFT' as InvoiceStatus);\n\n return (\n <tr className=\"hover:bg-muted/30 transition-colors\">\n <td className=\"p-4\">\n <button\n type=\"button\"\n onClick={onView}\n className=\"font-medium text-foreground hover:text-primary transition-colors\"\n >\n {formatInvoiceNumber(invoice.invoiceNumber)}\n </button>\n {(invoice.itemDescription ?? invoice.subscription?.plan?.name) && (\n <p className=\"text-sm text-muted-foreground mt-0.5\">\n {invoice.itemDescription ?? invoice.subscription?.plan?.name}\n </p>\n )}\n </td>\n <td className=\"p-4\">\n <span\n className={`inline-flex px-2 py-1 text-xs font-medium rounded ${getStatusBadgeClasses(statusColor)}`}\n >\n {formatInvoiceStatus(invoice.status)}\n </span>\n </td>\n {showAccount && (\n <td className=\"p-4 hidden lg:table-cell\">\n {accountName ? (\n <span className=\"inline-flex items-center px-2 py-0.5 text-xs font-medium rounded-full bg-muted text-muted-foreground border border-border\">\n {accountName}\n </span>\n ) : (\n <span className=\"text-sm text-muted-foreground\">, </span>\n )}\n </td>\n )}\n <td className=\"p-4 text-sm text-muted-foreground hidden sm:table-cell\">\n {formatDate(invoice.createdAt, 'short')}\n </td>\n <td className=\"p-4 text-sm text-muted-foreground hidden md:table-cell\">\n {invoice.dueDate ? formatDate(invoice.dueDate, 'short') : '—'}\n </td>\n <td className=\"p-4 text-right font-medium text-foreground\">\n {formatCurrency(invoice.total, invoice.currency)}\n </td>\n <td className=\"p-4 text-right\">\n <div className=\"flex items-center justify-end gap-2\">\n {invoice.invoiceUrl ? (\n <a\n href={invoice.invoiceUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors\"\n >\n View\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={onView}\n className=\"px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors\"\n >\n View\n </button>\n )}\n {invoice.pdfUrl && (\n <a\n href={invoice.pdfUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-primary hover:bg-primary/10 rounded-md transition-colors\"\n >\n PDF\n </a>\n )}\n {isOpen && canPay && (\n <button\n type=\"button\"\n className=\"px-3 py-1.5 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors\"\n >\n Pay\n </button>\n )}\n {(isOpen || isDraft) && canVoid && (\n <button\n type=\"button\"\n className=\"px-3 py-1.5 text-sm font-medium text-destructive hover:bg-destructive/10 rounded-md transition-colors\"\n >\n Void\n </button>\n )}\n </div>\n </td>\n </tr>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA6BA,IAAa,UAA6B;CACxC,IAAM,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAA6B;EACpD,IAAM,IAAa,EAAE,EAAI;AACzB,SAAO,MAAe,IAAM,IAAW;IAEnC,IAAa,GAAoB,EACjC,IAAc,GAAuB,EACrC,CAAC,KAAgB,GAAiB,EAClC,IAAsB,EAAa,IAAI,mBAAmB,IAAI,KAAA,GAE9D,EAAE,MAAM,MAAiB,EAAgC,EAAE,aAAa,eAAe,CAAC,EACxF,IAAkB,GAAc,2BAA2B,EAAE,EAK7D,CAAC,GAAmB,KAAwB,EAChD,EACD;AAED,SAAgB;AACd,IAAqB,EAAoB;IACxC,CAAC,EAAoB,CAAC;CAEzB,IAAM,IAAmB,SAEpB,EAAgB,MAAM,MAA0B,EAAE,UAAU,IAAI,EAAgB,KAAK,MACtF,KAAA,GACF,CAAC,EAAgB,CAClB,EAGK,IACJ,MAAsB,KAAA,IAAiC,KAAoB,OAAzC,GAE9B,CAAC,GAAc,KAAmB,EAAuB,MAAM,EAC/D,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAiB,KAAsB,EAAS,GAAG,EACpD,CAAC,GAAM,KAAW,EAAS,EAAE,EAC7B,IAAgB,EAA6C,KAAK;AAExE,UACM,EAAc,WA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,UAAD;OACE,MAAK;OACL,SAAS;OACT,WAAU;iBACX;OAEQ,CAAA;MAEV,EAAQ,UACP,kBAAC,KAAD;OACE,MAAM,EAAQ;OACd,QAAO;OACP,KAAI;OACJ,WAAU;iBACX;OAEG,CAAA;MAEL,KAAU,KACT,kBAAC,UAAD;OACE,MAAK;OACL,WAAU;iBACX;OAEQ,CAAA;OAET,KAAU,MAAY,KACtB,kBAAC,UAAD;OACE,MAAK;OACL,WAAU;iBACX;OAEQ,CAAA;MAEP;;IACH,CAAA;GACF"}
|
|
1
|
+
{"version":3,"file":"InvoicesListPage.js","names":[],"sources":["../../../../../src/billing/modules/billing/pages/InvoicesListPage.tsx"],"sourcesContent":["/**\n * Billing Module - Invoices List Page\n * Displays all invoices for the current tenant\n */\n\nimport { useEffect, useState, useMemo, useRef, type FC } from 'react';\nimport { RotateCcw } from 'lucide-react';\nimport { useSearchParams } from 'react-router-dom';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { usePaginatedInvoices } from '../hooks/useInvoices';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n useGetBillingAccountsByOrgQuery,\n type GetBillingAccountsByOrgQuery,\n} from '../../../../generated/global-operations';\n\ntype BillingAccountItem = GetBillingAccountsByOrgQuery['getBillingAccountsByOrg'][number];\nimport {\n formatCurrency,\n formatDate,\n formatInvoiceStatus,\n formatInvoiceNumber,\n} from '../../../shared/utils/format';\nimport { withBillingAccountId } from '../../../shared/utils/navigation';\nimport { getInvoiceStatusColor, getStatusBadgeClasses } from '../../../shared/utils/status';\nimport type { Invoice, InvoiceStatus } from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\ntype FilterStatus = 'all' | InvoiceStatus;\n\nexport const InvoicesListPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n const [searchParams] = useSearchParams();\n const urlBillingAccountId = searchParams.get('billingAccountId') ?? undefined;\n\n const { data: accountsData } = useGetBillingAccountsByOrgQuery({ fetchPolicy: 'cache-first' });\n const billingAccounts = accountsData?.getBillingAccountsByOrg ?? [];\n\n // undefined = user hasn't explicitly chosen yet → auto-pick default\n // null = user explicitly chose \"All Accounts\"\n // string = user explicitly chose a specific account\n const [explicitAccountId, setExplicitAccountId] = useState<string | null | undefined>(\n urlBillingAccountId\n );\n\n useEffect(() => {\n setExplicitAccountId(urlBillingAccountId);\n }, [urlBillingAccountId]);\n\n const defaultAccountId = useMemo(\n () =>\n (billingAccounts.find((a: BillingAccountItem) => a.isDefault) ?? billingAccounts[0])?.id ??\n undefined,\n [billingAccounts]\n );\n\n // Resolved selection: explicit choice wins; before any choice, use the default\n const selectedAccountId: string | null =\n explicitAccountId !== undefined ? explicitAccountId : (defaultAccountId ?? null);\n\n const [filterStatus, setFilterStatus] = useState<FilterStatus>('all');\n const [searchQuery, setSearchQuery] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n const [page, setPage] = useState(1);\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n debounceTimer.current = setTimeout(() => {\n setDebouncedSearch(searchQuery);\n setPage(1);\n }, 400);\n return () => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n };\n }, [searchQuery]);\n\n const { invoices, totalPages, isLoading, error, refetch } = usePaginatedInvoices({\n billingAccountId: selectedAccountId ?? undefined,\n status: filterStatus !== 'all' ? (filterStatus as InvoiceStatus) : undefined,\n search: debouncedSearch || undefined,\n page,\n pageSize: 20,\n });\n\n // Permission check\n if (!permissions.canViewInvoices) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <div className=\"size-12 mx-auto rounded-full bg-muted flex items-center justify-center\">\n <svg\n className=\"size-6 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-foreground\">\n {tr('billing.accessDenied.title', 'Access Denied')}\n </h2>\n <p className=\"text-sm text-muted-foreground max-w-sm\">\n {tr('billing.invoices.noViewPermission', \"You don't have permission to view invoices.\")}\n </p>\n </div>\n </div>\n );\n }\n\n // Loading state\n if (isLoading && invoices.length === 0) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-48 bg-muted animate-pulse rounded\" />\n <div className=\"space-y-3\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"border border-border rounded-lg p-4\">\n <div className=\"flex items-center gap-4\">\n <div className=\"size-10 bg-muted animate-pulse rounded\" />\n <div className=\"flex-1 space-y-2\">\n <div className=\"h-4 w-32 bg-muted animate-pulse rounded\" />\n <div className=\"h-3 w-48 bg-muted animate-pulse rounded\" />\n </div>\n </div>\n </div>\n ))}\n </div>\n </div>\n );\n }\n\n // Error state\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-4\">\n <div className=\"size-12 mx-auto rounded-full bg-destructive/10 flex items-center justify-center\">\n <svg\n className=\"size-6 text-destructive\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-foreground\">\n {tr('billing.invoices.failedToLoad', 'Failed to load invoices')}\n </h2>\n <p className=\"text-sm text-muted-foreground\">{error.message}</p>\n <button\n type=\"button\"\n onClick={() => refetch()}\n className=\"px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors\"\n >\n Try Again\n </button>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n {/* Header */}\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between\">\n <div>\n <h1 className=\"text-2xl font-bold text-foreground\">\n {tr('billing.invoices.title', 'Invoices')}\n </h1>\n <p className=\"text-sm text-muted-foreground mt-1\">\n {tr('billing.invoices.subtitle', 'View and manage your billing invoices')}\n </p>\n </div>\n <div className=\"flex items-center gap-3\">\n <button\n type=\"button\"\n onClick={() => navigateTo('/refunds')}\n className=\"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium border border-border text-foreground rounded-md hover:bg-muted transition-colors\"\n >\n <RotateCcw className=\"size-4\" />\n {tr('billing.invoices.myRefunds', 'My Refunds')}\n </button>\n {billingAccounts.length > 1 && (\n <div className=\"flex items-center gap-2\">\n <label className=\"text-sm text-muted-foreground whitespace-nowrap\">\n Billing Account\n </label>\n <select\n value={selectedAccountId ?? ''}\n onChange={(e) => setExplicitAccountId(e.target.value || null)}\n className=\"text-sm border border-border rounded-md bg-background text-foreground px-3 py-2 focus:outline-none focus:ring-2 focus:ring-primary\"\n >\n <option value=\"\">All Accounts</option>\n {billingAccounts.map((account: BillingAccountItem) => (\n <option key={account.id ?? ''} value={account.id ?? ''}>\n {account.name ?? account.email ?? account.id}\n {account.isDefault ? ' (Default)' : ''}\n </option>\n ))}\n </select>\n </div>\n )}\n </div>\n </div>\n\n {/* Filters */}\n <div className=\"flex flex-wrap items-center gap-4 pb-4 border-b border-border\">\n {/* Status Filter */}\n <div className=\"inline-flex rounded-lg border border-border p-1 bg-muted/50 flex-wrap\">\n {(['all', 'OPEN', 'PAID', 'DRAFT', 'VOID'] as FilterStatus[]).map((status) => (\n <button\n type=\"button\"\n key={status}\n onClick={() => {\n setFilterStatus(status);\n setPage(1);\n }}\n className={`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${\n filterStatus === status\n ? 'bg-background text-foreground shadow-sm'\n : 'text-muted-foreground hover:text-foreground'\n }`}\n >\n {status === 'all' ? 'All' : formatInvoiceStatus(status as InvoiceStatus)}\n </button>\n ))}\n </div>\n\n {/* Search */}\n <div className=\"relative flex-1 min-w-0 w-full sm:max-w-md\">\n <svg\n className=\"absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z\"\n />\n </svg>\n <input\n type=\"text\"\n placeholder={tr('billing.invoices.searchPlaceholder', 'Search by invoice number...')}\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n className=\"w-full pl-[3.25rem] pr-4 py-2 text-sm border border-border rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n </div>\n </div>\n\n {/* Invoices Table */}\n {!isLoading && invoices.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg\">\n <div className=\"size-12 rounded-full bg-muted flex items-center justify-center mb-4\">\n <svg\n className=\"size-6 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z\"\n />\n </svg>\n </div>\n <h3 className=\"text-lg font-medium text-foreground\">\n {tr('billing.invoices.noInvoicesFound', 'No invoices found')}\n </h3>\n <p className=\"text-sm text-muted-foreground mt-1\">\n {filterStatus !== 'all' || debouncedSearch\n ? tr('billing.invoices.noInvoicesFiltered', 'No invoices match your filters.')\n : tr('billing.invoices.noInvoicesYet', \"You don't have any invoices yet.\")}\n </p>\n </div>\n ) : (\n <>\n <div className=\"border border-border rounded-lg overflow-hidden\">\n <table className=\"w-full\">\n <thead className=\"bg-muted/50\">\n <tr>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground\">\n Invoice\n </th>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground\">\n Status\n </th>\n {!selectedAccountId && billingAccounts.length > 1 && (\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden lg:table-cell\">\n Account\n </th>\n )}\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden sm:table-cell\">\n Date\n </th>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden md:table-cell\">\n Due Date\n </th>\n <th className=\"text-right px-4 py-3 text-sm font-medium text-muted-foreground\">\n Amount\n </th>\n <th className=\"text-right px-4 py-3 text-sm font-medium text-muted-foreground\">\n Actions\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border\">\n {invoices.map((invoice) => (\n <InvoiceRow\n key={invoice.id}\n invoice={invoice}\n onView={() =>\n navigateTo(\n withBillingAccountId(`/invoices/${invoice.id}`, invoice.billingAccountId)\n )\n }\n canPay={permissions.canPayInvoice}\n canVoid={permissions.canVoidInvoice}\n showAccount={!selectedAccountId && billingAccounts.length > 1}\n accountName={\n billingAccounts.find(\n (a: BillingAccountItem) => a.id === invoice.billingAccountId\n )?.name ?? null\n }\n />\n ))}\n </tbody>\n </table>\n </div>\n\n {totalPages > 1 && (\n <div className=\"flex items-center justify-between pt-2\">\n <p className=\"text-sm text-muted-foreground\">\n Page {page} of {totalPages}\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setPage((p) => Math.max(1, p - 1))}\n disabled={page <= 1}\n className=\"px-3 py-1.5 text-sm font-medium border border-border rounded-md bg-background text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n Previous\n </button>\n <button\n type=\"button\"\n onClick={() => setPage((p) => Math.min(totalPages, p + 1))}\n disabled={page >= totalPages}\n className=\"px-3 py-1.5 text-sm font-medium border border-border rounded-md bg-background text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n Next\n </button>\n </div>\n </div>\n )}\n </>\n )}\n </div>\n );\n};\n\n// ============================================================================\n// Invoice Row Component\n// ============================================================================\n\ninterface InvoiceRowProps {\n invoice: Invoice;\n onView: () => void;\n canPay: boolean;\n canVoid: boolean;\n showAccount?: boolean;\n accountName?: string | null;\n}\n\nconst InvoiceRow: FC<InvoiceRowProps> = ({\n invoice,\n onView,\n canPay,\n canVoid,\n showAccount = false,\n accountName,\n}) => {\n const statusColor = getInvoiceStatusColor(invoice.status);\n const isOpen = invoice.status === ('OPEN' as InvoiceStatus);\n const isDraft = invoice.status === ('DRAFT' as InvoiceStatus);\n\n return (\n <tr className=\"hover:bg-muted/30 transition-colors\">\n <td className=\"p-4\">\n <button\n type=\"button\"\n onClick={onView}\n className=\"font-medium text-foreground hover:text-primary transition-colors\"\n >\n {formatInvoiceNumber(invoice.invoiceNumber)}\n </button>\n {(invoice.itemDescription ?? invoice.subscription?.plan?.name) && (\n <p className=\"text-sm text-muted-foreground mt-0.5\">\n {invoice.itemDescription ?? invoice.subscription?.plan?.name}\n </p>\n )}\n </td>\n <td className=\"p-4\">\n <span\n className={`inline-flex px-2 py-1 text-xs font-medium rounded ${getStatusBadgeClasses(statusColor)}`}\n >\n {formatInvoiceStatus(invoice.status)}\n </span>\n </td>\n {showAccount && (\n <td className=\"p-4 hidden lg:table-cell\">\n {accountName ? (\n <span className=\"inline-flex items-center px-2 py-0.5 text-xs font-medium rounded-full bg-muted text-muted-foreground border border-border\">\n {accountName}\n </span>\n ) : (\n <span className=\"text-sm text-muted-foreground\">, </span>\n )}\n </td>\n )}\n <td className=\"p-4 text-sm text-muted-foreground hidden sm:table-cell\">\n {formatDate(invoice.createdAt, 'short')}\n </td>\n <td className=\"p-4 text-sm text-muted-foreground hidden md:table-cell\">\n {invoice.dueDate ? formatDate(invoice.dueDate, 'short') : '—'}\n </td>\n <td className=\"p-4 text-right font-medium text-foreground\">\n {formatCurrency(invoice.total, invoice.currency)}\n </td>\n <td className=\"p-4 text-right\">\n <div className=\"flex items-center justify-end gap-2\">\n {invoice.invoiceUrl ? (\n <a\n href={invoice.invoiceUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors\"\n >\n View\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={onView}\n className=\"px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors\"\n >\n View\n </button>\n )}\n {invoice.pdfUrl && (\n <a\n href={invoice.pdfUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-primary hover:bg-primary/10 rounded-md transition-colors\"\n >\n PDF\n </a>\n )}\n {isOpen && canPay && (\n <button\n type=\"button\"\n className=\"px-3 py-1.5 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors\"\n >\n Pay\n </button>\n )}\n {(isOpen || isDraft) && canVoid && (\n <button\n type=\"button\"\n className=\"px-3 py-1.5 text-sm font-medium text-destructive hover:bg-destructive/10 rounded-md transition-colors\"\n >\n Void\n </button>\n )}\n </div>\n </td>\n </tr>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AA8BA,IAAa,UAA6B;CACxC,IAAM,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAA6B;EACpD,IAAM,IAAa,EAAE,EAAI;AACzB,SAAO,MAAe,IAAM,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import { PageHeader as e } from "../../../shared/components/PageHeader.js";
|
|
2
|
+
import "../../../shared/components/index.js";
|
|
3
|
+
import { formatCurrency as t, formatDateTime as n } from "../../../shared/utils/format.js";
|
|
4
|
+
import "../../../shared/utils/index.js";
|
|
5
|
+
import { useCreateRefundRecordMutation as r, useGetBillingAccountsCheckoutQuery as i, useGetRefundRecordsQuery as a, useGetTransactionLazyQuery as o } from "../../../../generated/global-operations.js";
|
|
6
|
+
import { useBillingNavigate as s } from "../../../hooks/useBillingNavigate.js";
|
|
7
|
+
import { RefundRecordStatus as c } from "../../../../generated/global-types.js";
|
|
8
|
+
import { useEffect as l, useRef as u, useState as d } from "react";
|
|
9
|
+
import { CheckCircle as f, Clock as p, CreditCard as m, Loader2 as h, PlusCircle as ee, RotateCcw as te, Search as ne, X as g, XCircle as _ } from "lucide-react";
|
|
10
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
11
|
+
import { useI18n as b } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
12
|
+
//#region src/billing/modules/billing/pages/UserRefundsPage.tsx
|
|
13
|
+
var x = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, S = {
|
|
14
|
+
[c.Pending]: {
|
|
15
|
+
label: "In Review",
|
|
16
|
+
className: "bg-status-warning-bg/20 text-status-warning-text border-status-warning-border",
|
|
17
|
+
icon: ({ className: e }) => /* @__PURE__ */ v(p, { className: e })
|
|
18
|
+
},
|
|
19
|
+
[c.Processing]: {
|
|
20
|
+
label: "Processing",
|
|
21
|
+
className: "bg-action-primary-bg/15 text-action-primary-bg border-action-primary-bg/30",
|
|
22
|
+
icon: ({ className: e }) => /* @__PURE__ */ v(h, { className: `${e} animate-spin` })
|
|
23
|
+
},
|
|
24
|
+
[c.Completed]: {
|
|
25
|
+
label: "Refunded",
|
|
26
|
+
className: "bg-status-success-bg/20 text-status-success-text border-status-success-border",
|
|
27
|
+
icon: ({ className: e }) => /* @__PURE__ */ v(f, { className: e })
|
|
28
|
+
},
|
|
29
|
+
[c.Failed]: {
|
|
30
|
+
label: "Failed",
|
|
31
|
+
className: "bg-status-error-bg/20 text-status-error-text border-status-error-border",
|
|
32
|
+
icon: ({ className: e }) => /* @__PURE__ */ v(_, { className: e })
|
|
33
|
+
},
|
|
34
|
+
[c.Skipped]: {
|
|
35
|
+
label: "Closed",
|
|
36
|
+
className: "bg-muted text-muted-foreground border-border",
|
|
37
|
+
icon: ({ className: e }) => /* @__PURE__ */ v(_, { className: e })
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
function re({ status: e }) {
|
|
41
|
+
let t = S[e] ?? {
|
|
42
|
+
label: e,
|
|
43
|
+
className: "bg-muted text-muted-foreground border-border",
|
|
44
|
+
icon: ({ className: e }) => /* @__PURE__ */ v(p, { className: e })
|
|
45
|
+
}, n = t.icon;
|
|
46
|
+
return /* @__PURE__ */ y("span", {
|
|
47
|
+
className: `inline-flex items-center gap-1 px-2 py-0.5 rounded-full border text-xs font-medium ${t.className}`,
|
|
48
|
+
children: [/* @__PURE__ */ v(n, { className: "size-3" }), t.label]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
var C = () => {
|
|
52
|
+
let { t: p } = b(), _ = (e, t) => {
|
|
53
|
+
let n = p(e);
|
|
54
|
+
return n === e ? t : n;
|
|
55
|
+
}, S = s(), [C, w] = d(!1), [T, E] = d(""), [D, O] = d(null), [k, A] = d(!1), [j, M] = d(""), [N, P] = d(""), [F, I] = d(null), [ie, L] = d(!1), { data: ae, loading: R } = i({ fetchPolicy: "cache-and-network" }), z = ae?.getBillingAccountsByOrg ?? [], [B, V] = d(void 0);
|
|
56
|
+
l(() => {
|
|
57
|
+
!B && z.length > 0 && V(z[0].id);
|
|
58
|
+
}, [z, B]);
|
|
59
|
+
let H = z.find((e) => e.id === B), [U, { data: W, loading: G, error: K }] = o({ fetchPolicy: "network-only" }), q = u("");
|
|
60
|
+
l(() => {
|
|
61
|
+
if (G) return;
|
|
62
|
+
let e = W?.getTransaction;
|
|
63
|
+
e ? (O(e), A(!1), P(String(e.amount))) : (W !== void 0 || K) && (O(null), A(!0), P(""));
|
|
64
|
+
}, [
|
|
65
|
+
W,
|
|
66
|
+
G,
|
|
67
|
+
K
|
|
68
|
+
]);
|
|
69
|
+
let J = (e, t) => {
|
|
70
|
+
q.current = `${e}::${t}`, O(null), A(!1), P(""), U({ variables: {
|
|
71
|
+
id: e,
|
|
72
|
+
billingAccountId: t
|
|
73
|
+
} });
|
|
74
|
+
}, oe = (e) => {
|
|
75
|
+
E(e), O(null), A(!1), P(""), x.test(e.trim()) && B && J(e.trim(), B);
|
|
76
|
+
}, se = (e) => {
|
|
77
|
+
V(e), O(null), A(!1), P(""), x.test(T.trim()) && J(T.trim(), e);
|
|
78
|
+
}, { data: ce, loading: le, refetch: ue } = a({
|
|
79
|
+
variables: {
|
|
80
|
+
billingAccountId: B,
|
|
81
|
+
pageSize: 20,
|
|
82
|
+
page: 1
|
|
83
|
+
},
|
|
84
|
+
skip: !B,
|
|
85
|
+
fetchPolicy: "cache-and-network"
|
|
86
|
+
}), Y = ce?.getRefundRecords.records ?? [], [de, { loading: X }] = r({ refetchQueries: ["GetRefundRecords"] }), Z = (e) => e ? e.stripePaymentId ? {
|
|
87
|
+
provider: "STRIPE",
|
|
88
|
+
gatewayPaymentId: e.stripePaymentId
|
|
89
|
+
} : e.razorpayPaymentId ? {
|
|
90
|
+
provider: "RAZORPAY",
|
|
91
|
+
gatewayPaymentId: e.razorpayPaymentId
|
|
92
|
+
} : null : null, fe = async (e) => {
|
|
93
|
+
if (e.preventDefault(), I(null), !D || !j.trim() || !N) {
|
|
94
|
+
I("Enter a valid transaction ID, an amount, and a reason.");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
let n = Z(D);
|
|
98
|
+
if (!n) {
|
|
99
|
+
I("No payment gateway info found for this transaction. Please contact support.");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
let r = parseFloat(N);
|
|
103
|
+
if (isNaN(r) || r <= 0) {
|
|
104
|
+
I("Please enter a valid amount greater than 0.");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (r > D.amount) {
|
|
108
|
+
I(`Cannot exceed the original payment amount (${t(D.amount, D.currency)}).`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
await de({ variables: {
|
|
113
|
+
billingAccountId: B,
|
|
114
|
+
provider: n.provider,
|
|
115
|
+
gatewayPaymentId: n.gatewayPaymentId,
|
|
116
|
+
amount: r,
|
|
117
|
+
currency: D.currency ?? H?.currency ?? "USD",
|
|
118
|
+
transactionId: D.id,
|
|
119
|
+
reason: j.trim(),
|
|
120
|
+
notes: "Requested by user via billing portal"
|
|
121
|
+
} }), L(!0), w(!1), Q(), await ue();
|
|
122
|
+
} catch (e) {
|
|
123
|
+
I(e instanceof Error ? e.message : "Failed to submit refund request.");
|
|
124
|
+
}
|
|
125
|
+
}, Q = () => {
|
|
126
|
+
E(""), O(null), A(!1), M(""), P(""), I(null);
|
|
127
|
+
}, $ = () => {
|
|
128
|
+
w(!1), L(!1), Q();
|
|
129
|
+
};
|
|
130
|
+
return /* @__PURE__ */ y("div", {
|
|
131
|
+
className: "space-y-6 p-6 max-w-3xl",
|
|
132
|
+
children: [
|
|
133
|
+
/* @__PURE__ */ v(e, {
|
|
134
|
+
title: _("billing.refunds.title", "Refunds"),
|
|
135
|
+
description: _("billing.refunds.description", "View your refund requests and submit new ones"),
|
|
136
|
+
actions: C ? void 0 : /* @__PURE__ */ y("button", {
|
|
137
|
+
type: "button",
|
|
138
|
+
onClick: () => {
|
|
139
|
+
w(!0), L(!1);
|
|
140
|
+
},
|
|
141
|
+
className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",
|
|
142
|
+
children: [/* @__PURE__ */ v(ee, { className: "size-4" }), _("billing.refunds.requestRefund", "Request Refund")]
|
|
143
|
+
})
|
|
144
|
+
}),
|
|
145
|
+
!R && z.length > 1 && /* @__PURE__ */ y("div", {
|
|
146
|
+
className: "flex items-center gap-3",
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ v(m, { className: "size-4 text-muted-foreground shrink-0" }),
|
|
149
|
+
/* @__PURE__ */ v("label", {
|
|
150
|
+
htmlFor: "accountSwitch",
|
|
151
|
+
className: "text-sm text-muted-foreground shrink-0",
|
|
152
|
+
children: _("billing.refunds.account", "Billing account")
|
|
153
|
+
}),
|
|
154
|
+
/* @__PURE__ */ v("select", {
|
|
155
|
+
id: "accountSwitch",
|
|
156
|
+
value: B ?? "",
|
|
157
|
+
onChange: (e) => se(e.target.value),
|
|
158
|
+
className: "flex-1 px-3 py-1.5 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary text-sm",
|
|
159
|
+
children: z.map((e) => /* @__PURE__ */ y("option", {
|
|
160
|
+
value: e.id,
|
|
161
|
+
children: [
|
|
162
|
+
e.name,
|
|
163
|
+
" (",
|
|
164
|
+
e.currency,
|
|
165
|
+
") — ",
|
|
166
|
+
e.email
|
|
167
|
+
]
|
|
168
|
+
}, e.id))
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
}),
|
|
172
|
+
ie && /* @__PURE__ */ y("div", {
|
|
173
|
+
className: "flex items-center justify-between p-4 rounded-lg border border-status-success-border bg-status-success-bg/10",
|
|
174
|
+
children: [/* @__PURE__ */ y("div", {
|
|
175
|
+
className: "flex items-center gap-2",
|
|
176
|
+
children: [/* @__PURE__ */ v(f, { className: "size-4 text-status-success-text" }), /* @__PURE__ */ v("p", {
|
|
177
|
+
className: "text-sm text-status-success-text font-medium",
|
|
178
|
+
children: _("billing.refunds.submitted", "Refund request submitted. Our team will review it shortly.")
|
|
179
|
+
})]
|
|
180
|
+
}), /* @__PURE__ */ v("button", {
|
|
181
|
+
type: "button",
|
|
182
|
+
onClick: () => L(!1),
|
|
183
|
+
className: "text-status-success-text hover:opacity-70",
|
|
184
|
+
children: /* @__PURE__ */ v(g, { className: "size-4" })
|
|
185
|
+
})]
|
|
186
|
+
}),
|
|
187
|
+
C && /* @__PURE__ */ y("div", {
|
|
188
|
+
className: "border border-border rounded-lg bg-card overflow-hidden",
|
|
189
|
+
children: [/* @__PURE__ */ y("div", {
|
|
190
|
+
className: "flex items-center justify-between p-4 border-b border-border bg-muted/30",
|
|
191
|
+
children: [/* @__PURE__ */ v("h2", {
|
|
192
|
+
className: "font-semibold text-foreground",
|
|
193
|
+
children: _("billing.refunds.newRequest", "New Refund Request")
|
|
194
|
+
}), /* @__PURE__ */ v("button", {
|
|
195
|
+
type: "button",
|
|
196
|
+
onClick: $,
|
|
197
|
+
className: "p-1 rounded hover:bg-muted transition-colors",
|
|
198
|
+
children: /* @__PURE__ */ v(g, { className: "size-4 text-muted-foreground" })
|
|
199
|
+
})]
|
|
200
|
+
}), /* @__PURE__ */ y("form", {
|
|
201
|
+
onSubmit: fe,
|
|
202
|
+
className: "p-4 space-y-4",
|
|
203
|
+
children: [
|
|
204
|
+
F && /* @__PURE__ */ v("div", {
|
|
205
|
+
className: "p-3 rounded-lg border border-status-error-border bg-status-error-bg/10",
|
|
206
|
+
children: /* @__PURE__ */ v("p", {
|
|
207
|
+
className: "text-sm text-status-error-text",
|
|
208
|
+
children: F
|
|
209
|
+
})
|
|
210
|
+
}),
|
|
211
|
+
/* @__PURE__ */ y("div", { children: [
|
|
212
|
+
/* @__PURE__ */ y("label", {
|
|
213
|
+
htmlFor: "txnId",
|
|
214
|
+
className: "block text-sm font-medium text-foreground mb-1",
|
|
215
|
+
children: [_("billing.refunds.transactionId", "Transaction ID"), " *"]
|
|
216
|
+
}),
|
|
217
|
+
/* @__PURE__ */ y("div", {
|
|
218
|
+
className: "relative",
|
|
219
|
+
children: [/* @__PURE__ */ v("input", {
|
|
220
|
+
id: "txnId",
|
|
221
|
+
type: "text",
|
|
222
|
+
value: T,
|
|
223
|
+
onChange: (e) => oe(e.target.value),
|
|
224
|
+
placeholder: "Paste your transaction ID...",
|
|
225
|
+
className: "w-full pl-3 pr-9 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary text-sm font-mono"
|
|
226
|
+
}), /* @__PURE__ */ v("div", {
|
|
227
|
+
className: "absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",
|
|
228
|
+
children: G ? /* @__PURE__ */ v(h, { className: "size-4 animate-spin" }) : /* @__PURE__ */ v(ne, { className: "size-4" })
|
|
229
|
+
})]
|
|
230
|
+
}),
|
|
231
|
+
D && /* @__PURE__ */ y("div", {
|
|
232
|
+
className: "mt-2 p-3 rounded-md border border-status-success-border bg-status-success-bg/10 text-sm space-y-0.5",
|
|
233
|
+
children: [/* @__PURE__ */ y("div", {
|
|
234
|
+
className: "flex items-center gap-2",
|
|
235
|
+
children: [
|
|
236
|
+
/* @__PURE__ */ v(f, { className: "size-3.5 text-status-success-text shrink-0" }),
|
|
237
|
+
/* @__PURE__ */ v("span", {
|
|
238
|
+
className: "font-medium text-foreground",
|
|
239
|
+
children: t(D.amount, D.currency)
|
|
240
|
+
}),
|
|
241
|
+
/* @__PURE__ */ v("span", {
|
|
242
|
+
className: "text-muted-foreground",
|
|
243
|
+
children: "·"
|
|
244
|
+
}),
|
|
245
|
+
/* @__PURE__ */ v("span", {
|
|
246
|
+
className: "text-muted-foreground",
|
|
247
|
+
children: n(D.createdAt)
|
|
248
|
+
}),
|
|
249
|
+
D.stripePaymentId && /* @__PURE__ */ v("span", {
|
|
250
|
+
className: "text-xs text-muted-foreground",
|
|
251
|
+
children: "Stripe"
|
|
252
|
+
}),
|
|
253
|
+
D.razorpayPaymentId && /* @__PURE__ */ v("span", {
|
|
254
|
+
className: "text-xs text-muted-foreground",
|
|
255
|
+
children: "Razorpay"
|
|
256
|
+
})
|
|
257
|
+
]
|
|
258
|
+
}), D.description && /* @__PURE__ */ v("p", {
|
|
259
|
+
className: "text-xs text-muted-foreground pl-5",
|
|
260
|
+
children: D.description
|
|
261
|
+
})]
|
|
262
|
+
}),
|
|
263
|
+
k && T.length > 0 && !G && /* @__PURE__ */ v("p", {
|
|
264
|
+
className: "mt-1 text-xs text-status-error-text",
|
|
265
|
+
children: _("billing.refunds.txnNotFound", "Transaction not found in this billing account.")
|
|
266
|
+
}),
|
|
267
|
+
!x.test(T.trim()) && T.length > 4 && /* @__PURE__ */ v("p", {
|
|
268
|
+
className: "mt-1 text-xs text-muted-foreground",
|
|
269
|
+
children: _("billing.refunds.txnIdHint", "Transaction IDs look like: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
|
|
270
|
+
})
|
|
271
|
+
] }),
|
|
272
|
+
D && /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ y("label", {
|
|
273
|
+
htmlFor: "refundAmount",
|
|
274
|
+
className: "block text-sm font-medium text-foreground mb-1",
|
|
275
|
+
children: [_("billing.refunds.amount", "Refund Amount"), " *"]
|
|
276
|
+
}), /* @__PURE__ */ y("div", {
|
|
277
|
+
className: "flex items-center gap-2",
|
|
278
|
+
children: [
|
|
279
|
+
/* @__PURE__ */ v("input", {
|
|
280
|
+
id: "refundAmount",
|
|
281
|
+
type: "number",
|
|
282
|
+
step: "0.01",
|
|
283
|
+
min: "0.01",
|
|
284
|
+
max: D.amount,
|
|
285
|
+
value: N,
|
|
286
|
+
onChange: (e) => P(e.target.value),
|
|
287
|
+
required: !0,
|
|
288
|
+
className: "w-40 px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary text-sm",
|
|
289
|
+
placeholder: "0.00"
|
|
290
|
+
}),
|
|
291
|
+
/* @__PURE__ */ v("span", {
|
|
292
|
+
className: "text-sm text-muted-foreground",
|
|
293
|
+
children: D.currency ?? H?.currency ?? "USD"
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ y("span", {
|
|
296
|
+
className: "text-xs text-muted-foreground",
|
|
297
|
+
children: ["max ", t(D.amount, D.currency)]
|
|
298
|
+
})
|
|
299
|
+
]
|
|
300
|
+
})] }),
|
|
301
|
+
/* @__PURE__ */ y("div", { children: [/* @__PURE__ */ y("label", {
|
|
302
|
+
htmlFor: "reason",
|
|
303
|
+
className: "block text-sm font-medium text-foreground mb-1",
|
|
304
|
+
children: [_("billing.refunds.reason", "Reason for refund"), " *"]
|
|
305
|
+
}), /* @__PURE__ */ v("textarea", {
|
|
306
|
+
id: "reason",
|
|
307
|
+
value: j,
|
|
308
|
+
onChange: (e) => M(e.target.value),
|
|
309
|
+
required: !0,
|
|
310
|
+
rows: 3,
|
|
311
|
+
className: "w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary text-sm resize-none",
|
|
312
|
+
placeholder: _("billing.refunds.reasonPlaceholder", "Describe why you are requesting a refund...")
|
|
313
|
+
})] }),
|
|
314
|
+
/* @__PURE__ */ y("div", {
|
|
315
|
+
className: "flex items-center gap-3 pt-1",
|
|
316
|
+
children: [/* @__PURE__ */ v("button", {
|
|
317
|
+
type: "submit",
|
|
318
|
+
disabled: X || !D || !j.trim() || !N,
|
|
319
|
+
className: "px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
320
|
+
children: X ? _("billing.refunds.submitting", "Submitting...") : _("billing.refunds.submitRequest", "Submit Request")
|
|
321
|
+
}), /* @__PURE__ */ v("button", {
|
|
322
|
+
type: "button",
|
|
323
|
+
onClick: $,
|
|
324
|
+
className: "px-4 py-2 text-sm border border-border text-foreground rounded-md hover:bg-muted transition-colors",
|
|
325
|
+
children: _("billing.common.cancel", "Cancel")
|
|
326
|
+
})]
|
|
327
|
+
})
|
|
328
|
+
]
|
|
329
|
+
})]
|
|
330
|
+
}),
|
|
331
|
+
/* @__PURE__ */ y("div", {
|
|
332
|
+
className: "border border-border rounded-lg bg-card overflow-hidden",
|
|
333
|
+
children: [/* @__PURE__ */ v("div", {
|
|
334
|
+
className: "p-4 border-b border-border bg-muted/30",
|
|
335
|
+
children: /* @__PURE__ */ v("h2", {
|
|
336
|
+
className: "font-semibold text-foreground",
|
|
337
|
+
children: _("billing.refunds.history", "Refund History")
|
|
338
|
+
})
|
|
339
|
+
}), R || le ? /* @__PURE__ */ v("div", {
|
|
340
|
+
className: "p-8 flex items-center justify-center",
|
|
341
|
+
children: /* @__PURE__ */ v(h, { className: "size-5 animate-spin text-muted-foreground" })
|
|
342
|
+
}) : Y.length === 0 ? /* @__PURE__ */ y("div", {
|
|
343
|
+
className: "p-10 flex flex-col items-center text-center gap-3",
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ v(te, { className: "size-8 text-muted-foreground" }),
|
|
346
|
+
/* @__PURE__ */ v("p", {
|
|
347
|
+
className: "text-sm font-medium text-foreground",
|
|
348
|
+
children: _("billing.refunds.noRefunds", "No refund requests yet")
|
|
349
|
+
}),
|
|
350
|
+
/* @__PURE__ */ v("p", {
|
|
351
|
+
className: "text-xs text-muted-foreground max-w-sm",
|
|
352
|
+
children: _("billing.refunds.noRefundsHint", "If you have an issue with a payment, click \"Request Refund\" to get started.")
|
|
353
|
+
})
|
|
354
|
+
]
|
|
355
|
+
}) : /* @__PURE__ */ v("ul", {
|
|
356
|
+
className: "divide-y divide-border",
|
|
357
|
+
children: Y.map((e) => /* @__PURE__ */ y("li", {
|
|
358
|
+
className: "flex items-start gap-4 p-4 hover:bg-muted/30 transition-colors",
|
|
359
|
+
children: [/* @__PURE__ */ y("div", {
|
|
360
|
+
className: "flex-1 min-w-0",
|
|
361
|
+
children: [
|
|
362
|
+
/* @__PURE__ */ y("div", {
|
|
363
|
+
className: "flex items-center gap-2 flex-wrap",
|
|
364
|
+
children: [
|
|
365
|
+
/* @__PURE__ */ v("span", {
|
|
366
|
+
className: "text-sm font-medium text-foreground",
|
|
367
|
+
children: t(e.amount, e.currency)
|
|
368
|
+
}),
|
|
369
|
+
/* @__PURE__ */ v(re, { status: e.status }),
|
|
370
|
+
e.purchaseDetail && /* @__PURE__ */ v("span", {
|
|
371
|
+
className: "text-xs text-muted-foreground truncate",
|
|
372
|
+
children: e.purchaseDetail
|
|
373
|
+
})
|
|
374
|
+
]
|
|
375
|
+
}),
|
|
376
|
+
e.reason && /* @__PURE__ */ v("p", {
|
|
377
|
+
className: "text-xs text-muted-foreground mt-1 line-clamp-2",
|
|
378
|
+
children: e.reason
|
|
379
|
+
}),
|
|
380
|
+
e.errorMessage && e.status === c.Failed && /* @__PURE__ */ v("p", {
|
|
381
|
+
className: "text-xs text-status-error-text mt-1",
|
|
382
|
+
children: e.errorMessage
|
|
383
|
+
})
|
|
384
|
+
]
|
|
385
|
+
}), /* @__PURE__ */ y("div", {
|
|
386
|
+
className: "text-right shrink-0",
|
|
387
|
+
children: [/* @__PURE__ */ v("p", {
|
|
388
|
+
className: "text-xs text-muted-foreground",
|
|
389
|
+
children: n(e.createdAt)
|
|
390
|
+
}), e.processedAt && /* @__PURE__ */ y("p", {
|
|
391
|
+
className: "text-xs text-muted-foreground mt-0.5",
|
|
392
|
+
children: ["Processed ", n(e.processedAt)]
|
|
393
|
+
})]
|
|
394
|
+
})]
|
|
395
|
+
}, e.id))
|
|
396
|
+
})]
|
|
397
|
+
}),
|
|
398
|
+
/* @__PURE__ */ y("p", {
|
|
399
|
+
className: "text-xs text-muted-foreground",
|
|
400
|
+
children: [
|
|
401
|
+
_("billing.refunds.footer", "Refund requests are reviewed by our team within 3–5 business days. For urgent issues, contact support."),
|
|
402
|
+
" ",
|
|
403
|
+
/* @__PURE__ */ v("button", {
|
|
404
|
+
type: "button",
|
|
405
|
+
onClick: () => S("/transactions/" + B),
|
|
406
|
+
className: "underline hover:no-underline",
|
|
407
|
+
children: _("billing.refunds.viewTransactions", "View all transactions")
|
|
408
|
+
})
|
|
409
|
+
]
|
|
410
|
+
})
|
|
411
|
+
]
|
|
412
|
+
});
|
|
413
|
+
};
|
|
414
|
+
//#endregion
|
|
415
|
+
export { C as UserRefundsPage };
|
|
416
|
+
|
|
417
|
+
//# sourceMappingURL=UserRefundsPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserRefundsPage.js","names":[],"sources":["../../../../../src/billing/modules/billing/pages/UserRefundsPage.tsx"],"sourcesContent":["/**\n * Billing Module - User Refunds Page\n * Shows the user's refund request history and allows submitting new requests.\n */\n\nimport { useState, useEffect, useRef, type FC, type FormEvent } from 'react';\nimport {\n RotateCcw,\n PlusCircle,\n X,\n Clock,\n CheckCircle,\n XCircle,\n Loader2,\n Search,\n CreditCard,\n} from 'lucide-react';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { formatCurrency, formatDateTime } from '../../../shared/utils';\nimport { PageHeader } from '../../../shared/components';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n useGetBillingAccountsCheckoutQuery,\n useGetTransactionLazyQuery,\n useGetRefundRecordsQuery,\n useCreateRefundRecordMutation,\n type GetRefundRecordsQuery,\n type GetTransactionQuery,\n} from '../../../../generated/global-operations';\nimport { RefundRecordStatus } from '../../../../generated/global-types';\n\ntype RefundItem = NonNullable<GetRefundRecordsQuery['getRefundRecords']['records']>[number];\ntype TxnLookup = NonNullable<GetTransactionQuery['getTransaction']>;\n\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n// ============================================================================\n// Status helpers\n// ============================================================================\n\nconst STATUS_CONFIG: Record<\n RefundRecordStatus,\n { label: string; className: string; icon: FC<{ className?: string }> }\n> = {\n [RefundRecordStatus.Pending]: {\n label: 'In Review',\n className: 'bg-status-warning-bg/20 text-status-warning-text border-status-warning-border',\n icon: ({ className }) => <Clock className={className} />,\n },\n [RefundRecordStatus.Processing]: {\n label: 'Processing',\n className: 'bg-action-primary-bg/15 text-action-primary-bg border-action-primary-bg/30',\n icon: ({ className }) => <Loader2 className={`${className} animate-spin`} />,\n },\n [RefundRecordStatus.Completed]: {\n label: 'Refunded',\n className: 'bg-status-success-bg/20 text-status-success-text border-status-success-border',\n icon: ({ className }) => <CheckCircle className={className} />,\n },\n [RefundRecordStatus.Failed]: {\n label: 'Failed',\n className: 'bg-status-error-bg/20 text-status-error-text border-status-error-border',\n icon: ({ className }) => <XCircle className={className} />,\n },\n [RefundRecordStatus.Skipped]: {\n label: 'Closed',\n className: 'bg-muted text-muted-foreground border-border',\n icon: ({ className }) => <XCircle className={className} />,\n },\n};\n\nfunction StatusBadge({ status }: { status: string }) {\n const cfg = STATUS_CONFIG[status as RefundRecordStatus] ?? {\n label: status,\n className: 'bg-muted text-muted-foreground border-border',\n icon: ({ className }: { className?: string }) => <Clock className={className} />,\n };\n const Icon = cfg.icon;\n return (\n <span\n className={`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border text-xs font-medium ${cfg.className}`}\n >\n <Icon className=\"size-3\" />\n {cfg.label}\n </span>\n );\n}\n\n// ============================================================================\n// Main page\n// ============================================================================\n\nexport const UserRefundsPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string) => {\n const v = t(key);\n return v === key ? fallback : v;\n };\n const navigateTo = useBillingNavigate();\n\n // Form state\n const [showForm, setShowForm] = useState(false);\n const [txnIdInput, setTxnIdInput] = useState('');\n const [lookedUpTxn, setLookedUpTxn] = useState<TxnLookup | null>(null);\n const [txnNotFound, setTxnNotFound] = useState(false);\n const [reason, setReason] = useState('');\n const [amount, setAmount] = useState('');\n const [formError, setFormError] = useState<string | null>(null);\n const [formSuccess, setFormSuccess] = useState(false);\n\n // All billing accounts\n const { data: accountsData, loading: accountsLoading } = useGetBillingAccountsCheckoutQuery({\n fetchPolicy: 'cache-and-network',\n });\n type BillingAccount = NonNullable<typeof accountsData>['getBillingAccountsByOrg'][number];\n const accounts: BillingAccount[] = accountsData?.getBillingAccountsByOrg ?? [];\n\n // Default to the first account; user can switch\n const [selectedAccountId, setSelectedAccountId] = useState<string | undefined>(undefined);\n useEffect(() => {\n if (!selectedAccountId && accounts.length > 0) {\n setSelectedAccountId(accounts[0].id);\n }\n }, [accounts, selectedAccountId]);\n\n const selectedAccount = accounts.find((a) => a.id === selectedAccountId);\n\n // Transaction lookup by ID (lazy — fires when user enters a valid UUID)\n const [fetchTxn, { data: txnLookupData, loading: txnLookupLoading, error: txnLookupError }] =\n useGetTransactionLazyQuery({ fetchPolicy: 'network-only' });\n\n // Track the \"active\" lookup key so we only apply results for the latest request\n const lastLookupKey = useRef('');\n\n useEffect(() => {\n if (txnLookupLoading) return;\n const txn = txnLookupData?.getTransaction;\n if (txn) {\n setLookedUpTxn(txn);\n setTxnNotFound(false);\n setAmount(String(txn.amount));\n } else if (txnLookupData !== undefined || txnLookupError) {\n setLookedUpTxn(null);\n setTxnNotFound(true);\n setAmount('');\n }\n }, [txnLookupData, txnLookupLoading, txnLookupError]);\n\n const triggerLookup = (txnId: string, accountId: string) => {\n const key = `${txnId}::${accountId}`;\n lastLookupKey.current = key;\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setAmount('');\n fetchTxn({ variables: { id: txnId, billingAccountId: accountId } });\n };\n\n const handleTxnIdChange = (value: string) => {\n setTxnIdInput(value);\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setAmount('');\n if (UUID_RE.test(value.trim()) && selectedAccountId) {\n triggerLookup(value.trim(), selectedAccountId);\n }\n };\n\n // When account changes, re-fetch the transaction if one is entered\n const handleAccountChange = (accountId: string) => {\n setSelectedAccountId(accountId);\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setAmount('');\n if (UUID_RE.test(txnIdInput.trim())) {\n triggerLookup(txnIdInput.trim(), accountId);\n }\n };\n\n // Refund history for selected account\n const {\n data: refundsData,\n loading: refundsLoading,\n refetch: refetchRefunds,\n } = useGetRefundRecordsQuery({\n variables: { billingAccountId: selectedAccountId, pageSize: 20, page: 1 },\n skip: !selectedAccountId,\n fetchPolicy: 'cache-and-network',\n });\n const refunds = refundsData?.getRefundRecords.records ?? [];\n\n const [createRefund, { loading: isSubmitting }] = useCreateRefundRecordMutation({\n refetchQueries: ['GetRefundRecords'],\n });\n\n const getGatewayInfo = (txn: TxnLookup | null) => {\n if (!txn) return null;\n if (txn.stripePaymentId) return { provider: 'STRIPE', gatewayPaymentId: txn.stripePaymentId };\n if (txn.razorpayPaymentId)\n return { provider: 'RAZORPAY', gatewayPaymentId: txn.razorpayPaymentId };\n return null;\n };\n\n const handleSubmit = async (e: FormEvent) => {\n e.preventDefault();\n setFormError(null);\n\n if (!lookedUpTxn || !reason.trim() || !amount) {\n setFormError('Enter a valid transaction ID, an amount, and a reason.');\n return;\n }\n const gatewayInfo = getGatewayInfo(lookedUpTxn);\n if (!gatewayInfo) {\n setFormError('No payment gateway info found for this transaction. Please contact support.');\n return;\n }\n const parsedAmount = parseFloat(amount);\n if (isNaN(parsedAmount) || parsedAmount <= 0) {\n setFormError('Please enter a valid amount greater than 0.');\n return;\n }\n if (parsedAmount > lookedUpTxn.amount) {\n setFormError(\n `Cannot exceed the original payment amount (${formatCurrency(lookedUpTxn.amount, lookedUpTxn.currency)}).`\n );\n return;\n }\n\n try {\n await createRefund({\n variables: {\n billingAccountId: selectedAccountId,\n provider: gatewayInfo.provider,\n gatewayPaymentId: gatewayInfo.gatewayPaymentId,\n amount: parsedAmount,\n currency: lookedUpTxn.currency ?? selectedAccount?.currency ?? 'USD',\n transactionId: lookedUpTxn.id,\n reason: reason.trim(),\n notes: `Requested by user via billing portal`,\n },\n });\n setFormSuccess(true);\n setShowForm(false);\n resetFormFields();\n await refetchRefunds();\n } catch (err) {\n setFormError(err instanceof Error ? err.message : 'Failed to submit refund request.');\n }\n };\n\n const resetFormFields = () => {\n setTxnIdInput('');\n setLookedUpTxn(null);\n setTxnNotFound(false);\n setReason('');\n setAmount('');\n setFormError(null);\n };\n\n const resetForm = () => {\n setShowForm(false);\n setFormSuccess(false);\n resetFormFields();\n };\n\n return (\n <div className=\"space-y-6 p-6 max-w-3xl\">\n <PageHeader\n title={tr('billing.refunds.title', 'Refunds')}\n description={tr(\n 'billing.refunds.description',\n 'View your refund requests and submit new ones'\n )}\n actions={\n !showForm ? (\n <button\n type=\"button\"\n onClick={() => {\n setShowForm(true);\n setFormSuccess(false);\n }}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors\"\n >\n <PlusCircle className=\"size-4\" />\n {tr('billing.refunds.requestRefund', 'Request Refund')}\n </button>\n ) : undefined\n }\n />\n\n {/* Billing account switcher */}\n {!accountsLoading && accounts.length > 1 && (\n <div className=\"flex items-center gap-3\">\n <CreditCard className=\"size-4 text-muted-foreground shrink-0\" />\n <label htmlFor=\"accountSwitch\" className=\"text-sm text-muted-foreground shrink-0\">\n {tr('billing.refunds.account', 'Billing account')}\n </label>\n <select\n id=\"accountSwitch\"\n value={selectedAccountId ?? ''}\n onChange={(e) => handleAccountChange(e.target.value)}\n className=\"flex-1 px-3 py-1.5 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary text-sm\"\n >\n {accounts.map((a) => (\n <option key={a.id} value={a.id}>\n {a.name} ({a.currency}) — {a.email}\n </option>\n ))}\n </select>\n </div>\n )}\n\n {/* Success banner */}\n {formSuccess && (\n <div className=\"flex items-center justify-between p-4 rounded-lg border border-status-success-border bg-status-success-bg/10\">\n <div className=\"flex items-center gap-2\">\n <CheckCircle className=\"size-4 text-status-success-text\" />\n <p className=\"text-sm text-status-success-text font-medium\">\n {tr(\n 'billing.refunds.submitted',\n 'Refund request submitted. Our team will review it shortly.'\n )}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => setFormSuccess(false)}\n className=\"text-status-success-text hover:opacity-70\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n )}\n\n {/* Request Refund Form */}\n {showForm && (\n <div className=\"border border-border rounded-lg bg-card overflow-hidden\">\n <div className=\"flex items-center justify-between p-4 border-b border-border bg-muted/30\">\n <h2 className=\"font-semibold text-foreground\">\n {tr('billing.refunds.newRequest', 'New Refund Request')}\n </h2>\n <button\n type=\"button\"\n onClick={resetForm}\n className=\"p-1 rounded hover:bg-muted transition-colors\"\n >\n <X className=\"size-4 text-muted-foreground\" />\n </button>\n </div>\n\n <form onSubmit={handleSubmit} className=\"p-4 space-y-4\">\n {formError && (\n <div className=\"p-3 rounded-lg border border-status-error-border bg-status-error-bg/10\">\n <p className=\"text-sm text-status-error-text\">{formError}</p>\n </div>\n )}\n\n {/* Transaction ID lookup */}\n <div>\n <label htmlFor=\"txnId\" className=\"block text-sm font-medium text-foreground mb-1\">\n {tr('billing.refunds.transactionId', 'Transaction ID')} *\n </label>\n <div className=\"relative\">\n <input\n id=\"txnId\"\n type=\"text\"\n value={txnIdInput}\n onChange={(e) => handleTxnIdChange(e.target.value)}\n placeholder=\"Paste your transaction ID...\"\n className=\"w-full pl-3 pr-9 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary text-sm font-mono\"\n />\n <div className=\"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground\">\n {txnLookupLoading ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <Search className=\"size-4\" />\n )}\n </div>\n </div>\n\n {/* Transaction lookup result */}\n {lookedUpTxn && (\n <div className=\"mt-2 p-3 rounded-md border border-status-success-border bg-status-success-bg/10 text-sm space-y-0.5\">\n <div className=\"flex items-center gap-2\">\n <CheckCircle className=\"size-3.5 text-status-success-text shrink-0\" />\n <span className=\"font-medium text-foreground\">\n {formatCurrency(lookedUpTxn.amount, lookedUpTxn.currency)}\n </span>\n <span className=\"text-muted-foreground\">·</span>\n <span className=\"text-muted-foreground\">\n {formatDateTime(lookedUpTxn.createdAt)}\n </span>\n {lookedUpTxn.stripePaymentId && (\n <span className=\"text-xs text-muted-foreground\">Stripe</span>\n )}\n {lookedUpTxn.razorpayPaymentId && (\n <span className=\"text-xs text-muted-foreground\">Razorpay</span>\n )}\n </div>\n {lookedUpTxn.description && (\n <p className=\"text-xs text-muted-foreground pl-5\">{lookedUpTxn.description}</p>\n )}\n </div>\n )}\n {txnNotFound && txnIdInput.length > 0 && !txnLookupLoading && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {tr(\n 'billing.refunds.txnNotFound',\n 'Transaction not found in this billing account.'\n )}\n </p>\n )}\n {!UUID_RE.test(txnIdInput.trim()) && txnIdInput.length > 4 && (\n <p className=\"mt-1 text-xs text-muted-foreground\">\n {tr(\n 'billing.refunds.txnIdHint',\n 'Transaction IDs look like: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'\n )}\n </p>\n )}\n </div>\n\n {/* Amount — only shown once transaction is found */}\n {lookedUpTxn && (\n <div>\n <label\n htmlFor=\"refundAmount\"\n className=\"block text-sm font-medium text-foreground mb-1\"\n >\n {tr('billing.refunds.amount', 'Refund Amount')} *\n </label>\n <div className=\"flex items-center gap-2\">\n <input\n id=\"refundAmount\"\n type=\"number\"\n step=\"0.01\"\n min=\"0.01\"\n max={lookedUpTxn.amount}\n value={amount}\n onChange={(e) => setAmount(e.target.value)}\n required\n className=\"w-40 px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary text-sm\"\n placeholder=\"0.00\"\n />\n <span className=\"text-sm text-muted-foreground\">\n {lookedUpTxn.currency ?? selectedAccount?.currency ?? 'USD'}\n </span>\n <span className=\"text-xs text-muted-foreground\">\n max {formatCurrency(lookedUpTxn.amount, lookedUpTxn.currency)}\n </span>\n </div>\n </div>\n )}\n\n {/* Reason */}\n <div>\n <label htmlFor=\"reason\" className=\"block text-sm font-medium text-foreground mb-1\">\n {tr('billing.refunds.reason', 'Reason for refund')} *\n </label>\n <textarea\n id=\"reason\"\n value={reason}\n onChange={(e) => setReason(e.target.value)}\n required\n rows={3}\n className=\"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary text-sm resize-none\"\n placeholder={tr(\n 'billing.refunds.reasonPlaceholder',\n 'Describe why you are requesting a refund...'\n )}\n />\n </div>\n\n <div className=\"flex items-center gap-3 pt-1\">\n <button\n type=\"submit\"\n disabled={isSubmitting || !lookedUpTxn || !reason.trim() || !amount}\n className=\"px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n {isSubmitting\n ? tr('billing.refunds.submitting', 'Submitting...')\n : tr('billing.refunds.submitRequest', 'Submit Request')}\n </button>\n <button\n type=\"button\"\n onClick={resetForm}\n className=\"px-4 py-2 text-sm border border-border text-foreground rounded-md hover:bg-muted transition-colors\"\n >\n {tr('billing.common.cancel', 'Cancel')}\n </button>\n </div>\n </form>\n </div>\n )}\n\n {/* Refund history */}\n <div className=\"border border-border rounded-lg bg-card overflow-hidden\">\n <div className=\"p-4 border-b border-border bg-muted/30\">\n <h2 className=\"font-semibold text-foreground\">\n {tr('billing.refunds.history', 'Refund History')}\n </h2>\n </div>\n\n {accountsLoading || refundsLoading ? (\n <div className=\"p-8 flex items-center justify-center\">\n <Loader2 className=\"size-5 animate-spin text-muted-foreground\" />\n </div>\n ) : refunds.length === 0 ? (\n <div className=\"p-10 flex flex-col items-center text-center gap-3\">\n <RotateCcw className=\"size-8 text-muted-foreground\" />\n <p className=\"text-sm font-medium text-foreground\">\n {tr('billing.refunds.noRefunds', 'No refund requests yet')}\n </p>\n <p className=\"text-xs text-muted-foreground max-w-sm\">\n {tr(\n 'billing.refunds.noRefundsHint',\n 'If you have an issue with a payment, click \"Request Refund\" to get started.'\n )}\n </p>\n </div>\n ) : (\n <ul className=\"divide-y divide-border\">\n {refunds.map((r: RefundItem) => (\n <li\n key={r.id}\n className=\"flex items-start gap-4 p-4 hover:bg-muted/30 transition-colors\"\n >\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span className=\"text-sm font-medium text-foreground\">\n {formatCurrency(r.amount, r.currency)}\n </span>\n <StatusBadge status={r.status} />\n {r.purchaseDetail && (\n <span className=\"text-xs text-muted-foreground truncate\">\n {r.purchaseDetail}\n </span>\n )}\n </div>\n {r.reason && (\n <p className=\"text-xs text-muted-foreground mt-1 line-clamp-2\">{r.reason}</p>\n )}\n {r.errorMessage && r.status === RefundRecordStatus.Failed && (\n <p className=\"text-xs text-status-error-text mt-1\">{r.errorMessage}</p>\n )}\n </div>\n <div className=\"text-right shrink-0\">\n <p className=\"text-xs text-muted-foreground\">{formatDateTime(r.createdAt)}</p>\n {r.processedAt && (\n <p className=\"text-xs text-muted-foreground mt-0.5\">\n Processed {formatDateTime(r.processedAt)}\n </p>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n <p className=\"text-xs text-muted-foreground\">\n {tr(\n 'billing.refunds.footer',\n 'Refund requests are reviewed by our team within 3–5 business days. For urgent issues, contact support.'\n )}{' '}\n <button\n type=\"button\"\n onClick={() => navigateTo('/transactions/' + selectedAccountId)}\n className=\"underline hover:no-underline\"\n >\n {tr('billing.refunds.viewTransactions', 'View all transactions')}\n </button>\n </p>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAkCA,IAAM,IAAU,mEAMV,IAGF;EACD,EAAmB,UAAU;EAC5B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAAC,GAAD,EAAkB,cAAa,CAAA;EACzD;EACA,EAAmB,aAAa;EAC/B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAAC,GAAD,EAAS,WAAW,GAAG,EAAU,gBAAkB,CAAA;EAC7E;EACA,EAAmB,YAAY;EAC9B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAAC,GAAD,EAAwB,cAAa,CAAA;EAC/D;EACA,EAAmB,SAAS;EAC3B,OAAO;EACP,WAAW;EACX,OAAO,EAAE,mBAAgB,kBAAC,GAAD,EAAoB,cAAa,CAAA;EAC3D;EACA,EAAmB,UAAU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