@burdenoff/microfe-headshotmarketing 2026.1107.1 → 2026.1107.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/generated/wspace-operations.d.ts +612 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +594 -368
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +8498 -352
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js +11 -7
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/headshotmarketing/pages/HomeMonthlyGoals.d.ts +9 -0
- package/dist/headshotmarketing/pages/HomeMonthlyGoals.d.ts.map +1 -0
- package/dist/headshotmarketing/pages/HomeMonthlyGoals.js +266 -0
- package/dist/headshotmarketing/pages/HomeMonthlyGoals.js.map +1 -0
- package/dist/headshotmarketing/pages/HomePage.d.ts.map +1 -1
- package/dist/headshotmarketing/pages/HomePage.js +299 -298
- package/dist/headshotmarketing/pages/HomePage.js.map +1 -1
- package/dist/headshotmarketing/pages/analytics/ReportScheduleDialog.d.ts +26 -0
- package/dist/headshotmarketing/pages/analytics/ReportScheduleDialog.d.ts.map +1 -0
- package/dist/headshotmarketing/pages/analytics/ReportScheduleDialog.js +402 -0
- package/dist/headshotmarketing/pages/analytics/ReportScheduleDialog.js.map +1 -0
- package/dist/headshotmarketing/pages/analytics/ReportsPage.d.ts.map +1 -1
- package/dist/headshotmarketing/pages/analytics/ReportsPage.js +356 -243
- package/dist/headshotmarketing/pages/analytics/ReportsPage.js.map +1 -1
- package/dist/headshotmarketing/pages/analytics/reportSchedule.d.ts +66 -0
- package/dist/headshotmarketing/pages/analytics/reportSchedule.d.ts.map +1 -0
- package/dist/headshotmarketing/pages/analytics/reportSchedule.js +131 -0
- package/dist/headshotmarketing/pages/analytics/reportSchedule.js.map +1 -0
- package/dist/headshotmarketing/utils/dashboardHome.d.ts +91 -0
- package/dist/headshotmarketing/utils/dashboardHome.d.ts.map +1 -0
- package/dist/headshotmarketing/utils/dashboardHome.js +94 -0
- package/dist/headshotmarketing/utils/dashboardHome.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReportsPage.js","names":[],"sources":["../../../../src/headshotmarketing/pages/analytics/ReportsPage.tsx"],"sourcesContent":["/**\n * Reports Page (mock 15, BOFF-4015)\n *\n * Saved reports on the left, the selected report's canvas on the right. A\n * saved report is a definition — name, description, widgets and date range —\n * stored by `headshotmarketingCreateSavedReport` and shared by everyone in the\n * workspace. Its canvas is drawn at view time from the date-ranged analytics\n * overview and attribution for the report's window, so a \"Last 30 days\"\n * report is always the latest 30 days.\n *\n * Actions: + New Report, Edit (rename, change widgets or range), Add widget,\n * Share (copies a deep link `?report=<id>` that opens the report for any\n * workspace member), Export CSV, Export PDF (the browser's print-to-PDF) and\n * Delete. Without a saved report selected, the built-in Executive Summary is\n * shown and can be saved as a new report.\n *\n * Scheduled delivery of reports is follow-up work (BOFF-10585); nothing on\n * this page claims a schedule it does not run.\n *\n * @module headshotmarketing/pages/analytics\n */\n\nimport { useMemo, useState, type FC } from \"react\";\nimport { useSearchParams } from \"react-router\";\nimport {\n ArrowUpRight,\n BarChart3,\n DollarSign,\n Download,\n FileDown,\n FileText,\n Pencil,\n Plus,\n Share2,\n Target,\n Trash2,\n TrendingUp,\n Users,\n} from \"lucide-react\";\nimport {\n ConfirmDeleteDialog,\n Modal,\n PageLayout,\n QueryStateBoundary,\n ToastContainer,\n} from \"../../components\";\nimport {\n EmphasisPanel,\n GradientText,\n PagePurpose,\n} from \"@burdenoff/fe-libs/ui\";\nimport { cn, exportRowsToCsv } from \"../../utils/helpers\";\nimport { useToast } from \"../../hooks/useToast\";\nimport { useHeadshotMarketing } from \"../../context/HeadshotMarketingContext\";\nimport {\n useHeadshotmarketingCreateSavedReportMutation,\n useHeadshotmarketingDeleteSavedReportMutation,\n useHeadshotmarketingSavedReportQuery,\n useHeadshotmarketingSavedReportsQuery,\n useHeadshotmarketingUpdateSavedReportMutation,\n type HeadshotmarketingSavedReportFieldsFragment,\n} from \"../../../generated/wspace-operations\";\nimport {\n analyticsCsvRows,\n dateRangeLabel,\n formatWindow,\n resolveDateWindow,\n} from \"./analyticsView\";\nimport {\n AnalyticsSourceNotice,\n DateRangeControl,\n ReportWidgetView,\n WIDGET_META,\n} from \"./analyticsWidgets\";\nimport {\n EXECUTIVE_SUMMARY,\n WIDGET_ORDER,\n draftFrom,\n reportShareUrl,\n toReportInput,\n toggleWidget,\n validateDraft,\n type DraftErrors,\n type ReportDefinition,\n type ReportDraft,\n} from \"./reportDraft\";\nimport { useAnalyticsData } from \"./useAnalyticsData\";\n\nconst REPORTS_REFETCH = [\n \"HeadshotmarketingSavedReports\",\n \"HeadshotmarketingSavedReport\",\n];\n/** Saved reports per page; the server caps a page at 100. */\nconst REPORTS_PAGE_SIZE = 100;\n\nconst BUTTON_SECONDARY =\n \"inline-flex min-h-[40px] items-center gap-2 rounded-md border border-border-seam bg-bg-surface px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-60\";\n\ntype SavedReport = HeadshotmarketingSavedReportFieldsFragment;\n\nfunction definitionOf(report: SavedReport): ReportDefinition {\n return {\n name: report.name,\n description: report.description ?? null,\n widgets: report.widgets,\n dateRange: report.dateRange,\n customStartDate: report.customStartDate ?? null,\n customEndDate: report.customEndDate ?? null,\n };\n}\n\nconst errorMessage = (error: unknown): string =>\n error instanceof Error ? error.message : \"Something went wrong.\";\n\n/** New / edit report dialog. */\nconst ReportEditor: FC<{\n open: boolean;\n title: string;\n submitLabel: string;\n draft: ReportDraft;\n onChange: (draft: ReportDraft) => void;\n errors: DraftErrors;\n serverError: string | null;\n saving: boolean;\n onClose: () => void;\n onSubmit: () => void;\n}> = ({\n open,\n title,\n submitLabel,\n draft,\n onChange,\n errors,\n serverError,\n saving,\n onClose,\n onSubmit,\n}) => (\n <Modal\n open={open}\n onClose={onClose}\n title={title}\n description=\"Choose what the report shows and the period it covers.\"\n size=\"lg\"\n footer={\n <>\n <button\n type=\"button\"\n onClick={onClose}\n disabled={saving}\n className={BUTTON_SECONDARY}\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={onSubmit}\n disabled={saving}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 disabled:cursor-not-allowed disabled:opacity-60\"\n >\n {saving ? \"Saving…\" : submitLabel}\n </button>\n </>\n }\n >\n <div className=\"space-y-5\">\n <div>\n <label\n htmlFor=\"hm-report-name\"\n className=\"mb-1 block text-sm font-medium text-text-primary\"\n >\n Name\n </label>\n <input\n id=\"hm-report-name\"\n value={draft.name}\n onChange={(e) => onChange({ ...draft, name: e.target.value })}\n aria-invalid={Boolean(errors.name)}\n className={cn(\n \"min-h-[44px] w-full rounded-md border bg-bg-surface px-3 py-2 text-sm text-text-primary\",\n errors.name ? \"border-status-error-border\" : \"border-border-seam\",\n )}\n placeholder=\"e.g. Weekly Executive Summary\"\n />\n {errors.name && (\n <p className=\"mt-1 text-xs text-status-error-text\">{errors.name}</p>\n )}\n </div>\n\n <div>\n <label\n htmlFor=\"hm-report-description\"\n className=\"mb-1 block text-sm font-medium text-text-primary\"\n >\n Description <span className=\"text-text-secondary\">(optional)</span>\n </label>\n <textarea\n id=\"hm-report-description\"\n value={draft.description}\n onChange={(e) => onChange({ ...draft, description: e.target.value })}\n rows={2}\n aria-invalid={Boolean(errors.description)}\n className={cn(\n \"w-full rounded-md border bg-bg-surface px-3 py-2 text-sm text-text-primary\",\n errors.description\n ? \"border-status-error-border\"\n : \"border-border-seam\",\n )}\n />\n {errors.description && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {errors.description}\n </p>\n )}\n </div>\n\n <div>\n <p className=\"mb-1 text-sm font-medium text-text-primary\">Period</p>\n <DateRangeControl\n idPrefix=\"hm-report-editor\"\n value={{\n preset: draft.dateRange,\n customStart: draft.customStart,\n customEnd: draft.customEnd,\n }}\n onChange={(value) =>\n onChange({\n ...draft,\n dateRange: value.preset,\n customStart: value.customStart,\n customEnd: value.customEnd,\n })\n }\n invalid={Boolean(errors.dateRange)}\n />\n {errors.dateRange && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {errors.dateRange}\n </p>\n )}\n </div>\n\n <fieldset>\n <legend className=\"mb-2 text-sm font-medium text-text-primary\">\n Widgets\n </legend>\n <div className=\"grid grid-cols-1 gap-2 sm:grid-cols-2\">\n {WIDGET_ORDER.map((widget) => {\n const meta = WIDGET_META[widget];\n const checked = draft.widgets.includes(widget);\n return (\n <label\n key={widget}\n className={cn(\n \"flex cursor-pointer items-start gap-3 rounded-lg border p-3 transition-colors\",\n checked\n ? \"border-action-primary-bg bg-bg-sunken/40\"\n : \"border-border-seam hover:bg-bg-sunken/30\",\n )}\n >\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={() =>\n onChange({\n ...draft,\n widgets: toggleWidget(draft.widgets, widget),\n })\n }\n className=\"mt-0.5 h-4 w-4\"\n />\n <span className=\"min-w-0\">\n <span className=\"flex items-center gap-1.5 text-sm font-medium text-text-primary\">\n {meta.icon}\n {meta.label}\n </span>\n <span className=\"mt-0.5 block text-xs text-text-secondary\">\n {meta.description}\n </span>\n </span>\n </label>\n );\n })}\n </div>\n {errors.widgets && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {errors.widgets}\n </p>\n )}\n </fieldset>\n\n {serverError && (\n <p\n role=\"alert\"\n className=\"rounded-lg border border-status-error-border px-4 py-3 text-sm text-status-error-text\"\n >\n {serverError}\n </p>\n )}\n </div>\n </Modal>\n);\n\n/** A shortcut into a live analytics view. */\nconst LIVE_VIEWS = [\n {\n id: \"campaigns\",\n name: \"Campaign performance\",\n description: \"Revenue, conversions and ROAS by campaign.\",\n icon: <Target className=\"h-5 w-5\" />,\n segment: \"/analytics/campaigns\",\n },\n {\n id: \"channels\",\n name: \"Channel analytics\",\n description: \"Revenue, ROAS and attribution by channel.\",\n icon: <BarChart3 className=\"h-5 w-5\" />,\n segment: \"/analytics\",\n },\n {\n id: \"ads\",\n name: \"Ad performance\",\n description: \"Paid spend, CPC and ROAS by platform.\",\n icon: <TrendingUp className=\"h-5 w-5\" />,\n segment: \"/analytics/ads\",\n },\n {\n id: \"social\",\n name: \"Social digest\",\n description: \"Reach, engagement and top posts by platform.\",\n icon: <Share2 className=\"h-5 w-5\" />,\n segment: \"/analytics/social\",\n },\n {\n id: \"attribution\",\n name: \"Attribution\",\n description: \"Which touches earned your won revenue.\",\n icon: <Users className=\"h-5 w-5\" />,\n segment: \"/analytics/attribution\",\n },\n {\n id: \"pipeline\",\n name: \"Lead pipeline\",\n description: \"Deals and value across your CRM pipeline.\",\n icon: <DollarSign className=\"h-5 w-5\" />,\n segment: \"/crm/pipeline\",\n },\n];\n\nexport const ReportsPage: FC = () => {\n const { navigate, basePath } = useHeadshotMarketing();\n const [searchParams, setSearchParams] = useSearchParams();\n const selectedId = searchParams.get(\"report\");\n const { toasts, toast, dismiss } = useToast();\n const [now] = useState(() => new Date());\n\n const reportsQuery = useHeadshotmarketingSavedReportsQuery({\n variables: { pagination: { limit: REPORTS_PAGE_SIZE } },\n fetchPolicy: \"cache-and-network\",\n });\n const [loadingMore, setLoadingMore] = useState(false);\n const reports: SavedReport[] =\n reportsQuery.data?.headshotmarketingSavedReports.items ?? [];\n const reportsTotal = reportsQuery.data?.headshotmarketingSavedReports.total;\n const hasMoreReports =\n reportsQuery.data?.headshotmarketingSavedReports.hasMore ?? false;\n const listed = reports.find((r) => r.id === selectedId) ?? null;\n const listLoaded = !reportsQuery.loading && reportsQuery.data !== undefined;\n // A shared link can point at a report outside the loaded page of the list,\n // so a selection the list does not hold is resolved by id on its own.\n const lookupById = selectedId !== null && listed === null && listLoaded;\n const byIdQuery = useHeadshotmarketingSavedReportQuery({\n variables: { id: selectedId ?? \"\" },\n skip: !lookupById,\n fetchPolicy: \"cache-and-network\",\n });\n const selected: SavedReport | null =\n listed ??\n (lookupById\n ? (byIdQuery.data?.headshotmarketingSavedReport ?? null)\n : null);\n const missingSelection =\n lookupById &&\n selected === null &&\n !byIdQuery.loading &&\n (byIdQuery.data !== undefined || byIdQuery.error !== undefined);\n const definition = selected ? definitionOf(selected) : EXECUTIVE_SUMMARY;\n\n const dateWindow = useMemo(\n () =>\n resolveDateWindow(\n definition.dateRange,\n now,\n definition.customStartDate,\n definition.customEndDate,\n ),\n [\n definition.dateRange,\n definition.customStartDate,\n definition.customEndDate,\n now,\n ],\n );\n const windowLabel = dateWindow ? formatWindow(dateWindow) : \"—\";\n const data = useAnalyticsData(dateWindow, 10);\n\n // Editor state: null = closed; reportId null = creating a new report.\n const [editor, setEditor] = useState<{\n reportId: string | null;\n draft: ReportDraft;\n } | null>(null);\n const [showErrors, setShowErrors] = useState(false);\n const [serverError, setServerError] = useState<string | null>(null);\n const [deleteOpen, setDeleteOpen] = useState(false);\n const [deleteError, setDeleteError] = useState<string | null>(null);\n\n const [createReport, createState] =\n useHeadshotmarketingCreateSavedReportMutation({\n refetchQueries: REPORTS_REFETCH,\n awaitRefetchQueries: true,\n });\n const [updateReport, updateState] =\n useHeadshotmarketingUpdateSavedReportMutation({\n refetchQueries: REPORTS_REFETCH,\n awaitRefetchQueries: true,\n });\n const [deleteReport, deleteState] =\n useHeadshotmarketingDeleteSavedReportMutation({\n refetchQueries: REPORTS_REFETCH,\n awaitRefetchQueries: true,\n });\n\n // Appends the next page of saved reports (offset paging; the server caps a\n // page at REPORTS_PAGE_SIZE).\n const loadMoreReports = async (): Promise<void> => {\n setLoadingMore(true);\n try {\n await reportsQuery.fetchMore({\n variables: {\n pagination: { limit: REPORTS_PAGE_SIZE, offset: reports.length },\n },\n updateQuery: (previous, { fetchMoreResult }) => {\n const seen = new Set(\n previous.headshotmarketingSavedReports.items.map(\n (r: SavedReport) => r.id,\n ),\n );\n return {\n ...fetchMoreResult,\n headshotmarketingSavedReports: {\n ...fetchMoreResult.headshotmarketingSavedReports,\n items: [\n ...previous.headshotmarketingSavedReports.items,\n ...fetchMoreResult.headshotmarketingSavedReports.items.filter(\n (r: SavedReport) => !seen.has(r.id),\n ),\n ],\n },\n };\n },\n });\n } catch (error) {\n toast({\n title: \"More reports could not be loaded\",\n description: errorMessage(error),\n variant: \"error\",\n });\n } finally {\n setLoadingMore(false);\n }\n };\n\n const selectReport = (id: string | null): void => {\n const next = new URLSearchParams(searchParams);\n if (id) next.set(\"report\", id);\n else next.delete(\"report\");\n setSearchParams(next);\n };\n\n const openEditor = (reportId: string | null, draft: ReportDraft): void => {\n setShowErrors(false);\n setServerError(null);\n setEditor({ reportId, draft });\n };\n\n const draftErrors = editor ? validateDraft(editor.draft, now) : {};\n\n const submitEditor = async (): Promise<void> => {\n if (!editor) return;\n setShowErrors(true);\n if (Object.keys(draftErrors).length > 0) return;\n setServerError(null);\n const input = toReportInput(editor.draft);\n try {\n if (editor.reportId) {\n await updateReport({ variables: { id: editor.reportId, input } });\n toast({ title: \"Report updated\", variant: \"success\" });\n } else {\n const result = await createReport({ variables: { input } });\n const id = result.data?.headshotmarketingCreateSavedReport.id;\n toast({ title: \"Report saved\", variant: \"success\" });\n if (id) selectReport(id);\n }\n setEditor(null);\n } catch (error) {\n setServerError(errorMessage(error));\n }\n };\n\n const confirmDelete = async (): Promise<void> => {\n if (!selected) return;\n setDeleteError(null);\n try {\n await deleteReport({ variables: { id: selected.id } });\n setDeleteOpen(false);\n selectReport(null);\n toast({ title: \"Report deleted\", variant: \"success\" });\n } catch (error) {\n setDeleteError(errorMessage(error));\n }\n };\n\n const shareReport = async (): Promise<void> => {\n if (!selected) return;\n const url = reportShareUrl(globalThis.location.href, selected.id);\n try {\n await navigator.clipboard.writeText(url);\n toast({\n title: \"Link copied\",\n description:\n \"Anyone in this workspace with access to reports can open it.\",\n variant: \"success\",\n });\n } catch {\n toast({\n title: \"Copy this link to share the report\",\n description: url,\n });\n }\n };\n\n const exportCsv = (): void => {\n const { headers, rows } = analyticsCsvRows({\n title: definition.name,\n windowLabel,\n view: data.view,\n attribution: data.attribution,\n });\n const slug =\n definition.name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-|-$/g, \"\") || \"report\";\n exportRowsToCsv(slug, headers, rows);\n };\n\n // Hand the rendered report to the browser's print-to-PDF with a sensible\n // document title, then restore it once the dialog has captured it.\n const exportPdf = (): void => {\n const previousTitle = document.title;\n document.title = `${definition.name} — ${windowLabel}`;\n globalThis.print();\n document.title = previousTitle;\n };\n\n const saving = createState.loading || updateState.loading;\n\n return (\n <PageLayout\n title=\"Reports\"\n description=\"Saved reports you can open, share and export\"\n actions={\n <button\n type=\"button\"\n onClick={() =>\n openEditor(null, draftFrom(EXECUTIVE_SUMMARY, now, \"New report\"))\n }\n className=\"inline-flex min-h-[44px] items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2.5 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90\"\n >\n <Plus className=\"h-4 w-4\" />\n New Report\n </button>\n }\n >\n <PagePurpose>\n Save the views your team reads every week. A report keeps its widgets\n and period — for example the last 30 days — and always shows the latest\n numbers for that period. Share a link with your workspace, export it to\n CSV or save it as a PDF.\n </PagePurpose>\n\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-[300px_minmax(0,1fr)]\">\n {/* Saved report list */}\n <aside\n aria-label=\"Reports\"\n className=\"h-fit rounded-lg border border-border-seam bg-gloss-card p-3 shadow-pop\"\n >\n <h2 className=\"px-2 pb-2 pt-1 text-sm font-semibold text-text-secondary\">\n Reports\n </h2>\n <ul className=\"space-y-1\">\n <li>\n <button\n type=\"button\"\n onClick={() => selectReport(null)}\n aria-current={selected === null ? \"true\" : undefined}\n className={cn(\n \"w-full rounded-md px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\",\n selected === null ? \"bg-bg-sunken\" : \"hover:bg-bg-sunken/50\",\n )}\n >\n <span className=\"block text-sm font-medium text-text-primary\">\n {EXECUTIVE_SUMMARY.name}\n </span>\n <span className=\"mt-1 inline-flex items-center gap-2 text-xs text-text-secondary\">\n <span className=\"rounded bg-action-primary-bg px-1.5 py-0.5 text-action-primary-text\">\n Built-in\n </span>\n {dateRangeLabel(EXECUTIVE_SUMMARY.dateRange)}\n </span>\n </button>\n </li>\n {reports.map((report) => (\n <li key={report.id}>\n <button\n type=\"button\"\n onClick={() => selectReport(report.id)}\n aria-current={selected?.id === report.id ? \"true\" : undefined}\n className={cn(\n \"w-full rounded-md px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\",\n selected?.id === report.id\n ? \"bg-bg-sunken\"\n : \"hover:bg-bg-sunken/50\",\n )}\n >\n <span className=\"block truncate text-sm font-medium text-text-primary\">\n {report.name}\n </span>\n <span className=\"mt-1 inline-flex flex-wrap items-center gap-2 text-xs text-text-secondary\">\n <span className=\"rounded border border-border-seam px-1.5 py-0.5\">\n {dateRangeLabel(report.dateRange)}\n </span>\n Updated{\" \"}\n {new Date(report.updatedAt).toLocaleDateString(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n })}\n </span>\n </button>\n </li>\n ))}\n </ul>\n {hasMoreReports && (\n <button\n type=\"button\"\n onClick={() => void loadMoreReports()}\n disabled={loadingMore}\n className=\"mt-2 w-full rounded-md px-3 py-2 text-left text-xs font-medium text-text-secondary transition-colors hover:bg-bg-sunken/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] disabled:opacity-50\"\n >\n Show more reports\n {reportsTotal !== undefined\n ? ` (${reports.length} of ${reportsTotal})`\n : \"\"}\n </button>\n )}\n {reportsQuery.error && (\n <p className=\"px-2 pt-2 text-xs text-status-error-text\">\n Saved reports could not be loaded: {reportsQuery.error.message}\n </p>\n )}\n {!reportsQuery.error && reportsQuery.data && reports.length === 0 && (\n <p className=\"px-2 pt-2 text-xs text-text-secondary\">\n No saved reports yet. Use New Report, or save the Executive\n Summary as your own.\n </p>\n )}\n </aside>\n\n {/* Report canvas */}\n <section aria-label=\"Report\" className=\"min-w-0 space-y-6\">\n {missingSelection && (\n <p\n role=\"status\"\n className=\"rounded-lg border border-border-seam px-4 py-3 text-sm text-text-secondary\"\n >\n That report no longer exists or is not in this workspace. Showing\n the Executive Summary instead.\n </p>\n )}\n\n <EmphasisPanel>\n <div className=\"flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between\">\n <div className=\"min-w-0\">\n <h2 className=\"text-xl font-bold tracking-tight\">\n <GradientText>{definition.name}</GradientText>\n </h2>\n <p className=\"mt-0.5 text-sm text-text-secondary\">\n {dateRangeLabel(definition.dateRange)}\n {dateWindow ? ` · ${windowLabel}` : \"\"}\n </p>\n {definition.description && (\n <p className=\"mt-1 text-sm text-text-secondary\">\n {definition.description}\n </p>\n )}\n </div>\n <div className=\"flex flex-wrap items-center gap-2\">\n {selected ? (\n <>\n <button\n type=\"button\"\n onClick={() =>\n openEditor(selected.id, draftFrom(definition, now))\n }\n className={BUTTON_SECONDARY}\n >\n <Pencil className=\"h-4 w-4\" />\n Edit\n </button>\n <button\n type=\"button\"\n onClick={() => void shareReport()}\n className={BUTTON_SECONDARY}\n >\n <Share2 className=\"h-4 w-4\" />\n Share\n </button>\n </>\n ) : (\n <button\n type=\"button\"\n onClick={() =>\n openEditor(\n null,\n draftFrom(\n EXECUTIVE_SUMMARY,\n now,\n `${EXECUTIVE_SUMMARY.name} (copy)`,\n ),\n )\n }\n className={BUTTON_SECONDARY}\n >\n <FileText className=\"h-4 w-4\" />\n Save as report\n </button>\n )}\n <button\n type=\"button\"\n onClick={exportCsv}\n disabled={!data.hasData}\n className={BUTTON_SECONDARY}\n >\n <Download className=\"h-4 w-4\" />\n Export CSV\n </button>\n <button\n type=\"button\"\n onClick={exportPdf}\n disabled={!data.hasData}\n title=\"Save this report as a PDF (opens your browser's print dialog)\"\n className={BUTTON_SECONDARY}\n >\n <FileDown className=\"h-4 w-4\" />\n Export PDF\n </button>\n {selected && (\n <button\n type=\"button\"\n onClick={() => {\n setDeleteError(null);\n setDeleteOpen(true);\n }}\n aria-label=\"Delete report\"\n className={cn(BUTTON_SECONDARY, \"text-status-error-text\")}\n >\n <Trash2 className=\"h-4 w-4\" />\n </button>\n )}\n </div>\n </div>\n </EmphasisPanel>\n\n <QueryStateBoundary\n loading={data.loading}\n error={data.error}\n onRetry={data.refetch}\n hasData={data.hasData}\n >\n <AnalyticsSourceNotice\n source={data.view.source}\n windowLabel={windowLabel}\n />\n <div className=\"grid grid-cols-1 gap-6 xl:grid-cols-2\">\n {definition.widgets.map((widget) => (\n <div\n key={widget}\n className={cn(WIDGET_META[widget].wide && \"xl:col-span-2\")}\n >\n <ReportWidgetView\n widget={widget}\n view={data.view}\n attribution={data.attribution}\n attributionLoading={data.attributionLoading}\n attributionError={data.attributionError}\n onOpenCampaign={(id) =>\n navigate(basePath + \"/campaigns/\" + id)\n }\n />\n </div>\n ))}\n <button\n type=\"button\"\n onClick={() =>\n selected\n ? openEditor(selected.id, draftFrom(definition, now))\n : openEditor(\n null,\n draftFrom(\n EXECUTIVE_SUMMARY,\n now,\n `${EXECUTIVE_SUMMARY.name} (copy)`,\n ),\n )\n }\n className=\"flex min-h-[160px] flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-border-seam text-sm font-medium text-text-secondary transition-colors hover:bg-bg-sunken/40 hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] print:hidden\"\n >\n <Plus className=\"h-6 w-6\" />\n Add widget\n </button>\n </div>\n </QueryStateBoundary>\n </section>\n </div>\n\n {/* Live analytics views */}\n <EmphasisPanel>\n <h3 className=\"mb-4 text-sm font-semibold text-text-primary\">\n Open a live view\n </h3>\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3\">\n {LIVE_VIEWS.map((view) => (\n <button\n key={view.id}\n type=\"button\"\n onClick={() => navigate(basePath + view.segment)}\n className=\"group flex items-start gap-3 rounded-lg border border-border-seam bg-gloss-card p-4 text-left shadow-pop transition-colors hover:bg-bg-sunken/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n <span className=\"text-text-secondary transition-colors group-hover:text-action-primary-bg\">\n {view.icon}\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"flex items-center gap-1 text-sm font-medium text-text-primary\">\n {view.name}\n <ArrowUpRight className=\"h-3.5 w-3.5 shrink-0 text-text-secondary opacity-0 transition-opacity group-hover:opacity-100\" />\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {view.description}\n </p>\n </div>\n </button>\n ))}\n </div>\n </EmphasisPanel>\n\n {editor && (\n <ReportEditor\n open\n title={editor.reportId ? \"Edit report\" : \"New report\"}\n submitLabel={editor.reportId ? \"Save changes\" : \"Save report\"}\n draft={editor.draft}\n onChange={(draft) => setEditor({ ...editor, draft })}\n errors={showErrors ? draftErrors : {}}\n serverError={serverError}\n saving={saving}\n onClose={() => setEditor(null)}\n onSubmit={() => void submitEditor()}\n />\n )}\n\n <ConfirmDeleteDialog\n open={deleteOpen}\n onClose={() => setDeleteOpen(false)}\n title=\"Delete report\"\n message={`Delete \"${definition.name}\"? Everyone in the workspace loses this saved report. The underlying analytics are not affected.`}\n deleting={deleteState.loading}\n error={deleteError}\n onConfirm={() => void confirmDelete()}\n />\n\n <ToastContainer\n toasts={toasts.map((t) => ({ ...t, onDismiss: dismiss }))}\n />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwFA,IAAM,IAAkB,CACtB,iCACA,+BACD,EAEK,IAAoB,KAEpB,IACJ;AAIF,SAAS,GAAa,GAAuC;AAC3D,QAAO;EACL,MAAM,EAAO;EACb,aAAa,EAAO,eAAe;EACnC,SAAS,EAAO;EAChB,WAAW,EAAO;EAClB,iBAAiB,EAAO,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AD;OAAG,WAAU;iBAAb,CACG,EAAK,MACN,kBAAC,IAAD,EAAc,WAAU,iGAAkG,CAAA,CACxH;UACJ,kBAAC,KAAD;OAAG,WAAU;iBACV,EAAK;OACJ,CAAA,CACA;QACC;OAjBF,EAAK,GAiBH,CACT;IACE,CAAA,CACQ,EAAA,CAAA;GAEf,KACC,kBAAC,IAAD;IACE,MAAA;IACA,OAAO,EAAO,WAAW,gBAAgB;IACzC,aAAa,EAAO,WAAW,iBAAiB;IAChD,OAAO,EAAO;IACd,WAAW,MAAU,EAAU;KAAE,GAAG;KAAQ;KAAO,CAAC;IACpD,QAAQ,KAAa,KAAc,EAAE;IACxB;IACL;IACR,eAAe,EAAU,KAAK;IAC9B,gBAAgB,KAAK,IAAc;IACnC,CAAA;GAGJ,kBAAC,GAAD;IACE,MAAM;IACN,eAAe,EAAc,GAAM;IACnC,OAAM;IACN,SAAS,WAAW,EAAW,KAAK;IACpC,UAAU,GAAY;IACtB,OAAO;IACP,iBAAiB,KAAK,IAAe;IACrC,CAAA;GAEF,kBAAC,GAAD,EACE,QAAQ,EAAO,KAAK,OAAO;IAAE,GAAG;IAAG,WAAW;IAAS,EAAE,EACzD,CAAA;GACS"}
|
|
1
|
+
{"version":3,"file":"ReportsPage.js","names":[],"sources":["../../../../src/headshotmarketing/pages/analytics/ReportsPage.tsx"],"sourcesContent":["/**\n * Reports Page (mock 15, BOFF-4015)\n *\n * Saved reports on the left, the selected report's canvas on the right. A\n * saved report is a definition — name, description, widgets and date range —\n * stored by `headshotmarketingCreateSavedReport` and shared by everyone in the\n * workspace. Its canvas is drawn at view time from the date-ranged analytics\n * overview and attribution for the report's window, so a \"Last 30 days\"\n * report is always the latest 30 days.\n *\n * Actions: + New Report, Edit (rename, change widgets or range), Add widget,\n * Share (copies a deep link `?report=<id>` that opens the report for any\n * workspace member), Export CSV, Export PDF (the browser's print-to-PDF) and\n * Delete. Without a saved report selected, the built-in Executive Summary is\n * shown and can be saved as a new report.\n *\n * Schedule (BOFF-10585) emails a saved report to chosen workspace members\n * weekly or monthly; the list shows each report's cadence badge and the\n * canvas header its next delivery and last delivery status.\n *\n * @module headshotmarketing/pages/analytics\n */\n\nimport { useMemo, useState, type FC } from \"react\";\nimport { useSearchParams } from \"react-router\";\nimport {\n ArrowUpRight,\n BarChart3,\n CalendarClock,\n DollarSign,\n Download,\n FileDown,\n FileText,\n Pencil,\n Plus,\n Share2,\n Target,\n Trash2,\n TrendingUp,\n Users,\n} from \"lucide-react\";\nimport {\n ConfirmDeleteDialog,\n Modal,\n PageLayout,\n QueryStateBoundary,\n ToastContainer,\n} from \"../../components\";\nimport {\n EmphasisPanel,\n GradientText,\n PagePurpose,\n} from \"@burdenoff/fe-libs/ui\";\nimport { cn, exportRowsToCsv } from \"../../utils/helpers\";\nimport { useToast } from \"../../hooks/useToast\";\nimport { useHeadshotMarketing } from \"../../context/HeadshotMarketingContext\";\nimport {\n useHeadshotmarketingCreateSavedReportMutation,\n useHeadshotmarketingDeleteSavedReportMutation,\n useHeadshotmarketingDeleteSavedReportScheduleMutation,\n useHeadshotmarketingSendSavedReportNowMutation,\n useHeadshotmarketingSetSavedReportScheduleMutation,\n useHeadshotmarketingSavedReportQuery,\n useHeadshotmarketingSavedReportsQuery,\n useHeadshotmarketingUpdateSavedReportMutation,\n type HeadshotmarketingSavedReportFieldsFragment,\n} from \"../../../generated/wspace-operations\";\nimport {\n analyticsCsvRows,\n dateRangeLabel,\n formatWindow,\n resolveDateWindow,\n} from \"./analyticsView\";\nimport {\n AnalyticsSourceNotice,\n DateRangeControl,\n ReportWidgetView,\n WIDGET_META,\n} from \"./analyticsWidgets\";\nimport {\n EXECUTIVE_SUMMARY,\n WIDGET_ORDER,\n draftFrom,\n reportShareUrl,\n toReportInput,\n toggleWidget,\n validateDraft,\n type DraftErrors,\n type ReportDefinition,\n type ReportDraft,\n} from \"./reportDraft\";\nimport { useAnalyticsData } from \"./useAnalyticsData\";\nimport { ReportScheduleDialog } from \"./ReportScheduleDialog\";\nimport {\n browserTimezone,\n cadenceBadge,\n deliveryStatusLabel,\n deliveryStatusTone,\n describeSchedule,\n formatInstant,\n scheduleDraftFrom,\n toScheduleInput,\n validateScheduleDraft,\n type ScheduleDraft,\n} from \"./reportSchedule\";\n\nconst REPORTS_REFETCH = [\n \"HeadshotmarketingSavedReports\",\n \"HeadshotmarketingSavedReport\",\n];\nconst SCHEDULE_REFETCH = [\n ...REPORTS_REFETCH,\n \"HeadshotmarketingSavedReportDeliveryRuns\",\n];\n\nconst STATUS_TONE_CLASSES = {\n success: \"text-status-success-text\",\n warning: \"text-status-warning-text\",\n error: \"text-status-error-text\",\n neutral: \"text-text-secondary\",\n} as const;\n/** Saved reports per page; the server caps a page at 100. */\nconst REPORTS_PAGE_SIZE = 100;\n\nconst BUTTON_SECONDARY =\n \"inline-flex min-h-[40px] items-center gap-2 rounded-md border border-border-seam bg-bg-surface px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-60\";\n\ntype SavedReport = HeadshotmarketingSavedReportFieldsFragment;\n\nfunction definitionOf(report: SavedReport): ReportDefinition {\n return {\n name: report.name,\n description: report.description ?? null,\n widgets: report.widgets,\n dateRange: report.dateRange,\n customStartDate: report.customStartDate ?? null,\n customEndDate: report.customEndDate ?? null,\n };\n}\n\nconst errorMessage = (error: unknown): string =>\n error instanceof Error ? error.message : \"Something went wrong.\";\n\n/** New / edit report dialog. */\nconst ReportEditor: FC<{\n open: boolean;\n title: string;\n submitLabel: string;\n draft: ReportDraft;\n onChange: (draft: ReportDraft) => void;\n errors: DraftErrors;\n serverError: string | null;\n saving: boolean;\n onClose: () => void;\n onSubmit: () => void;\n}> = ({\n open,\n title,\n submitLabel,\n draft,\n onChange,\n errors,\n serverError,\n saving,\n onClose,\n onSubmit,\n}) => (\n <Modal\n open={open}\n onClose={onClose}\n title={title}\n description=\"Choose what the report shows and the period it covers.\"\n size=\"lg\"\n footer={\n <>\n <button\n type=\"button\"\n onClick={onClose}\n disabled={saving}\n className={BUTTON_SECONDARY}\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={onSubmit}\n disabled={saving}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 disabled:cursor-not-allowed disabled:opacity-60\"\n >\n {saving ? \"Saving…\" : submitLabel}\n </button>\n </>\n }\n >\n <div className=\"space-y-5\">\n <div>\n <label\n htmlFor=\"hm-report-name\"\n className=\"mb-1 block text-sm font-medium text-text-primary\"\n >\n Name\n </label>\n <input\n id=\"hm-report-name\"\n value={draft.name}\n onChange={(e) => onChange({ ...draft, name: e.target.value })}\n aria-invalid={Boolean(errors.name)}\n className={cn(\n \"min-h-[44px] w-full rounded-md border bg-bg-surface px-3 py-2 text-sm text-text-primary\",\n errors.name ? \"border-status-error-border\" : \"border-border-seam\",\n )}\n placeholder=\"e.g. Weekly Executive Summary\"\n />\n {errors.name && (\n <p className=\"mt-1 text-xs text-status-error-text\">{errors.name}</p>\n )}\n </div>\n\n <div>\n <label\n htmlFor=\"hm-report-description\"\n className=\"mb-1 block text-sm font-medium text-text-primary\"\n >\n Description <span className=\"text-text-secondary\">(optional)</span>\n </label>\n <textarea\n id=\"hm-report-description\"\n value={draft.description}\n onChange={(e) => onChange({ ...draft, description: e.target.value })}\n rows={2}\n aria-invalid={Boolean(errors.description)}\n className={cn(\n \"w-full rounded-md border bg-bg-surface px-3 py-2 text-sm text-text-primary\",\n errors.description\n ? \"border-status-error-border\"\n : \"border-border-seam\",\n )}\n />\n {errors.description && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {errors.description}\n </p>\n )}\n </div>\n\n <div>\n <p className=\"mb-1 text-sm font-medium text-text-primary\">Period</p>\n <DateRangeControl\n idPrefix=\"hm-report-editor\"\n value={{\n preset: draft.dateRange,\n customStart: draft.customStart,\n customEnd: draft.customEnd,\n }}\n onChange={(value) =>\n onChange({\n ...draft,\n dateRange: value.preset,\n customStart: value.customStart,\n customEnd: value.customEnd,\n })\n }\n invalid={Boolean(errors.dateRange)}\n />\n {errors.dateRange && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {errors.dateRange}\n </p>\n )}\n </div>\n\n <fieldset>\n <legend className=\"mb-2 text-sm font-medium text-text-primary\">\n Widgets\n </legend>\n <div className=\"grid grid-cols-1 gap-2 sm:grid-cols-2\">\n {WIDGET_ORDER.map((widget) => {\n const meta = WIDGET_META[widget];\n const checked = draft.widgets.includes(widget);\n return (\n <label\n key={widget}\n className={cn(\n \"flex cursor-pointer items-start gap-3 rounded-lg border p-3 transition-colors\",\n checked\n ? \"border-action-primary-bg bg-bg-sunken/40\"\n : \"border-border-seam hover:bg-bg-sunken/30\",\n )}\n >\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={() =>\n onChange({\n ...draft,\n widgets: toggleWidget(draft.widgets, widget),\n })\n }\n className=\"mt-0.5 h-4 w-4\"\n />\n <span className=\"min-w-0\">\n <span className=\"flex items-center gap-1.5 text-sm font-medium text-text-primary\">\n {meta.icon}\n {meta.label}\n </span>\n <span className=\"mt-0.5 block text-xs text-text-secondary\">\n {meta.description}\n </span>\n </span>\n </label>\n );\n })}\n </div>\n {errors.widgets && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {errors.widgets}\n </p>\n )}\n </fieldset>\n\n {serverError && (\n <p\n role=\"alert\"\n className=\"rounded-lg border border-status-error-border px-4 py-3 text-sm text-status-error-text\"\n >\n {serverError}\n </p>\n )}\n </div>\n </Modal>\n);\n\n/** A shortcut into a live analytics view. */\nconst LIVE_VIEWS = [\n {\n id: \"campaigns\",\n name: \"Campaign performance\",\n description: \"Revenue, conversions and ROAS by campaign.\",\n icon: <Target className=\"h-5 w-5\" />,\n segment: \"/analytics/campaigns\",\n },\n {\n id: \"channels\",\n name: \"Channel analytics\",\n description: \"Revenue, ROAS and attribution by channel.\",\n icon: <BarChart3 className=\"h-5 w-5\" />,\n segment: \"/analytics\",\n },\n {\n id: \"ads\",\n name: \"Ad performance\",\n description: \"Paid spend, CPC and ROAS by platform.\",\n icon: <TrendingUp className=\"h-5 w-5\" />,\n segment: \"/analytics/ads\",\n },\n {\n id: \"social\",\n name: \"Social digest\",\n description: \"Reach, engagement and top posts by platform.\",\n icon: <Share2 className=\"h-5 w-5\" />,\n segment: \"/analytics/social\",\n },\n {\n id: \"attribution\",\n name: \"Attribution\",\n description: \"Which touches earned your won revenue.\",\n icon: <Users className=\"h-5 w-5\" />,\n segment: \"/analytics/attribution\",\n },\n {\n id: \"pipeline\",\n name: \"Lead pipeline\",\n description: \"Deals and value across your CRM pipeline.\",\n icon: <DollarSign className=\"h-5 w-5\" />,\n segment: \"/crm/pipeline\",\n },\n];\n\nexport const ReportsPage: FC = () => {\n const { navigate, basePath, workspaceId, currentUser } =\n useHeadshotMarketing();\n const [searchParams, setSearchParams] = useSearchParams();\n const selectedId = searchParams.get(\"report\");\n const { toasts, toast, dismiss } = useToast();\n const [now] = useState(() => new Date());\n\n const reportsQuery = useHeadshotmarketingSavedReportsQuery({\n variables: { pagination: { limit: REPORTS_PAGE_SIZE } },\n fetchPolicy: \"cache-and-network\",\n });\n const [loadingMore, setLoadingMore] = useState(false);\n const reports: SavedReport[] =\n reportsQuery.data?.headshotmarketingSavedReports.items ?? [];\n const reportsTotal = reportsQuery.data?.headshotmarketingSavedReports.total;\n const hasMoreReports =\n reportsQuery.data?.headshotmarketingSavedReports.hasMore ?? false;\n const listed = reports.find((r) => r.id === selectedId) ?? null;\n const listLoaded = !reportsQuery.loading && reportsQuery.data !== undefined;\n // A shared link can point at a report outside the loaded page of the list,\n // so a selection the list does not hold is resolved by id on its own.\n const lookupById = selectedId !== null && listed === null && listLoaded;\n const byIdQuery = useHeadshotmarketingSavedReportQuery({\n variables: { id: selectedId ?? \"\" },\n skip: !lookupById,\n fetchPolicy: \"cache-and-network\",\n });\n const selected: SavedReport | null =\n listed ??\n (lookupById\n ? (byIdQuery.data?.headshotmarketingSavedReport ?? null)\n : null);\n const missingSelection =\n lookupById &&\n selected === null &&\n !byIdQuery.loading &&\n (byIdQuery.data !== undefined || byIdQuery.error !== undefined);\n const definition = selected ? definitionOf(selected) : EXECUTIVE_SUMMARY;\n\n const dateWindow = useMemo(\n () =>\n resolveDateWindow(\n definition.dateRange,\n now,\n definition.customStartDate,\n definition.customEndDate,\n ),\n [\n definition.dateRange,\n definition.customStartDate,\n definition.customEndDate,\n now,\n ],\n );\n const windowLabel = dateWindow ? formatWindow(dateWindow) : \"—\";\n const data = useAnalyticsData(dateWindow, 10);\n\n // Editor state: null = closed; reportId null = creating a new report.\n const [editor, setEditor] = useState<{\n reportId: string | null;\n draft: ReportDraft;\n } | null>(null);\n const [showErrors, setShowErrors] = useState(false);\n const [serverError, setServerError] = useState<string | null>(null);\n const [deleteOpen, setDeleteOpen] = useState(false);\n const [deleteError, setDeleteError] = useState<string | null>(null);\n // Schedule dialog: null = closed.\n const [scheduleDraft, setScheduleDraft] = useState<ScheduleDraft | null>(\n null,\n );\n const [showScheduleErrors, setShowScheduleErrors] = useState(false);\n const [scheduleError, setScheduleError] = useState<string | null>(null);\n\n const [createReport, createState] =\n useHeadshotmarketingCreateSavedReportMutation({\n refetchQueries: REPORTS_REFETCH,\n awaitRefetchQueries: true,\n });\n const [updateReport, updateState] =\n useHeadshotmarketingUpdateSavedReportMutation({\n refetchQueries: REPORTS_REFETCH,\n awaitRefetchQueries: true,\n });\n const [deleteReport, deleteState] =\n useHeadshotmarketingDeleteSavedReportMutation({\n refetchQueries: REPORTS_REFETCH,\n awaitRefetchQueries: true,\n });\n const [setSchedule, setScheduleState] =\n useHeadshotmarketingSetSavedReportScheduleMutation({\n refetchQueries: SCHEDULE_REFETCH,\n awaitRefetchQueries: true,\n });\n const [removeSchedule, removeScheduleState] =\n useHeadshotmarketingDeleteSavedReportScheduleMutation({\n refetchQueries: SCHEDULE_REFETCH,\n awaitRefetchQueries: true,\n });\n const [sendNow, sendNowState] =\n useHeadshotmarketingSendSavedReportNowMutation({\n refetchQueries: SCHEDULE_REFETCH,\n awaitRefetchQueries: true,\n });\n\n // Appends the next page of saved reports (offset paging; the server caps a\n // page at REPORTS_PAGE_SIZE).\n const loadMoreReports = async (): Promise<void> => {\n setLoadingMore(true);\n try {\n await reportsQuery.fetchMore({\n variables: {\n pagination: { limit: REPORTS_PAGE_SIZE, offset: reports.length },\n },\n updateQuery: (previous, { fetchMoreResult }) => {\n const seen = new Set(\n previous.headshotmarketingSavedReports.items.map(\n (r: SavedReport) => r.id,\n ),\n );\n return {\n ...fetchMoreResult,\n headshotmarketingSavedReports: {\n ...fetchMoreResult.headshotmarketingSavedReports,\n items: [\n ...previous.headshotmarketingSavedReports.items,\n ...fetchMoreResult.headshotmarketingSavedReports.items.filter(\n (r: SavedReport) => !seen.has(r.id),\n ),\n ],\n },\n };\n },\n });\n } catch (error) {\n toast({\n title: \"More reports could not be loaded\",\n description: errorMessage(error),\n variant: \"error\",\n });\n } finally {\n setLoadingMore(false);\n }\n };\n\n const selectReport = (id: string | null): void => {\n const next = new URLSearchParams(searchParams);\n if (id) next.set(\"report\", id);\n else next.delete(\"report\");\n setSearchParams(next);\n };\n\n const openEditor = (reportId: string | null, draft: ReportDraft): void => {\n setShowErrors(false);\n setServerError(null);\n setEditor({ reportId, draft });\n };\n\n const draftErrors = editor ? validateDraft(editor.draft, now) : {};\n\n const submitEditor = async (): Promise<void> => {\n if (!editor) return;\n setShowErrors(true);\n if (Object.keys(draftErrors).length > 0) return;\n setServerError(null);\n const input = toReportInput(editor.draft);\n try {\n if (editor.reportId) {\n await updateReport({ variables: { id: editor.reportId, input } });\n toast({ title: \"Report updated\", variant: \"success\" });\n } else {\n const result = await createReport({ variables: { input } });\n const id = result.data?.headshotmarketingCreateSavedReport.id;\n toast({ title: \"Report saved\", variant: \"success\" });\n if (id) selectReport(id);\n }\n setEditor(null);\n } catch (error) {\n setServerError(errorMessage(error));\n }\n };\n\n const confirmDelete = async (): Promise<void> => {\n if (!selected) return;\n setDeleteError(null);\n try {\n await deleteReport({ variables: { id: selected.id } });\n setDeleteOpen(false);\n selectReport(null);\n toast({ title: \"Report deleted\", variant: \"success\" });\n } catch (error) {\n setDeleteError(errorMessage(error));\n }\n };\n\n const selectedSchedule = selected?.schedule ?? null;\n const scheduleErrors = scheduleDraft\n ? validateScheduleDraft(scheduleDraft)\n : {};\n const scheduleBusy = setScheduleState.loading\n ? \"save\"\n : removeScheduleState.loading\n ? \"remove\"\n : sendNowState.loading\n ? \"send\"\n : null;\n\n const openSchedule = (): void => {\n if (!selected) return;\n setShowScheduleErrors(false);\n setScheduleError(null);\n setScheduleDraft(\n scheduleDraftFrom(selectedSchedule, {\n timezone: browserTimezone(),\n recipientUserId: currentUser?.id ?? null,\n }),\n );\n };\n\n const saveSchedule = async (): Promise<void> => {\n if (!selected || !scheduleDraft) return;\n setShowScheduleErrors(true);\n if (Object.keys(scheduleErrors).length > 0) return;\n setScheduleError(null);\n try {\n await setSchedule({\n variables: {\n reportId: selected.id,\n input: toScheduleInput(scheduleDraft),\n },\n });\n setScheduleDraft(null);\n toast({\n title: scheduleDraft.enabled ? \"Schedule saved\" : \"Schedule paused\",\n variant: \"success\",\n });\n } catch (error) {\n setScheduleError(errorMessage(error));\n }\n };\n\n const deleteSchedule = async (): Promise<void> => {\n if (!selected) return;\n setScheduleError(null);\n try {\n await removeSchedule({ variables: { reportId: selected.id } });\n setScheduleDraft(null);\n toast({ title: \"Schedule removed\", variant: \"success\" });\n } catch (error) {\n setScheduleError(errorMessage(error));\n }\n };\n\n const sendReportNow = async (): Promise<void> => {\n if (!selected) return;\n setScheduleError(null);\n try {\n const result = await sendNow({ variables: { reportId: selected.id } });\n const run = result.data?.headshotmarketingSendSavedReportNow;\n if (!run) return;\n const tone = deliveryStatusTone(run.status);\n toast({\n title: `${deliveryStatusLabel(run.status)}: ${run.deliveredCount} of ${run.recipientCount} recipients`,\n description: run.error ?? undefined,\n variant:\n tone === \"success\"\n ? \"success\"\n : tone === \"error\"\n ? \"error\"\n : undefined,\n });\n } catch (error) {\n setScheduleError(errorMessage(error));\n }\n };\n\n const shareReport = async (): Promise<void> => {\n if (!selected) return;\n const url = reportShareUrl(globalThis.location.href, selected.id);\n try {\n await navigator.clipboard.writeText(url);\n toast({\n title: \"Link copied\",\n description:\n \"Anyone in this workspace with access to reports can open it.\",\n variant: \"success\",\n });\n } catch {\n toast({\n title: \"Copy this link to share the report\",\n description: url,\n });\n }\n };\n\n const exportCsv = (): void => {\n const { headers, rows } = analyticsCsvRows({\n title: definition.name,\n windowLabel,\n view: data.view,\n attribution: data.attribution,\n });\n const slug =\n definition.name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-|-$/g, \"\") || \"report\";\n exportRowsToCsv(slug, headers, rows);\n };\n\n // Hand the rendered report to the browser's print-to-PDF with a sensible\n // document title, then restore it once the dialog has captured it.\n const exportPdf = (): void => {\n const previousTitle = document.title;\n document.title = `${definition.name} — ${windowLabel}`;\n globalThis.print();\n document.title = previousTitle;\n };\n\n const saving = createState.loading || updateState.loading;\n\n return (\n <PageLayout\n title=\"Reports\"\n description=\"Saved reports you can open, share and export\"\n actions={\n <button\n type=\"button\"\n onClick={() =>\n openEditor(null, draftFrom(EXECUTIVE_SUMMARY, now, \"New report\"))\n }\n className=\"inline-flex min-h-[44px] items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2.5 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90\"\n >\n <Plus className=\"h-4 w-4\" />\n New Report\n </button>\n }\n >\n <PagePurpose>\n Save the views your team reads every week. A report keeps its widgets\n and period — for example the last 30 days — and always shows the latest\n numbers for that period. Share a link with your workspace, export it to\n CSV or save it as a PDF.\n </PagePurpose>\n\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-[300px_minmax(0,1fr)]\">\n {/* Saved report list */}\n <aside\n aria-label=\"Reports\"\n className=\"h-fit rounded-lg border border-border-seam bg-gloss-card p-3 shadow-pop\"\n >\n <h2 className=\"px-2 pb-2 pt-1 text-sm font-semibold text-text-secondary\">\n Reports\n </h2>\n <ul className=\"space-y-1\">\n <li>\n <button\n type=\"button\"\n onClick={() => selectReport(null)}\n aria-current={selected === null ? \"true\" : undefined}\n className={cn(\n \"w-full rounded-md px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\",\n selected === null ? \"bg-bg-sunken\" : \"hover:bg-bg-sunken/50\",\n )}\n >\n <span className=\"block text-sm font-medium text-text-primary\">\n {EXECUTIVE_SUMMARY.name}\n </span>\n <span className=\"mt-1 inline-flex items-center gap-2 text-xs text-text-secondary\">\n <span className=\"rounded bg-action-primary-bg px-1.5 py-0.5 text-action-primary-text\">\n Built-in\n </span>\n {dateRangeLabel(EXECUTIVE_SUMMARY.dateRange)}\n </span>\n </button>\n </li>\n {reports.map((report) => (\n <li key={report.id}>\n <button\n type=\"button\"\n onClick={() => selectReport(report.id)}\n aria-current={selected?.id === report.id ? \"true\" : undefined}\n className={cn(\n \"w-full rounded-md px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\",\n selected?.id === report.id\n ? \"bg-bg-sunken\"\n : \"hover:bg-bg-sunken/50\",\n )}\n >\n <span className=\"block truncate text-sm font-medium text-text-primary\">\n {report.name}\n </span>\n <span className=\"mt-1 inline-flex flex-wrap items-center gap-2 text-xs text-text-secondary\">\n <span className=\"rounded border border-border-seam px-1.5 py-0.5\">\n {dateRangeLabel(report.dateRange)}\n </span>\n {report.schedule && (\n <span\n className=\"inline-flex items-center gap-1 rounded bg-bg-sunken px-1.5 py-0.5 text-text-primary\"\n title={describeSchedule(report.schedule)}\n >\n <CalendarClock className=\"h-3 w-3\" />\n {cadenceBadge(report.schedule)}\n </span>\n )}\n Updated{\" \"}\n {new Date(report.updatedAt).toLocaleDateString(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n })}\n </span>\n </button>\n </li>\n ))}\n </ul>\n {hasMoreReports && (\n <button\n type=\"button\"\n onClick={() => void loadMoreReports()}\n disabled={loadingMore}\n className=\"mt-2 w-full rounded-md px-3 py-2 text-left text-xs font-medium text-text-secondary transition-colors hover:bg-bg-sunken/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] disabled:opacity-50\"\n >\n Show more reports\n {reportsTotal !== undefined\n ? ` (${reports.length} of ${reportsTotal})`\n : \"\"}\n </button>\n )}\n {reportsQuery.error && (\n <p className=\"px-2 pt-2 text-xs text-status-error-text\">\n Saved reports could not be loaded: {reportsQuery.error.message}\n </p>\n )}\n {!reportsQuery.error && reportsQuery.data && reports.length === 0 && (\n <p className=\"px-2 pt-2 text-xs text-text-secondary\">\n No saved reports yet. Use New Report, or save the Executive\n Summary as your own.\n </p>\n )}\n </aside>\n\n {/* Report canvas */}\n <section aria-label=\"Report\" className=\"min-w-0 space-y-6\">\n {missingSelection && (\n <p\n role=\"status\"\n className=\"rounded-lg border border-border-seam px-4 py-3 text-sm text-text-secondary\"\n >\n That report no longer exists or is not in this workspace. Showing\n the Executive Summary instead.\n </p>\n )}\n\n <EmphasisPanel>\n <div className=\"flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between\">\n <div className=\"min-w-0\">\n <h2 className=\"text-xl font-bold tracking-tight\">\n <GradientText>{definition.name}</GradientText>\n </h2>\n <p className=\"mt-0.5 text-sm text-text-secondary\">\n {dateRangeLabel(definition.dateRange)}\n {dateWindow ? ` · ${windowLabel}` : \"\"}\n </p>\n {definition.description && (\n <p className=\"mt-1 text-sm text-text-secondary\">\n {definition.description}\n </p>\n )}\n {selectedSchedule && (\n <p\n className=\"mt-1 inline-flex flex-wrap items-center gap-x-1.5 text-xs text-text-secondary\"\n data-testid=\"report-schedule-summary\"\n >\n <CalendarClock className=\"h-3.5 w-3.5\" />\n {selectedSchedule.enabled\n ? `${describeSchedule(selectedSchedule)} · next ${formatInstant(selectedSchedule.nextRunAt)}`\n : \"Delivery paused\"}\n {selectedSchedule.lastRunStatus && (\n <span>\n · last delivery{\" \"}\n <span\n className={\n STATUS_TONE_CLASSES[\n deliveryStatusTone(selectedSchedule.lastRunStatus)\n ]\n }\n title={selectedSchedule.lastRunError ?? undefined}\n >\n {deliveryStatusLabel(selectedSchedule.lastRunStatus)}\n </span>{\" \"}\n {formatInstant(selectedSchedule.lastRunAt)}\n </span>\n )}\n </p>\n )}\n </div>\n <div className=\"flex flex-wrap items-center gap-2\">\n {selected ? (\n <>\n <button\n type=\"button\"\n onClick={() =>\n openEditor(selected.id, draftFrom(definition, now))\n }\n className={BUTTON_SECONDARY}\n >\n <Pencil className=\"h-4 w-4\" />\n Edit\n </button>\n <button\n type=\"button\"\n onClick={() => void shareReport()}\n className={BUTTON_SECONDARY}\n >\n <Share2 className=\"h-4 w-4\" />\n Share\n </button>\n <button\n type=\"button\"\n onClick={openSchedule}\n className={BUTTON_SECONDARY}\n >\n <CalendarClock className=\"h-4 w-4\" />\n Schedule\n </button>\n </>\n ) : (\n <button\n type=\"button\"\n onClick={() =>\n openEditor(\n null,\n draftFrom(\n EXECUTIVE_SUMMARY,\n now,\n `${EXECUTIVE_SUMMARY.name} (copy)`,\n ),\n )\n }\n className={BUTTON_SECONDARY}\n >\n <FileText className=\"h-4 w-4\" />\n Save as report\n </button>\n )}\n <button\n type=\"button\"\n onClick={exportCsv}\n disabled={!data.hasData}\n className={BUTTON_SECONDARY}\n >\n <Download className=\"h-4 w-4\" />\n Export CSV\n </button>\n <button\n type=\"button\"\n onClick={exportPdf}\n disabled={!data.hasData}\n title=\"Save this report as a PDF (opens your browser's print dialog)\"\n className={BUTTON_SECONDARY}\n >\n <FileDown className=\"h-4 w-4\" />\n Export PDF\n </button>\n {selected && (\n <button\n type=\"button\"\n onClick={() => {\n setDeleteError(null);\n setDeleteOpen(true);\n }}\n aria-label=\"Delete report\"\n className={cn(BUTTON_SECONDARY, \"text-status-error-text\")}\n >\n <Trash2 className=\"h-4 w-4\" />\n </button>\n )}\n </div>\n </div>\n </EmphasisPanel>\n\n <QueryStateBoundary\n loading={data.loading}\n error={data.error}\n onRetry={data.refetch}\n hasData={data.hasData}\n >\n <AnalyticsSourceNotice\n source={data.view.source}\n windowLabel={windowLabel}\n />\n <div className=\"grid grid-cols-1 gap-6 xl:grid-cols-2\">\n {definition.widgets.map((widget) => (\n <div\n key={widget}\n className={cn(WIDGET_META[widget].wide && \"xl:col-span-2\")}\n >\n <ReportWidgetView\n widget={widget}\n view={data.view}\n attribution={data.attribution}\n attributionLoading={data.attributionLoading}\n attributionError={data.attributionError}\n onOpenCampaign={(id) =>\n navigate(basePath + \"/campaigns/\" + id)\n }\n />\n </div>\n ))}\n <button\n type=\"button\"\n onClick={() =>\n selected\n ? openEditor(selected.id, draftFrom(definition, now))\n : openEditor(\n null,\n draftFrom(\n EXECUTIVE_SUMMARY,\n now,\n `${EXECUTIVE_SUMMARY.name} (copy)`,\n ),\n )\n }\n className=\"flex min-h-[160px] flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-border-seam text-sm font-medium text-text-secondary transition-colors hover:bg-bg-sunken/40 hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] print:hidden\"\n >\n <Plus className=\"h-6 w-6\" />\n Add widget\n </button>\n </div>\n </QueryStateBoundary>\n </section>\n </div>\n\n {/* Live analytics views */}\n <EmphasisPanel>\n <h3 className=\"mb-4 text-sm font-semibold text-text-primary\">\n Open a live view\n </h3>\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3\">\n {LIVE_VIEWS.map((view) => (\n <button\n key={view.id}\n type=\"button\"\n onClick={() => navigate(basePath + view.segment)}\n className=\"group flex items-start gap-3 rounded-lg border border-border-seam bg-gloss-card p-4 text-left shadow-pop transition-colors hover:bg-bg-sunken/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n <span className=\"text-text-secondary transition-colors group-hover:text-action-primary-bg\">\n {view.icon}\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"flex items-center gap-1 text-sm font-medium text-text-primary\">\n {view.name}\n <ArrowUpRight className=\"h-3.5 w-3.5 shrink-0 text-text-secondary opacity-0 transition-opacity group-hover:opacity-100\" />\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {view.description}\n </p>\n </div>\n </button>\n ))}\n </div>\n </EmphasisPanel>\n\n {editor && (\n <ReportEditor\n open\n title={editor.reportId ? \"Edit report\" : \"New report\"}\n submitLabel={editor.reportId ? \"Save changes\" : \"Save report\"}\n draft={editor.draft}\n onChange={(draft) => setEditor({ ...editor, draft })}\n errors={showErrors ? draftErrors : {}}\n serverError={serverError}\n saving={saving}\n onClose={() => setEditor(null)}\n onSubmit={() => void submitEditor()}\n />\n )}\n\n {selected && scheduleDraft && (\n <ReportScheduleDialog\n open\n reportId={selected.id}\n reportName={selected.name}\n workspaceId={workspaceId}\n schedule={selectedSchedule}\n draft={scheduleDraft}\n onChange={setScheduleDraft}\n errors={showScheduleErrors ? scheduleErrors : {}}\n serverError={scheduleError}\n busy={scheduleBusy}\n onClose={() => setScheduleDraft(null)}\n onSave={() => void saveSchedule()}\n onRemove={() => void deleteSchedule()}\n onSendNow={() => void sendReportNow()}\n />\n )}\n\n <ConfirmDeleteDialog\n open={deleteOpen}\n onClose={() => setDeleteOpen(false)}\n title=\"Delete report\"\n message={`Delete \"${definition.name}\"? Everyone in the workspace loses this saved report. The underlying analytics are not affected.`}\n deleting={deleteState.loading}\n error={deleteError}\n onConfirm={() => void confirmDelete()}\n />\n\n <ToastContainer\n toasts={toasts.map((t) => ({ ...t, onDismiss: dismiss }))}\n />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0GA,IAAM,IAAkB,CACtB,iCACA,+BACD,EACK,IAAmB,CACvB,GAAG,GACH,2CACD,EAEK,KAAsB;CAC1B,SAAS;CACT,SAAS;CACT,OAA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ACD,CAAA,EACP,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,KAAD;OAAG,WAAU;iBAAb,CACG,EAAK,MACN,kBAAC,IAAD,EAAc,WAAU,iGAAkG,CAAA,CACxH;UACJ,kBAAC,KAAD;OAAG,WAAU;iBACV,EAAK;OACJ,CAAA,CACA;QACC;OAjBF,EAAK,GAiBH,CACT;IACE,CAAA,CACQ,EAAA,CAAA;GAEf,KACC,kBAAC,IAAD;IACE,MAAA;IACA,OAAO,EAAO,WAAW,gBAAgB;IACzC,aAAa,EAAO,WAAW,iBAAiB;IAChD,OAAO,EAAO;IACd,WAAW,MAAU,EAAU;KAAE,GAAG;KAAQ;KAAO,CAAC;IACpD,QAAQ,KAAa,KAAc,EAAE;IACxB;IACL;IACR,eAAe,EAAU,KAAK;IAC9B,gBAAgB,KAAK,IAAc;IACnC,CAAA;GAGH,KAAY,KACX,kBAAC,IAAD;IACE,MAAA;IACA,UAAU,EAAS;IACnB,YAAY,EAAS;IACR;IACb,UAAU;IACV,OAAO;IACP,UAAU;IACV,QAAQ,KAAqB,KAAiB,EAAE;IAChD,aAAa;IACb,MAAM;IACN,eAAe,EAAiB,KAAK;IACrC,cAAc,KAAK,IAAc;IACjC,gBAAgB,KAAK,IAAgB;IACrC,iBAAiB,KAAK,IAAe;IACrC,CAAA;GAGJ,kBAAC,IAAD;IACE,MAAM;IACN,eAAe,EAAc,GAAM;IACnC,OAAM;IACN,SAAS,WAAW,EAAW,KAAK;IACpC,UAAU,GAAY;IACtB,OAAO;IACP,iBAAiB,KAAK,IAAe;IACrC,CAAA;GAEF,kBAAC,IAAD,EACE,QAAQ,EAAO,KAAK,OAAO;IAAE,GAAG;IAAG,WAAW;IAAS,EAAE,EACzD,CAAA;GACS"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { HeadshotmarketingReportDeliveryStatus, HeadshotmarketingReportScheduleCadence, HeadshotmarketingSetSavedReportScheduleInput } from '../../../generated/wspace-types';
|
|
2
|
+
|
|
3
|
+
/** The service accepts 1 to 50 recipients per schedule. */
|
|
4
|
+
export declare const MAX_SCHEDULE_RECIPIENTS = 50;
|
|
5
|
+
/** Monthly deliveries run on day 1 to 28 so every month has the day. */
|
|
6
|
+
export declare const MAX_DAY_OF_MONTH = 28;
|
|
7
|
+
export declare const WEEKDAYS: readonly ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
8
|
+
/** The schedule fields the helpers read. */
|
|
9
|
+
export interface ScheduleLike {
|
|
10
|
+
cadence: HeadshotmarketingReportScheduleCadence;
|
|
11
|
+
dayOfWeek?: number | null;
|
|
12
|
+
dayOfMonth?: number | null;
|
|
13
|
+
hour: number;
|
|
14
|
+
timezone: string;
|
|
15
|
+
recipientUserIds: readonly string[];
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ScheduleDraft {
|
|
19
|
+
cadence: HeadshotmarketingReportScheduleCadence;
|
|
20
|
+
dayOfWeek: number;
|
|
21
|
+
dayOfMonth: number;
|
|
22
|
+
hour: number;
|
|
23
|
+
timezone: string;
|
|
24
|
+
recipientUserIds: string[];
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
}
|
|
27
|
+
export type ScheduleDraftErrors = Partial<Record<"dayOfWeek" | "dayOfMonth" | "hour" | "timezone" | "recipients", string>>;
|
|
28
|
+
/** True when the runtime knows `timezone` as an IANA zone. */
|
|
29
|
+
export declare function isValidTimezone(timezone: string): boolean;
|
|
30
|
+
/** The viewer's own timezone, falling back to UTC. */
|
|
31
|
+
export declare function browserTimezone(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Timezones offered in the picker: every zone the runtime knows, with the
|
|
34
|
+
* current value kept even if the list omits it (e.g. "UTC" on some engines).
|
|
35
|
+
*/
|
|
36
|
+
export declare function timezoneOptions(current: string): string[];
|
|
37
|
+
/**
|
|
38
|
+
* A draft for the Schedule dialog: the report's schedule when it has one,
|
|
39
|
+
* otherwise weekly on Monday at 09:00 in the viewer's timezone, sent to the
|
|
40
|
+
* viewer.
|
|
41
|
+
*/
|
|
42
|
+
export declare function scheduleDraftFrom(schedule: ScheduleLike | null | undefined, defaults: {
|
|
43
|
+
timezone: string;
|
|
44
|
+
recipientUserId: string | null;
|
|
45
|
+
}): ScheduleDraft;
|
|
46
|
+
/** Mirrors the service's validation so most mistakes never reach it. */
|
|
47
|
+
export declare function validateScheduleDraft(draft: ScheduleDraft): ScheduleDraftErrors;
|
|
48
|
+
/** The GraphQL input for `headshotmarketingSetSavedReportSchedule`. */
|
|
49
|
+
export declare function toScheduleInput(draft: ScheduleDraft): HeadshotmarketingSetSavedReportScheduleInput;
|
|
50
|
+
/** Adds or removes one recipient. */
|
|
51
|
+
export declare function toggleRecipient(ids: readonly string[], userId: string): string[];
|
|
52
|
+
/** "09:00" for hour 9. */
|
|
53
|
+
export declare function formatHour(hour: number): string;
|
|
54
|
+
/** "1st", "2nd", "3rd", "4th" … "28th". */
|
|
55
|
+
export declare function ordinal(day: number): string;
|
|
56
|
+
/** Badge text for the report list: "Weekly", "Monthly" or "Paused". */
|
|
57
|
+
export declare function cadenceBadge(schedule: ScheduleLike): string;
|
|
58
|
+
/** "Every Monday at 09:00 (Asia/Kolkata)" / "Monthly on the 1st at …". */
|
|
59
|
+
export declare function describeSchedule(schedule: ScheduleLike): string;
|
|
60
|
+
/** Human label for a delivery status. */
|
|
61
|
+
export declare function deliveryStatusLabel(status: HeadshotmarketingReportDeliveryStatus): string;
|
|
62
|
+
/** Tone of a delivery status for colouring. */
|
|
63
|
+
export declare function deliveryStatusTone(status: HeadshotmarketingReportDeliveryStatus): "success" | "warning" | "error" | "neutral";
|
|
64
|
+
/** "Nov 9, 09:00" for an ISO instant, in the viewer's locale and zone. */
|
|
65
|
+
export declare function formatInstant(iso: string | null | undefined): string;
|
|
66
|
+
//# sourceMappingURL=reportSchedule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportSchedule.d.ts","sour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.js";
|
|
2
|
+
var n = [
|
|
3
|
+
"Sunday",
|
|
4
|
+
"Monday",
|
|
5
|
+
"Tuesday",
|
|
6
|
+
"Wednesday",
|
|
7
|
+
"Thursday",
|
|
8
|
+
"Friday",
|
|
9
|
+
"Saturday"
|
|
10
|
+
];
|
|
11
|
+
function r(e) {
|
|
12
|
+
if (!e.trim()) return !1;
|
|
13
|
+
try {
|
|
14
|
+
return new Intl.DateTimeFormat("en-US", { timeZone: e }), !0;
|
|
15
|
+
} catch {
|
|
16
|
+
return !1;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function i() {
|
|
20
|
+
try {
|
|
21
|
+
let e = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
22
|
+
return e && r(e) ? e : "UTC";
|
|
23
|
+
} catch {
|
|
24
|
+
return "UTC";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function a(e) {
|
|
28
|
+
let t = [], n = Intl;
|
|
29
|
+
if (typeof n.supportedValuesOf == "function") try {
|
|
30
|
+
t = n.supportedValuesOf("timeZone");
|
|
31
|
+
} catch {
|
|
32
|
+
t = [];
|
|
33
|
+
}
|
|
34
|
+
let r = new Set(t);
|
|
35
|
+
return r.add("UTC"), e && r.add(e), [...r].sort((e, t) => e.localeCompare(t));
|
|
36
|
+
}
|
|
37
|
+
function o(e, n) {
|
|
38
|
+
return e ? {
|
|
39
|
+
cadence: e.cadence,
|
|
40
|
+
dayOfWeek: e.dayOfWeek ?? 1,
|
|
41
|
+
dayOfMonth: e.dayOfMonth ?? 1,
|
|
42
|
+
hour: e.hour,
|
|
43
|
+
timezone: e.timezone,
|
|
44
|
+
recipientUserIds: [...e.recipientUserIds],
|
|
45
|
+
enabled: e.enabled
|
|
46
|
+
} : {
|
|
47
|
+
cadence: t.Weekly,
|
|
48
|
+
dayOfWeek: 1,
|
|
49
|
+
dayOfMonth: 1,
|
|
50
|
+
hour: 9,
|
|
51
|
+
timezone: n.timezone,
|
|
52
|
+
recipientUserIds: n.recipientUserId ? [n.recipientUserId] : [],
|
|
53
|
+
enabled: !0
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
var s = (e, t, n) => Number.isInteger(e) && e >= t && e <= n;
|
|
57
|
+
function c(e) {
|
|
58
|
+
let n = {};
|
|
59
|
+
e.cadence === t.Weekly && !s(e.dayOfWeek, 0, 6) && (n.dayOfWeek = "Choose a day of the week."), e.cadence === t.Monthly && !s(e.dayOfMonth, 1, 28) && (n.dayOfMonth = "Choose a day from 1 to 28."), s(e.hour, 0, 23) || (n.hour = "Choose an hour from 00:00 to 23:00."), r(e.timezone) || (n.timezone = "Choose a timezone.");
|
|
60
|
+
let i = new Set(e.recipientUserIds);
|
|
61
|
+
return i.size === 0 ? n.recipients = "Choose at least one recipient." : i.size > 50 && (n.recipients = "Choose at most 50 recipients."), n;
|
|
62
|
+
}
|
|
63
|
+
function l(e) {
|
|
64
|
+
let n = e.cadence === t.Weekly;
|
|
65
|
+
return {
|
|
66
|
+
cadence: e.cadence,
|
|
67
|
+
dayOfWeek: n ? e.dayOfWeek : null,
|
|
68
|
+
dayOfMonth: n ? null : e.dayOfMonth,
|
|
69
|
+
hour: e.hour,
|
|
70
|
+
timezone: e.timezone,
|
|
71
|
+
recipientUserIds: [...new Set(e.recipientUserIds)],
|
|
72
|
+
enabled: e.enabled
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function u(e, t) {
|
|
76
|
+
return e.includes(t) ? e.filter((e) => e !== t) : [...e, t];
|
|
77
|
+
}
|
|
78
|
+
function d(e) {
|
|
79
|
+
return `${String(e).padStart(2, "0")}:00`;
|
|
80
|
+
}
|
|
81
|
+
function f(e) {
|
|
82
|
+
let t = e % 100;
|
|
83
|
+
if (t >= 11 && t <= 13) return `${e}th`;
|
|
84
|
+
switch (e % 10) {
|
|
85
|
+
case 1: return `${e}st`;
|
|
86
|
+
case 2: return `${e}nd`;
|
|
87
|
+
case 3: return `${e}rd`;
|
|
88
|
+
default: return `${e}th`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function p(e) {
|
|
92
|
+
return e.enabled ? e.cadence === t.Weekly ? "Weekly" : "Monthly" : "Paused";
|
|
93
|
+
}
|
|
94
|
+
function m(e) {
|
|
95
|
+
let r = `at ${d(e.hour)} (${e.timezone})`;
|
|
96
|
+
return e.cadence === t.Weekly ? `Every ${n[e.dayOfWeek ?? -1] ?? "—"} ${r}` : `Monthly on the ${f(e.dayOfMonth ?? 1)} ${r}`;
|
|
97
|
+
}
|
|
98
|
+
var h = {
|
|
99
|
+
[e.Running]: "Sending",
|
|
100
|
+
[e.Sent]: "Sent",
|
|
101
|
+
[e.Partial]: "Partly sent",
|
|
102
|
+
[e.Failed]: "Failed",
|
|
103
|
+
[e.Skipped]: "Skipped"
|
|
104
|
+
};
|
|
105
|
+
function g(e) {
|
|
106
|
+
return h[e] ?? e;
|
|
107
|
+
}
|
|
108
|
+
function _(t) {
|
|
109
|
+
switch (t) {
|
|
110
|
+
case e.Sent: return "success";
|
|
111
|
+
case e.Partial:
|
|
112
|
+
case e.Skipped: return "warning";
|
|
113
|
+
case e.Failed: return "error";
|
|
114
|
+
default: return "neutral";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function v(e) {
|
|
118
|
+
if (!e) return "—";
|
|
119
|
+
let t = new Date(e);
|
|
120
|
+
return Number.isNaN(t.getTime()) ? "—" : t.toLocaleString("en-US", {
|
|
121
|
+
month: "short",
|
|
122
|
+
day: "numeric",
|
|
123
|
+
hour: "2-digit",
|
|
124
|
+
minute: "2-digit",
|
|
125
|
+
hour12: !1
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { n as WEEKDAYS, i as browserTimezone, p as cadenceBadge, g as deliveryStatusLabel, _ as deliveryStatusTone, m as describeSchedule, d as formatHour, v as formatInstant, f as ordinal, o as scheduleDraftFrom, a as timezoneOptions, l as toScheduleInput, u as toggleRecipient, c as validateScheduleDraft };
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=reportSchedule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportSchedule.js","names":[],"sources":["../../../../src/headshotmarketing/pages/analytics/reportSchedule.ts"],"sourcesContent":["/**\n * Scheduled-delivery helpers for saved reports (BOFF-10585)\n *\n * The form model behind the Schedule dialog on the Reports page: building a\n * draft from a report's existing schedule (or sensible defaults), validating\n * it with the same rules `wspace-headshotmarketing-svc` enforces, turning it\n * into the GraphQL input, and the short labels the page shows for a schedule\n * (cadence badge, \"Every Monday at 09:00 (Asia/Kolkata)\", last delivery).\n *\n * @module headshotmarketing/pages/analytics\n */\n\nimport {\n HeadshotmarketingReportDeliveryStatus,\n HeadshotmarketingReportScheduleCadence,\n type HeadshotmarketingSetSavedReportScheduleInput,\n} from \"../../../generated/wspace-types\";\n\n/** The service accepts 1 to 50 recipients per schedule. */\nexport const MAX_SCHEDULE_RECIPIENTS = 50;\n/** Monthly deliveries run on day 1 to 28 so every month has the day. */\nexport const MAX_DAY_OF_MONTH = 28;\n\nexport const WEEKDAYS = [\n \"Sunday\",\n \"Monday\",\n \"Tuesday\",\n \"Wednesday\",\n \"Thursday\",\n \"Friday\",\n \"Saturday\",\n] as const;\n\n/** The schedule fields the helpers read. */\nexport interface ScheduleLike {\n cadence: HeadshotmarketingReportScheduleCadence;\n dayOfWeek?: number | null;\n dayOfMonth?: number | null;\n hour: number;\n timezone: string;\n recipientUserIds: readonly string[];\n enabled: boolean;\n}\n\nexport interface ScheduleDraft {\n cadence: HeadshotmarketingReportScheduleCadence;\n dayOfWeek: number;\n dayOfMonth: number;\n hour: number;\n timezone: string;\n recipientUserIds: string[];\n enabled: boolean;\n}\n\nexport type ScheduleDraftErrors = Partial<\n Record<\n \"dayOfWeek\" | \"dayOfMonth\" | \"hour\" | \"timezone\" | \"recipients\",\n string\n >\n>;\n\n/** True when the runtime knows `timezone` as an IANA zone. */\nexport function isValidTimezone(timezone: string): boolean {\n if (!timezone.trim()) return false;\n try {\n new Intl.DateTimeFormat(\"en-US\", { timeZone: timezone });\n return true;\n } catch {\n return false;\n }\n}\n\n/** The viewer's own timezone, falling back to UTC. */\nexport function browserTimezone(): string {\n try {\n const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n return zone && isValidTimezone(zone) ? zone : \"UTC\";\n } catch {\n return \"UTC\";\n }\n}\n\n/**\n * Timezones offered in the picker: every zone the runtime knows, with the\n * current value kept even if the list omits it (e.g. \"UTC\" on some engines).\n */\nexport function timezoneOptions(current: string): string[] {\n let zones: string[] = [];\n const intl = Intl as typeof Intl & {\n supportedValuesOf?: (key: \"timeZone\") => string[];\n };\n if (typeof intl.supportedValuesOf === \"function\") {\n try {\n zones = intl.supportedValuesOf(\"timeZone\");\n } catch {\n zones = [];\n }\n }\n const set = new Set(zones);\n set.add(\"UTC\");\n if (current) set.add(current);\n return [...set].sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * A draft for the Schedule dialog: the report's schedule when it has one,\n * otherwise weekly on Monday at 09:00 in the viewer's timezone, sent to the\n * viewer.\n */\nexport function scheduleDraftFrom(\n schedule: ScheduleLike | null | undefined,\n defaults: { timezone: string; recipientUserId: string | null },\n): ScheduleDraft {\n if (schedule) {\n return {\n cadence: schedule.cadence,\n dayOfWeek: schedule.dayOfWeek ?? 1,\n dayOfMonth: schedule.dayOfMonth ?? 1,\n hour: schedule.hour,\n timezone: schedule.timezone,\n recipientUserIds: [...schedule.recipientUserIds],\n enabled: schedule.enabled,\n };\n }\n return {\n cadence: HeadshotmarketingReportScheduleCadence.Weekly,\n dayOfWeek: 1,\n dayOfMonth: 1,\n hour: 9,\n timezone: defaults.timezone,\n recipientUserIds: defaults.recipientUserId\n ? [defaults.recipientUserId]\n : [],\n enabled: true,\n };\n}\n\nconst isIntIn = (value: number, min: number, max: number): boolean =>\n Number.isInteger(value) && value >= min && value <= max;\n\n/** Mirrors the service's validation so most mistakes never reach it. */\nexport function validateScheduleDraft(\n draft: ScheduleDraft,\n): ScheduleDraftErrors {\n const errors: ScheduleDraftErrors = {};\n if (\n draft.cadence === HeadshotmarketingReportScheduleCadence.Weekly &&\n !isIntIn(draft.dayOfWeek, 0, 6)\n ) {\n errors.dayOfWeek = \"Choose a day of the week.\";\n }\n if (\n draft.cadence === HeadshotmarketingReportScheduleCadence.Monthly &&\n !isIntIn(draft.dayOfMonth, 1, MAX_DAY_OF_MONTH)\n ) {\n errors.dayOfMonth = `Choose a day from 1 to ${MAX_DAY_OF_MONTH}.`;\n }\n if (!isIntIn(draft.hour, 0, 23)) {\n errors.hour = \"Choose an hour from 00:00 to 23:00.\";\n }\n if (!isValidTimezone(draft.timezone)) {\n errors.timezone = \"Choose a timezone.\";\n }\n const recipients = new Set(draft.recipientUserIds);\n if (recipients.size === 0) {\n errors.recipients = \"Choose at least one recipient.\";\n } else if (recipients.size > MAX_SCHEDULE_RECIPIENTS) {\n errors.recipients = `Choose at most ${MAX_SCHEDULE_RECIPIENTS} recipients.`;\n }\n return errors;\n}\n\n/** The GraphQL input for `headshotmarketingSetSavedReportSchedule`. */\nexport function toScheduleInput(\n draft: ScheduleDraft,\n): HeadshotmarketingSetSavedReportScheduleInput {\n const weekly =\n draft.cadence === HeadshotmarketingReportScheduleCadence.Weekly;\n return {\n cadence: draft.cadence,\n dayOfWeek: weekly ? draft.dayOfWeek : null,\n dayOfMonth: weekly ? null : draft.dayOfMonth,\n hour: draft.hour,\n timezone: draft.timezone,\n recipientUserIds: [...new Set(draft.recipientUserIds)],\n enabled: draft.enabled,\n };\n}\n\n/** Adds or removes one recipient. */\nexport function toggleRecipient(\n ids: readonly string[],\n userId: string,\n): string[] {\n return ids.includes(userId)\n ? ids.filter((id) => id !== userId)\n : [...ids, userId];\n}\n\n/** \"09:00\" for hour 9. */\nexport function formatHour(hour: number): string {\n return `${String(hour).padStart(2, \"0\")}:00`;\n}\n\n/** \"1st\", \"2nd\", \"3rd\", \"4th\" … \"28th\". */\nexport function ordinal(day: number): string {\n const tens = day % 100;\n if (tens >= 11 && tens <= 13) return `${day}th`;\n switch (day % 10) {\n case 1:\n return `${day}st`;\n case 2:\n return `${day}nd`;\n case 3:\n return `${day}rd`;\n default:\n return `${day}th`;\n }\n}\n\n/** Badge text for the report list: \"Weekly\", \"Monthly\" or \"Paused\". */\nexport function cadenceBadge(schedule: ScheduleLike): string {\n if (!schedule.enabled) return \"Paused\";\n return schedule.cadence === HeadshotmarketingReportScheduleCadence.Weekly\n ? \"Weekly\"\n : \"Monthly\";\n}\n\n/** \"Every Monday at 09:00 (Asia/Kolkata)\" / \"Monthly on the 1st at …\". */\nexport function describeSchedule(schedule: ScheduleLike): string {\n const at = `at ${formatHour(schedule.hour)} (${schedule.timezone})`;\n if (schedule.cadence === HeadshotmarketingReportScheduleCadence.Weekly) {\n const day = WEEKDAYS[schedule.dayOfWeek ?? -1] ?? \"—\";\n return `Every ${day} ${at}`;\n }\n return `Monthly on the ${ordinal(schedule.dayOfMonth ?? 1)} ${at}`;\n}\n\nconst STATUS_LABELS: Record<HeadshotmarketingReportDeliveryStatus, string> = {\n [HeadshotmarketingReportDeliveryStatus.Running]: \"Sending\",\n [HeadshotmarketingReportDeliveryStatus.Sent]: \"Sent\",\n [HeadshotmarketingReportDeliveryStatus.Partial]: \"Partly sent\",\n [HeadshotmarketingReportDeliveryStatus.Failed]: \"Failed\",\n [HeadshotmarketingReportDeliveryStatus.Skipped]: \"Skipped\",\n};\n\n/** Human label for a delivery status. */\nexport function deliveryStatusLabel(\n status: HeadshotmarketingReportDeliveryStatus,\n): string {\n return STATUS_LABELS[status] ?? status;\n}\n\n/** Tone of a delivery status for colouring. */\nexport function deliveryStatusTone(\n status: HeadshotmarketingReportDeliveryStatus,\n): \"success\" | \"warning\" | \"error\" | \"neutral\" {\n switch (status) {\n case HeadshotmarketingReportDeliveryStatus.Sent:\n return \"success\";\n case HeadshotmarketingReportDeliveryStatus.Partial:\n case HeadshotmarketingReportDeliveryStatus.Skipped:\n return \"warning\";\n case HeadshotmarketingReportDeliveryStatus.Failed:\n return \"error\";\n default:\n return \"neutral\";\n }\n}\n\n/** \"Nov 9, 09:00\" for an ISO instant, in the viewer's locale and zone. */\nexport function formatInstant(iso: string | null | undefined): string {\n if (!iso) return \"—\";\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return \"—\";\n return date.toLocaleString(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n hour12: false,\n });\n}\n"],"mappings":";AAuBA,IAAa,IAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AA+BD,SAAgB,EAAgB,GAA2B;AACzD,KAAI,CAAC,EAAS,MAAM,CAAE,QAAO;AAC7B,KAAI;AAEF,SADA,IAAI,KAAK,eAAe,SAAS,EAAE,UAAU,GAAU,CAAC,EACjD;SACD;AACN,SAAO;;;AAKX,SAAgB,IAA0B;AACxC,KAAI;EACF,IAAM,IAAO,KAAK,gBAAgB,CAAC,iBAAiB,CAAC;AACrD,SAAO,KAAQ,EAAgB,EAAK,GAAG,IAAO;SACxC;AACN,SAAO;;;AAQX,SAAgB,EAAgB,GAA2B;CACzD,IAAI,IAAkB,EAAE,EAClB,IAAO;AAGb,KAAI,OAAO,EAAK,qBAAsB,WACpC,KAAI;AACF,MAAQ,EAAK,kBAAkB,WAAW;SACpC;AACN,MAAQ,EAAE;;CAGd,IAAM,IAAM,IAAI,IAAI,EAAM;AAG1B,QAFA,EAAI,IAAI,MAAM,EACV,KAAS,EAAI,IAAI,EAAQ,EACtB,CAAC,GAAG,EAAI,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,EAAE,CAAC;;AAQpD,SAAgB,EACd,GACA,GACe;AAYf,QAXI,IACK;EACL,SAAS,EAAS;EAClB,WAAW,EAAS,aAAa;EACjC,YAAY,EAAS,cAAc;EACnC,MAAM,EAAS;EACf,UAAU,EAAS;EACnB,kBAAkB,CAAC,GAAG,EAAS,iBAAiB;EAChD,SAAS,EAAS;EACnB,GAEI;EAC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
|
+
* Pure presentation helpers for the dashboard home (mock 01): the home
|
|
5
|
+
* window, the daily sparkline series built from the analytics overview's
|
|
6
|
+
* per-channel daily points, the lifecycle funnel stages and the Monthly Goals
|
|
7
|
+
* form. No React, no I/O, so everything is unit tested.
|
|
8
|
+
*
|
|
9
|
+
* @module headshotmarketing
|
|
10
|
+
*/
|
|
11
|
+
/** Days covered by the home's funnel and sparklines (today included). */
|
|
12
|
+
export declare const HOME_WINDOW_DAYS = 30;
|
|
13
|
+
export interface HomeWindow {
|
|
14
|
+
/** ISO timestamp of the first UTC day's start. */
|
|
15
|
+
start: string;
|
|
16
|
+
/** ISO timestamp of the last UTC day's end. */
|
|
17
|
+
end: string;
|
|
18
|
+
/** Every UTC day in the window, oldest first, as YYYY-MM-DD. */
|
|
19
|
+
days: string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The last `days` UTC calendar days ending today: start is 00:00:00.000Z on
|
|
23
|
+
* the first day and end is 23:59:59.999Z today.
|
|
24
|
+
*/
|
|
25
|
+
export declare function homeWindow(now?: Date, days?: number): HomeWindow;
|
|
26
|
+
export interface DailyChannelPoint {
|
|
27
|
+
date: string;
|
|
28
|
+
revenue: number;
|
|
29
|
+
cost: number;
|
|
30
|
+
conversions: number;
|
|
31
|
+
}
|
|
32
|
+
export interface DailySeries {
|
|
33
|
+
revenue: number[];
|
|
34
|
+
conversions: number[];
|
|
35
|
+
/** Revenue / cost per day; 0 on a day without cost. */
|
|
36
|
+
roas: number[];
|
|
37
|
+
/** True when at least one day in the window has a recorded point. */
|
|
38
|
+
hasData: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fold per-channel daily points into one value per day of the window
|
|
42
|
+
* (channels summed), with days that have no record as 0, so each sparkline
|
|
43
|
+
* is a continuous daily series.
|
|
44
|
+
*/
|
|
45
|
+
export declare function toDailySeries(points: readonly DailyChannelPoint[], days: readonly string[]): DailySeries;
|
|
46
|
+
export type LifecycleStageKey = "VISITORS" | "LEADS" | "MQL" | "CUSTOMERS";
|
|
47
|
+
export interface LifecycleStageInput {
|
|
48
|
+
key: LifecycleStageKey;
|
|
49
|
+
count: number;
|
|
50
|
+
conversionRate?: number | null;
|
|
51
|
+
}
|
|
52
|
+
export interface FunnelStageView {
|
|
53
|
+
name: string;
|
|
54
|
+
count: number;
|
|
55
|
+
conversionRate: number | null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Lifecycle stages as the home funnel renders them, labelled by `labels`.
|
|
59
|
+
* Returns an empty list when every stage is 0 so the caller can show its
|
|
60
|
+
* empty state.
|
|
61
|
+
*/
|
|
62
|
+
export declare function toLifecycleFunnelStages(stages: readonly LifecycleStageInput[], labels: Record<LifecycleStageKey, string>): FunnelStageView[];
|
|
63
|
+
export type GoalField = "revenueTarget" | "customersTarget" | "roiTarget" | "trafficTarget";
|
|
64
|
+
export declare const GOAL_FIELDS: readonly GoalField[];
|
|
65
|
+
export type GoalFormValues = Record<GoalField, string>;
|
|
66
|
+
export interface GoalTargets {
|
|
67
|
+
revenueTarget: number | null;
|
|
68
|
+
customersTarget: number | null;
|
|
69
|
+
roiTarget: number | null;
|
|
70
|
+
trafficTarget: number | null;
|
|
71
|
+
}
|
|
72
|
+
export type GoalFormErrorCode = "required" | "notNumber" | "negative" | "notWhole" | "roiRange";
|
|
73
|
+
export interface GoalFormResult {
|
|
74
|
+
targets: GoalTargets | null;
|
|
75
|
+
errors: Partial<Record<GoalField, GoalFormErrorCode>>;
|
|
76
|
+
/** Set when every field is blank. */
|
|
77
|
+
formError: GoalFormErrorCode | null;
|
|
78
|
+
}
|
|
79
|
+
/** Form values for an existing goal (blank for unset targets). */
|
|
80
|
+
export declare function goalFormValues(goal: Partial<Record<GoalField, number | null>> | null | undefined): GoalFormValues;
|
|
81
|
+
/**
|
|
82
|
+
* Parse and validate the goal form with the same rules as the backend:
|
|
83
|
+
* revenue, customers and traffic 0 or more (customers and traffic whole
|
|
84
|
+
* numbers), ROI between 0 and 100000, at least one target set.
|
|
85
|
+
*/
|
|
86
|
+
export declare function parseGoalForm(values: GoalFormValues): GoalFormResult;
|
|
87
|
+
/** Width (0-100) of a goal progress bar; overshoot is capped at a full bar. */
|
|
88
|
+
export declare function progressBarWidth(progressPercent: number | null | undefined): number;
|
|
89
|
+
/** The current UTC month as YYYY-MM. */
|
|
90
|
+
export declare function currentMonth(now?: Date): string;
|
|
91
|
+
//# sourceMappingURL=dashboardHome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboardHome.d.ts","sourceRoot":"","sources":["../../../src/headshotmarketing/utils/dashboardHome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAInC,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,GAAE,IAAiB,EACtB,IAAI,GAAE,MAAyB,GAC9B,UAAU,CAgBZ;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,uDAAuD;IACvD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,qEAAqE;IACrE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,iBAAiB,EAAE,EACpC,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,WAAW,CA4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