@burdenoff/microfe-healthybowl 2026.802.2 → 2026.803.1

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.
@@ -9,45 +9,26 @@ var a = [{
9
9
  }, {
10
10
  value: "healthybowl.order.paid",
11
11
  label: "Order paid (order.paid)"
12
- }], o = "\n id\n name\n key\n isActive\n createdAt\n lastUsedAt\n expiresAt\n permissions\n", s = "\n id\n name\n url\n events\n isActive\n lastDelivery\n lastError\n deliveryCount\n failureCount\n createdAt\n", c = n`
13
- query HealthyBowlApiKeys {
14
- apiKeys {
15
- ${o}
16
- }
17
- }
18
- `, l = n`
19
- mutation HealthyBowlCreateApiKey($input: CreateApiKeyInput!) {
20
- createApiKey(input: $input) {
21
- ${o}
22
- }
23
- }
24
- `, u = n`
25
- mutation HealthyBowlRevokeApiKey($id: ID!) {
26
- revokeApiKey(id: $id) {
27
- id
28
- isActive
29
- }
30
- }
31
- `, d = n`
12
+ }], o = "\n id\n name\n url\n events\n isActive\n lastDelivery\n lastError\n deliveryCount\n failureCount\n createdAt\n", s = n`
32
13
  query HealthyBowlWebhooks {
33
14
  webhooks {
34
15
  items {
35
- ${s}
16
+ ${o}
36
17
  }
37
18
  total
38
19
  }
39
20
  }
40
- `, f = n`
21
+ `, c = n`
41
22
  mutation HealthyBowlCreateWebhook($input: CreateWebhookInput!) {
42
23
  createWebhook(input: $input) {
43
- ${s}
24
+ ${o}
44
25
  }
45
26
  }
46
- `, p = n`
27
+ `, l = n`
47
28
  mutation HealthyBowlDeleteWebhook($id: ID!) {
48
29
  deleteWebhook(id: $id)
49
30
  }
50
- `, m = n`
31
+ `, u = n`
51
32
  query HealthyBowlBigConsoleDashboards($first: Int) {
52
33
  listDashboards(first: $first) {
53
34
  totalCount
@@ -62,60 +43,42 @@ var a = [{
62
43
  }
63
44
  }
64
45
  `;
65
- function h() {
66
- let { workspaceId: n } = e(), a = { workspaceId: n }, o = i(c, {
67
- skip: !n,
68
- fetchPolicy: "cache-and-network",
69
- notifyOnNetworkStatusChange: !0,
70
- errorPolicy: "all"
71
- }), s = i(d, {
46
+ function d() {
47
+ let { workspaceId: n } = e(), a = { workspaceId: n }, o = i(s, {
72
48
  skip: !n,
73
49
  fetchPolicy: "cache-and-network",
74
50
  notifyOnNetworkStatusChange: !0,
75
51
  errorPolicy: "all"
76
- }), h = i(m, {
52
+ }), d = i(u, {
77
53
  variables: { first: 50 },
78
54
  skip: !n,
79
55
  fetchPolicy: "cache-and-network",
80
56
  notifyOnNetworkStatusChange: !0,
81
57
  errorPolicy: "all"
82
- }), [g] = r(l), [_] = r(u), [v] = r(f), [y] = r(p), b = t(async (e, t) => {
83
- let n = await g({ variables: { input: {
84
- name: e,
85
- permissions: t
86
- } } });
87
- return await o.refetch(), n.data?.createApiKey ?? null;
88
- }, [g, o]), x = t(async (e) => {
89
- await _({ variables: { id: e } }), await o.refetch();
90
- }, [_, o]), S = t(async (e) => {
91
- await v({ variables: { input: {
58
+ }), [f] = r(c), [p] = r(l), m = t(async (e) => {
59
+ await f({ variables: { input: {
92
60
  ...e,
93
61
  context: a
94
- } } }), await s.refetch();
62
+ } } }), await o.refetch();
95
63
  }, [
96
- v,
97
- s,
64
+ f,
65
+ o,
98
66
  n
99
- ]), C = t(async (e) => {
100
- await y({ variables: { id: e } }), await s.refetch();
101
- }, [y, s]);
67
+ ]), h = t(async (e) => {
68
+ await p({ variables: { id: e } }), await o.refetch();
69
+ }, [p, o]);
102
70
  return {
103
- apiKeys: o.data?.apiKeys ?? [],
104
- apiKeysLoading: o.loading,
105
- apiKeysError: o.error?.message ?? null,
106
- createApiKey: b,
107
- revokeApiKey: x,
108
- webhooks: s.data?.webhooks?.items ?? [],
109
- webhooksLoading: s.loading,
110
- webhooksError: s.error?.message ?? null,
111
- createWebhook: S,
112
- deleteWebhook: C,
113
- dashboards: (h.data?.listDashboards?.edges ?? []).map((e) => e.node),
114
- dashboardsLoading: h.loading,
115
- dashboardsError: h.error?.message ?? null
71
+ webhooks: o.data?.webhooks?.items ?? [],
72
+ webhooksLoading: o.loading,
73
+ webhooksError: o.error?.message ?? null,
74
+ createWebhook: m,
75
+ deleteWebhook: h,
76
+ dashboards: (d.data?.listDashboards?.edges ?? []).map((e) => e.node),
77
+ dashboardsLoading: d.loading,
78
+ dashboardsError: d.error?.message ?? null
116
79
  };
117
80
  }
118
81
  //#endregion
119
- export { a as HB_WEBHOOK_EVENTS, h as useReportsApi };
82
+ export { a as HB_WEBHOOK_EVENTS, d as useReportsApi };
120
83
 
121
84
  //# sourceMappingURL=useReportsApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useReportsApi.js","names":[],"sources":["../../../src/healthybowl/hooks/useReportsApi.ts"],"sourcesContent":["/**\n * Reports & API management hook (roadmap #19 — Custom Report Builder & Developer API).\n *\n * HealthyBowl owns ONLY the \"Reports & API\" management surface; the engines are reused\n * from sibling products over the workspace gateway (no new HB charting / API / webhook\n * engine — see spec §5):\n *\n * · API keys → wspace-analytics-svc (`apiKeys` / `createApiKey` / `revokeApiKey`,\n * RBAC resource `analytics-api-key`). The key is returned in full ONLY\n * from `createApiKey`; list rows carry the same `key` field, which the\n * UI masks (analytics-svc stores just a 4-char preview for display).\n * · Webhooks → the platform webhook engine (`webhooks` / `createWebhook` /\n * `deleteWebhook`, RBAC resource `webhook`, vibecontrols-owned). Events\n * are free-form strings; HB subscribes its domain events by name.\n * · Dashboards → BigConsole (`listDashboards`, RBAC resource `bigconsole-dashboard`) —\n * the saved no-code dashboards a farmer builds in the BigConsole app.\n *\n * Every read uses `errorPolicy: 'all'` so a cross-product RBAC denial or a cold subgraph\n * degrades to an empty list + a surfaced error, never a page crash — these composed ops\n * depend on cross-product RBAC seeding that is provisioned per environment.\n *\n * Mirrors the hand-written raw-`gql` pattern used across HB (see `useSuppliers`,\n * `useAuctions`) because the offline codegen does not type these composed operations.\n * @module healthybowl\n */\nimport { useCallback } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A workspace-scoped developer API key (analytics-svc). */\nexport interface HBApiKey {\n id: string;\n name: string;\n /** Full secret on create; masked in the list UI. */\n key: string;\n isActive: boolean;\n createdAt: string;\n lastUsedAt?: string | null;\n expiresAt?: string | null;\n permissions: string[];\n}\n\n/** An outbound webhook subscription (platform webhook engine). */\nexport interface HBWebhook {\n id: string;\n name: string;\n url: string;\n events: string[];\n isActive: boolean;\n lastDelivery?: string | null;\n lastError?: string | null;\n deliveryCount: number;\n failureCount: number;\n createdAt: string;\n}\n\n/** A saved BigConsole dashboard (report builder output). */\nexport interface HBDashboard {\n id: string;\n name: string;\n category: string;\n updatedAt: string;\n}\n\n/** The HB domain events a workspace can subscribe a webhook to (spec §3, gap M-2). */\nexport const HB_WEBHOOK_EVENTS = [\n { value: 'healthybowl.harvest.created', label: 'Harvest recorded (harvest.created)' },\n { value: 'healthybowl.order.paid', label: 'Order paid (order.paid)' },\n] as const;\n\nconst API_KEY_FIELDS = `\n id\n name\n key\n isActive\n createdAt\n lastUsedAt\n expiresAt\n permissions\n`;\n\nconst WEBHOOK_FIELDS = `\n id\n name\n url\n events\n isActive\n lastDelivery\n lastError\n deliveryCount\n failureCount\n createdAt\n`;\n\nconst API_KEYS_QUERY = gql`\n query HealthyBowlApiKeys {\n apiKeys {\n ${API_KEY_FIELDS}\n }\n }\n`;\n\nconst CREATE_API_KEY = gql`\n mutation HealthyBowlCreateApiKey($input: CreateApiKeyInput!) {\n createApiKey(input: $input) {\n ${API_KEY_FIELDS}\n }\n }\n`;\n\nconst REVOKE_API_KEY = gql`\n mutation HealthyBowlRevokeApiKey($id: ID!) {\n revokeApiKey(id: $id) {\n id\n isActive\n }\n }\n`;\n\nconst WEBHOOKS_QUERY = gql`\n query HealthyBowlWebhooks {\n webhooks {\n items {\n ${WEBHOOK_FIELDS}\n }\n total\n }\n }\n`;\n\nconst CREATE_WEBHOOK = gql`\n mutation HealthyBowlCreateWebhook($input: CreateWebhookInput!) {\n createWebhook(input: $input) {\n ${WEBHOOK_FIELDS}\n }\n }\n`;\n\nconst DELETE_WEBHOOK = gql`\n mutation HealthyBowlDeleteWebhook($id: ID!) {\n deleteWebhook(id: $id)\n }\n`;\n\nconst DASHBOARDS_QUERY = gql`\n query HealthyBowlBigConsoleDashboards($first: Int) {\n listDashboards(first: $first) {\n totalCount\n edges {\n node {\n id\n name\n category\n updatedAt\n }\n }\n }\n }\n`;\n\ninterface ApiKeysData {\n apiKeys: HBApiKey[];\n}\ninterface CreateApiKeyData {\n createApiKey: HBApiKey;\n}\ninterface WebhooksData {\n webhooks: { items: HBWebhook[]; total: number };\n}\ninterface DashboardsData {\n listDashboards: { totalCount: number; edges: { node: HBDashboard }[] };\n}\n\n/** Editable fields for a new webhook subscription (context is attached from the hook). */\nexport interface WebhookInput {\n name: string;\n url: string;\n events: string[];\n}\n\n/**\n * Loads the workspace's API keys, webhook subscriptions and saved BigConsole\n * dashboards, and exposes create/revoke/delete helpers. Mutations refetch their\n * list so the caller's view stays in sync. Reads never throw — a denied or cold\n * composed op surfaces as an error string with an empty list.\n */\nexport function useReportsApi() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const apiKeysQuery = useQuery<ApiKeysData>(API_KEYS_QUERY, {\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n errorPolicy: 'all',\n });\n\n const webhooksQuery = useQuery<WebhooksData>(WEBHOOKS_QUERY, {\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n errorPolicy: 'all',\n });\n\n const dashboardsQuery = useQuery<DashboardsData>(DASHBOARDS_QUERY, {\n variables: { first: 50 },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n errorPolicy: 'all',\n });\n\n const [createApiKeyMutation] = useMutation<CreateApiKeyData>(CREATE_API_KEY);\n const [revokeApiKeyMutation] = useMutation(REVOKE_API_KEY);\n const [createWebhookMutation] = useMutation(CREATE_WEBHOOK);\n const [deleteWebhookMutation] = useMutation(DELETE_WEBHOOK);\n\n /** Create a key and return the FULL secret once so the caller can reveal + copy it. */\n const createApiKey = useCallback(\n async (name: string, permissions: string[]): Promise<HBApiKey | null> => {\n const res = await createApiKeyMutation({ variables: { input: { name, permissions } } });\n await apiKeysQuery.refetch();\n return res.data?.createApiKey ?? null;\n },\n [createApiKeyMutation, apiKeysQuery]\n );\n\n const revokeApiKey = useCallback(\n async (id: string) => {\n await revokeApiKeyMutation({ variables: { id } });\n await apiKeysQuery.refetch();\n },\n [revokeApiKeyMutation, apiKeysQuery]\n );\n\n const createWebhook = useCallback(\n async (input: WebhookInput) => {\n await createWebhookMutation({ variables: { input: { ...input, context } } });\n await webhooksQuery.refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [createWebhookMutation, webhooksQuery, workspaceId]\n );\n\n const deleteWebhook = useCallback(\n async (id: string) => {\n await deleteWebhookMutation({ variables: { id } });\n await webhooksQuery.refetch();\n },\n [deleteWebhookMutation, webhooksQuery]\n );\n\n return {\n // API keys\n apiKeys: apiKeysQuery.data?.apiKeys ?? [],\n apiKeysLoading: apiKeysQuery.loading,\n apiKeysError: apiKeysQuery.error?.message ?? null,\n createApiKey,\n revokeApiKey,\n // Webhooks\n webhooks: webhooksQuery.data?.webhooks?.items ?? [],\n webhooksLoading: webhooksQuery.loading,\n webhooksError: webhooksQuery.error?.message ?? null,\n createWebhook,\n deleteWebhook,\n // Dashboards (BigConsole)\n dashboards: (dashboardsQuery.data?.listDashboards?.edges ?? []).map((e) => e.node),\n dashboardsLoading: dashboardsQuery.loading,\n dashboardsError: dashboardsQuery.error?.message ?? null,\n };\n}\n"],"mappings":";;;;;AAkEA,IAAa,IAAoB,CAC/B;CAAE,OAAO;CAA+B,OAAO;CAAsC,EACrF;CAAE,OAAO;CAA0B,OAAO;CAA2B,CACtE,EAEK,IAAiB,8FAWjB,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AG;GAAO;GAAS,EAAE,EAAE,CAAC,EAC5E,MAAM,EAAc,SAAS;IAG/B;EAAC;EAAuB;EAAe;EAAY,CACpD,EAEK,IAAgB,EACpB,OAAO,MAAe;AAEpB,EADA,MAAM,EAAsB,EAAE,WAAW,EAAE,OAAI,EAAE,CAAC,EAClD,MAAM,EAAc,SAAS;IAE/B,CAAC,GAAuB,EAAc,CACvC;AAED,QAAO;EAEL,SAAS,EAAa,MAAM,WAAW,EAAE;EACzC,gBAAgB,EAAa;EAC7B,cAAc,EAAa,OAAO,WAAW;EAC7C;EACA;EAEA,UAAU,EAAc,MAAM,UAAU,SAAS,EAAE;EACnD,iBAAiB,EAAc;EAC/B,eAAe,EAAc,OAAO,WAAW;EAC/C;EACA;EAEA,aAAa,EAAgB,MAAM,gBAAgB,SAAS,EAAE,EAAE,KAAK,MAAM,EAAE,KAAK;EAClF,mBAAmB,EAAgB;EACnC,iBAAiB,EAAgB,OAAO,WAAW;EACpD"}
1
+ {"version":3,"file":"useReportsApi.js","names":[],"sources":["../../../src/healthybowl/hooks/useReportsApi.ts"],"sourcesContent":["/**\n * Reports & API management hook (roadmap #19 — Custom Report Builder & Developer API).\n *\n * HealthyBowl owns ONLY the \"Reports & API\" management surface; the engines are reused\n * from sibling products over the workspace gateway (no new HB charting / API / webhook\n * engine — see spec §5):\n *\n * · API keys → REMOVED. wspace-analytics-svc dropped its local API-key stack in\n * 958e761 (\"global-auth-svc is the canonical owner\"): no code path\n * ever read `analytics_api_keys` to authenticate, and it stored the\n * raw key rather than a hash — it minted credentials nothing could\n * redeem. global-auth-svc owns `myApiKeys` / `generateAPIKey` at\n * GLOBAL scope; restoring a key surface here is a feature, not a\n * re-point (it needs an appId, and no revoke op is exposed).\n * · Webhooks → the platform webhook engine (`webhooks` / `createWebhook` /\n * `deleteWebhook`, RBAC resource `webhook`, vibecontrols-owned). Events\n * are free-form strings; HB subscribes its domain events by name.\n * · Dashboards → BigConsole (`listDashboards`, RBAC resource `bigconsole-dashboard`) —\n * the saved no-code dashboards a farmer builds in the BigConsole app.\n *\n * Every read uses `errorPolicy: 'all'` so a cross-product RBAC denial or a cold subgraph\n * degrades to an empty list + a surfaced error, never a page crash — these composed ops\n * depend on cross-product RBAC seeding that is provisioned per environment.\n *\n * Mirrors the hand-written raw-`gql` pattern used across HB (see `useSuppliers`,\n * `useAuctions`) because the offline codegen does not type these composed operations.\n * @module healthybowl\n */\nimport { useCallback } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** An outbound webhook subscription (platform webhook engine). */\nexport interface HBWebhook {\n id: string;\n name: string;\n url: string;\n events: string[];\n isActive: boolean;\n lastDelivery?: string | null;\n lastError?: string | null;\n deliveryCount: number;\n failureCount: number;\n createdAt: string;\n}\n\n/** A saved BigConsole dashboard (report builder output). */\nexport interface HBDashboard {\n id: string;\n name: string;\n category: string;\n updatedAt: string;\n}\n\n/** The HB domain events a workspace can subscribe a webhook to (spec §3, gap M-2). */\nexport const HB_WEBHOOK_EVENTS = [\n { value: 'healthybowl.harvest.created', label: 'Harvest recorded (harvest.created)' },\n { value: 'healthybowl.order.paid', label: 'Order paid (order.paid)' },\n] as const;\n\nconst WEBHOOK_FIELDS = `\n id\n name\n url\n events\n isActive\n lastDelivery\n lastError\n deliveryCount\n failureCount\n createdAt\n`;\n\nconst WEBHOOKS_QUERY = gql`\n query HealthyBowlWebhooks {\n webhooks {\n items {\n ${WEBHOOK_FIELDS}\n }\n total\n }\n }\n`;\n\nconst CREATE_WEBHOOK = gql`\n mutation HealthyBowlCreateWebhook($input: CreateWebhookInput!) {\n createWebhook(input: $input) {\n ${WEBHOOK_FIELDS}\n }\n }\n`;\n\nconst DELETE_WEBHOOK = gql`\n mutation HealthyBowlDeleteWebhook($id: ID!) {\n deleteWebhook(id: $id)\n }\n`;\n\nconst DASHBOARDS_QUERY = gql`\n query HealthyBowlBigConsoleDashboards($first: Int) {\n listDashboards(first: $first) {\n totalCount\n edges {\n node {\n id\n name\n category\n updatedAt\n }\n }\n }\n }\n`;\n\ninterface WebhooksData {\n webhooks: { items: HBWebhook[]; total: number };\n}\ninterface DashboardsData {\n listDashboards: { totalCount: number; edges: { node: HBDashboard }[] };\n}\n\n/** Editable fields for a new webhook subscription (context is attached from the hook). */\nexport interface WebhookInput {\n name: string;\n url: string;\n events: string[];\n}\n\n/**\n * Loads the workspace's API keys, webhook subscriptions and saved BigConsole\n * dashboards, and exposes create/revoke/delete helpers. Mutations refetch their\n * list so the caller's view stays in sync. Reads never throw — a denied or cold\n * composed op surfaces as an error string with an empty list.\n */\nexport function useReportsApi() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const webhooksQuery = useQuery<WebhooksData>(WEBHOOKS_QUERY, {\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n errorPolicy: 'all',\n });\n\n const dashboardsQuery = useQuery<DashboardsData>(DASHBOARDS_QUERY, {\n variables: { first: 50 },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n errorPolicy: 'all',\n });\n\n const [createWebhookMutation] = useMutation(CREATE_WEBHOOK);\n const [deleteWebhookMutation] = useMutation(DELETE_WEBHOOK);\n\n const createWebhook = useCallback(\n async (input: WebhookInput) => {\n await createWebhookMutation({ variables: { input: { ...input, context } } });\n await webhooksQuery.refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [createWebhookMutation, webhooksQuery, workspaceId]\n );\n\n const deleteWebhook = useCallback(\n async (id: string) => {\n await deleteWebhookMutation({ variables: { id } });\n await webhooksQuery.refetch();\n },\n [deleteWebhookMutation, webhooksQuery]\n );\n\n return {\n // Webhooks\n webhooks: webhooksQuery.data?.webhooks?.items ?? [],\n webhooksLoading: webhooksQuery.loading,\n webhooksError: webhooksQuery.error?.message ?? null,\n createWebhook,\n deleteWebhook,\n // Dashboards (BigConsole)\n dashboards: (dashboardsQuery.data?.listDashboards?.edges ?? []).map((e) => e.node),\n dashboardsLoading: dashboardsQuery.loading,\n dashboardsError: dashboardsQuery.error?.message ?? null,\n };\n}\n"],"mappings":";;;;;AAwDA,IAAa,IAAoB,CAC/B;CAAE,OAAO;CAA+B,OAAO;CAAsC,EACrF;CAAE,OAAO;CAA0B,OAAO;CAA2B,CACtE,EAEK,IAAiB,4HAajB,IAAiB,CAAG;;;;UAIhB,EAAe;;;;;GAOnB,IAAiB,CAAG;;;QAGlB,EAAe;;;GAKjB,IAAiB,CAAG;;;;GAMpB,IAAmB,CAAG;;;;;;;;;;;;;;;AAoC5B,SAAgB,IAAgB;CAC9B,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EAEzB,IAAgB,EAAuB,GAAgB;EAC3D,MAAM,CAAC;EACP,aAAa;EACb,6BAA6B;EAC7B,aAAa;EACd,CAAC,EAEI,IAAkB,EAAyB,GAAkB;EACjE,WAAW,EAAE,OAAO,IAAI;EACxB,MAAM,CAAC;EACP,aAAa;EACb,6BAA6B;EAC7B,aAAa;EACd,CAAC,EAEI,CAAC,KAAyB,EAAY,EAAe,EACrD,CAAC,KAAyB,EAAY,EAAe,EAErD,IAAgB,EACpB,OAAO,MAAwB;AAE7B,EADA,MAAM,EAAsB,EAAE,WAAW,EAAE,OAAO;GAAE,GAAG;GAAO;GAAS,EAAE,EAAE,CAAC,EAC5E,MAAM,EAAc,SAAS;IAG/B;EAAC;EAAuB;EAAe;EAAY,CACpD,EAEK,IAAgB,EACpB,OAAO,MAAe;AAEpB,EADA,MAAM,EAAsB,EAAE,WAAW,EAAE,OAAI,EAAE,CAAC,EAClD,MAAM,EAAc,SAAS;IAE/B,CAAC,GAAuB,EAAc,CACvC;AAED,QAAO;EAEL,UAAU,EAAc,MAAM,UAAU,SAAS,EAAE;EACnD,iBAAiB,EAAc;EAC/B,eAAe,EAAc,OAAO,WAAW;EAC/C;EACA;EAEA,aAAa,EAAgB,MAAM,gBAAgB,SAAS,EAAE,EAAE,KAAK,MAAM,EAAE,KAAK;EAClF,mBAAmB,EAAgB;EACnC,iBAAiB,EAAgB,OAAO,WAAW;EACpD"}
@@ -1,519 +1,287 @@
1
1
  import { formatDateOnly as e } from "../../utils/helpers.js";
2
2
  import { PageLayout as t } from "../../components/PageLayout.js";
3
- import { StatCard as n } from "../../components/StatCard.js";
4
- import { DataTable as r } from "../../components/DataTable.js";
5
- import { StatusBadge as i } from "../../components/StatusBadge.js";
6
- import { EmptyState as a } from "../../components/EmptyState.js";
7
- import { ErrorState as o } from "../../components/ErrorState.js";
8
- import { ToastContainer as s } from "../../components/Toast.js";
9
- import { useConfirm as ee } from "../../components/ConfirmDialog.js";
3
+ import { DataTable as n } from "../../components/DataTable.js";
4
+ import { StatusBadge as r } from "../../components/StatusBadge.js";
5
+ import { EmptyState as i } from "../../components/EmptyState.js";
6
+ import { ErrorState as a } from "../../components/ErrorState.js";
7
+ import { ToastContainer as o } from "../../components/Toast.js";
8
+ import { useConfirm as s } from "../../components/ConfirmDialog.js";
10
9
  import { Modal as c } from "../../components/Modal.js";
11
- import { useToast as te } from "../../hooks/useToast.js";
10
+ import { useToast as l } from "../../hooks/useToast.js";
12
11
  import "../../components/index.js";
13
- import { HB_WEBHOOK_EVENTS as l, useReportsApi as ne } from "../../hooks/useReportsApi.js";
14
- import { useMemo as re, useState as u } from "react";
15
- import { useI18n as ie } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
16
- import { BarChart3 as d, Code2 as ae, Copy as f, ExternalLink as p, KeyRound as m, Plus as h, Trash2 as g, Webhook as _ } from "lucide-react";
17
- import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
18
- import { Button as x } from "@burdenoff/fe-libs/ui";
19
- import { getProductUrl as S } from "@burdenoff/fe-libs/shared/config";
12
+ import { HB_WEBHOOK_EVENTS as u, useReportsApi as d } from "../../hooks/useReportsApi.js";
13
+ import { useMemo as f, useState as p } from "react";
14
+ import { useI18n as m } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
15
+ import { BarChart3 as h, ExternalLink as g, Plus as _, Trash2 as v, Webhook as y } from "lucide-react";
16
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
17
+ import { Button as C } from "@burdenoff/fe-libs/ui";
18
+ import { getProductUrl as w } from "@burdenoff/fe-libs/shared/config";
20
19
  //#region src/healthybowl/pages/reports-api/ReportsApiPage.tsx
21
- var C = "h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", w = "https://api.gethealthybowl.com/v1";
22
- function oe(e) {
23
- return !e || e.length <= 10 ? "••••••••" : `${e.slice(0, 6)}…${e.slice(-4)}`;
24
- }
25
- function T() {
26
- let { t: T } = ie(), E = ee(), { toasts: D, toast: O, dismiss: se } = te(), { apiKeys: k, apiKeysLoading: ce, apiKeysError: A, createApiKey: le, revokeApiKey: ue, webhooks: j, webhooksLoading: de, webhooksError: M, createWebhook: fe, deleteWebhook: pe, dashboards: N, dashboardsLoading: me, dashboardsError: P } = ne(), [F, I] = u("keys"), [L, R] = u(!1), [z, B] = u(""), [V, H] = u(!1), [U, W] = u(!1), [G, K] = u(null), [he, q] = u(!1), [J, Y] = u(""), [X, ge] = u(l[0].value), [Z, Q] = u(!1), $ = re(() => {
20
+ var T = "h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]";
21
+ function E() {
22
+ let { t: E } = m(), D = s(), { toasts: O, toast: k, dismiss: A } = l(), { webhooks: j, webhooksLoading: M, webhooksError: N, createWebhook: P, deleteWebhook: F, dashboards: I, dashboardsLoading: L, dashboardsError: R } = d(), [z, B] = p("webhooks"), [V, H] = p(!1), [U, W] = p(""), [G, K] = p(u[0].value), [q, J] = p(!1), Y = f(() => {
27
23
  try {
28
- return S("bigconsole");
24
+ return w("bigconsole");
29
25
  } catch {
30
26
  return "https://app.bigconsole.com/";
31
27
  }
32
- }, []), _e = () => {
33
- B(""), H(!1), K(null), R(!0);
34
- }, ve = async () => {
35
- if (!z.trim()) {
36
- O({
37
- title: T("healthybowl.reportsApi.keys.nameRequired.title", "Name required"),
38
- description: T("healthybowl.reportsApi.keys.nameRequired.desc", "Give the key a recognizable name."),
39
- variant: "warning"
40
- });
41
- return;
42
- }
43
- W(!0);
44
- try {
45
- let e = V ? ["read", "write"] : ["read"], t = await le(z.trim(), e);
46
- t && (K(t), O({
47
- title: T("healthybowl.reportsApi.keys.created.title", "API key generated"),
48
- description: T("healthybowl.reportsApi.keys.created.desc", "Copy it now — it is shown only once."),
49
- variant: "success"
50
- }));
51
- } catch (e) {
52
- O({
53
- title: T("healthybowl.reportsApi.keys.createError.title", "Could not generate key"),
54
- description: e instanceof Error ? e.message : T("healthybowl.common.error", "Something went wrong."),
55
- variant: "error"
56
- });
57
- } finally {
58
- W(!1);
59
- }
60
- }, ye = async (e) => {
61
- if (await E({ message: T("healthybowl.reportsApi.keys.confirmRevoke", "Revoke \"{{name}}\"? Apps using it will stop working.", { name: e.name }) })) try {
62
- await ue(e.id), O({
63
- title: T("healthybowl.reportsApi.keys.revoked.title", "API key revoked"),
64
- variant: "success"
65
- });
66
- } catch (e) {
67
- O({
68
- title: T("healthybowl.reportsApi.keys.revokeError.title", "Could not revoke key"),
69
- description: e instanceof Error ? e.message : T("healthybowl.common.error", "Something went wrong."),
70
- variant: "error"
71
- });
72
- }
73
- }, be = async () => {
74
- if (!J.trim() || !/^https?:\/\//i.test(J.trim())) {
75
- O({
76
- title: T("healthybowl.reportsApi.webhooks.urlRequired.title", "Valid URL required"),
77
- description: T("healthybowl.reportsApi.webhooks.urlRequired.desc", "Enter the https URL to POST events to."),
28
+ }, []), X = async () => {
29
+ if (!U.trim() || !/^https?:\/\//i.test(U.trim())) {
30
+ k({
31
+ title: E("healthybowl.reportsApi.webhooks.urlRequired.title", "Valid URL required"),
32
+ description: E("healthybowl.reportsApi.webhooks.urlRequired.desc", "Enter the https URL to POST events to."),
78
33
  variant: "warning"
79
34
  });
80
35
  return;
81
36
  }
82
- Q(!0);
37
+ J(!0);
83
38
  try {
84
- await fe({
85
- name: `HealthyBowl · ${l.find((e) => e.value === X)?.label ?? X}`,
86
- url: J.trim(),
87
- events: [X]
88
- }), q(!1), Y(""), O({
89
- title: T("healthybowl.reportsApi.webhooks.added.title", "Webhook added"),
90
- description: T("healthybowl.reportsApi.webhooks.added.desc", "It will POST when the event fires."),
39
+ await P({
40
+ name: `HealthyBowl · ${u.find((e) => e.value === G)?.label ?? G}`,
41
+ url: U.trim(),
42
+ events: [G]
43
+ }), H(!1), W(""), k({
44
+ title: E("healthybowl.reportsApi.webhooks.added.title", "Webhook added"),
45
+ description: E("healthybowl.reportsApi.webhooks.added.desc", "It will POST when the event fires."),
91
46
  variant: "success"
92
47
  });
93
48
  } catch (e) {
94
- O({
95
- title: T("healthybowl.reportsApi.webhooks.addError.title", "Could not add webhook"),
96
- description: e instanceof Error ? e.message : T("healthybowl.common.error", "Something went wrong."),
49
+ k({
50
+ title: E("healthybowl.reportsApi.webhooks.addError.title", "Could not add webhook"),
51
+ description: e instanceof Error ? e.message : E("healthybowl.common.error", "Something went wrong."),
97
52
  variant: "error"
98
53
  });
99
54
  } finally {
100
- Q(!1);
55
+ J(!1);
101
56
  }
102
- }, xe = async (e) => {
103
- if (await E({ message: T("healthybowl.reportsApi.webhooks.confirmDelete", "Delete this webhook subscription?") })) try {
104
- await pe(e.id), O({
105
- title: T("healthybowl.reportsApi.webhooks.deleted.title", "Webhook deleted"),
57
+ }, Z = async (e) => {
58
+ if (await D({ message: E("healthybowl.reportsApi.webhooks.confirmDelete", "Delete this webhook subscription?") })) try {
59
+ await F(e.id), k({
60
+ title: E("healthybowl.reportsApi.webhooks.deleted.title", "Webhook deleted"),
106
61
  variant: "success"
107
62
  });
108
63
  } catch (e) {
109
- O({
110
- title: T("healthybowl.reportsApi.webhooks.deleteError.title", "Could not delete webhook"),
111
- description: e instanceof Error ? e.message : T("healthybowl.common.error", "Something went wrong."),
64
+ k({
65
+ title: E("healthybowl.reportsApi.webhooks.deleteError.title", "Could not delete webhook"),
66
+ description: e instanceof Error ? e.message : E("healthybowl.common.error", "Something went wrong."),
112
67
  variant: "error"
113
68
  });
114
69
  }
115
- }, Se = async (e) => {
116
- try {
117
- await navigator.clipboard.writeText(e), O({
118
- title: T("healthybowl.reportsApi.copied", "Copied to clipboard"),
119
- variant: "success"
120
- });
121
- } catch {
122
- O({
123
- title: T("healthybowl.reportsApi.copyFailed", "Copy failed"),
124
- variant: "error"
125
- });
126
- }
127
- }, Ce = [
128
- {
129
- key: "name",
130
- header: T("healthybowl.reportsApi.keys.col.name", "Name"),
131
- sortable: !0
132
- },
133
- {
134
- key: "key",
135
- header: T("healthybowl.reportsApi.keys.col.key", "Key"),
136
- render: (e) => /* @__PURE__ */ y("span", {
137
- className: "font-mono text-xs text-text-secondary",
138
- children: oe(e.key)
139
- })
140
- },
141
- {
142
- key: "permissions",
143
- header: T("healthybowl.reportsApi.keys.col.scope", "Scope"),
144
- render: (e) => /* @__PURE__ */ y("span", {
145
- className: "text-xs text-text-secondary",
146
- children: e.permissions.join(", ") || "—"
147
- })
148
- },
149
- {
150
- key: "createdAt",
151
- header: T("healthybowl.reportsApi.keys.col.created", "Created"),
152
- render: (t) => e(t.createdAt)
153
- },
154
- {
155
- key: "lastUsedAt",
156
- header: T("healthybowl.reportsApi.keys.col.lastUsed", "Last used"),
157
- render: (t) => t.lastUsedAt ? e(t.lastUsedAt) : T("healthybowl.reportsApi.never", "Never")
158
- },
159
- {
160
- key: "status",
161
- header: T("healthybowl.reportsApi.keys.col.status", "Status"),
162
- render: (e) => e.isActive ? /* @__PURE__ */ y(i, {
163
- label: T("healthybowl.reportsApi.active", "Active"),
164
- variant: "success",
165
- dot: !0
166
- }) : /* @__PURE__ */ y(i, {
167
- label: T("healthybowl.reportsApi.revoked", "Revoked"),
168
- variant: "muted"
169
- })
170
- },
171
- {
172
- key: "actions",
173
- header: "",
174
- render: (e) => e.isActive ? /* @__PURE__ */ b(x, {
175
- variant: "ghost",
176
- size: "sm",
177
- onClick: () => ye(e),
178
- children: [/* @__PURE__ */ y(g, { className: "mr-1 h-4 w-4" }), T("healthybowl.reportsApi.keys.revoke", "Revoke")]
179
- }) : null
180
- }
181
- ], we = [
70
+ }, Q = [
182
71
  {
183
72
  key: "events",
184
- header: T("healthybowl.reportsApi.webhooks.col.event", "Event"),
185
- render: (e) => /* @__PURE__ */ y("span", {
73
+ header: E("healthybowl.reportsApi.webhooks.col.event", "Event"),
74
+ render: (e) => /* @__PURE__ */ x("span", {
186
75
  className: "font-mono text-xs",
187
76
  children: e.events.join(", ")
188
77
  })
189
78
  },
190
79
  {
191
80
  key: "url",
192
- header: T("healthybowl.reportsApi.webhooks.col.url", "Target URL"),
193
- render: (e) => /* @__PURE__ */ y("span", {
81
+ header: E("healthybowl.reportsApi.webhooks.col.url", "Target URL"),
82
+ render: (e) => /* @__PURE__ */ x("span", {
194
83
  className: "max-w-[22rem] truncate font-mono text-xs text-text-secondary",
195
84
  children: e.url
196
85
  })
197
86
  },
198
87
  {
199
88
  key: "status",
200
- header: T("healthybowl.reportsApi.webhooks.col.status", "Status"),
201
- render: (e) => e.isActive ? e.lastError ? /* @__PURE__ */ y(i, {
202
- label: T("healthybowl.reportsApi.failed", "Failed"),
89
+ header: E("healthybowl.reportsApi.webhooks.col.status", "Status"),
90
+ render: (e) => e.isActive ? e.lastError ? /* @__PURE__ */ x(r, {
91
+ label: E("healthybowl.reportsApi.failed", "Failed"),
203
92
  variant: "error",
204
93
  dot: !0
205
- }) : /* @__PURE__ */ y(i, {
206
- label: T("healthybowl.reportsApi.active", "Active"),
94
+ }) : /* @__PURE__ */ x(r, {
95
+ label: E("healthybowl.reportsApi.active", "Active"),
207
96
  variant: "success",
208
97
  dot: !0
209
- }) : /* @__PURE__ */ y(i, {
210
- label: T("healthybowl.reportsApi.paused", "Paused"),
98
+ }) : /* @__PURE__ */ x(r, {
99
+ label: E("healthybowl.reportsApi.paused", "Paused"),
211
100
  variant: "muted"
212
101
  })
213
102
  },
214
103
  {
215
104
  key: "lastDelivery",
216
- header: T("healthybowl.reportsApi.webhooks.col.lastDelivery", "Last delivery"),
217
- render: (t) => t.lastDelivery ? e(t.lastDelivery) : T("healthybowl.reportsApi.never", "Never")
105
+ header: E("healthybowl.reportsApi.webhooks.col.lastDelivery", "Last delivery"),
106
+ render: (t) => t.lastDelivery ? e(t.lastDelivery) : E("healthybowl.reportsApi.never", "Never")
218
107
  },
219
108
  {
220
109
  key: "actions",
221
110
  header: "",
222
- render: (e) => /* @__PURE__ */ b(x, {
111
+ render: (e) => /* @__PURE__ */ S(C, {
223
112
  variant: "ghost",
224
113
  size: "sm",
225
- onClick: () => xe(e),
226
- children: [/* @__PURE__ */ y(g, { className: "mr-1 h-4 w-4" }), T("healthybowl.common.delete", "Delete")]
114
+ onClick: () => Z(e),
115
+ children: [/* @__PURE__ */ x(v, { className: "mr-1 h-4 w-4" }), E("healthybowl.common.delete", "Delete")]
227
116
  })
228
117
  }
229
- ], Te = [
118
+ ], $ = [
230
119
  {
231
120
  key: "name",
232
- header: T("healthybowl.reportsApi.reports.col.name", "Dashboard"),
121
+ header: E("healthybowl.reportsApi.reports.col.name", "Dashboard"),
233
122
  sortable: !0
234
123
  },
235
124
  {
236
125
  key: "category",
237
- header: T("healthybowl.reportsApi.reports.col.category", "Category"),
238
- render: (e) => /* @__PURE__ */ y("span", {
126
+ header: E("healthybowl.reportsApi.reports.col.category", "Category"),
127
+ render: (e) => /* @__PURE__ */ x("span", {
239
128
  className: "text-xs text-text-secondary",
240
129
  children: e.category
241
130
  })
242
131
  },
243
132
  {
244
133
  key: "updatedAt",
245
- header: T("healthybowl.reportsApi.reports.col.updated", "Updated"),
134
+ header: E("healthybowl.reportsApi.reports.col.updated", "Updated"),
246
135
  render: (t) => e(t.updatedAt)
247
136
  },
248
137
  {
249
138
  key: "actions",
250
139
  header: "",
251
- render: (e) => /* @__PURE__ */ b("a", {
252
- href: `${$}${$.endsWith("/") ? "" : "/"}dashboards/${e.id}`,
140
+ render: (e) => /* @__PURE__ */ S("a", {
141
+ href: `${Y}${Y.endsWith("/") ? "" : "/"}dashboards/${e.id}`,
253
142
  target: "_blank",
254
143
  rel: "noopener noreferrer",
255
144
  className: "inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline",
256
- children: [T("healthybowl.reportsApi.reports.open", "Open"), /* @__PURE__ */ y(p, { className: "h-3.5 w-3.5" })]
145
+ children: [E("healthybowl.reportsApi.reports.open", "Open"), /* @__PURE__ */ x(g, { className: "h-3.5 w-3.5" })]
257
146
  })
258
147
  }
259
- ], Ee = [
260
- {
261
- id: "keys",
262
- label: T("healthybowl.reportsApi.tab.keys", "API Keys"),
263
- icon: /* @__PURE__ */ y(m, { className: "h-4 w-4" })
264
- },
265
- {
266
- id: "webhooks",
267
- label: T("healthybowl.reportsApi.tab.webhooks", "Webhooks"),
268
- icon: /* @__PURE__ */ y(_, { className: "h-4 w-4" })
269
- },
270
- {
271
- id: "reports",
272
- label: T("healthybowl.reportsApi.tab.reports", "Reports & Dashboards"),
273
- icon: /* @__PURE__ */ y(d, { className: "h-4 w-4" })
274
- }
275
- ], De = k.filter((e) => e.isActive).length;
276
- return /* @__PURE__ */ b(t, {
277
- title: T("healthybowl.reportsApi.title", "Reports & API"),
278
- titleAccent: T("healthybowl.reportsApi.titleAccent", "API"),
148
+ ], ee = [{
149
+ id: "webhooks",
150
+ label: E("healthybowl.reportsApi.tab.webhooks", "Webhooks"),
151
+ icon: /* @__PURE__ */ x(y, { className: "h-4 w-4" })
152
+ }, {
153
+ id: "reports",
154
+ label: E("healthybowl.reportsApi.tab.reports", "Reports & Dashboards"),
155
+ icon: /* @__PURE__ */ x(h, { className: "h-4 w-4" })
156
+ }];
157
+ return /* @__PURE__ */ S(t, {
158
+ title: E("healthybowl.reportsApi.title", "Reports & API"),
159
+ titleAccent: E("healthybowl.reportsApi.titleAccent", "API"),
279
160
  hero: !0,
280
- description: T("healthybowl.reportsApi.description", "Build custom dashboards, issue developer API keys, and subscribe webhooks — one place to connect HealthyBowl to your other tools."),
281
- helpPrompt: T("healthybowl.reportsApi.help", "How do I use the HealthyBowl API keys, webhooks and custom dashboards?"),
161
+ description: E("healthybowl.reportsApi.description", "Build custom dashboards and subscribe webhooks — one place to connect HealthyBowl to your other tools."),
162
+ helpPrompt: E("healthybowl.reportsApi.help", "How do I use HealthyBowl webhooks and custom dashboards?"),
282
163
  children: [
283
- /* @__PURE__ */ y("div", {
164
+ /* @__PURE__ */ x("div", {
284
165
  className: "mb-6 flex flex-wrap gap-1 border-b border-border-subtle",
285
- children: Ee.map((e) => /* @__PURE__ */ b("button", {
166
+ children: ee.map((e) => /* @__PURE__ */ S("button", {
286
167
  type: "button",
287
- onClick: () => I(e.id),
288
- className: `flex items-center gap-2 border-b-2 px-4 py-2 text-sm font-medium transition-colors ${F === e.id ? "border-primary text-text-primary" : "border-transparent text-text-secondary hover:text-text-primary"}`,
168
+ onClick: () => B(e.id),
169
+ className: `flex items-center gap-2 border-b-2 px-4 py-2 text-sm font-medium transition-colors ${z === e.id ? "border-primary text-text-primary" : "border-transparent text-text-secondary hover:text-text-primary"}`,
289
170
  children: [e.icon, e.label]
290
171
  }, e.id))
291
172
  }),
292
- F === "keys" && /* @__PURE__ */ b("div", {
293
- className: "space-y-6",
294
- children: [
295
- /* @__PURE__ */ b("div", {
296
- className: "grid grid-cols-2 gap-4 sm:max-w-md",
297
- children: [/* @__PURE__ */ y(n, {
298
- label: T("healthybowl.reportsApi.keys.stat.total", "Total keys"),
299
- value: k.length,
300
- icon: /* @__PURE__ */ y(m, {})
301
- }), /* @__PURE__ */ y(n, {
302
- label: T("healthybowl.reportsApi.keys.stat.active", "Active"),
303
- value: De
304
- })]
305
- }),
306
- /* @__PURE__ */ b("div", {
307
- className: "flex items-center justify-between",
308
- children: [/* @__PURE__ */ y("p", {
309
- className: "text-sm text-text-secondary",
310
- children: T("healthybowl.reportsApi.keys.blurb", "Keys authenticate a third party reading THIS workspace’s data. Read-first, with role-based access control.")
311
- }), /* @__PURE__ */ b(x, {
312
- onClick: _e,
313
- children: [/* @__PURE__ */ y(h, { className: "mr-1 h-4 w-4" }), T("healthybowl.reportsApi.keys.generate", "Generate key")]
314
- })]
315
- }),
316
- /* @__PURE__ */ b("div", {
317
- className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
318
- children: [
319
- /* @__PURE__ */ b("div", {
320
- className: "mb-2 flex items-center gap-2 text-sm font-medium text-text-primary",
321
- children: [/* @__PURE__ */ y(ae, { className: "h-4 w-4" }), T("healthybowl.reportsApi.keys.endpoint.title", "Public API endpoint")]
322
- }),
323
- /* @__PURE__ */ y("pre", {
324
- className: "overflow-x-auto rounded-md bg-bg-muted p-3 font-mono text-xs text-text-secondary",
325
- children: `curl -H "Authorization: Bearer ak_…" \\\n ${w}/harvests`
326
- }),
327
- /* @__PURE__ */ y("p", {
328
- className: "mt-2 text-xs text-text-secondary",
329
- children: T("healthybowl.reportsApi.keys.endpoint.note", "Read endpoints (harvests, orders, crops) are scoped to your workspace with role-based access control. Send the key as a Bearer token.")
330
- })
331
- ]
332
- }),
333
- A ? /* @__PURE__ */ y(o, {
334
- title: T("healthybowl.reportsApi.keys.error", "Could not load API keys"),
335
- description: A
336
- }) : k.length === 0 && !ce ? /* @__PURE__ */ y(a, {
337
- icon: /* @__PURE__ */ y(m, {}),
338
- title: T("healthybowl.reportsApi.keys.empty.title", "No API keys yet"),
339
- description: T("healthybowl.reportsApi.keys.empty.desc", "Generate a key to let an external tool read your farm data.")
340
- }) : /* @__PURE__ */ y(r, {
341
- columns: Ce,
342
- data: k,
343
- keyField: "id"
344
- })
345
- ]
346
- }),
347
- F === "webhooks" && /* @__PURE__ */ b("div", {
173
+ z === "webhooks" && /* @__PURE__ */ S("div", {
348
174
  className: "space-y-6",
349
- children: [/* @__PURE__ */ b("div", {
175
+ children: [/* @__PURE__ */ S("div", {
350
176
  className: "flex items-center justify-between",
351
- children: [/* @__PURE__ */ y("p", {
177
+ children: [/* @__PURE__ */ x("p", {
352
178
  className: "text-sm text-text-secondary",
353
- children: T("healthybowl.reportsApi.webhooks.blurb", "POST an HB event to any URL or a Zapier hook when it fires — e.g. push every new harvest into a buyer’s system.")
354
- }), /* @__PURE__ */ b(x, {
355
- onClick: () => q(!0),
356
- children: [/* @__PURE__ */ y(h, { className: "mr-1 h-4 w-4" }), T("healthybowl.reportsApi.webhooks.add", "Add webhook")]
179
+ children: E("healthybowl.reportsApi.webhooks.blurb", "POST an HB event to any URL or a Zapier hook when it fires — e.g. push every new harvest into a buyer’s system.")
180
+ }), /* @__PURE__ */ S(C, {
181
+ onClick: () => H(!0),
182
+ children: [/* @__PURE__ */ x(_, { className: "mr-1 h-4 w-4" }), E("healthybowl.reportsApi.webhooks.add", "Add webhook")]
357
183
  })]
358
- }), M ? /* @__PURE__ */ y(o, {
359
- title: T("healthybowl.reportsApi.webhooks.error", "Could not load webhooks"),
360
- description: M
361
- }) : j.length === 0 && !de ? /* @__PURE__ */ y(a, {
362
- icon: /* @__PURE__ */ y(_, {}),
363
- title: T("healthybowl.reportsApi.webhooks.empty.title", "No webhooks yet"),
364
- description: T("healthybowl.reportsApi.webhooks.empty.desc", "Subscribe harvest.created or order.paid to an outbound URL.")
365
- }) : /* @__PURE__ */ y(r, {
366
- columns: we,
184
+ }), N ? /* @__PURE__ */ x(a, {
185
+ title: E("healthybowl.reportsApi.webhooks.error", "Could not load webhooks"),
186
+ description: N
187
+ }) : j.length === 0 && !M ? /* @__PURE__ */ x(i, {
188
+ icon: /* @__PURE__ */ x(y, {}),
189
+ title: E("healthybowl.reportsApi.webhooks.empty.title", "No webhooks yet"),
190
+ description: E("healthybowl.reportsApi.webhooks.empty.desc", "Subscribe harvest.created or order.paid to an outbound URL.")
191
+ }) : /* @__PURE__ */ x(n, {
192
+ columns: Q,
367
193
  data: j,
368
194
  keyField: "id"
369
195
  })]
370
196
  }),
371
- F === "reports" && /* @__PURE__ */ b("div", {
197
+ z === "reports" && /* @__PURE__ */ S("div", {
372
198
  className: "space-y-6",
373
- children: [/* @__PURE__ */ b("div", {
199
+ children: [/* @__PURE__ */ S("div", {
374
200
  className: "rounded-lg border border-border-subtle bg-bg-surface p-5",
375
201
  children: [
376
- /* @__PURE__ */ b("div", {
202
+ /* @__PURE__ */ S("div", {
377
203
  className: "mb-1 flex items-center gap-2 text-base font-semibold text-text-primary",
378
- children: [/* @__PURE__ */ y(d, { className: "h-5 w-5" }), T("healthybowl.reportsApi.reports.builder.title", "Build a custom dashboard")]
204
+ children: [/* @__PURE__ */ x(h, { className: "h-5 w-5" }), E("healthybowl.reportsApi.reports.builder.title", "Build a custom dashboard")]
379
205
  }),
380
- /* @__PURE__ */ y("p", {
206
+ /* @__PURE__ */ x("p", {
381
207
  className: "mb-4 max-w-2xl text-sm text-text-secondary",
382
- children: T("healthybowl.reportsApi.reports.builder.desc", "Drag HealthyBowl data fields (crop yield, revenue, livestock count, compliance) onto a canvas and pick charts, KPI cards and tables — no engineering needed. Custom dashboards export to CSV/PDF and can be emailed on a schedule, all in BigConsole.")
208
+ children: E("healthybowl.reportsApi.reports.builder.desc", "Drag HealthyBowl data fields (crop yield, revenue, livestock count, compliance) onto a canvas and pick charts, KPI cards and tables — no engineering needed. Custom dashboards export to CSV/PDF and can be emailed on a schedule, all in BigConsole.")
383
209
  }),
384
- /* @__PURE__ */ y("a", {
385
- href: $,
210
+ /* @__PURE__ */ x("a", {
211
+ href: Y,
386
212
  target: "_blank",
387
213
  rel: "noopener noreferrer",
388
- children: /* @__PURE__ */ b(x, { children: [T("healthybowl.reportsApi.reports.builder.cta", "Open the dashboard builder"), /* @__PURE__ */ y(p, { className: "ml-1 h-4 w-4" })] })
214
+ children: /* @__PURE__ */ S(C, { children: [E("healthybowl.reportsApi.reports.builder.cta", "Open the dashboard builder"), /* @__PURE__ */ x(g, { className: "ml-1 h-4 w-4" })] })
389
215
  })
390
216
  ]
391
- }), /* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("h3", {
217
+ }), /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("h3", {
392
218
  className: "mb-3 text-sm font-semibold text-text-primary",
393
- children: T("healthybowl.reportsApi.reports.saved.title", "Saved dashboards")
394
- }), P ? /* @__PURE__ */ y(o, {
395
- title: T("healthybowl.reportsApi.reports.error", "Could not load dashboards"),
396
- description: P
397
- }) : N.length === 0 && !me ? /* @__PURE__ */ y(a, {
398
- icon: /* @__PURE__ */ y(d, {}),
399
- title: T("healthybowl.reportsApi.reports.empty.title", "No custom dashboards yet"),
400
- description: T("healthybowl.reportsApi.reports.empty.desc", "Dashboards you build in BigConsole appear here.")
401
- }) : /* @__PURE__ */ y(r, {
402
- columns: Te,
403
- data: N,
219
+ children: E("healthybowl.reportsApi.reports.saved.title", "Saved dashboards")
220
+ }), R ? /* @__PURE__ */ x(a, {
221
+ title: E("healthybowl.reportsApi.reports.error", "Could not load dashboards"),
222
+ description: R
223
+ }) : I.length === 0 && !L ? /* @__PURE__ */ x(i, {
224
+ icon: /* @__PURE__ */ x(h, {}),
225
+ title: E("healthybowl.reportsApi.reports.empty.title", "No custom dashboards yet"),
226
+ description: E("healthybowl.reportsApi.reports.empty.desc", "Dashboards you build in BigConsole appear here.")
227
+ }) : /* @__PURE__ */ x(n, {
228
+ columns: $,
229
+ data: I,
404
230
  keyField: "id"
405
231
  })] })]
406
232
  }),
407
- /* @__PURE__ */ y(c, {
408
- open: L,
409
- onClose: () => R(!1),
410
- title: G ? T("healthybowl.reportsApi.keys.modal.createdTitle", "API key created") : T("healthybowl.reportsApi.keys.modal.title", "Generate API key"),
411
- description: G ? T("healthybowl.reportsApi.keys.modal.createdDesc", "Copy this key now — it will not be shown again.") : T("healthybowl.reportsApi.keys.modal.desc", "Name the key and choose its scope."),
412
- size: "md",
413
- footer: G ? /* @__PURE__ */ y(x, {
414
- onClick: () => R(!1),
415
- children: T("healthybowl.common.done", "Done")
416
- }) : /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(x, {
417
- variant: "outline",
418
- onClick: () => R(!1),
419
- children: T("healthybowl.common.cancel", "Cancel")
420
- }), /* @__PURE__ */ y(x, {
421
- onClick: ve,
422
- disabled: U,
423
- children: U ? T("healthybowl.reportsApi.keys.generating", "Generating…") : T("healthybowl.reportsApi.keys.generate", "Generate key")
424
- })] }),
425
- children: G ? /* @__PURE__ */ b("div", {
426
- className: "space-y-3",
427
- children: [/* @__PURE__ */ b("div", {
428
- className: "flex items-center gap-2",
429
- children: [/* @__PURE__ */ y("code", {
430
- className: "flex-1 overflow-x-auto rounded-md border border-border-subtle bg-bg-muted p-3 font-mono text-xs text-text-primary",
431
- children: G.key
432
- }), /* @__PURE__ */ b(x, {
433
- variant: "outline",
434
- size: "sm",
435
- onClick: () => Se(G.key),
436
- children: [/* @__PURE__ */ y(f, { className: "mr-1 h-4 w-4" }), T("healthybowl.common.copy", "Copy")]
437
- })]
438
- }), /* @__PURE__ */ y("p", {
439
- className: "text-xs text-text-secondary",
440
- children: T("healthybowl.reportsApi.keys.modal.storeSafe", "Store it in your secrets manager. If you lose it, revoke and generate a new one.")
441
- })]
442
- }) : /* @__PURE__ */ b("div", {
443
- className: "space-y-4",
444
- children: [/* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("label", {
445
- htmlFor: "key-name",
446
- className: "mb-1 block text-sm font-medium text-text-primary",
447
- children: T("healthybowl.reportsApi.keys.form.name", "Key name *")
448
- }), /* @__PURE__ */ y("input", {
449
- id: "key-name",
450
- type: "text",
451
- value: z,
452
- onChange: (e) => B(e.target.value),
453
- placeholder: T("healthybowl.reportsApi.keys.form.namePlaceholder", "e.g., Buyer integration"),
454
- className: C
455
- })] }), /* @__PURE__ */ b("label", {
456
- className: "flex items-center gap-2 text-sm text-text-primary",
457
- children: [/* @__PURE__ */ y("input", {
458
- type: "checkbox",
459
- checked: V,
460
- onChange: (e) => H(e.target.checked)
461
- }), T("healthybowl.reportsApi.keys.form.allowWrite", "Allow write access (default is read-only)")]
462
- })]
463
- })
464
- }),
465
- /* @__PURE__ */ y(c, {
466
- open: he,
467
- onClose: () => q(!1),
468
- title: T("healthybowl.reportsApi.webhooks.modal.title", "Add webhook"),
469
- description: T("healthybowl.reportsApi.webhooks.modal.desc", "Pick an event and the URL to POST it to."),
233
+ /* @__PURE__ */ x(c, {
234
+ open: V,
235
+ onClose: () => H(!1),
236
+ title: E("healthybowl.reportsApi.webhooks.modal.title", "Add webhook"),
237
+ description: E("healthybowl.reportsApi.webhooks.modal.desc", "Pick an event and the URL to POST it to."),
470
238
  size: "md",
471
- footer: /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(x, {
239
+ footer: /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(C, {
472
240
  variant: "outline",
473
- onClick: () => q(!1),
474
- children: T("healthybowl.common.cancel", "Cancel")
475
- }), /* @__PURE__ */ y(x, {
476
- onClick: be,
477
- disabled: Z,
478
- children: Z ? T("healthybowl.reportsApi.webhooks.adding", "Adding…") : T("healthybowl.reportsApi.webhooks.add", "Add webhook")
241
+ onClick: () => H(!1),
242
+ children: E("healthybowl.common.cancel", "Cancel")
243
+ }), /* @__PURE__ */ x(C, {
244
+ onClick: X,
245
+ disabled: q,
246
+ children: q ? E("healthybowl.reportsApi.webhooks.adding", "Adding…") : E("healthybowl.reportsApi.webhooks.add", "Add webhook")
479
247
  })] }),
480
- children: /* @__PURE__ */ b("div", {
248
+ children: /* @__PURE__ */ S("div", {
481
249
  className: "space-y-4",
482
- children: [/* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("label", {
250
+ children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
483
251
  htmlFor: "hook-event",
484
252
  className: "mb-1 block text-sm font-medium text-text-primary",
485
- children: T("healthybowl.reportsApi.webhooks.form.event", "Event")
486
- }), /* @__PURE__ */ y("select", {
253
+ children: E("healthybowl.reportsApi.webhooks.form.event", "Event")
254
+ }), /* @__PURE__ */ x("select", {
487
255
  id: "hook-event",
488
- value: X,
489
- onChange: (e) => ge(e.target.value),
490
- className: C,
491
- children: l.map((e) => /* @__PURE__ */ y("option", {
256
+ value: G,
257
+ onChange: (e) => K(e.target.value),
258
+ className: T,
259
+ children: u.map((e) => /* @__PURE__ */ x("option", {
492
260
  value: e.value,
493
261
  children: e.label
494
262
  }, e.value))
495
- })] }), /* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("label", {
263
+ })] }), /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
496
264
  htmlFor: "hook-url",
497
265
  className: "mb-1 block text-sm font-medium text-text-primary",
498
- children: T("healthybowl.reportsApi.webhooks.form.url", "Target URL *")
499
- }), /* @__PURE__ */ y("input", {
266
+ children: E("healthybowl.reportsApi.webhooks.form.url", "Target URL *")
267
+ }), /* @__PURE__ */ x("input", {
500
268
  id: "hook-url",
501
269
  type: "url",
502
- value: J,
503
- onChange: (e) => Y(e.target.value),
270
+ value: U,
271
+ onChange: (e) => W(e.target.value),
504
272
  placeholder: "https://hooks.zapier.com/…",
505
- className: C
273
+ className: T
506
274
  })] })]
507
275
  })
508
276
  }),
509
- /* @__PURE__ */ y(s, {
510
- toasts: D,
511
- onDismiss: se
277
+ /* @__PURE__ */ x(o, {
278
+ toasts: O,
279
+ onDismiss: A
512
280
  })
513
281
  ]
514
282
  });
515
283
  }
516
284
  //#endregion
517
- export { T as ReportsApiPage };
285
+ export { E as ReportsApiPage };
518
286
 
519
287
  //# sourceMappingURL=ReportsApiPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReportsApiPage.js","names":[],"sources":["../../../../src/healthybowl/pages/reports-api/ReportsApiPage.tsx"],"sourcesContent":["/**\n * Reports & API — the single management surface for roadmap #19 (Custom Report\n * Builder & Developer API).\n *\n * A non-engineer manages everything the farm exposes to the outside world from one\n * screen, across three tabs:\n * · API Keys — issue / copy-once / revoke per-workspace developer keys for the\n * documented public API (analytics-svc; the key authenticates a\n * third party reading this workspace's harvests / orders / crops).\n * · Webhooks — subscribe an outbound webhook to an HB event (harvest.created /\n * order.paid) so a buyer's / Zapier endpoint is POSTed when it fires\n * (platform webhook engine).\n * · Reports — build a no-code custom dashboard in BigConsole (drag-and-drop\n * canvas, CSV/PDF export, scheduled email) and see the saved ones.\n *\n * Per spec §5 HealthyBowl builds NO charting / API / webhook engine — this page is\n * pure management UI over composed ops (see `useReportsApi`) plus a deep-link into\n * the BigConsole builder app.\n * @module healthybowl\n */\nimport { useMemo, useState, type ReactNode } from 'react';\nimport { BarChart3, Code2, Copy, ExternalLink, KeyRound, Plus, Trash2, Webhook } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { getProductUrl } from '@burdenoff/fe-libs/shared/config';\nimport {\n PageLayout,\n DataTable,\n type Column,\n Modal,\n StatCard,\n StatusBadge,\n EmptyState,\n ErrorState,\n useConfirm,\n} from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport {\n useReportsApi,\n HB_WEBHOOK_EVENTS,\n type HBApiKey,\n type HBWebhook,\n type HBDashboard,\n} from '../../hooks/useReportsApi';\nimport { formatDateOnly } from '../../utils/helpers';\n\ntype TabId = 'keys' | 'webhooks' | 'reports';\n\nconst inputClass =\n 'h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\n\n/** The documented public endpoint the issued key authenticates against (gateway-fronted). */\nconst API_BASE = 'https://api.gethealthybowl.com/v1';\n\n/** Show only the prefix + last 4 chars of a secret; the full value is revealed once on create. */\nfunction maskKey(key: string): string {\n if (!key || key.length <= 10) return '••••••••';\n return `${key.slice(0, 6)}…${key.slice(-4)}`;\n}\n\nexport function ReportsApiPage() {\n const { t } = useI18n();\n const confirm = useConfirm();\n const { toasts, toast, dismiss } = useToast();\n const {\n apiKeys,\n apiKeysLoading,\n apiKeysError,\n createApiKey,\n revokeApiKey,\n webhooks,\n webhooksLoading,\n webhooksError,\n createWebhook,\n deleteWebhook,\n dashboards,\n dashboardsLoading,\n dashboardsError,\n } = useReportsApi();\n\n const [tab, setTab] = useState<TabId>('keys');\n\n // ── API-key create modal + reveal-once state ───────────────────────────────\n const [keyModalOpen, setKeyModalOpen] = useState(false);\n const [keyName, setKeyName] = useState('');\n const [keyCanWrite, setKeyCanWrite] = useState(false);\n const [submittingKey, setSubmittingKey] = useState(false);\n const [revealedKey, setRevealedKey] = useState<HBApiKey | null>(null);\n\n // ── Webhook create modal ────────────────────────────────────────────────────\n const [hookModalOpen, setHookModalOpen] = useState(false);\n const [hookUrl, setHookUrl] = useState('');\n const [hookEvent, setHookEvent] = useState<string>(HB_WEBHOOK_EVENTS[0].value);\n const [submittingHook, setSubmittingHook] = useState(false);\n\n const bigConsoleUrl = useMemo(() => {\n try {\n return getProductUrl('bigconsole');\n } catch {\n return 'https://app.bigconsole.com/';\n }\n }, []);\n\n const openKeyModal = () => {\n setKeyName('');\n setKeyCanWrite(false);\n setRevealedKey(null);\n setKeyModalOpen(true);\n };\n\n const handleCreateKey = async () => {\n if (!keyName.trim()) {\n toast({\n title: t('healthybowl.reportsApi.keys.nameRequired.title', 'Name required'),\n description: t('healthybowl.reportsApi.keys.nameRequired.desc', 'Give the key a recognizable name.'),\n variant: 'warning',\n });\n return;\n }\n setSubmittingKey(true);\n try {\n const permissions = keyCanWrite ? ['read', 'write'] : ['read'];\n const created = await createApiKey(keyName.trim(), permissions);\n if (created) {\n setRevealedKey(created);\n toast({\n title: t('healthybowl.reportsApi.keys.created.title', 'API key generated'),\n description: t('healthybowl.reportsApi.keys.created.desc', 'Copy it now — it is shown only once.'),\n variant: 'success',\n });\n }\n } catch (err) {\n toast({\n title: t('healthybowl.reportsApi.keys.createError.title', 'Could not generate key'),\n description: err instanceof Error ? err.message : t('healthybowl.common.error', 'Something went wrong.'),\n variant: 'error',\n });\n } finally {\n setSubmittingKey(false);\n }\n };\n\n const handleRevokeKey = async (k: HBApiKey) => {\n if (\n !(await confirm({\n message: t('healthybowl.reportsApi.keys.confirmRevoke', 'Revoke \"{{name}}\"? Apps using it will stop working.', {\n name: k.name,\n }),\n }))\n ) {\n return;\n }\n try {\n await revokeApiKey(k.id);\n toast({\n title: t('healthybowl.reportsApi.keys.revoked.title', 'API key revoked'),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.reportsApi.keys.revokeError.title', 'Could not revoke key'),\n description: err instanceof Error ? err.message : t('healthybowl.common.error', 'Something went wrong.'),\n variant: 'error',\n });\n }\n };\n\n const handleCreateHook = async () => {\n if (!hookUrl.trim() || !/^https?:\\/\\//i.test(hookUrl.trim())) {\n toast({\n title: t('healthybowl.reportsApi.webhooks.urlRequired.title', 'Valid URL required'),\n description: t('healthybowl.reportsApi.webhooks.urlRequired.desc', 'Enter the https URL to POST events to.'),\n variant: 'warning',\n });\n return;\n }\n setSubmittingHook(true);\n try {\n const eventLabel = HB_WEBHOOK_EVENTS.find((e) => e.value === hookEvent)?.label ?? hookEvent;\n await createWebhook({\n name: `HealthyBowl · ${eventLabel}`,\n url: hookUrl.trim(),\n events: [hookEvent],\n });\n setHookModalOpen(false);\n setHookUrl('');\n toast({\n title: t('healthybowl.reportsApi.webhooks.added.title', 'Webhook added'),\n description: t('healthybowl.reportsApi.webhooks.added.desc', 'It will POST when the event fires.'),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.reportsApi.webhooks.addError.title', 'Could not add webhook'),\n description: err instanceof Error ? err.message : t('healthybowl.common.error', 'Something went wrong.'),\n variant: 'error',\n });\n } finally {\n setSubmittingHook(false);\n }\n };\n\n const handleDeleteHook = async (h: HBWebhook) => {\n if (\n !(await confirm({\n message: t('healthybowl.reportsApi.webhooks.confirmDelete', 'Delete this webhook subscription?'),\n }))\n ) {\n return;\n }\n try {\n await deleteWebhook(h.id);\n toast({ title: t('healthybowl.reportsApi.webhooks.deleted.title', 'Webhook deleted'), variant: 'success' });\n } catch (err) {\n toast({\n title: t('healthybowl.reportsApi.webhooks.deleteError.title', 'Could not delete webhook'),\n description: err instanceof Error ? err.message : t('healthybowl.common.error', 'Something went wrong.'),\n variant: 'error',\n });\n }\n };\n\n const copy = async (value: string) => {\n try {\n await navigator.clipboard.writeText(value);\n toast({ title: t('healthybowl.reportsApi.copied', 'Copied to clipboard'), variant: 'success' });\n } catch {\n toast({ title: t('healthybowl.reportsApi.copyFailed', 'Copy failed'), variant: 'error' });\n }\n };\n\n // ── Column defs ─────────────────────────────────────────────────────────────\n const keyColumns: Column<HBApiKey>[] = [\n { key: 'name', header: t('healthybowl.reportsApi.keys.col.name', 'Name'), sortable: true },\n {\n key: 'key',\n header: t('healthybowl.reportsApi.keys.col.key', 'Key'),\n render: (k) => <span className=\"font-mono text-xs text-text-secondary\">{maskKey(k.key)}</span>,\n },\n {\n key: 'permissions',\n header: t('healthybowl.reportsApi.keys.col.scope', 'Scope'),\n render: (k) => <span className=\"text-xs text-text-secondary\">{k.permissions.join(', ') || '—'}</span>,\n },\n {\n key: 'createdAt',\n header: t('healthybowl.reportsApi.keys.col.created', 'Created'),\n render: (k) => formatDateOnly(k.createdAt),\n },\n {\n key: 'lastUsedAt',\n header: t('healthybowl.reportsApi.keys.col.lastUsed', 'Last used'),\n render: (k) => (k.lastUsedAt ? formatDateOnly(k.lastUsedAt) : t('healthybowl.reportsApi.never', 'Never')),\n },\n {\n key: 'status',\n header: t('healthybowl.reportsApi.keys.col.status', 'Status'),\n render: (k) =>\n k.isActive ? (\n <StatusBadge label={t('healthybowl.reportsApi.active', 'Active')} variant=\"success\" dot />\n ) : (\n <StatusBadge label={t('healthybowl.reportsApi.revoked', 'Revoked')} variant=\"muted\" />\n ),\n },\n {\n key: 'actions',\n header: '',\n render: (k) =>\n k.isActive ? (\n <Button variant=\"ghost\" size=\"sm\" onClick={() => handleRevokeKey(k)}>\n <Trash2 className=\"mr-1 h-4 w-4\" />\n {t('healthybowl.reportsApi.keys.revoke', 'Revoke')}\n </Button>\n ) : null,\n },\n ];\n\n const hookColumns: Column<HBWebhook>[] = [\n {\n key: 'events',\n header: t('healthybowl.reportsApi.webhooks.col.event', 'Event'),\n render: (h) => <span className=\"font-mono text-xs\">{h.events.join(', ')}</span>,\n },\n {\n key: 'url',\n header: t('healthybowl.reportsApi.webhooks.col.url', 'Target URL'),\n render: (h) => <span className=\"max-w-[22rem] truncate font-mono text-xs text-text-secondary\">{h.url}</span>,\n },\n {\n key: 'status',\n header: t('healthybowl.reportsApi.webhooks.col.status', 'Status'),\n render: (h) =>\n !h.isActive ? (\n <StatusBadge label={t('healthybowl.reportsApi.paused', 'Paused')} variant=\"muted\" />\n ) : h.lastError ? (\n <StatusBadge label={t('healthybowl.reportsApi.failed', 'Failed')} variant=\"error\" dot />\n ) : (\n <StatusBadge label={t('healthybowl.reportsApi.active', 'Active')} variant=\"success\" dot />\n ),\n },\n {\n key: 'lastDelivery',\n header: t('healthybowl.reportsApi.webhooks.col.lastDelivery', 'Last delivery'),\n render: (h) => (h.lastDelivery ? formatDateOnly(h.lastDelivery) : t('healthybowl.reportsApi.never', 'Never')),\n },\n {\n key: 'actions',\n header: '',\n render: (h) => (\n <Button variant=\"ghost\" size=\"sm\" onClick={() => handleDeleteHook(h)}>\n <Trash2 className=\"mr-1 h-4 w-4\" />\n {t('healthybowl.common.delete', 'Delete')}\n </Button>\n ),\n },\n ];\n\n const dashboardColumns: Column<HBDashboard>[] = [\n { key: 'name', header: t('healthybowl.reportsApi.reports.col.name', 'Dashboard'), sortable: true },\n {\n key: 'category',\n header: t('healthybowl.reportsApi.reports.col.category', 'Category'),\n render: (d) => <span className=\"text-xs text-text-secondary\">{d.category}</span>,\n },\n {\n key: 'updatedAt',\n header: t('healthybowl.reportsApi.reports.col.updated', 'Updated'),\n render: (d) => formatDateOnly(d.updatedAt),\n },\n {\n key: 'actions',\n header: '',\n render: (d) => (\n <a\n href={`${bigConsoleUrl}${bigConsoleUrl.endsWith('/') ? '' : '/'}dashboards/${d.id}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline\"\n >\n {t('healthybowl.reportsApi.reports.open', 'Open')}\n <ExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n ),\n },\n ];\n\n const tabs: { id: TabId; label: string; icon: ReactNode }[] = [\n { id: 'keys', label: t('healthybowl.reportsApi.tab.keys', 'API Keys'), icon: <KeyRound className=\"h-4 w-4\" /> },\n {\n id: 'webhooks',\n label: t('healthybowl.reportsApi.tab.webhooks', 'Webhooks'),\n icon: <Webhook className=\"h-4 w-4\" />,\n },\n {\n id: 'reports',\n label: t('healthybowl.reportsApi.tab.reports', 'Reports & Dashboards'),\n icon: <BarChart3 className=\"h-4 w-4\" />,\n },\n ];\n\n const activeKeys = apiKeys.filter((k) => k.isActive).length;\n\n return (\n <PageLayout\n title={t('healthybowl.reportsApi.title', 'Reports & API')}\n titleAccent={t('healthybowl.reportsApi.titleAccent', 'API')}\n hero\n description={t(\n 'healthybowl.reportsApi.description',\n 'Build custom dashboards, issue developer API keys, and subscribe webhooks — one place to connect HealthyBowl to your other tools.'\n )}\n helpPrompt={t(\n 'healthybowl.reportsApi.help',\n 'How do I use the HealthyBowl API keys, webhooks and custom dashboards?'\n )}\n >\n {/* Tab bar */}\n <div className=\"mb-6 flex flex-wrap gap-1 border-b border-border-subtle\">\n {tabs.map((tb) => (\n <button\n key={tb.id}\n type=\"button\"\n onClick={() => setTab(tb.id)}\n className={`flex items-center gap-2 border-b-2 px-4 py-2 text-sm font-medium transition-colors ${\n tab === tb.id\n ? 'border-primary text-text-primary'\n : 'border-transparent text-text-secondary hover:text-text-primary'\n }`}\n >\n {tb.icon}\n {tb.label}\n </button>\n ))}\n </div>\n\n {/* ── API KEYS ─────────────────────────────────────────────────────────── */}\n {tab === 'keys' && (\n <div className=\"space-y-6\">\n <div className=\"grid grid-cols-2 gap-4 sm:max-w-md\">\n <StatCard\n label={t('healthybowl.reportsApi.keys.stat.total', 'Total keys')}\n value={apiKeys.length}\n icon={<KeyRound />}\n />\n <StatCard label={t('healthybowl.reportsApi.keys.stat.active', 'Active')} value={activeKeys} />\n </div>\n\n <div className=\"flex items-center justify-between\">\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'healthybowl.reportsApi.keys.blurb',\n 'Keys authenticate a third party reading THIS workspace’s data. Read-first, with role-based access control.'\n )}\n </p>\n <Button onClick={openKeyModal}>\n <Plus className=\"mr-1 h-4 w-4\" />\n {t('healthybowl.reportsApi.keys.generate', 'Generate key')}\n </Button>\n </div>\n\n {/* Documented endpoint reference */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <div className=\"mb-2 flex items-center gap-2 text-sm font-medium text-text-primary\">\n <Code2 className=\"h-4 w-4\" />\n {t('healthybowl.reportsApi.keys.endpoint.title', 'Public API endpoint')}\n </div>\n <pre className=\"overflow-x-auto rounded-md bg-bg-muted p-3 font-mono text-xs text-text-secondary\">\n {`curl -H \"Authorization: Bearer ak_…\" \\\\\\n ${API_BASE}/harvests`}\n </pre>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.reportsApi.keys.endpoint.note',\n 'Read endpoints (harvests, orders, crops) are scoped to your workspace with role-based access control. Send the key as a Bearer token.'\n )}\n </p>\n </div>\n\n {apiKeysError ? (\n <ErrorState\n title={t('healthybowl.reportsApi.keys.error', 'Could not load API keys')}\n description={apiKeysError}\n />\n ) : apiKeys.length === 0 && !apiKeysLoading ? (\n <EmptyState\n icon={<KeyRound />}\n title={t('healthybowl.reportsApi.keys.empty.title', 'No API keys yet')}\n description={t(\n 'healthybowl.reportsApi.keys.empty.desc',\n 'Generate a key to let an external tool read your farm data.'\n )}\n />\n ) : (\n <DataTable columns={keyColumns} data={apiKeys} keyField=\"id\" />\n )}\n </div>\n )}\n\n {/* ── WEBHOOKS ─────────────────────────────────────────────────────────── */}\n {tab === 'webhooks' && (\n <div className=\"space-y-6\">\n <div className=\"flex items-center justify-between\">\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'healthybowl.reportsApi.webhooks.blurb',\n 'POST an HB event to any URL or a Zapier hook when it fires — e.g. push every new harvest into a buyer’s system.'\n )}\n </p>\n <Button onClick={() => setHookModalOpen(true)}>\n <Plus className=\"mr-1 h-4 w-4\" />\n {t('healthybowl.reportsApi.webhooks.add', 'Add webhook')}\n </Button>\n </div>\n\n {webhooksError ? (\n <ErrorState\n title={t('healthybowl.reportsApi.webhooks.error', 'Could not load webhooks')}\n description={webhooksError}\n />\n ) : webhooks.length === 0 && !webhooksLoading ? (\n <EmptyState\n icon={<Webhook />}\n title={t('healthybowl.reportsApi.webhooks.empty.title', 'No webhooks yet')}\n description={t(\n 'healthybowl.reportsApi.webhooks.empty.desc',\n 'Subscribe harvest.created or order.paid to an outbound URL.'\n )}\n />\n ) : (\n <DataTable columns={hookColumns} data={webhooks} keyField=\"id\" />\n )}\n </div>\n )}\n\n {/* ── REPORTS & DASHBOARDS ─────────────────────────────────────────────── */}\n {tab === 'reports' && (\n <div className=\"space-y-6\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-5\">\n <div className=\"mb-1 flex items-center gap-2 text-base font-semibold text-text-primary\">\n <BarChart3 className=\"h-5 w-5\" />\n {t('healthybowl.reportsApi.reports.builder.title', 'Build a custom dashboard')}\n </div>\n <p className=\"mb-4 max-w-2xl text-sm text-text-secondary\">\n {t(\n 'healthybowl.reportsApi.reports.builder.desc',\n 'Drag HealthyBowl data fields (crop yield, revenue, livestock count, compliance) onto a canvas and pick charts, KPI cards and tables — no engineering needed. Custom dashboards export to CSV/PDF and can be emailed on a schedule, all in BigConsole.'\n )}\n </p>\n <a href={bigConsoleUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n <Button>\n {t('healthybowl.reportsApi.reports.builder.cta', 'Open the dashboard builder')}\n <ExternalLink className=\"ml-1 h-4 w-4\" />\n </Button>\n </a>\n </div>\n\n <div>\n <h3 className=\"mb-3 text-sm font-semibold text-text-primary\">\n {t('healthybowl.reportsApi.reports.saved.title', 'Saved dashboards')}\n </h3>\n {dashboardsError ? (\n <ErrorState\n title={t('healthybowl.reportsApi.reports.error', 'Could not load dashboards')}\n description={dashboardsError}\n />\n ) : dashboards.length === 0 && !dashboardsLoading ? (\n <EmptyState\n icon={<BarChart3 />}\n title={t('healthybowl.reportsApi.reports.empty.title', 'No custom dashboards yet')}\n description={t(\n 'healthybowl.reportsApi.reports.empty.desc',\n 'Dashboards you build in BigConsole appear here.'\n )}\n />\n ) : (\n <DataTable columns={dashboardColumns} data={dashboards} keyField=\"id\" />\n )}\n </div>\n </div>\n )}\n\n {/* ── API-key modal (create → reveal once) ─────────────────────────────── */}\n <Modal\n open={keyModalOpen}\n onClose={() => setKeyModalOpen(false)}\n title={\n revealedKey\n ? t('healthybowl.reportsApi.keys.modal.createdTitle', 'API key created')\n : t('healthybowl.reportsApi.keys.modal.title', 'Generate API key')\n }\n description={\n revealedKey\n ? t('healthybowl.reportsApi.keys.modal.createdDesc', 'Copy this key now — it will not be shown again.')\n : t('healthybowl.reportsApi.keys.modal.desc', 'Name the key and choose its scope.')\n }\n size=\"md\"\n footer={\n revealedKey ? (\n <Button onClick={() => setKeyModalOpen(false)}>{t('healthybowl.common.done', 'Done')}</Button>\n ) : (\n <>\n <Button variant=\"outline\" onClick={() => setKeyModalOpen(false)}>\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleCreateKey} disabled={submittingKey}>\n {submittingKey\n ? t('healthybowl.reportsApi.keys.generating', 'Generating…')\n : t('healthybowl.reportsApi.keys.generate', 'Generate key')}\n </Button>\n </>\n )\n }\n >\n {revealedKey ? (\n <div className=\"space-y-3\">\n <div className=\"flex items-center gap-2\">\n <code className=\"flex-1 overflow-x-auto rounded-md border border-border-subtle bg-bg-muted p-3 font-mono text-xs text-text-primary\">\n {revealedKey.key}\n </code>\n <Button variant=\"outline\" size=\"sm\" onClick={() => copy(revealedKey.key)}>\n <Copy className=\"mr-1 h-4 w-4\" />\n {t('healthybowl.common.copy', 'Copy')}\n </Button>\n </div>\n <p className=\"text-xs text-text-secondary\">\n {t(\n 'healthybowl.reportsApi.keys.modal.storeSafe',\n 'Store it in your secrets manager. If you lose it, revoke and generate a new one.'\n )}\n </p>\n </div>\n ) : (\n <div className=\"space-y-4\">\n <div>\n <label htmlFor=\"key-name\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.reportsApi.keys.form.name', 'Key name *')}\n </label>\n <input\n id=\"key-name\"\n type=\"text\"\n value={keyName}\n onChange={(e) => setKeyName(e.target.value)}\n placeholder={t('healthybowl.reportsApi.keys.form.namePlaceholder', 'e.g., Buyer integration')}\n className={inputClass}\n />\n </div>\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input type=\"checkbox\" checked={keyCanWrite} onChange={(e) => setKeyCanWrite(e.target.checked)} />\n {t('healthybowl.reportsApi.keys.form.allowWrite', 'Allow write access (default is read-only)')}\n </label>\n </div>\n )}\n </Modal>\n\n {/* ── Webhook modal ────────────────────────────────────────────────────── */}\n <Modal\n open={hookModalOpen}\n onClose={() => setHookModalOpen(false)}\n title={t('healthybowl.reportsApi.webhooks.modal.title', 'Add webhook')}\n description={t('healthybowl.reportsApi.webhooks.modal.desc', 'Pick an event and the URL to POST it to.')}\n size=\"md\"\n footer={\n <>\n <Button variant=\"outline\" onClick={() => setHookModalOpen(false)}>\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleCreateHook} disabled={submittingHook}>\n {submittingHook\n ? t('healthybowl.reportsApi.webhooks.adding', 'Adding…')\n : t('healthybowl.reportsApi.webhooks.add', 'Add webhook')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-4\">\n <div>\n <label htmlFor=\"hook-event\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.reportsApi.webhooks.form.event', 'Event')}\n </label>\n <select\n id=\"hook-event\"\n value={hookEvent}\n onChange={(e) => setHookEvent(e.target.value)}\n className={inputClass}\n >\n {HB_WEBHOOK_EVENTS.map((ev) => (\n <option key={ev.value} value={ev.value}>\n {ev.label}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"hook-url\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.reportsApi.webhooks.form.url', 'Target URL *')}\n </label>\n <input\n id=\"hook-url\"\n type=\"url\"\n value={hookUrl}\n onChange={(e) => setHookUrl(e.target.value)}\n placeholder=\"https://hooks.zapier.com/…\"\n className={inputClass}\n />\n </div>\n </div>\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiDA,IAAM,IACJ,uMAGI,IAAW;AAGjB,SAAS,GAAQ,GAAqB;AAEpC,QADI,CAAC,KAAO,EAAI,UAAU,KAAW,aAC9B,GAAG,EAAI,MAAM,GAAG,EAAE,CAAC,GAAG,EAAI,MAAM,GAAG;;AAG5C,SAAgB,IAAiB;CAC/B,IAAM,EAAE,SAAM,IAAS,EACjB,IAAU,IAAY,EACtB,EAAE,WAAQ,UAAO,gBAAY,IAAU,EACvC,EACJ,YACA,oBACA,iBACA,kBACA,kBACA,aACA,qBACA,kBACA,mBACA,mBACA,eACA,uBACA,uBACE,IAAe,EAEb,CAAC,GAAK,KAAU,EAAgB,OAAO,EAGvC,CAAC,GAAc,KAAmB,EAAS,GAAM,EACjD,CAAC,GAAS,KAAc,EAAS,GAAG,EACpC,CAAC,GAAa,KAAkB,EAAS,GAAM,EAC/C,CAAC,GAAe,KAAoB,EAAS,GAAM,EACnD,CAAC,GAAa,KAAkB,EAA0B,KAAK,EAG/D,CAAC,IAAe,KAAoB,EAAS,GAAM,EACnD,CAAC,GAAS,KAAc,EAAS,GAAG,EACpC,CAAC,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{"version":3,"file":"ReportsApiPage.js","names":[],"sources":["../../../../src/healthybowl/pages/reports-api/ReportsApiPage.tsx"],"sourcesContent":["/**\n * Reports & API — the single management surface for roadmap #19 (Custom Report\n * Builder & Developer API).\n *\n * A non-engineer manages everything the farm exposes to the outside world from one\n * screen, across three tabs:\n * · API Keys — issue / copy-once / revoke per-workspace developer keys for the\n * documented public API (analytics-svc; the key authenticates a\n * third party reading this workspace's harvests / orders / crops).\n * · Webhooks — subscribe an outbound webhook to an HB event (harvest.created /\n * order.paid) so a buyer's / Zapier endpoint is POSTed when it fires\n * (platform webhook engine).\n * · Reports — build a no-code custom dashboard in BigConsole (drag-and-drop\n * canvas, CSV/PDF export, scheduled email) and see the saved ones.\n *\n * Per spec §5 HealthyBowl builds NO charting / API / webhook engine — this page is\n * pure management UI over composed ops (see `useReportsApi`) plus a deep-link into\n * the BigConsole builder app.\n * @module healthybowl\n */\nimport { useMemo, useState, type ReactNode } from 'react';\nimport { BarChart3, ExternalLink, Plus, Trash2, Webhook } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { getProductUrl } from '@burdenoff/fe-libs/shared/config';\nimport {\n PageLayout,\n DataTable,\n type Column,\n Modal,\n StatusBadge,\n EmptyState,\n ErrorState,\n useConfirm,\n} from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { useReportsApi, HB_WEBHOOK_EVENTS, type HBWebhook, type HBDashboard } from '../../hooks/useReportsApi';\nimport { formatDateOnly } from '../../utils/helpers';\n\ntype TabId = 'webhooks' | 'reports';\n\nconst inputClass =\n 'h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\n\nexport function ReportsApiPage() {\n const { t } = useI18n();\n const confirm = useConfirm();\n const { toasts, toast, dismiss } = useToast();\n const {\n webhooks,\n webhooksLoading,\n webhooksError,\n createWebhook,\n deleteWebhook,\n dashboards,\n dashboardsLoading,\n dashboardsError,\n } = useReportsApi();\n\n const [tab, setTab] = useState<TabId>('webhooks');\n\n // ── Webhook create modal ────────────────────────────────────────────────────\n const [hookModalOpen, setHookModalOpen] = useState(false);\n const [hookUrl, setHookUrl] = useState('');\n const [hookEvent, setHookEvent] = useState<string>(HB_WEBHOOK_EVENTS[0].value);\n const [submittingHook, setSubmittingHook] = useState(false);\n\n const bigConsoleUrl = useMemo(() => {\n try {\n return getProductUrl('bigconsole');\n } catch {\n return 'https://app.bigconsole.com/';\n }\n }, []);\n\n const handleCreateHook = async () => {\n if (!hookUrl.trim() || !/^https?:\\/\\//i.test(hookUrl.trim())) {\n toast({\n title: t('healthybowl.reportsApi.webhooks.urlRequired.title', 'Valid URL required'),\n description: t('healthybowl.reportsApi.webhooks.urlRequired.desc', 'Enter the https URL to POST events to.'),\n variant: 'warning',\n });\n return;\n }\n setSubmittingHook(true);\n try {\n const eventLabel = HB_WEBHOOK_EVENTS.find((e) => e.value === hookEvent)?.label ?? hookEvent;\n await createWebhook({\n name: `HealthyBowl · ${eventLabel}`,\n url: hookUrl.trim(),\n events: [hookEvent],\n });\n setHookModalOpen(false);\n setHookUrl('');\n toast({\n title: t('healthybowl.reportsApi.webhooks.added.title', 'Webhook added'),\n description: t('healthybowl.reportsApi.webhooks.added.desc', 'It will POST when the event fires.'),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.reportsApi.webhooks.addError.title', 'Could not add webhook'),\n description: err instanceof Error ? err.message : t('healthybowl.common.error', 'Something went wrong.'),\n variant: 'error',\n });\n } finally {\n setSubmittingHook(false);\n }\n };\n\n const handleDeleteHook = async (h: HBWebhook) => {\n if (\n !(await confirm({\n message: t('healthybowl.reportsApi.webhooks.confirmDelete', 'Delete this webhook subscription?'),\n }))\n ) {\n return;\n }\n try {\n await deleteWebhook(h.id);\n toast({ title: t('healthybowl.reportsApi.webhooks.deleted.title', 'Webhook deleted'), variant: 'success' });\n } catch (err) {\n toast({\n title: t('healthybowl.reportsApi.webhooks.deleteError.title', 'Could not delete webhook'),\n description: err instanceof Error ? err.message : t('healthybowl.common.error', 'Something went wrong.'),\n variant: 'error',\n });\n }\n };\n\n // ── Column defs ─────────────────────────────────────────────────────────────\n const hookColumns: Column<HBWebhook>[] = [\n {\n key: 'events',\n header: t('healthybowl.reportsApi.webhooks.col.event', 'Event'),\n render: (h) => <span className=\"font-mono text-xs\">{h.events.join(', ')}</span>,\n },\n {\n key: 'url',\n header: t('healthybowl.reportsApi.webhooks.col.url', 'Target URL'),\n render: (h) => <span className=\"max-w-[22rem] truncate font-mono text-xs text-text-secondary\">{h.url}</span>,\n },\n {\n key: 'status',\n header: t('healthybowl.reportsApi.webhooks.col.status', 'Status'),\n render: (h) =>\n !h.isActive ? (\n <StatusBadge label={t('healthybowl.reportsApi.paused', 'Paused')} variant=\"muted\" />\n ) : h.lastError ? (\n <StatusBadge label={t('healthybowl.reportsApi.failed', 'Failed')} variant=\"error\" dot />\n ) : (\n <StatusBadge label={t('healthybowl.reportsApi.active', 'Active')} variant=\"success\" dot />\n ),\n },\n {\n key: 'lastDelivery',\n header: t('healthybowl.reportsApi.webhooks.col.lastDelivery', 'Last delivery'),\n render: (h) => (h.lastDelivery ? formatDateOnly(h.lastDelivery) : t('healthybowl.reportsApi.never', 'Never')),\n },\n {\n key: 'actions',\n header: '',\n render: (h) => (\n <Button variant=\"ghost\" size=\"sm\" onClick={() => handleDeleteHook(h)}>\n <Trash2 className=\"mr-1 h-4 w-4\" />\n {t('healthybowl.common.delete', 'Delete')}\n </Button>\n ),\n },\n ];\n\n const dashboardColumns: Column<HBDashboard>[] = [\n { key: 'name', header: t('healthybowl.reportsApi.reports.col.name', 'Dashboard'), sortable: true },\n {\n key: 'category',\n header: t('healthybowl.reportsApi.reports.col.category', 'Category'),\n render: (d) => <span className=\"text-xs text-text-secondary\">{d.category}</span>,\n },\n {\n key: 'updatedAt',\n header: t('healthybowl.reportsApi.reports.col.updated', 'Updated'),\n render: (d) => formatDateOnly(d.updatedAt),\n },\n {\n key: 'actions',\n header: '',\n render: (d) => (\n <a\n href={`${bigConsoleUrl}${bigConsoleUrl.endsWith('/') ? '' : '/'}dashboards/${d.id}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline\"\n >\n {t('healthybowl.reportsApi.reports.open', 'Open')}\n <ExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n ),\n },\n ];\n\n const tabs: { id: TabId; label: string; icon: ReactNode }[] = [\n {\n id: 'webhooks',\n label: t('healthybowl.reportsApi.tab.webhooks', 'Webhooks'),\n icon: <Webhook className=\"h-4 w-4\" />,\n },\n {\n id: 'reports',\n label: t('healthybowl.reportsApi.tab.reports', 'Reports & Dashboards'),\n icon: <BarChart3 className=\"h-4 w-4\" />,\n },\n ];\n\n return (\n <PageLayout\n title={t('healthybowl.reportsApi.title', 'Reports & API')}\n titleAccent={t('healthybowl.reportsApi.titleAccent', 'API')}\n hero\n description={t(\n 'healthybowl.reportsApi.description',\n 'Build custom dashboards and subscribe webhooks — one place to connect HealthyBowl to your other tools.'\n )}\n helpPrompt={t('healthybowl.reportsApi.help', 'How do I use HealthyBowl webhooks and custom dashboards?')}\n >\n {/* Tab bar */}\n <div className=\"mb-6 flex flex-wrap gap-1 border-b border-border-subtle\">\n {tabs.map((tb) => (\n <button\n key={tb.id}\n type=\"button\"\n onClick={() => setTab(tb.id)}\n className={`flex items-center gap-2 border-b-2 px-4 py-2 text-sm font-medium transition-colors ${\n tab === tb.id\n ? 'border-primary text-text-primary'\n : 'border-transparent text-text-secondary hover:text-text-primary'\n }`}\n >\n {tb.icon}\n {tb.label}\n </button>\n ))}\n </div>\n\n {/* ── WEBHOOKS ─────────────────────────────────────────────────────────── */}\n {tab === 'webhooks' && (\n <div className=\"space-y-6\">\n <div className=\"flex items-center justify-between\">\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'healthybowl.reportsApi.webhooks.blurb',\n 'POST an HB event to any URL or a Zapier hook when it fires — e.g. push every new harvest into a buyer’s system.'\n )}\n </p>\n <Button onClick={() => setHookModalOpen(true)}>\n <Plus className=\"mr-1 h-4 w-4\" />\n {t('healthybowl.reportsApi.webhooks.add', 'Add webhook')}\n </Button>\n </div>\n\n {webhooksError ? (\n <ErrorState\n title={t('healthybowl.reportsApi.webhooks.error', 'Could not load webhooks')}\n description={webhooksError}\n />\n ) : webhooks.length === 0 && !webhooksLoading ? (\n <EmptyState\n icon={<Webhook />}\n title={t('healthybowl.reportsApi.webhooks.empty.title', 'No webhooks yet')}\n description={t(\n 'healthybowl.reportsApi.webhooks.empty.desc',\n 'Subscribe harvest.created or order.paid to an outbound URL.'\n )}\n />\n ) : (\n <DataTable columns={hookColumns} data={webhooks} keyField=\"id\" />\n )}\n </div>\n )}\n\n {/* ── REPORTS & DASHBOARDS ─────────────────────────────────────────────── */}\n {tab === 'reports' && (\n <div className=\"space-y-6\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-5\">\n <div className=\"mb-1 flex items-center gap-2 text-base font-semibold text-text-primary\">\n <BarChart3 className=\"h-5 w-5\" />\n {t('healthybowl.reportsApi.reports.builder.title', 'Build a custom dashboard')}\n </div>\n <p className=\"mb-4 max-w-2xl text-sm text-text-secondary\">\n {t(\n 'healthybowl.reportsApi.reports.builder.desc',\n 'Drag HealthyBowl data fields (crop yield, revenue, livestock count, compliance) onto a canvas and pick charts, KPI cards and tables — no engineering needed. Custom dashboards export to CSV/PDF and can be emailed on a schedule, all in BigConsole.'\n )}\n </p>\n <a href={bigConsoleUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n <Button>\n {t('healthybowl.reportsApi.reports.builder.cta', 'Open the dashboard builder')}\n <ExternalLink className=\"ml-1 h-4 w-4\" />\n </Button>\n </a>\n </div>\n\n <div>\n <h3 className=\"mb-3 text-sm font-semibold text-text-primary\">\n {t('healthybowl.reportsApi.reports.saved.title', 'Saved dashboards')}\n </h3>\n {dashboardsError ? (\n <ErrorState\n title={t('healthybowl.reportsApi.reports.error', 'Could not load dashboards')}\n description={dashboardsError}\n />\n ) : dashboards.length === 0 && !dashboardsLoading ? (\n <EmptyState\n icon={<BarChart3 />}\n title={t('healthybowl.reportsApi.reports.empty.title', 'No custom dashboards yet')}\n description={t(\n 'healthybowl.reportsApi.reports.empty.desc',\n 'Dashboards you build in BigConsole appear here.'\n )}\n />\n ) : (\n <DataTable columns={dashboardColumns} data={dashboards} keyField=\"id\" />\n )}\n </div>\n </div>\n )}\n\n {/* ── Webhook modal ────────────────────────────────────────────────────── */}\n <Modal\n open={hookModalOpen}\n onClose={() => setHookModalOpen(false)}\n title={t('healthybowl.reportsApi.webhooks.modal.title', 'Add webhook')}\n description={t('healthybowl.reportsApi.webhooks.modal.desc', 'Pick an event and the URL to POST it to.')}\n size=\"md\"\n footer={\n <>\n <Button variant=\"outline\" onClick={() => setHookModalOpen(false)}>\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleCreateHook} disabled={submittingHook}>\n {submittingHook\n ? t('healthybowl.reportsApi.webhooks.adding', 'Adding…')\n : t('healthybowl.reportsApi.webhooks.add', 'Add webhook')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-4\">\n <div>\n <label htmlFor=\"hook-event\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.reportsApi.webhooks.form.event', 'Event')}\n </label>\n <select\n id=\"hook-event\"\n value={hookEvent}\n onChange={(e) => setHookEvent(e.target.value)}\n className={inputClass}\n >\n {HB_WEBHOOK_EVENTS.map((ev) => (\n <option key={ev.value} value={ev.value}>\n {ev.label}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"hook-url\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.reportsApi.webhooks.form.url', 'Target URL *')}\n </label>\n <input\n id=\"hook-url\"\n type=\"url\"\n value={hookUrl}\n onChange={(e) => setHookUrl(e.target.value)}\n placeholder=\"https://hooks.zapier.com/…\"\n className={inputClass}\n />\n </div>\n </div>\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0CA,IAAM,IACJ;AAEF,SAAgB,IAAiB;CAC/B,IAAM,EAAE,SAAM,GAAS,EACjB,IAAU,GAAY,EACtB,EAAE,WAAQ,UAAO,eAAY,GAAU,EACvC,EACJ,aACA,oBACA,kBACA,kBACA,kBACA,eACA,sBACA,uBACE,GAAe,EAEb,CAAC,GAAK,KAAU,EAAgB,WAAW,EAG3C,CAAC,GAAe,KAAoB,EAAS,GAAM,EACnD,CAAC,GAAS,KAAc,EAAS,GAAG,EACpC,CAAC,GAAW,KAAgB,EAAiB,EAAkB,GAAG,MAAM,EACxE,CAAC,GAAgB,KAAqB,EAAS,GAAM,EAErD,IAAgB,QAAc;AAClC,MAAI;AACF,UAAO,EAAc,aAAa;UAC5B;AACN,UAAO;;IAER,EAAE,CAAC,EAEA,IAAmB,YAAY;AACnC,MAAI,CAAC,EAAQ,MAAM,IAAI,CAAC,gBAAgB,KAAK,EAAQ,MAAM,CAAC,EAAE;AAC5D,KAAM;IACJ,OAAO,EAAE,qDAAqD,qBAAqB;IACnF,aAAa,EAAE,oDAAoD,yCAAyC;IAC5G,SAAS;IACV,CAAC;AACF;;AAEF,IAAkB,GAAK;AACvB,MAAI;AASF,GAPA,MAAM,EAAc;IAClB,MAAM,iBAFW,EAAkB,MAAM,MAAM,EAAE,UAAU,EAAU,EAAE,SAAS;IAGhF,KAAK,EAAQ,MAAM;IACnB,QAAQ,CAAC,EAAU;IACpB,CAAC,EACF,EAAiB,GAAM,EACvB,EAAW,GAAG,EACd,EAAM;IACJ,OAAO,EAAE,+CAA+C,gBAAgB;IACxE,aAAa,EAAE,8CAA8C,qCAAqC;IAClG,SAAS;IACV,CAAC;WACK,GAAK;AACZ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AA,CAAA,EACN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;MAAO,SAAQ;MAAW,WAAU;gBACjC,EAAE,4CAA4C,eAAe;MACxD,CAAA,EACR,kBAAC,SAAD;MACE,IAAG;MACH,MAAK;MACL,OAAO;MACP,WAAW,MAAM,EAAW,EAAE,OAAO,MAAM;MAC3C,aAAY;MACZ,WAAW;MACX,CAAA,CACE,EAAA,CAAA,CACF;;IACA,CAAA;GAER,kBAAC,GAAD;IAAwB;IAAQ,WAAW;IAAW,CAAA;GAC3C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.802.2",
3
+ "version": "2026.803.1",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [