@burdenoff/microfe-housingvista 2026.1031.2 → 2026.1102.2

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.
Files changed (55) hide show
  1. package/dist/housingvista/components/ContactOwnerDialog.d.ts +6 -0
  2. package/dist/housingvista/components/ContactOwnerDialog.d.ts.map +1 -1
  3. package/dist/housingvista/components/ContactOwnerDialog.js +39 -29
  4. package/dist/housingvista/components/ContactOwnerDialog.js.map +1 -1
  5. package/dist/housingvista/hooks/index.d.ts +12 -14
  6. package/dist/housingvista/hooks/index.d.ts.map +1 -1
  7. package/dist/housingvista/hooks/index.js +288 -280
  8. package/dist/housingvista/hooks/index.js.map +1 -1
  9. package/dist/housingvista/pages/amc/AMCManagementPage.d.ts.map +1 -1
  10. package/dist/housingvista/pages/amc/AMCManagementPage.js +205 -194
  11. package/dist/housingvista/pages/amc/AMCManagementPage.js.map +1 -1
  12. package/dist/housingvista/pages/amc/AmcContractFormDialog.d.ts.map +1 -1
  13. package/dist/housingvista/pages/amc/AmcContractFormDialog.js +95 -90
  14. package/dist/housingvista/pages/amc/AmcContractFormDialog.js.map +1 -1
  15. package/dist/housingvista/pages/amc/amcDates.d.ts +2 -0
  16. package/dist/housingvista/pages/amc/amcDates.d.ts.map +1 -1
  17. package/dist/housingvista/pages/amc/amcDates.js +4 -1
  18. package/dist/housingvista/pages/amc/amcDates.js.map +1 -1
  19. package/dist/housingvista/pages/amc/amcStats.d.ts +16 -0
  20. package/dist/housingvista/pages/amc/amcStats.d.ts.map +1 -0
  21. package/dist/housingvista/pages/amc/amcStats.js +18 -0
  22. package/dist/housingvista/pages/amc/amcStats.js.map +1 -0
  23. package/dist/housingvista/pages/amc/useAmcManagement.d.ts +6 -1
  24. package/dist/housingvista/pages/amc/useAmcManagement.d.ts.map +1 -1
  25. package/dist/housingvista/pages/amc/useAmcManagement.js +28 -25
  26. package/dist/housingvista/pages/amc/useAmcManagement.js.map +1 -1
  27. package/dist/housingvista/pages/analytics/AnalyticsPage.d.ts.map +1 -1
  28. package/dist/housingvista/pages/analytics/AnalyticsPage.js +109 -105
  29. package/dist/housingvista/pages/analytics/AnalyticsPage.js.map +1 -1
  30. package/dist/housingvista/pages/finance/HomeLoanDetailPage.d.ts.map +1 -1
  31. package/dist/housingvista/pages/finance/HomeLoanDetailPage.js +161 -152
  32. package/dist/housingvista/pages/finance/HomeLoanDetailPage.js.map +1 -1
  33. package/dist/housingvista/pages/finance/HomeLoansPage.d.ts.map +1 -1
  34. package/dist/housingvista/pages/finance/HomeLoansPage.js +147 -139
  35. package/dist/housingvista/pages/finance/HomeLoansPage.js.map +1 -1
  36. package/dist/housingvista/pages/investments/InvestmentsPage.d.ts.map +1 -1
  37. package/dist/housingvista/pages/investments/InvestmentsPage.js +6 -2
  38. package/dist/housingvista/pages/investments/InvestmentsPage.js.map +1 -1
  39. package/dist/housingvista/pages/legal/LegalPage.d.ts.map +1 -1
  40. package/dist/housingvista/pages/legal/LegalPage.js +6 -1
  41. package/dist/housingvista/pages/legal/LegalPage.js.map +1 -1
  42. package/dist/housingvista/pages/marketplace/MarketplacePage.d.ts.map +1 -1
  43. package/dist/housingvista/pages/marketplace/MarketplacePage.js +6 -1
  44. package/dist/housingvista/pages/marketplace/MarketplacePage.js.map +1 -1
  45. package/dist/housingvista/pages/properties/PropertyDetailPage.d.ts.map +1 -1
  46. package/dist/housingvista/pages/properties/PropertyDetailPage.js +275 -264
  47. package/dist/housingvista/pages/properties/PropertyDetailPage.js.map +1 -1
  48. package/dist/housingvista/utils/helpers.d.ts +2 -0
  49. package/dist/housingvista/utils/helpers.d.ts.map +1 -1
  50. package/dist/housingvista/utils/helpers.js.map +1 -1
  51. package/dist/housingvista/utils/loanApplyContext.d.ts +42 -0
  52. package/dist/housingvista/utils/loanApplyContext.d.ts.map +1 -0
  53. package/dist/housingvista/utils/loanApplyContext.js +40 -0
  54. package/dist/housingvista/utils/loanApplyContext.js.map +1 -0
  55. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"AMCManagementPage.js","names":[],"sources":["../../../../src/housingvista/pages/amc/AMCManagementPage.tsx"],"sourcesContent":["import { useState, useMemo, useEffect } from 'react';\nimport { useNavigate } from 'react-router';\nimport {\n Shield,\n DollarSign,\n Calendar,\n Plus,\n Download,\n Clock,\n AlertTriangle,\n Wrench,\n RotateCcw,\n MapPin,\n Pencil,\n Ban,\n Trash2,\n} from 'lucide-react';\nimport { Button, EmphasisPanel, NextSteps, Pagination } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components';\nimport { StatCard } from '../../components';\nimport { StatusBadge } from '../../components';\nimport { FilterBar } from '../../components';\nimport { EmptyState } from '../../components';\nimport { useAMCContracts, useCreateAmcContract, useMaintenanceRequests } from '../../hooks';\nimport { useServerPagination } from '../../hooks/useServerPagination';\nimport { cn, formatCurrency } from '../../utils/helpers';\nimport { notify } from '../../lib/toast';\nimport type { AMCContract } from '../../types';\nimport { useTrackPageView } from '../../hooks/useHousingVistaAnalytics';\nimport { AmcContractFormDialog, type AmcContractFormValues } from './AmcContractFormDialog';\nimport { AmcCancelDialog, AmcDeleteDialog, AmcRenewDialog } from './AmcContractActionDialogs';\nimport { useAmcManagement } from './useAmcManagement';\nimport { calendarDaysUntil, formatCalendarDate } from './amcDates';\n\nfunction getStatusVariant(status: AMCContract['status']): 'success' | 'warning' | 'error' | 'muted' {\n switch (status) {\n case 'active':\n return 'success';\n case 'expiring_soon':\n return 'warning';\n case 'expired':\n return 'error';\n case 'cancelled':\n return 'muted';\n default:\n return 'muted';\n }\n}\n\nexport function AMCManagementPage() {\n useTrackPageView('housingvista.amc.viewed');\n const navigate = useNavigate();\n const pagination = useServerPagination(10);\n const [search, setSearch] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n\n // Debounce the raw search input into the value that feeds the server filter.\n useEffect(() => {\n const timer = setTimeout(() => setDebouncedSearch(search), 300);\n return () => clearTimeout(timer);\n }, [search]);\n\n const { data: amcContracts, loading: contractsLoading } = useAMCContracts({\n filter: { search: debouncedSearch.trim() || undefined },\n pagination: pagination.pagination,\n });\n\n // Deleting the last row on page 2+ leaves an empty page (the Pagination control is hidden when the list is\n // empty) — step back to the previous page instead of stranding the user (Codex P2 on mfe#22).\n const { page: currentPage, setPage: setCurrentPage } = pagination;\n useEffect(() => {\n if (!contractsLoading && amcContracts.length === 0 && currentPage > 1) {\n setCurrentPage(currentPage - 1);\n }\n }, [contractsLoading, amcContracts.length, currentPage, setCurrentPage]);\n\n const { createAmcContract, loading: creating } = useCreateAmcContract();\n\n // Open maintenance requests across the portfolio — real count for the sidebar stat.\n const { data: maintenanceRequests } = useMaintenanceRequests({\n filter: { status: 'open' },\n pagination: { limit: 100, offset: 0 },\n });\n const openMaintenanceCount = maintenanceRequests.length;\n\n const handleSearchChange = (value: string) => {\n setSearch(value);\n pagination.setPage(1);\n };\n\n const handleExport = () => {\n if (amcContracts.length === 0) {\n notify.warning('Nothing to export', 'There are no contracts to export yet.');\n return;\n }\n const escape = (value: string) => `\"${value.replace(/\"/g, '\"\"')}\"`;\n const headers = ['Package', 'Property', 'Provider', 'Monthly Cost', 'Start', 'End', 'Status', 'Services'];\n const rows = amcContracts.map((c) =>\n [\n c.packageName,\n c.propertyTitle,\n c.providerName,\n String(c.monthlyCost),\n c.startDate,\n c.endDate,\n c.status,\n c.servicesIncluded.join('; '),\n ]\n .map((cell) => escape(String(cell)))\n .join(',')\n );\n const csv = [headers.map(escape).join(','), ...rows].join('\\n');\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = `housingvista-amc-contracts-${new Date().toISOString().slice(0, 10)}.csv`;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(url);\n notify.success('Export ready', `${amcContracts.length} contracts exported to CSV.`);\n };\n\n const [createOpen, setCreateOpen] = useState(false);\n const manage = useAmcManagement();\n\n const handleCreate = async (values: AmcContractFormValues) => {\n try {\n await createAmcContract({\n propertyId: values.propertyId || undefined,\n marketplaceServiceId: values.marketplaceServiceId || undefined,\n propertyTitle: values.propertyTitle,\n packageName: values.packageName,\n providerName: values.providerName,\n monthlyCost: values.monthlyCost,\n startDate: values.startDate,\n endDate: values.endDate,\n status: 'active',\n nextServiceDate: values.nextServiceDate || undefined,\n servicesIncluded: values.servicesIncluded.length > 0 ? values.servicesIncluded : undefined,\n });\n notify.success('Contract created', `${values.packageName} added for ${values.propertyTitle}.`);\n setCreateOpen(false);\n } catch (err) {\n notify.error('Could not create contract', (err as Error).message);\n }\n };\n\n const handleEdit = async (values: AmcContractFormValues) => {\n const target = manage.editTarget;\n if (!target) return;\n try {\n await manage.updateAmcContract(target.id, {\n // null unlinks: picking \"Other\" turns the property / provider back into free text.\n propertyId: values.propertyId || null,\n marketplaceServiceId: values.marketplaceServiceId || null,\n propertyTitle: values.propertyTitle,\n packageName: values.packageName,\n providerName: values.providerName,\n monthlyCost: values.monthlyCost,\n startDate: values.startDate,\n endDate: values.endDate,\n // null clears a previously scheduled service.\n nextServiceDate: values.nextServiceDate || null,\n servicesIncluded: values.servicesIncluded,\n });\n notify.success('Contract updated', `${values.packageName} saved.`);\n manage.setEditTarget(null);\n } catch (err) {\n notify.error('Could not update contract', (err as Error).message);\n }\n };\n\n const openCreate = () => setCreateOpen(true);\n\n // Only live contracts feed the schedule AND the \"Upcoming Services\" stat, so the two always agree.\n const scheduledServices = useMemo(\n () =>\n amcContracts\n .filter((c) => c.nextServiceDate && (c.status === 'active' || c.status === 'expiring_soon'))\n .sort((a, b) => new Date(a.nextServiceDate).getTime() - new Date(b.nextServiceDate).getTime()),\n [amcContracts]\n );\n\n const stats = useMemo(() => {\n const activeContracts = amcContracts.filter((c) => c.status === 'active' || c.status === 'expiring_soon').length;\n const pendingRenewals = amcContracts.filter((c) => c.status === 'expiring_soon').length;\n const totalMonthlySpent = amcContracts\n .filter((c) => c.status === 'active' || c.status === 'expiring_soon')\n .reduce((sum, c) => sum + c.monthlyCost, 0);\n const upcomingServices = scheduledServices.filter((c) => {\n const daysUntil = calendarDaysUntil(c.nextServiceDate);\n return daysUntil >= 0 && daysUntil <= 30;\n }).length;\n return { activeContracts, pendingRenewals, totalMonthlySpent, upcomingServices };\n }, [amcContracts, scheduledServices]);\n\n // Accent styling per contract status for the card treatment.\n const statusAccent: Record<AMCContract['status'], string> = {\n active: 'border-l-4 border-l-status-success-border',\n expiring_soon: 'border-l-4 border-l-status-warning-border bg-status-warning-bg-subtle/30',\n expired: 'border-l-4 border-l-status-error-border',\n cancelled: 'border-l-4 border-l-border-strong',\n };\n\n return (\n <PageLayout\n title=\"AMC Management\"\n description=\"Manage Annual Maintenance Contracts and service packages\"\n purpose=\"Keep your properties maintained without surprises. Track every Annual Maintenance Contract, see what each covers and costs, get ahead of renewals, and know which services are due in the next 30 days so nothing slips.\"\n actions={\n <div className=\"flex items-center gap-2\">\n <button\n onClick={handleExport}\n className=\"inline-flex items-center gap-2 rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken\"\n >\n <Download className=\"h-4 w-4\" />\n Export\n </button>\n <Button type=\"button\" onClick={openCreate} className=\"gap-2\">\n <Plus className=\"h-4 w-4\" />\n New Contract\n </Button>\n </div>\n }\n >\n {/* Stats — primary insight zone (one EmphasisPanel per page) */}\n <EmphasisPanel className=\"p-4\">\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard label=\"Active Contracts\" value={stats.activeContracts} icon={<Shield className=\"h-4 w-4\" />} />\n <StatCard label=\"Pending Renewals\" value={stats.pendingRenewals} icon={<RotateCcw className=\"h-4 w-4\" />} />\n <StatCard\n label=\"Total Monthly Spent\"\n value={stats.totalMonthlySpent}\n prefix=\"$\"\n icon={<DollarSign className=\"h-4 w-4\" />}\n />\n <StatCard label=\"Upcoming Services\" value={stats.upcomingServices} icon={<Calendar className=\"h-4 w-4\" />} />\n </div>\n </EmphasisPanel>\n\n <NextSteps\n storageKey=\"housingvista-amc\"\n steps={[\n {\n id: 'pick-property',\n label: 'Add coverage for a property',\n description: 'Choose a property to set up a new maintenance contract.',\n onClick: openCreate,\n },\n {\n id: 'compare-providers',\n label: 'Compare your providers',\n description: 'Search by provider name to weigh coverage and monthly cost.',\n onClick: () => {\n const firstProvider = amcContracts[0]?.providerName;\n if (firstProvider) {\n setSearch(firstProvider);\n pagination.setPage(1);\n }\n },\n },\n {\n id: 'check-legal',\n label: 'Review contract paperwork',\n description: 'Open the legal hub to manage the underlying documents.',\n onClick: () => navigate('../legal'),\n },\n ]}\n />\n\n {/* Contract cards (left) + service schedule & open-maintenance sidebar (right) */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-3\">\n <div className=\"space-y-4 lg:col-span-2\">\n <div className=\"flex flex-col gap-3\">\n <h2 className=\"text-lg font-semibold text-text-primary\">All Contracts</h2>\n <FilterBar\n searchValue={search}\n onSearchChange={handleSearchChange}\n searchPlaceholder=\"Search contracts, providers, properties...\"\n />\n </div>\n {amcContracts.length > 0 ? (\n <>\n <div className=\"space-y-3\">\n {amcContracts.map((contract) => (\n <div\n key={contract.id}\n className={cn(\n 'rounded-lg border border-border-subtle bg-bg-surface p-5 shadow-sm',\n statusAccent[contract.status]\n )}\n >\n <div className=\"flex flex-wrap items-start justify-between gap-2\">\n <div className=\"min-w-0\">\n <p className=\"flex items-center gap-1 text-xs text-text-secondary\">\n <MapPin className=\"h-3 w-3\" />\n Property\n </p>\n {contract.propertyId ? (\n <button\n type=\"button\"\n onClick={() => navigate(`../properties/${contract.propertyId}`)}\n className=\"block max-w-full truncate text-left text-base font-semibold text-text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n {contract.propertyTitle}\n </button>\n ) : (\n <h3 className=\"truncate text-base font-semibold text-text-primary\">\n {contract.propertyTitle}\n </h3>\n )}\n <p className=\"text-xs text-text-secondary\">{contract.packageName}</p>\n </div>\n <StatusBadge\n label={contract.status.replace('_', ' ')}\n variant={getStatusVariant(contract.status)}\n dot\n />\n </div>\n <div className=\"mt-4 grid grid-cols-2 gap-4 border-t border-border-subtle pt-4 sm:grid-cols-4\">\n <div>\n <p className=\"text-xs text-text-secondary\">Provider</p>\n {contract.marketplaceServiceId ? (\n <button\n type=\"button\"\n onClick={() => navigate(`../marketplace/${contract.marketplaceServiceId}`)}\n className=\"mt-0.5 block max-w-full truncate text-left text-sm font-medium text-text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n {contract.providerName}\n </button>\n ) : (\n <p className=\"mt-0.5 text-sm font-medium text-text-primary\">{contract.providerName}</p>\n )}\n </div>\n <div>\n <p className=\"text-xs text-text-secondary\">Coverage</p>\n <p className=\"mt-0.5 truncate text-sm font-medium text-text-primary\">\n {contract.servicesIncluded.length > 0\n ? contract.servicesIncluded.slice(0, 2).join(', ')\n : '—'}\n {contract.servicesIncluded.length > 2 ? ` +${contract.servicesIncluded.length - 2}` : ''}\n </p>\n </div>\n <div>\n <p className=\"text-xs text-text-secondary\">Monthly Cost</p>\n <p className=\"mt-0.5 text-sm font-semibold text-text-primary\">\n {formatCurrency(contract.monthlyCost)}\n <span className=\"text-xs font-normal text-text-secondary\">/mo</span>\n </p>\n </div>\n <div>\n <p className=\"text-xs text-text-secondary\">Renewal Date</p>\n <p className=\"mt-0.5 text-sm font-medium text-text-primary\">\n {formatCalendarDate(contract.endDate)}\n </p>\n </div>\n </div>\n {contract.nextServiceDate && (\n <p className=\"mt-3 flex items-center gap-1.5 text-xs text-text-secondary\">\n <Calendar className=\"h-3.5 w-3.5\" />\n Next service {formatCalendarDate(contract.nextServiceDate)}\n </p>\n )}\n <div className=\"mt-3 flex flex-wrap items-center gap-2 border-t border-border-subtle pt-3\">\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => manage.setEditTarget(contract)}>\n <Pencil className=\"mr-1.5 h-3.5 w-3.5\" />\n Edit\n </Button>\n {contract.status !== 'cancelled' && (\n <>\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => manage.openRenew(contract)}>\n <RotateCcw className=\"mr-1.5 h-3.5 w-3.5\" />\n Renew\n </Button>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => manage.setCancelTarget(contract)}\n >\n <Ban className=\"mr-1.5 h-3.5 w-3.5\" />\n Cancel\n </Button>\n </>\n )}\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"ml-auto text-status-error-text\"\n onClick={() => manage.setDeleteTarget(contract)}\n >\n <Trash2 className=\"mr-1.5 h-3.5 w-3.5\" />\n Delete\n </Button>\n </div>\n </div>\n ))}\n </div>\n <Pagination\n page={pagination.page}\n pageSize={pagination.pageSize}\n hasNextPage={amcContracts.length >= pagination.pageSize}\n hasPreviousPage={pagination.page > 1}\n onPageChange={pagination.setPage}\n onPageSizeChange={pagination.setPageSize}\n />\n </>\n ) : (\n <EmptyState\n illustration=\"empty-search\"\n icon={<Shield className=\"h-12 w-12\" />}\n title=\"No contracts found\"\n description=\"Try adjusting your search criteria or create a new contract.\"\n action={\n <Button type=\"button\" onClick={openCreate} className=\"gap-2\">\n <Plus className=\"h-4 w-4\" />\n New Contract\n </Button>\n }\n />\n )}\n </div>\n\n {/* Sidebar */}\n <aside className=\"space-y-6 lg:col-span-1\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-5 shadow-sm\">\n <h3 className=\"mb-4 text-base font-semibold text-text-primary\">Upcoming Service Schedule</h3>\n {scheduledServices.length === 0 ? (\n <EmptyState\n illustration=\"empty-generic\"\n title=\"No services scheduled\"\n description=\"Upcoming service dates from your active contracts will appear here.\"\n className=\"border-0 bg-transparent p-4\"\n />\n ) : (\n <ol className=\"space-y-4\">\n {scheduledServices.map((contract) => {\n const daysUntil = calendarDaysUntil(contract.nextServiceDate);\n const isUrgent = daysUntil <= 7;\n const isPast = daysUntil < 0;\n return (\n <li key={contract.id} className=\"flex gap-3\">\n <div\n className={cn(\n 'flex h-9 w-9 shrink-0 items-center justify-center rounded-full',\n isPast\n ? 'bg-status-error-bg-subtle'\n : isUrgent\n ? 'bg-status-warning-bg-subtle'\n : 'bg-status-info-bg-subtle'\n )}\n >\n {isPast ? (\n <AlertTriangle className=\"h-4 w-4 text-status-error-text\" />\n ) : isUrgent ? (\n <Clock className=\"h-4 w-4 text-status-warning-text\" />\n ) : (\n <Wrench className=\"h-4 w-4 text-status-info-text\" />\n )}\n </div>\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">\n {formatCalendarDate(contract.nextServiceDate)}\n </p>\n <p className=\"truncate text-sm text-text-primary\">\n {contract.packageName} — {contract.propertyTitle}\n </p>\n <p className=\"truncate text-xs text-text-secondary\">{contract.providerName}</p>\n <p\n className={cn(\n 'text-xs font-medium',\n isPast\n ? 'text-status-error-text'\n : isUrgent\n ? 'text-status-warning-text'\n : 'text-text-secondary'\n )}\n >\n {isPast\n ? `${Math.abs(daysUntil)} days overdue`\n : daysUntil === 0\n ? 'Today'\n : `In ${daysUntil} days`}\n </p>\n </div>\n </li>\n );\n })}\n </ol>\n )}\n </div>\n\n <button\n type=\"button\"\n onClick={() => navigate('../rental')}\n className=\"flex w-full items-center gap-3 rounded-lg border border-border-subtle bg-bg-surface p-4 text-left shadow-sm transition-colors hover:bg-bg-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n <div className=\"rounded-lg bg-status-info-bg-subtle p-2.5\">\n <Wrench className=\"h-5 w-5 text-status-info-text\" />\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Open maintenance requests</p>\n <p className=\"text-xl font-bold text-text-primary\">{openMaintenanceCount}</p>\n </div>\n </button>\n </aside>\n </div>\n\n <AmcContractFormDialog\n open={createOpen || manage.editTarget !== null}\n onOpenChange={(open) => {\n if (!open) {\n setCreateOpen(false);\n manage.setEditTarget(null);\n }\n }}\n contract={manage.editTarget}\n saving={creating || manage.updating}\n onSubmit={manage.editTarget ? handleEdit : handleCreate}\n />\n <AmcRenewDialog\n contract={manage.renewTarget}\n endDate={manage.renewEnd}\n onEndDateChange={manage.setRenewEnd}\n onClose={() => manage.setRenewTarget(null)}\n onSubmit={manage.handleRenew}\n busy={manage.renewing}\n />\n <AmcCancelDialog\n contract={manage.cancelTarget}\n onClose={() => manage.setCancelTarget(null)}\n onConfirm={manage.confirmCancel}\n busy={manage.updating}\n />\n <AmcDeleteDialog\n contract={manage.deleteTarget}\n onClose={() => manage.setDeleteTarget(null)}\n onConfirm={manage.confirmDelete}\n busy={manage.deleting}\n />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,SAAS,EAAiB,GAA0E;AAClG,SAAQ,GAAR;EACE,KAAK,SACH,QAAO;EACT,KAAK,gBACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,KAAK,YACH,QAAO;EACT,QACE,QAAO;;;AAIb,SAAgB,IAAoB;AAClC,GAAiB,0BAA0B;CAC3C,IAAM,IAAW,GAAa,EACxB,IAAa,EAAoB,GAAG,EACpC,CAAC,GAAQ,KAAa,EAAS,GAAG,EAClC,CAAC,GAAiB,KAAsB,EAAS,GAAG;AAG1D,SAAgB;EACd,IAAM,IAAQ,iBAAiB,EAAmB,EAAO,EAAE,IAAI;AAC/D,eAAa,aAAa,EAAM;IAC/B,CAAC,EAAO,CAAC;CAEZ,IAAM,EAAE,MAAM,GAAc,SAAS,MAAqB,EAAgB;EACxE,QAAQ,EAAE,QAAQ,EAAgB,MAAM,IAAI,KAAA,GAAW;EACvD,YAAY,EAAW;EACxB,CAAC,EAII,EAAE,MAAM,GAAa,SAAS,MAAmB;AACvD,SAAgB;AACd,EAAI,CAAC,KAAoB,EAAa,WAAW,KAAK,IAAc,KAClE,EAAe,IAAc,EAAE;IAEhC;EAAC;EAAkB,EAAa;EAAQ;EAAa;EAAe,CAAC;CAExE,IAAM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GAAD,EAAQ,WAAU,iCAAkC,CAAA;OAChD,CAAA,EACN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,KAAD;OAAG,WAAU;iBAA8B;OAA6B,CAAA,EACxE,kBAAC,KAAD;OAAG,WAAU;iBAAuC;OAAyB,CAAA,CACzE,EAAA,CAAA,CACC;QACH;OACJ;;GAEN,kBAAC,GAAD;IACE,MAAM,MAAc,EAAO,eAAe;IAC1C,eAAe,MAAS;AACtB,KAAK,MACH,EAAc,GAAM,EACpB,EAAO,cAAc,KAAK;;IAG9B,UAAU,EAAO;IACjB,QAAQ,MAAY,EAAO;IAC3B,UAAU,EAAO,aAAa,KAAa;IAC3C,CAAA;GACF,kBAAC,GAAD;IACE,UAAU,EAAO;IACjB,SAAS,EAAO;IAChB,iBAAiB,EAAO;IACxB,eAAe,EAAO,eAAe,KAAK;IAC1C,UAAU,EAAO;IACjB,MAAM,EAAO;IACb,CAAA;GACF,kBAAC,GAAD;IACE,UAAU,EAAO;IACjB,eAAe,EAAO,gBAAgB,KAAK;IAC3C,WAAW,EAAO;IAClB,MAAM,EAAO;IACb,CAAA;GACF,kBAAC,GAAD;IACE,UAAU,EAAO;IACjB,eAAe,EAAO,gBAAgB,KAAK;IAC3C,WAAW,EAAO;IAClB,MAAM,EAAO;IACb,CAAA;GACS"}
1
+ {"version":3,"file":"AMCManagementPage.js","names":[],"sources":["../../../../src/housingvista/pages/amc/AMCManagementPage.tsx"],"sourcesContent":["import { useState, useMemo, useEffect } from 'react';\nimport { useNavigate } from 'react-router';\nimport {\n Shield,\n IndianRupee,\n Calendar,\n Plus,\n Download,\n Clock,\n AlertTriangle,\n Wrench,\n RotateCcw,\n MapPin,\n Pencil,\n Ban,\n Trash2,\n} from 'lucide-react';\nimport { Button, EmphasisPanel, NextSteps, Pagination } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components';\nimport { StatCard } from '../../components';\nimport { StatusBadge } from '../../components';\nimport { FilterBar } from '../../components';\nimport { EmptyState, LoadingSkeleton } from '../../components';\nimport { useAllAmcContracts, useAMCContracts, useCreateAmcContract, useMaintenanceRequests } from '../../hooks';\nimport { useServerPagination } from '../../hooks/useServerPagination';\nimport { cn, formatCurrency } from '../../utils/helpers';\nimport { notify } from '../../lib/toast';\nimport type { AMCContract } from '../../types';\nimport { useTrackPageView } from '../../hooks/useHousingVistaAnalytics';\nimport { AmcContractFormDialog, type AmcContractFormValues } from './AmcContractFormDialog';\nimport { AmcCancelDialog, AmcDeleteDialog, AmcRenewDialog } from './AmcContractActionDialogs';\nimport { useAmcManagement } from './useAmcManagement';\nimport { calendarDaysUntil, formatCalendarDate } from './amcDates';\nimport { computeAmcStats, listScheduledServices } from './amcStats';\n\nfunction getStatusVariant(status: AMCContract['status']): 'success' | 'warning' | 'error' | 'muted' {\n switch (status) {\n case 'active':\n return 'success';\n case 'expiring_soon':\n return 'warning';\n case 'expired':\n return 'error';\n case 'cancelled':\n return 'muted';\n default:\n return 'muted';\n }\n}\n\n/** Shown in place of the portfolio-wide figures when reading every contract failed (BOFF-9605). */\nfunction PortfolioLoadError({ onRetry }: { onRetry: () => void }) {\n return (\n <div role=\"alert\" className=\"flex flex-wrap items-center gap-3 text-sm text-status-error-text\">\n <span>Couldn&apos;t load every contract, so totals and the schedule are hidden.</span>\n <button\n type=\"button\"\n onClick={onRetry}\n className=\"rounded-md border border-border-subtle px-3 py-1 text-xs font-medium text-text-primary transition-colors hover:bg-bg-sunken\"\n >\n Retry\n </button>\n </div>\n );\n}\n\nexport function AMCManagementPage() {\n useTrackPageView('housingvista.amc.viewed');\n const navigate = useNavigate();\n const pagination = useServerPagination(10);\n const [search, setSearch] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n\n // Debounce the raw search input into the value that feeds the server filter.\n useEffect(() => {\n const timer = setTimeout(() => setDebouncedSearch(search), 300);\n return () => clearTimeout(timer);\n }, [search]);\n\n const { data: amcContracts, loading: contractsLoading } = useAMCContracts({\n filter: { search: debouncedSearch.trim() || undefined },\n pagination: pagination.pagination,\n });\n\n // Deleting the last row on page 2+ leaves an empty page (the Pagination control is hidden when the list is\n // empty) — step back to the previous page instead of stranding the user (Codex P2 on mfe#22).\n const { page: currentPage, setPage: setCurrentPage } = pagination;\n useEffect(() => {\n if (!contractsLoading && amcContracts.length === 0 && currentPage > 1) {\n setCurrentPage(currentPage - 1);\n }\n }, [contractsLoading, amcContracts.length, currentPage, setCurrentPage]);\n\n // Stat cards and the service schedule describe the whole portfolio, not the visible page or the active search\n // (BOFF-9605), so they read every contract; mutations refresh it explicitly.\n const {\n data: allContracts,\n loading: allContractsLoading,\n error: allContractsError,\n refetch: refetchAllContracts,\n } = useAllAmcContracts();\n\n const { createAmcContract, loading: creating } = useCreateAmcContract();\n\n // Open maintenance requests across the portfolio — real count for the sidebar stat.\n const { data: maintenanceRequests } = useMaintenanceRequests({\n filter: { status: 'open' },\n pagination: { limit: 100, offset: 0 },\n });\n const openMaintenanceCount = maintenanceRequests.length;\n\n const handleSearchChange = (value: string) => {\n setSearch(value);\n pagination.setPage(1);\n };\n\n const handleExport = () => {\n if (amcContracts.length === 0) {\n notify.warning('Nothing to export', 'There are no contracts to export yet.');\n return;\n }\n const escape = (value: string) => `\"${value.replace(/\"/g, '\"\"')}\"`;\n const headers = ['Package', 'Property', 'Provider', 'Monthly Cost', 'Start', 'End', 'Status', 'Services'];\n const rows = amcContracts.map((c) =>\n [\n c.packageName,\n c.propertyTitle,\n c.providerName,\n String(c.monthlyCost),\n c.startDate,\n c.endDate,\n c.status,\n c.servicesIncluded.join('; '),\n ]\n .map((cell) => escape(String(cell)))\n .join(',')\n );\n const csv = [headers.map(escape).join(','), ...rows].join('\\n');\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = `housingvista-amc-contracts-${new Date().toISOString().slice(0, 10)}.csv`;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(url);\n notify.success('Export ready', `${amcContracts.length} contracts exported to CSV.`);\n };\n\n const [createOpen, setCreateOpen] = useState(false);\n const manage = useAmcManagement({ onChanged: () => void refetchAllContracts() });\n\n const handleCreate = async (values: AmcContractFormValues) => {\n try {\n await createAmcContract({\n propertyId: values.propertyId || undefined,\n marketplaceServiceId: values.marketplaceServiceId || undefined,\n propertyTitle: values.propertyTitle,\n packageName: values.packageName,\n providerName: values.providerName,\n monthlyCost: values.monthlyCost,\n startDate: values.startDate,\n endDate: values.endDate,\n status: 'active',\n nextServiceDate: values.nextServiceDate || undefined,\n servicesIncluded: values.servicesIncluded.length > 0 ? values.servicesIncluded : undefined,\n });\n notify.success('Contract created', `${values.packageName} added for ${values.propertyTitle}.`);\n setCreateOpen(false);\n void refetchAllContracts();\n } catch (err) {\n notify.error('Could not create contract', (err as Error).message);\n }\n };\n\n const handleEdit = async (values: AmcContractFormValues) => {\n const target = manage.editTarget;\n if (!target) return;\n try {\n await manage.updateAmcContract(target.id, {\n // null unlinks: picking \"Other\" turns the property / provider back into free text.\n propertyId: values.propertyId || null,\n marketplaceServiceId: values.marketplaceServiceId || null,\n propertyTitle: values.propertyTitle,\n packageName: values.packageName,\n providerName: values.providerName,\n monthlyCost: values.monthlyCost,\n startDate: values.startDate,\n endDate: values.endDate,\n // null clears a previously scheduled service.\n nextServiceDate: values.nextServiceDate || null,\n servicesIncluded: values.servicesIncluded,\n });\n notify.success('Contract updated', `${values.packageName} saved.`);\n manage.setEditTarget(null);\n } catch (err) {\n notify.error('Could not update contract', (err as Error).message);\n }\n };\n\n const openCreate = () => setCreateOpen(true);\n\n // Only live contracts feed the schedule AND the \"Upcoming Services\" stat, so the two always agree.\n const scheduledServices = useMemo(() => listScheduledServices(allContracts), [allContracts]);\n const stats = useMemo(\n () => computeAmcStats(allContracts, new Date(), scheduledServices),\n [allContracts, scheduledServices]\n );\n // Until the first full read lands — or if a read fails — the totals are unknown, not zero: a failed page of the\n // portfolio crawl must never read as an empty portfolio.\n const portfolioUnknown = Boolean(allContractsError) || (allContractsLoading && allContracts.length === 0);\n const statValue = (value: number): number | string => (portfolioUnknown ? '—' : value);\n const portfolioRetry = allContractsError ? <PortfolioLoadError onRetry={() => void refetchAllContracts()} /> : null;\n\n // Accent styling per contract status for the card treatment.\n const statusAccent: Record<AMCContract['status'], string> = {\n active: 'border-l-4 border-l-status-success-border',\n expiring_soon: 'border-l-4 border-l-status-warning-border bg-status-warning-bg-subtle/30',\n expired: 'border-l-4 border-l-status-error-border',\n cancelled: 'border-l-4 border-l-border-strong',\n };\n\n return (\n <PageLayout\n title=\"AMC Management\"\n description=\"Manage Annual Maintenance Contracts and service packages\"\n purpose=\"Keep your properties maintained without surprises. Track every Annual Maintenance Contract, see what each covers and costs, get ahead of renewals, and know which services are due in the next 30 days so nothing slips.\"\n actions={\n <div className=\"flex items-center gap-2\">\n <button\n onClick={handleExport}\n className=\"inline-flex items-center gap-2 rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken\"\n >\n <Download className=\"h-4 w-4\" />\n Export\n </button>\n <Button type=\"button\" onClick={openCreate} className=\"gap-2\">\n <Plus className=\"h-4 w-4\" />\n New Contract\n </Button>\n </div>\n }\n >\n {/* Stats — primary insight zone (one EmphasisPanel per page) */}\n <EmphasisPanel className=\"p-4\">\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n label=\"Active Contracts\"\n value={statValue(stats.activeContracts)}\n icon={<Shield className=\"h-4 w-4\" />}\n />\n <StatCard\n label=\"Pending Renewals\"\n value={statValue(stats.pendingRenewals)}\n icon={<RotateCcw className=\"h-4 w-4\" />}\n />\n <StatCard\n label=\"Total Monthly Spent\"\n value={portfolioUnknown ? '—' : formatCurrency(stats.totalMonthlySpent)}\n icon={<IndianRupee className=\"h-4 w-4\" />}\n />\n <StatCard\n label=\"Upcoming Services\"\n value={statValue(stats.upcomingServices)}\n icon={<Calendar className=\"h-4 w-4\" />}\n />\n </div>\n {portfolioRetry && <div className=\"mt-3\">{portfolioRetry}</div>}\n </EmphasisPanel>\n\n <NextSteps\n storageKey=\"housingvista-amc\"\n steps={[\n {\n id: 'pick-property',\n label: 'Add coverage for a property',\n description: 'Choose a property to set up a new maintenance contract.',\n onClick: openCreate,\n },\n {\n id: 'compare-providers',\n label: 'Compare your providers',\n description: 'Search by provider name to weigh coverage and monthly cost.',\n onClick: () => {\n const firstProvider = amcContracts[0]?.providerName;\n if (firstProvider) {\n setSearch(firstProvider);\n pagination.setPage(1);\n }\n },\n },\n {\n id: 'check-legal',\n label: 'Review contract paperwork',\n description: 'Open the legal hub to manage the underlying documents.',\n onClick: () => navigate('../legal'),\n },\n ]}\n />\n\n {/* Contract cards (left) + service schedule & open-maintenance sidebar (right) */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-3\">\n <div className=\"space-y-4 lg:col-span-2\">\n <div className=\"flex flex-col gap-3\">\n <h2 className=\"text-lg font-semibold text-text-primary\">All Contracts</h2>\n <FilterBar\n searchValue={search}\n onSearchChange={handleSearchChange}\n searchPlaceholder=\"Search contracts, providers, properties...\"\n />\n </div>\n {amcContracts.length > 0 ? (\n <>\n <div className=\"space-y-3\">\n {amcContracts.map((contract) => (\n <div\n key={contract.id}\n className={cn(\n 'rounded-lg border border-border-subtle bg-bg-surface p-5 shadow-sm',\n statusAccent[contract.status]\n )}\n >\n <div className=\"flex flex-wrap items-start justify-between gap-2\">\n <div className=\"min-w-0\">\n <p className=\"flex items-center gap-1 text-xs text-text-secondary\">\n <MapPin className=\"h-3 w-3\" />\n Property\n </p>\n {contract.propertyId ? (\n <button\n type=\"button\"\n onClick={() => navigate(`../properties/${contract.propertyId}`)}\n className=\"block max-w-full truncate text-left text-base font-semibold text-text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n {contract.propertyTitle}\n </button>\n ) : (\n <h3 className=\"truncate text-base font-semibold text-text-primary\">\n {contract.propertyTitle}\n </h3>\n )}\n <p className=\"text-xs text-text-secondary\">{contract.packageName}</p>\n </div>\n <StatusBadge\n label={contract.status.replace('_', ' ')}\n variant={getStatusVariant(contract.status)}\n dot\n />\n </div>\n <div className=\"mt-4 grid grid-cols-2 gap-4 border-t border-border-subtle pt-4 sm:grid-cols-4\">\n <div>\n <p className=\"text-xs text-text-secondary\">Provider</p>\n {contract.marketplaceServiceId ? (\n <button\n type=\"button\"\n onClick={() => navigate(`../marketplace/${contract.marketplaceServiceId}`)}\n className=\"mt-0.5 block max-w-full truncate text-left text-sm font-medium text-text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n {contract.providerName}\n </button>\n ) : (\n <p className=\"mt-0.5 text-sm font-medium text-text-primary\">{contract.providerName}</p>\n )}\n </div>\n <div>\n <p className=\"text-xs text-text-secondary\">Coverage</p>\n <p className=\"mt-0.5 truncate text-sm font-medium text-text-primary\">\n {contract.servicesIncluded.length > 0\n ? contract.servicesIncluded.slice(0, 2).join(', ')\n : '—'}\n {contract.servicesIncluded.length > 2 ? ` +${contract.servicesIncluded.length - 2}` : ''}\n </p>\n </div>\n <div>\n <p className=\"text-xs text-text-secondary\">Monthly Cost</p>\n <p className=\"mt-0.5 text-sm font-semibold text-text-primary\">\n {formatCurrency(contract.monthlyCost)}\n <span className=\"text-xs font-normal text-text-secondary\">/mo</span>\n </p>\n </div>\n <div>\n <p className=\"text-xs text-text-secondary\">Renewal Date</p>\n <p className=\"mt-0.5 text-sm font-medium text-text-primary\">\n {formatCalendarDate(contract.endDate)}\n </p>\n </div>\n </div>\n {contract.nextServiceDate && (\n <p className=\"mt-3 flex items-center gap-1.5 text-xs text-text-secondary\">\n <Calendar className=\"h-3.5 w-3.5\" />\n Next service {formatCalendarDate(contract.nextServiceDate)}\n </p>\n )}\n <div className=\"mt-3 flex flex-wrap items-center gap-2 border-t border-border-subtle pt-3\">\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => manage.setEditTarget(contract)}>\n <Pencil className=\"mr-1.5 h-3.5 w-3.5\" />\n Edit\n </Button>\n {contract.status !== 'cancelled' && (\n <>\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => manage.openRenew(contract)}>\n <RotateCcw className=\"mr-1.5 h-3.5 w-3.5\" />\n Renew\n </Button>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => manage.setCancelTarget(contract)}\n >\n <Ban className=\"mr-1.5 h-3.5 w-3.5\" />\n Cancel\n </Button>\n </>\n )}\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"ml-auto text-status-error-text\"\n onClick={() => manage.setDeleteTarget(contract)}\n >\n <Trash2 className=\"mr-1.5 h-3.5 w-3.5\" />\n Delete\n </Button>\n </div>\n </div>\n ))}\n </div>\n <Pagination\n page={pagination.page}\n pageSize={pagination.pageSize}\n hasNextPage={amcContracts.length >= pagination.pageSize}\n hasPreviousPage={pagination.page > 1}\n onPageChange={pagination.setPage}\n onPageSizeChange={pagination.setPageSize}\n />\n </>\n ) : (\n <EmptyState\n illustration=\"empty-search\"\n icon={<Shield className=\"h-12 w-12\" />}\n title=\"No contracts found\"\n description=\"Try adjusting your search criteria or create a new contract.\"\n action={\n <Button type=\"button\" onClick={openCreate} className=\"gap-2\">\n <Plus className=\"h-4 w-4\" />\n New Contract\n </Button>\n }\n />\n )}\n </div>\n\n {/* Sidebar */}\n <aside className=\"space-y-6 lg:col-span-1\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-5 shadow-sm\">\n <h3 className=\"mb-4 text-base font-semibold text-text-primary\">Upcoming Service Schedule</h3>\n {portfolioRetry ? (\n portfolioRetry\n ) : portfolioUnknown ? (\n <LoadingSkeleton variant=\"card\" count={2} />\n ) : scheduledServices.length === 0 ? (\n <EmptyState\n illustration=\"empty-generic\"\n title=\"No services scheduled\"\n description=\"Upcoming service dates from your active contracts will appear here.\"\n className=\"border-0 bg-transparent p-4\"\n />\n ) : (\n <ol className=\"space-y-4\">\n {scheduledServices.map((contract) => {\n const daysUntil = calendarDaysUntil(contract.nextServiceDate);\n const isUrgent = daysUntil <= 7;\n const isPast = daysUntil < 0;\n return (\n <li key={contract.id} className=\"flex gap-3\">\n <div\n className={cn(\n 'flex h-9 w-9 shrink-0 items-center justify-center rounded-full',\n isPast\n ? 'bg-status-error-bg-subtle'\n : isUrgent\n ? 'bg-status-warning-bg-subtle'\n : 'bg-status-info-bg-subtle'\n )}\n >\n {isPast ? (\n <AlertTriangle className=\"h-4 w-4 text-status-error-text\" />\n ) : isUrgent ? (\n <Clock className=\"h-4 w-4 text-status-warning-text\" />\n ) : (\n <Wrench className=\"h-4 w-4 text-status-info-text\" />\n )}\n </div>\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">\n {formatCalendarDate(contract.nextServiceDate)}\n </p>\n <p className=\"truncate text-sm text-text-primary\">\n {contract.packageName} — {contract.propertyTitle}\n </p>\n <p className=\"truncate text-xs text-text-secondary\">{contract.providerName}</p>\n <p\n className={cn(\n 'text-xs font-medium',\n isPast\n ? 'text-status-error-text'\n : isUrgent\n ? 'text-status-warning-text'\n : 'text-text-secondary'\n )}\n >\n {isPast\n ? `${Math.abs(daysUntil)} days overdue`\n : daysUntil === 0\n ? 'Today'\n : `In ${daysUntil} days`}\n </p>\n </div>\n </li>\n );\n })}\n </ol>\n )}\n </div>\n\n <button\n type=\"button\"\n onClick={() => navigate('../rental')}\n className=\"flex w-full items-center gap-3 rounded-lg border border-border-subtle bg-bg-surface p-4 text-left shadow-sm transition-colors hover:bg-bg-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n <div className=\"rounded-lg bg-status-info-bg-subtle p-2.5\">\n <Wrench className=\"h-5 w-5 text-status-info-text\" />\n </div>\n <div>\n <p className=\"text-sm text-text-secondary\">Open maintenance requests</p>\n <p className=\"text-xl font-bold text-text-primary\">{openMaintenanceCount}</p>\n </div>\n </button>\n </aside>\n </div>\n\n <AmcContractFormDialog\n open={createOpen || manage.editTarget !== null}\n onOpenChange={(open) => {\n if (!open) {\n setCreateOpen(false);\n manage.setEditTarget(null);\n }\n }}\n contract={manage.editTarget}\n saving={creating || manage.updating}\n onSubmit={manage.editTarget ? handleEdit : handleCreate}\n />\n <AmcRenewDialog\n contract={manage.renewTarget}\n endDate={manage.renewEnd}\n onEndDateChange={manage.setRenewEnd}\n onClose={() => manage.setRenewTarget(null)}\n onSubmit={manage.handleRenew}\n busy={manage.renewing}\n />\n <AmcCancelDialog\n contract={manage.cancelTarget}\n onClose={() => manage.setCancelTarget(null)}\n onConfirm={manage.confirmCancel}\n busy={manage.updating}\n />\n <AmcDeleteDialog\n contract={manage.deleteTarget}\n onClose={() => manage.setDeleteTarget(null)}\n onConfirm={manage.confirmDelete}\n busy={manage.deleting}\n />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAS,EAAiB,GAA0E;AAClG,SAAQ,GAAR;EACE,KAAK,SACH,QAAO;EACT,KAAK,gBACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,KAAK,YACH,QAAO;EACT,QACE,QAAO;;;AAKb,SAAS,EAAmB,EAAE,cAAoC;AAChE,QACE,kBAAC,OAAD;EAAK,MAAK;EAAQ,WAAU;YAA5B,CACE,kBAAC,QAAD,EAAA,UAAM,wEAAgF,CAAA,EACtF,kBAAC,UAAD;GACE,MAAK;GACL,SAAS;GACT,WAAU;aACX;GAEQ,CAAA,CACL;;;AAIV,SAAgB,IAAoB;AAClC,IAAiB,0BAA0B;CAC3C,IAAM,IAAW,IAAa,EACxB,IAAa,GAAoB,GAAG,EACpC,CAAC,GAAQ,KAAa,EAAS,GAAG,EAClC,CAAC,GAAiB,MAAsB,EAAS,GAAG;AAG1D,SAAgB;EACd,IAAM,IAAQ,iBAAiB,GAAmB,EAAO,EAAE,IAAI;AAC/D,eAAa,aAAa,EAAM;IA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E,6BACA,sBACP;sBAEA,IACG,GAAG,KAAK,IAAI,EAAU,CAAC,iBACvB,MAAc,IACZ,UACA,MAAM,EAAU;YACpB,CAAA;WACA;YACH;WA5CI,EAAS,GA4Cb;SAEP;OACC,CAAA,EAEH;SAEN,kBAAC,UAAD;MACE,MAAK;MACL,eAAe,EAAS,YAAY;MACpC,WAAU;gBAHZ,CAKE,kBAAC,OAAD;OAAK,WAAU;iBACb,kBAAC,GAAD,EAAQ,WAAU,iCAAkC,CAAA;OAChD,CAAA,EACN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,KAAD;OAAG,WAAU;iBAA8B;OAA6B,CAAA,EACxE,kBAAC,KAAD;OAAG,WAAU;iBAAuC;OAAyB,CAAA,CACzE,EAAA,CAAA,CACC;QACH;OACJ;;GAEN,kBAAC,IAAD;IACE,MAAM,MAAc,EAAO,eAAe;IAC1C,eAAe,MAAS;AACtB,KAAK,MACH,EAAc,GAAM,EACpB,EAAO,cAAc,KAAK;;IAG9B,UAAU,EAAO;IACjB,QAAQ,MAAY,EAAO;IAC3B,UAAU,EAAO,aAAa,IAAa;IAC3C,CAAA;GACF,kBAAC,GAAD;IACE,UAAU,EAAO;IACjB,SAAS,EAAO;IAChB,iBAAiB,EAAO;IACxB,eAAe,EAAO,eAAe,KAAK;IAC1C,UAAU,EAAO;IACjB,MAAM,EAAO;IACb,CAAA;GACF,kBAAC,GAAD;IACE,UAAU,EAAO;IACjB,eAAe,EAAO,gBAAgB,KAAK;IAC3C,WAAW,EAAO;IAClB,MAAM,EAAO;IACb,CAAA;GACF,kBAAC,GAAD;IACE,UAAU,EAAO;IACjB,eAAe,EAAO,gBAAgB,KAAK;IAC3C,WAAW,EAAO;IAClB,MAAM,EAAO;IACb,CAAA;GACS"}
@@ -1 +1 @@
1
- {"version":3,"file":"AmcContractFormDialog.d.ts","sourceRoot":"","sources":["../../../../src/housingvista/pages/amc/AmcContractFormDialog.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EA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AM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,UAAU,0BAA0B;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,6DAA6D;IAC7D,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D;AAED,wBAAgB,qBAAqB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,0BAA0B,+BA2LnH"}
@@ -1,160 +1,165 @@
1
1
  import { notify as e } from "../../lib/toast.js";
2
- import { dateInputToIso as t, toDateInput as n, withinContractWindow as r } from "./amcDates.js";
3
- import { inputClass as i } from "./amcStyles.js";
4
- import { AmcLinkFields as a } from "./AmcLinkFields.js";
5
- import { useEffect as o, useState as s } from "react";
6
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
7
- import { Button as u, ResponsiveDialog as d, ResponsiveDialogContent as f, ResponsiveDialogDescription as p, ResponsiveDialogFooter as m, ResponsiveDialogHeader as h, ResponsiveDialogTitle as g } from "@burdenoff/fe-libs/ui";
2
+ import { dateInputToIso as t, isEndBeforeStart as n, toDateInput as r, withinContractWindow as i } from "./amcDates.js";
3
+ import { inputClass as a } from "./amcStyles.js";
4
+ import { AmcLinkFields as o } from "./AmcLinkFields.js";
5
+ import { useEffect as s, useState as c } from "react";
6
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
+ import { Button as d, ResponsiveDialog as f, ResponsiveDialogContent as p, ResponsiveDialogDescription as m, ResponsiveDialogFooter as h, ResponsiveDialogHeader as g, ResponsiveDialogTitle as _ } from "@burdenoff/fe-libs/ui";
8
8
  //#region src/housingvista/pages/amc/AmcContractFormDialog.tsx
9
- function _({ open: _, onOpenChange: v, contract: y, saving: b, onSubmit: x }) {
10
- let S = y !== null, [C, w] = s(""), [T, E] = s(""), [D, O] = s(""), [k, A] = s(""), [j, M] = s(""), [N, P] = s(""), [F, I] = s(""), [L, R] = s(""), [z, B] = s(""), [V, H] = s("");
11
- return o(() => {
12
- _ && (w(y?.propertyId ?? ""), E(y?.propertyTitle ?? ""), O(y?.marketplaceServiceId ?? ""), A(y?.packageName ?? ""), M(y?.providerName ?? ""), P(y ? String(y.monthlyCost) : ""), I(y ? n(y.startDate) : ""), R(y ? n(y.endDate) : ""), B(y ? n(y.nextServiceDate ?? "") : ""), H(y ? y.servicesIncluded.join(", ") : ""));
13
- }, [_, y]), /* @__PURE__ */ c(d, {
14
- open: _,
15
- onOpenChange: v,
16
- children: /* @__PURE__ */ c(f, {
9
+ function v({ open: v, onOpenChange: y, contract: b, saving: x, onSubmit: S }) {
10
+ let C = b !== null, [w, T] = c(""), [E, D] = c(""), [O, k] = c(""), [A, j] = c(""), [M, N] = c(""), [P, F] = c(""), [I, L] = c(""), [R, z] = c(""), [B, V] = c(""), [H, U] = c("");
11
+ return s(() => {
12
+ v && (T(b?.propertyId ?? ""), D(b?.propertyTitle ?? ""), k(b?.marketplaceServiceId ?? ""), j(b?.packageName ?? ""), N(b?.providerName ?? ""), F(b ? String(b.monthlyCost) : ""), L(b ? r(b.startDate) : ""), z(b ? r(b.endDate) : ""), V(b ? r(b.nextServiceDate ?? "") : ""), U(b ? b.servicesIncluded.join(", ") : ""));
13
+ }, [v, b]), /* @__PURE__ */ l(f, {
14
+ open: v,
15
+ onOpenChange: y,
16
+ children: /* @__PURE__ */ l(p, {
17
17
  className: "sm:max-w-lg",
18
- children: /* @__PURE__ */ l("form", {
19
- onSubmit: async (n) => {
20
- n.preventDefault();
21
- let i = Number(N);
22
- if (!T.trim() || !k.trim() || !j.trim()) {
18
+ children: /* @__PURE__ */ u("form", {
19
+ onSubmit: async (r) => {
20
+ r.preventDefault();
21
+ let a = Number(P);
22
+ if (!E.trim() || !A.trim() || !M.trim()) {
23
23
  e.warning("Missing details", "Property, package and provider are required.");
24
24
  return;
25
25
  }
26
- if (!Number.isFinite(i) || i <= 0) {
26
+ if (!Number.isFinite(a) || a <= 0) {
27
27
  e.warning("Enter a valid monthly cost");
28
28
  return;
29
29
  }
30
- if (S && (!F || !L)) {
31
- e.warning("Dates are required", "Start and end dates cannot be cleared on an existing contract.");
30
+ if (!I || !R) {
31
+ e.warning("Dates are required", "Choose both a start date and an end date.");
32
32
  return;
33
33
  }
34
- if (z && !r(t(F), t(L), t(z))) {
34
+ if (n(t(I), t(R))) {
35
+ e.warning("End date is before the start date", "The contract must end on or after the day it starts.");
36
+ return;
37
+ }
38
+ if (B && !i(t(I), t(R), t(B))) {
35
39
  e.warning("Next service date out of range", "It must fall between the contract start and end dates.");
36
40
  return;
37
41
  }
38
- await x({
39
- propertyId: C,
40
- marketplaceServiceId: D,
41
- propertyTitle: T.trim(),
42
- packageName: k.trim(),
43
- providerName: j.trim(),
44
- monthlyCost: i,
45
- startDate: t(F),
46
- endDate: t(L),
47
- nextServiceDate: t(z),
48
- servicesIncluded: V.split(",").map((e) => e.trim()).filter((e) => e.length > 0)
42
+ await S({
43
+ propertyId: w,
44
+ marketplaceServiceId: O,
45
+ propertyTitle: E.trim(),
46
+ packageName: A.trim(),
47
+ providerName: M.trim(),
48
+ monthlyCost: a,
49
+ startDate: t(I),
50
+ endDate: t(R),
51
+ nextServiceDate: t(B),
52
+ servicesIncluded: H.split(",").map((e) => e.trim()).filter((e) => e.length > 0)
49
53
  });
50
54
  },
51
55
  children: [
52
- /* @__PURE__ */ l(h, { children: [/* @__PURE__ */ c(g, { children: S ? "Edit maintenance contract" : "New maintenance contract" }), /* @__PURE__ */ c(p, { children: S ? "Update the coverage, cost or dates of this Annual Maintenance Contract." : "Set up an Annual Maintenance Contract to track coverage, cost and renewal dates." })] }),
53
- /* @__PURE__ */ l("div", {
56
+ /* @__PURE__ */ u(g, { children: [/* @__PURE__ */ l(_, { children: C ? "Edit maintenance contract" : "New maintenance contract" }), /* @__PURE__ */ l(m, { children: C ? "Update the coverage, cost or dates of this Annual Maintenance Contract." : "Set up an Annual Maintenance Contract to track coverage, cost and renewal dates." })] }),
57
+ /* @__PURE__ */ u("div", {
54
58
  className: "space-y-3 py-2",
55
59
  children: [
56
- /* @__PURE__ */ c(a, {
57
- propertyId: C,
58
- propertyTitle: T,
60
+ /* @__PURE__ */ l(o, {
61
+ propertyId: w,
62
+ propertyTitle: E,
59
63
  onProperty: (e, t) => {
60
- w(e), E(t);
64
+ T(e), D(t);
61
65
  },
62
- marketplaceServiceId: D,
63
- providerName: j,
66
+ marketplaceServiceId: O,
67
+ providerName: M,
64
68
  onProvider: (e, t) => {
65
- O(e), M(t);
69
+ k(e), N(t);
66
70
  }
67
71
  }),
68
- /* @__PURE__ */ l("div", {
72
+ /* @__PURE__ */ u("div", {
69
73
  className: "grid grid-cols-1 gap-3 sm:grid-cols-2",
70
- children: [/* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
74
+ children: [/* @__PURE__ */ u("div", { children: [/* @__PURE__ */ l("label", {
71
75
  className: "mb-1.5 block text-sm font-medium text-text-primary",
72
76
  children: "Package *"
73
- }), /* @__PURE__ */ c("input", {
77
+ }), /* @__PURE__ */ l("input", {
74
78
  type: "text",
75
79
  required: !0,
76
80
  placeholder: "e.g. Premium Care",
77
- value: k,
78
- onChange: (e) => A(e.target.value),
79
- className: i
80
- })] }), /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
81
+ value: A,
82
+ onChange: (e) => j(e.target.value),
83
+ className: a
84
+ })] }), /* @__PURE__ */ u("div", { children: [/* @__PURE__ */ l("label", {
81
85
  className: "mb-1.5 block text-sm font-medium text-text-primary",
82
86
  children: "Monthly cost *"
83
- }), /* @__PURE__ */ c("input", {
87
+ }), /* @__PURE__ */ l("input", {
84
88
  type: "number",
85
89
  required: !0,
86
90
  min: 0,
87
91
  step: "0.01",
88
92
  placeholder: "0.00",
89
- value: N,
90
- onChange: (e) => P(e.target.value),
91
- className: i
93
+ value: P,
94
+ onChange: (e) => F(e.target.value),
95
+ className: a
92
96
  })] })]
93
97
  }),
94
- /* @__PURE__ */ l("div", {
98
+ /* @__PURE__ */ u("div", {
95
99
  className: "grid grid-cols-1 gap-3 sm:grid-cols-2",
96
- children: [/* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
100
+ children: [/* @__PURE__ */ u("div", { children: [/* @__PURE__ */ l("label", {
97
101
  className: "mb-1.5 block text-sm font-medium text-text-primary",
98
- children: "Start date"
99
- }), /* @__PURE__ */ c("input", {
102
+ children: "Start date *"
103
+ }), /* @__PURE__ */ l("input", {
100
104
  type: "date",
101
- required: S,
102
- value: F,
103
- onChange: (e) => I(e.target.value),
104
- className: i
105
- })] }), /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
105
+ required: !0,
106
+ value: I,
107
+ onChange: (e) => L(e.target.value),
108
+ className: a
109
+ })] }), /* @__PURE__ */ u("div", { children: [/* @__PURE__ */ l("label", {
106
110
  className: "mb-1.5 block text-sm font-medium text-text-primary",
107
- children: "End date"
108
- }), /* @__PURE__ */ c("input", {
111
+ children: "End date *"
112
+ }), /* @__PURE__ */ l("input", {
109
113
  type: "date",
110
- required: S,
111
- value: L,
112
- onChange: (e) => R(e.target.value),
113
- className: i
114
+ required: !0,
115
+ min: I || void 0,
116
+ value: R,
117
+ onChange: (e) => z(e.target.value),
118
+ className: a
114
119
  })] })]
115
120
  }),
116
- /* @__PURE__ */ c("div", {
121
+ /* @__PURE__ */ l("div", {
117
122
  className: "grid grid-cols-1 gap-3 sm:grid-cols-2",
118
- children: /* @__PURE__ */ l("div", { children: [
119
- /* @__PURE__ */ c("label", {
123
+ children: /* @__PURE__ */ u("div", { children: [
124
+ /* @__PURE__ */ l("label", {
120
125
  className: "mb-1.5 block text-sm font-medium text-text-primary",
121
126
  children: "Next service date"
122
127
  }),
123
- /* @__PURE__ */ c("input", {
128
+ /* @__PURE__ */ l("input", {
124
129
  type: "date",
125
- min: F || void 0,
126
- max: L || void 0,
127
- value: z,
128
- onChange: (e) => B(e.target.value),
129
- className: i
130
+ min: I || void 0,
131
+ max: R || void 0,
132
+ value: B,
133
+ onChange: (e) => V(e.target.value),
134
+ className: a
130
135
  }),
131
- /* @__PURE__ */ c("p", {
136
+ /* @__PURE__ */ l("p", {
132
137
  className: "mt-1 text-xs text-text-secondary",
133
138
  children: "Optional — shows in the upcoming service schedule."
134
139
  })
135
140
  ] })
136
141
  }),
137
- /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
142
+ /* @__PURE__ */ u("div", { children: [/* @__PURE__ */ l("label", {
138
143
  className: "mb-1.5 block text-sm font-medium text-text-primary",
139
144
  children: "Services included"
140
- }), /* @__PURE__ */ c("input", {
145
+ }), /* @__PURE__ */ l("input", {
141
146
  type: "text",
142
147
  placeholder: "Comma-separated, e.g. Plumbing, Electrical, HVAC",
143
- value: V,
144
- onChange: (e) => H(e.target.value),
145
- className: i
148
+ value: H,
149
+ onChange: (e) => U(e.target.value),
150
+ className: a
146
151
  })] })
147
152
  ]
148
153
  }),
149
- /* @__PURE__ */ l(m, { children: [/* @__PURE__ */ c(u, {
154
+ /* @__PURE__ */ u(h, { children: [/* @__PURE__ */ l(d, {
150
155
  type: "button",
151
156
  variant: "outline",
152
- onClick: () => v(!1),
157
+ onClick: () => y(!1),
153
158
  children: "Cancel"
154
- }), /* @__PURE__ */ c(u, {
159
+ }), /* @__PURE__ */ l(d, {
155
160
  type: "submit",
156
- disabled: b,
157
- children: b ? "Saving…" : S ? "Save changes" : "Create contract"
161
+ disabled: x,
162
+ children: x ? "Saving…" : C ? "Save changes" : "Create contract"
158
163
  })] })
159
164
  ]
160
165
  })
@@ -162,6 +167,6 @@ function _({ open: _, onOpenChange: v, contract: y, saving: b, onSubmit: x }) {
162
167
  });
163
168
  }
164
169
  //#endregion
165
- export { _ as AmcContractFormDialog };
170
+ export { v as AmcContractFormDialog };
166
171
 
167
172
  //# sourceMappingURL=AmcContractFormDialog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AmcContractFormDialog.js","names":[],"sources":["../../../../src/housingvista/pages/amc/AmcContractFormDialog.tsx"],"sourcesContent":["/**\n * New / edit contract dialog for the AMC page (BOFF-9600). One form for both\n * modes: `contract` null = create, otherwise edit with the fields prefilled.\n * There is no status field: it is derived from the end date on the server\n * (BOFF-9602). A contract is cancelled through the Cancel action and\n * reactivated through Renew.\n */\nimport { useEffect, useState, type FormEvent } from 'react';\nimport {\n Button,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n} from '@burdenoff/fe-libs/ui';\nimport { notify } from '../../lib/toast';\nimport type { AMCContract } from '../../types';\nimport { dateInputToIso, toDateInput, withinContractWindow } from './amcDates';\nimport { inputClass } from './amcStyles';\nimport { AmcLinkFields } from './AmcLinkFields';\n\nexport interface AmcContractFormValues {\n /** Linked property id, or '' for a free-text property name. */\n propertyId: string;\n propertyTitle: string;\n /** Linked marketplace service id, or '' for a free-text provider name. */\n marketplaceServiceId: string;\n packageName: string;\n providerName: string;\n monthlyCost: number;\n startDate: string;\n endDate: string;\n /** ISO date, or '' when no upcoming service is scheduled. */\n nextServiceDate: string;\n servicesIncluded: string[];\n}\n\ninterface AmcContractFormDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** null = create a new contract; otherwise edit this one. */\n contract: AMCContract | null;\n saving: boolean;\n onSubmit: (values: AmcContractFormValues) => Promise<void>;\n}\n\nexport function AmcContractFormDialog({ open, onOpenChange, contract, saving, onSubmit }: AmcContractFormDialogProps) {\n const isEdit = contract !== null;\n const [propertyId, setPropertyId] = useState('');\n const [propertyTitle, setPropertyTitle] = useState('');\n const [marketplaceServiceId, setMarketplaceServiceId] = useState('');\n const [packageName, setPackageName] = useState('');\n const [providerName, setProviderName] = useState('');\n const [monthlyCost, setMonthlyCost] = useState('');\n const [startDate, setStartDate] = useState('');\n const [endDate, setEndDate] = useState('');\n const [nextServiceDate, setNextServiceDate] = useState('');\n const [servicesIncluded, setServicesIncluded] = useState('');\n\n // Reset (create) or prefill (edit) every time the dialog opens.\n useEffect(() => {\n if (!open) return;\n setPropertyId(contract?.propertyId ?? '');\n setPropertyTitle(contract?.propertyTitle ?? '');\n setMarketplaceServiceId(contract?.marketplaceServiceId ?? '');\n setPackageName(contract?.packageName ?? '');\n setProviderName(contract?.providerName ?? '');\n setMonthlyCost(contract ? String(contract.monthlyCost) : '');\n setStartDate(contract ? toDateInput(contract.startDate) : '');\n setEndDate(contract ? toDateInput(contract.endDate) : '');\n // The column is nullable: a contract without a scheduled service reads back null.\n setNextServiceDate(contract ? toDateInput(contract.nextServiceDate ?? '') : '');\n setServicesIncluded(contract ? contract.servicesIncluded.join(', ') : '');\n }, [open, contract]);\n\n const handleSubmit = async (event: FormEvent) => {\n event.preventDefault();\n const cost = Number(monthlyCost);\n if (!propertyTitle.trim() || !packageName.trim() || !providerName.trim()) {\n notify.warning('Missing details', 'Property, package and provider are required.');\n return;\n }\n if (!Number.isFinite(cost) || cost <= 0) {\n notify.warning('Enter a valid monthly cost');\n return;\n }\n if (isEdit && (!startDate || !endDate)) {\n notify.warning('Dates are required', 'Start and end dates cannot be cleared on an existing contract.');\n return;\n }\n if (\n nextServiceDate &&\n !withinContractWindow(dateInputToIso(startDate), dateInputToIso(endDate), dateInputToIso(nextServiceDate))\n ) {\n notify.warning('Next service date out of range', 'It must fall between the contract start and end dates.');\n return;\n }\n await onSubmit({\n propertyId,\n marketplaceServiceId,\n propertyTitle: propertyTitle.trim(),\n packageName: packageName.trim(),\n providerName: providerName.trim(),\n monthlyCost: cost,\n startDate: dateInputToIso(startDate),\n endDate: dateInputToIso(endDate),\n nextServiceDate: dateInputToIso(nextServiceDate),\n servicesIncluded: servicesIncluded\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0),\n });\n };\n\n return (\n <ResponsiveDialog open={open} onOpenChange={onOpenChange}>\n <ResponsiveDialogContent className=\"sm:max-w-lg\">\n <form onSubmit={handleSubmit}>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>\n {isEdit ? 'Edit maintenance contract' : 'New maintenance contract'}\n </ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {isEdit\n ? 'Update the coverage, cost or dates of this Annual Maintenance Contract.'\n : 'Set up an Annual Maintenance Contract to track coverage, cost and renewal dates.'}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n <div className=\"space-y-3 py-2\">\n <AmcLinkFields\n propertyId={propertyId}\n propertyTitle={propertyTitle}\n onProperty={(id, title) => {\n setPropertyId(id);\n setPropertyTitle(title);\n }}\n marketplaceServiceId={marketplaceServiceId}\n providerName={providerName}\n onProvider={(id, name) => {\n setMarketplaceServiceId(id);\n setProviderName(name);\n }}\n />\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">Package *</label>\n <input\n type=\"text\"\n required\n placeholder=\"e.g. Premium Care\"\n value={packageName}\n onChange={(e) => setPackageName(e.target.value)}\n className={inputClass}\n />\n </div>\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">Monthly cost *</label>\n <input\n type=\"number\"\n required\n min={0}\n step=\"0.01\"\n placeholder=\"0.00\"\n value={monthlyCost}\n onChange={(e) => setMonthlyCost(e.target.value)}\n className={inputClass}\n />\n </div>\n </div>\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">Start date</label>\n <input\n type=\"date\"\n required={isEdit}\n value={startDate}\n onChange={(e) => setStartDate(e.target.value)}\n className={inputClass}\n />\n </div>\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">End date</label>\n <input\n type=\"date\"\n required={isEdit}\n value={endDate}\n onChange={(e) => setEndDate(e.target.value)}\n className={inputClass}\n />\n </div>\n </div>\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">Next service date</label>\n <input\n type=\"date\"\n min={startDate || undefined}\n max={endDate || undefined}\n value={nextServiceDate}\n onChange={(e) => setNextServiceDate(e.target.value)}\n className={inputClass}\n />\n <p className=\"mt-1 text-xs text-text-secondary\">Optional — shows in the upcoming service schedule.</p>\n </div>\n </div>\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">Services included</label>\n <input\n type=\"text\"\n placeholder=\"Comma-separated, e.g. Plumbing, Electrical, HVAC\"\n value={servicesIncluded}\n onChange={(e) => setServicesIncluded(e.target.value)}\n className={inputClass}\n />\n </div>\n </div>\n <ResponsiveDialogFooter>\n <Button type=\"button\" variant=\"outline\" onClick={() => onOpenChange(false)}>\n Cancel\n </Button>\n <Button type=\"submit\" disabled={saving}>\n {saving ? 'Saving…' : isEdit ? 'Save changes' : 'Create contract'}\n </Button>\n </ResponsiveDialogFooter>\n </form>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;AAgDA,SAAgB,EAAsB,EAAE,SAAM,iBAAc,aAAU,WAAQ,eAAwC;CACpH,IAAM,IAAS,MAAa,MACtB,CAAC,GAAY,KAAiB,EAAS,GAAG,EAC1C,CAAC,GAAe,KAAoB,EAAS,GAAG,EAChD,CAAC,GAAsB,KAA2B,EAAS,GAAG,EAC9D,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAc,KAAmB,EAAS,GAAG,EAC9C,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAW,KAAgB,EAAS,GAAG,EACxC,CAAC,GAAS,KAAc,EAAS,GAAG,EACpC,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":3,"file":"AmcContractFormDialog.js","names":[],"sources":["../../../../src/housingvista/pages/amc/AmcContractFormDialog.tsx"],"sourcesContent":["/**\n * New / edit contract dialog for the AMC page (BOFF-9600). One form for both\n * modes: `contract` null = create, otherwise edit with the fields prefilled.\n * There is no status field: it is derived from the end date on the server\n * (BOFF-9602). A contract is cancelled through the Cancel action and\n * reactivated through Renew.\n */\nimport { useEffect, useState, type FormEvent } from 'react';\nimport {\n Button,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n} from '@burdenoff/fe-libs/ui';\nimport { notify } from '../../lib/toast';\nimport type { AMCContract } from '../../types';\nimport { dateInputToIso, isEndBeforeStart, toDateInput, withinContractWindow } from './amcDates';\nimport { inputClass } from './amcStyles';\nimport { AmcLinkFields } from './AmcLinkFields';\n\nexport interface AmcContractFormValues {\n /** Linked property id, or '' for a free-text property name. */\n propertyId: string;\n propertyTitle: string;\n /** Linked marketplace service id, or '' for a free-text provider name. */\n marketplaceServiceId: string;\n packageName: string;\n providerName: string;\n monthlyCost: number;\n startDate: string;\n endDate: string;\n /** ISO date, or '' when no upcoming service is scheduled. */\n nextServiceDate: string;\n servicesIncluded: string[];\n}\n\ninterface AmcContractFormDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** null = create a new contract; otherwise edit this one. */\n contract: AMCContract | null;\n saving: boolean;\n onSubmit: (values: AmcContractFormValues) => Promise<void>;\n}\n\nexport function AmcContractFormDialog({ open, onOpenChange, contract, saving, onSubmit }: AmcContractFormDialogProps) {\n const isEdit = contract !== null;\n const [propertyId, setPropertyId] = useState('');\n const [propertyTitle, setPropertyTitle] = useState('');\n const [marketplaceServiceId, setMarketplaceServiceId] = useState('');\n const [packageName, setPackageName] = useState('');\n const [providerName, setProviderName] = useState('');\n const [monthlyCost, setMonthlyCost] = useState('');\n const [startDate, setStartDate] = useState('');\n const [endDate, setEndDate] = useState('');\n const [nextServiceDate, setNextServiceDate] = useState('');\n const [servicesIncluded, setServicesIncluded] = useState('');\n\n // Reset (create) or prefill (edit) every time the dialog opens.\n useEffect(() => {\n if (!open) return;\n setPropertyId(contract?.propertyId ?? '');\n setPropertyTitle(contract?.propertyTitle ?? '');\n setMarketplaceServiceId(contract?.marketplaceServiceId ?? '');\n setPackageName(contract?.packageName ?? '');\n setProviderName(contract?.providerName ?? '');\n setMonthlyCost(contract ? String(contract.monthlyCost) : '');\n setStartDate(contract ? toDateInput(contract.startDate) : '');\n setEndDate(contract ? toDateInput(contract.endDate) : '');\n // The column is nullable: a contract without a scheduled service reads back null.\n setNextServiceDate(contract ? toDateInput(contract.nextServiceDate ?? '') : '');\n setServicesIncluded(contract ? contract.servicesIncluded.join(', ') : '');\n }, [open, contract]);\n\n const handleSubmit = async (event: FormEvent) => {\n event.preventDefault();\n const cost = Number(monthlyCost);\n if (!propertyTitle.trim() || !packageName.trim() || !providerName.trim()) {\n notify.warning('Missing details', 'Property, package and provider are required.');\n return;\n }\n if (!Number.isFinite(cost) || cost <= 0) {\n notify.warning('Enter a valid monthly cost');\n return;\n }\n if (!startDate || !endDate) {\n notify.warning('Dates are required', 'Choose both a start date and an end date.');\n return;\n }\n if (isEndBeforeStart(dateInputToIso(startDate), dateInputToIso(endDate))) {\n notify.warning('End date is before the start date', 'The contract must end on or after the day it starts.');\n return;\n }\n if (\n nextServiceDate &&\n !withinContractWindow(dateInputToIso(startDate), dateInputToIso(endDate), dateInputToIso(nextServiceDate))\n ) {\n notify.warning('Next service date out of range', 'It must fall between the contract start and end dates.');\n return;\n }\n await onSubmit({\n propertyId,\n marketplaceServiceId,\n propertyTitle: propertyTitle.trim(),\n packageName: packageName.trim(),\n providerName: providerName.trim(),\n monthlyCost: cost,\n startDate: dateInputToIso(startDate),\n endDate: dateInputToIso(endDate),\n nextServiceDate: dateInputToIso(nextServiceDate),\n servicesIncluded: servicesIncluded\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0),\n });\n };\n\n return (\n <ResponsiveDialog open={open} onOpenChange={onOpenChange}>\n <ResponsiveDialogContent className=\"sm:max-w-lg\">\n <form onSubmit={handleSubmit}>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>\n {isEdit ? 'Edit maintenance contract' : 'New maintenance contract'}\n </ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {isEdit\n ? 'Update the coverage, cost or dates of this Annual Maintenance Contract.'\n : 'Set up an Annual Maintenance Contract to track coverage, cost and renewal dates.'}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n <div className=\"space-y-3 py-2\">\n <AmcLinkFields\n propertyId={propertyId}\n propertyTitle={propertyTitle}\n onProperty={(id, title) => {\n setPropertyId(id);\n setPropertyTitle(title);\n }}\n marketplaceServiceId={marketplaceServiceId}\n providerName={providerName}\n onProvider={(id, name) => {\n setMarketplaceServiceId(id);\n setProviderName(name);\n }}\n />\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">Package *</label>\n <input\n type=\"text\"\n required\n placeholder=\"e.g. Premium Care\"\n value={packageName}\n onChange={(e) => setPackageName(e.target.value)}\n className={inputClass}\n />\n </div>\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">Monthly cost *</label>\n <input\n type=\"number\"\n required\n min={0}\n step=\"0.01\"\n placeholder=\"0.00\"\n value={monthlyCost}\n onChange={(e) => setMonthlyCost(e.target.value)}\n className={inputClass}\n />\n </div>\n </div>\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">Start date *</label>\n <input\n type=\"date\"\n required\n value={startDate}\n onChange={(e) => setStartDate(e.target.value)}\n className={inputClass}\n />\n </div>\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">End date *</label>\n <input\n type=\"date\"\n required\n min={startDate || undefined}\n value={endDate}\n onChange={(e) => setEndDate(e.target.value)}\n className={inputClass}\n />\n </div>\n </div>\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">Next service date</label>\n <input\n type=\"date\"\n min={startDate || undefined}\n max={endDate || undefined}\n value={nextServiceDate}\n onChange={(e) => setNextServiceDate(e.target.value)}\n className={inputClass}\n />\n <p className=\"mt-1 text-xs text-text-secondary\">Optional — shows in the upcoming service schedule.</p>\n </div>\n </div>\n <div>\n <label className=\"mb-1.5 block text-sm font-medium text-text-primary\">Services included</label>\n <input\n type=\"text\"\n placeholder=\"Comma-separated, e.g. Plumbing, Electrical, HVAC\"\n value={servicesIncluded}\n onChange={(e) => setServicesIncluded(e.target.value)}\n className={inputClass}\n />\n </div>\n </div>\n <ResponsiveDialogFooter>\n <Button type=\"button\" variant=\"outline\" onClick={() => onOpenChange(false)}>\n Cancel\n </Button>\n <Button type=\"submit\" disabled={saving}>\n {saving ? 'Saving…' : isEdit ? 'Save changes' : 'Create contract'}\n </Button>\n </ResponsiveDialogFooter>\n </form>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;AAgDA,SAAgB,EAAsB,EAAE,SAAM,iBAAc,aAAU,WAAQ,eAAwC;CACpH,IAAM,IAAS,MAAa,MACtB,CAAC,GAAY,KAAiB,EAAS,GAAG,EAC1C,CAAC,GAAe,KAAoB,EAAS,GAAG,EAChD,CAAC,GAAsB,KAA2B,EAAS,GAAG,EAC9D,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAc,KAAmB,EAAS,GAAG,EAC9C,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAW,KAAgB,EAAS,GAAG,EACxC,CAAC,GAAS,KAAc,EAAS,GAAG,EACpC,CAAC,GAAiB,KAAsB,EAAS,GAAG,EACpD,CAAC,GAAkB,KAAuB,EAAS,GAAG;AA6D5D,QA1DA,QAA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B;;GACiB,CAAA;EACT,CAAA"}
@@ -28,4 +28,6 @@ export declare const plusOneYear: (iso: string) => string;
28
28
  export declare const withinContractWindow: (startIso: string, endIso: string, dateIso: string) => boolean;
29
29
  /** True when `candidateIso` is strictly after `currentIso`. */
30
30
  export declare const extendsContract: (currentIso: string, candidateIso: string) => boolean;
31
+ /** True when both dates are set and the end falls before the start (equal days are fine). */
32
+ export declare const isEndBeforeStart: (startIso: string, endIso: string) => boolean;
31
33
  //# sourceMappingURL=amcDates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"amcDates.d.ts","sourceRoot":"","sources":["../../../../src/housingvista/pages/amc/amcDates.ts"],"names":[],"mappings":"AAAA,oHAAoH;AAEpH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,MAIhD,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,EAAE,MAAK,IAAiB,KAAG,MAMvE,CAAC;AAEF,oGAAoG;AACpG,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAAuC,CAAC;AAElF,+FAA+F;AAC/F,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,KAAG,MAKtC,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,MAI9C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAOzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,OAMxF,CAAC;AAEF,+DAA+D;AAC/D,eAAO,MAAM,eAAe,GAAI,YAAY,MAAM,EAAE,cAAc,MAAM,KAAG,OAI1E,CAAC"}
1
+ {"version":3,"file":"amcDates.d.ts","sourceRoot":"","sources":["../../../../src/housingvista/pages/amc/amcDates.ts"],"names":[],"mappings":"AAAA,oHAAoH;AAEpH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,MAIhD,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,EAAE,MAAK,IAAiB,KAAG,MAMvE,CAAC;AAEF,oGAAoG;AACpG,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAAuC,CAAC;AAElF,+FAA+F;AAC/F,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,KAAG,MAKtC,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,MAI9C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAOzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,OAMxF,CAAC;AAEF,+DAA+D;AAC/D,eAAO,MAAM,eAAe,GAAI,YAAY,MAAM,EAAE,cAAc,MAAM,KAAG,OAI1E,CAAC;AAEF,6FAA6F;AAC7F,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAInE,CAAC"}
@@ -26,8 +26,11 @@ var e = (e) => {
26
26
  }, c = (e, t) => {
27
27
  let n = new Date(t).getTime(), r = new Date(e).getTime();
28
28
  return Number.isFinite(n) && Number.isFinite(r) && n > r;
29
+ }, l = (e, t) => {
30
+ let n = new Date(e).getTime(), r = new Date(t).getTime();
31
+ return Number.isFinite(n) && Number.isFinite(r) && r < n;
29
32
  };
30
33
  //#endregion
31
- export { n as calendarDaysUntil, a as dateInputToIso, i as dayAfter, c as extendsContract, e as formatCalendarDate, o as plusOneYear, r as toDateInput, s as withinContractWindow };
34
+ export { n as calendarDaysUntil, a as dateInputToIso, i as dayAfter, c as extendsContract, e as formatCalendarDate, l as isEndBeforeStart, o as plusOneYear, r as toDateInput, s as withinContractWindow };
32
35
 
33
36
  //# sourceMappingURL=amcDates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"amcDates.js","names":[],"sources":["../../../../src/housingvista/pages/amc/amcDates.ts"],"sourcesContent":["/** Date helpers for the AMC page (BOFF-9600). Dates travel as ISO strings; <input type=\"date\"> wants YYYY-MM-DD. */\n\n/**\n * Display a stored contract date (UTC midnight, as dateInputToIso writes it) as the calendar day the user picked.\n * The shared `formatDate` renders in the browser's local zone, which shows the previous day west of UTC.\n */\nexport const formatCalendarDate = (iso: string): string => {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return '—';\n return date.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' });\n};\n\nconst MS_PER_DAY = 86_400_000;\n\n/**\n * Whole calendar days from the user's today until a stored contract date. The stored date is UTC midnight of the\n * day the user picked, so compare its UTC calendar day with today's calendar day in the user's own zone: a service\n * scheduled for today is 0 (not negative once the instant has passed), tomorrow is 1, yesterday is -1.\n */\nexport const calendarDaysUntil = (iso: string, now: Date = new Date()): number => {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return Number.NaN;\n const storedDay = Math.floor(date.getTime() / MS_PER_DAY);\n const today = Math.floor(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) / MS_PER_DAY);\n return storedDay - today;\n};\n\n/** ISO timestamp -> the YYYY-MM-DD an <input type=\"date\"> expects (UTC calendar day, as stored). */\nexport const toDateInput = (iso: string): string => (iso ? iso.slice(0, 10) : '');\n\n/** The calendar day after `iso` (UTC) as YYYY-MM-DD — the earliest date a renewal may pick. */\nexport const dayAfter = (iso: string): string => {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return '';\n date.setUTCDate(date.getUTCDate() + 1);\n return date.toISOString().slice(0, 10);\n};\n\n/** YYYY-MM-DD from a date input -> ISO at UTC midnight; empty/invalid -> ''. */\nexport const dateInputToIso = (value: string): string => {\n if (!value) return '';\n const date = new Date(`${value}T00:00:00.000Z`);\n return Number.isNaN(date.getTime()) ? '' : date.toISOString();\n};\n\n/**\n * Calendar-accurate +1 year (UTC) used as the default renewal end date. A Feb 29 end clamps to Feb 28 of a\n * non-leap year instead of rolling to Mar 1 (which would shift the contract's anniversary by a day).\n */\nexport const plusOneYear = (iso: string): string => {\n const date = new Date(iso);\n const originalDay = date.getUTCDate();\n date.setUTCFullYear(date.getUTCFullYear() + 1);\n // Only a Feb 29 start overflows into the next month; step back to the last day of February.\n if (date.getUTCDate() !== originalDay) date.setUTCDate(0);\n return date.toISOString();\n};\n\n/**\n * True when `dateIso` lies within [startIso, endIso] (inclusive). A missing bound is not enforced, so a form\n * with a blank start or end date is judged on the bound(s) it does have.\n */\nexport const withinContractWindow = (startIso: string, endIso: string, dateIso: string): boolean => {\n const date = new Date(dateIso).getTime();\n if (!Number.isFinite(date)) return false;\n if (startIso && date < new Date(startIso).getTime()) return false;\n if (endIso && date > new Date(endIso).getTime()) return false;\n return true;\n};\n\n/** True when `candidateIso` is strictly after `currentIso`. */\nexport const extendsContract = (currentIso: string, candidateIso: string): boolean => {\n const candidate = new Date(candidateIso).getTime();\n const current = new Date(currentIso).getTime();\n return Number.isFinite(candidate) && Number.isFinite(current) && candidate > current;\n};\n"],"mappings":";AAMA,IAAa,KAAsB,MAAwB;CACzD,IAAM,IAAO,IAAI,KAAK,EAAI;AAE1B,QADI,OAAO,MAAM,EAAK,SAAS,CAAC,GAAS,MAClC,EAAK,mBAAmB,SAAS;EAAE,MAAM;EAAW,OAAO;EAAS,KAAK;EAAW,UAAU;EAAO,CAAC;GAGzG,IAAa,OAON,KAAqB,GAAa,oBAAY,IAAI,MAAM,KAAa;CAChF,IAAM,IAAO,IAAI,KAAK,EAAI;AAI1B,QAHI,OAAO,MAAM,EAAK,SAAS,CAAC,GAAS,MACvB,KAAK,MAAM,EAAK,SAAS,GAAG,EAAW,GAC3C,KAAK,MAAM,KAAK,IAAI,EAAI,aAAa,EAAE,EAAI,UAAU,EAAE,EAAI,SAAS,CAAC,GAAG,EAAW;GAKtF,KAAe,MAAyB,IAAM,EAAI,MAAM,GAAG,GAAG,GAAG,IAGjE,KAAY,MAAwB;CAC/C,IAAM,IAAO,IAAI,KAAK,EAAI;AAG1B,QAFI,OAAO,MAAM,EAAK,SAAS,CAAC,GAAS,MACzC,EAAK,WAAW,EAAK,YAAY,GAAG,EAAE,EAC/B,EAAK,aAAa,CAAC,MAAM,GAAG,GAAG;GAI3B,KAAkB,MAA0B;AACvD,KAAI,CAAC,EAAO,QAAO;CACnB,IAAM,oBAAO,IAAI,KAAK,GAAG,EAAM,gBAAgB;AAC/C,QAAO,OAAO,MAAM,EAAK,SAAS,CAAC,GAAG,KAAK,EAAK,aAAa;GAOlD,KAAe,MAAwB;CAClD,IAAM,IAAO,IAAI,KAAK,EAAI,EACpB,IAAc,EAAK,YAAY;AAIrC,QAHA,EAAK,eAAe,EAAK,gBAAgB,GAAG,EAAE,EAE1C,EAAK,YAAY,KAAK,KAAa,EAAK,WAAW,EAAE,EAClD,EAAK,aAAa;GAOd,KAAwB,GAAkB,GAAgB,MAA6B;CAClG,IAAM,IAAO,IAAI,KAAK,EAAQ,CAAC,SAAS;AAIxC,QADA,EAFI,CAAC,OAAO,SAAS,EAAK,IACtB,KAAY,IAAO,IAAI,KAAK,EAAS,CAAC,SAAS,IAC/C,KAAU,IAAO,IAAI,KAAK,EAAO,CAAC,SAAS;GAKpC,KAAmB,GAAoB,MAAkC;CACpF,IAAM,IAAY,IAAI,KAAK,EAAa,CAAC,SAAS,EAC5C,IAAU,IAAI,KAAK,EAAW,CAAC,SAAS;AAC9C,QAAO,OAAO,SAAS,EAAU,IAAI,OAAO,SAAS,EAAQ,IAAI,IAAY"}
1
+ {"version":3,"file":"amcDates.js","names":[],"sources":["../../../../src/housingvista/pages/amc/amcDates.ts"],"sourcesContent":["/** Date helpers for the AMC page (BOFF-9600). Dates travel as ISO strings; <input type=\"date\"> wants YYYY-MM-DD. */\n\n/**\n * Display a stored contract date (UTC midnight, as dateInputToIso writes it) as the calendar day the user picked.\n * The shared `formatDate` renders in the browser's local zone, which shows the previous day west of UTC.\n */\nexport const formatCalendarDate = (iso: string): string => {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return '—';\n return date.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' });\n};\n\nconst MS_PER_DAY = 86_400_000;\n\n/**\n * Whole calendar days from the user's today until a stored contract date. The stored date is UTC midnight of the\n * day the user picked, so compare its UTC calendar day with today's calendar day in the user's own zone: a service\n * scheduled for today is 0 (not negative once the instant has passed), tomorrow is 1, yesterday is -1.\n */\nexport const calendarDaysUntil = (iso: string, now: Date = new Date()): number => {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return Number.NaN;\n const storedDay = Math.floor(date.getTime() / MS_PER_DAY);\n const today = Math.floor(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) / MS_PER_DAY);\n return storedDay - today;\n};\n\n/** ISO timestamp -> the YYYY-MM-DD an <input type=\"date\"> expects (UTC calendar day, as stored). */\nexport const toDateInput = (iso: string): string => (iso ? iso.slice(0, 10) : '');\n\n/** The calendar day after `iso` (UTC) as YYYY-MM-DD — the earliest date a renewal may pick. */\nexport const dayAfter = (iso: string): string => {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return '';\n date.setUTCDate(date.getUTCDate() + 1);\n return date.toISOString().slice(0, 10);\n};\n\n/** YYYY-MM-DD from a date input -> ISO at UTC midnight; empty/invalid -> ''. */\nexport const dateInputToIso = (value: string): string => {\n if (!value) return '';\n const date = new Date(`${value}T00:00:00.000Z`);\n return Number.isNaN(date.getTime()) ? '' : date.toISOString();\n};\n\n/**\n * Calendar-accurate +1 year (UTC) used as the default renewal end date. A Feb 29 end clamps to Feb 28 of a\n * non-leap year instead of rolling to Mar 1 (which would shift the contract's anniversary by a day).\n */\nexport const plusOneYear = (iso: string): string => {\n const date = new Date(iso);\n const originalDay = date.getUTCDate();\n date.setUTCFullYear(date.getUTCFullYear() + 1);\n // Only a Feb 29 start overflows into the next month; step back to the last day of February.\n if (date.getUTCDate() !== originalDay) date.setUTCDate(0);\n return date.toISOString();\n};\n\n/**\n * True when `dateIso` lies within [startIso, endIso] (inclusive). A missing bound is not enforced, so a form\n * with a blank start or end date is judged on the bound(s) it does have.\n */\nexport const withinContractWindow = (startIso: string, endIso: string, dateIso: string): boolean => {\n const date = new Date(dateIso).getTime();\n if (!Number.isFinite(date)) return false;\n if (startIso && date < new Date(startIso).getTime()) return false;\n if (endIso && date > new Date(endIso).getTime()) return false;\n return true;\n};\n\n/** True when `candidateIso` is strictly after `currentIso`. */\nexport const extendsContract = (currentIso: string, candidateIso: string): boolean => {\n const candidate = new Date(candidateIso).getTime();\n const current = new Date(currentIso).getTime();\n return Number.isFinite(candidate) && Number.isFinite(current) && candidate > current;\n};\n\n/** True when both dates are set and the end falls before the start (equal days are fine). */\nexport const isEndBeforeStart = (startIso: string, endIso: string): boolean => {\n const start = new Date(startIso).getTime();\n const end = new Date(endIso).getTime();\n return Number.isFinite(start) && Number.isFinite(end) && end < start;\n};\n"],"mappings":";AAMA,IAAa,KAAsB,MAAwB;CACzD,IAAM,IAAO,IAAI,KAAK,EAAI;AAE1B,QADI,OAAO,MAAM,EAAK,SAAS,CAAC,GAAS,MAClC,EAAK,mBAAmB,SAAS;EAAE,MAAM;EAAW,OAAO;EAAS,KAAK;EAAW,UAAU;EAAO,CAAC;GAGzG,IAAa,OAON,KAAqB,GAAa,oBAAY,IAAI,MAAM,KAAa;CAChF,IAAM,IAAO,IAAI,KAAK,EAAI;AAI1B,QAHI,OAAO,MAAM,EAAK,SAAS,CAAC,GAAS,MACvB,KAAK,MAAM,EAAK,SAAS,GAAG,EAAW,GAC3C,KAAK,MAAM,KAAK,IAAI,EAAI,aAAa,EAAE,EAAI,UAAU,EAAE,EAAI,SAAS,CAAC,GAAG,EAAW;GAKtF,KAAe,MAAyB,IAAM,EAAI,MAAM,GAAG,GAAG,G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{
4
+ activeContracts: number;
5
+ pendingRenewals: number;
6
+ /** Sum of monthly cost across live contracts, in the app currency. */
7
+ totalMonthlySpent: number;
8
+ /** Live contracts whose next service falls within the next 30 days (today included). */
9
+ upcomingServices: number;
10
+ }
11
+ /** Live contracts with a scheduled service, soonest first — feeds both the schedule and the "Upcoming Services" stat. */
12
+ export declare const listScheduledServices: (contracts: readonly AMCContract[]) => AMCContract[];
13
+ export declare const computeAmcStats: (contracts: readonly AMCContract[], now?: Date,
14
+ /** Pass the already-computed schedule to skip filtering and sorting the portfolio a second time. */
15
+ scheduled?: readonly AMCContract[]) => AmcStats;
16
+ //# sourceMappingURL=amcStats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amcStats.d.ts","sourceRoot":"","sources":["../../../../src/housingvista/pages/amc/amcStats.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,WAAW,QAAQ;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wFAAwF;IACxF,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAID,yHAAyH;AACzH,eAAO,MAAM,qBAAqB,GAAI,WAAW,SAAS,WAAW,EAAE,KAAG,WAAW,EAGa,CAAC;AAEnG,eAAO,MAAM,eAAe,GAC1B,WAAW,SAAS,WAAW,EAAE,EACjC,MAAK,IAAiB;AACtB,oGAAoG;AACpG,YAAW,SAAS,WAAW,EAAqC,KACnE,QAWF,CAAC"}