@agent-native/core 0.123.0 → 0.123.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.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +16 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/templates-meta.ts +12 -0
- package/corpus/templates/crm/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +177 -0
- package/corpus/templates/crm/.agents/skills/crm/SKILL.md +205 -0
- package/corpus/templates/crm/.agents/skills/customizing-agent-native/SKILL.md +220 -0
- package/corpus/templates/crm/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/crm/.agents/skills/sharing/SKILL.md +228 -0
- package/corpus/templates/crm/.agents/skills/storing-data/SKILL.md +178 -0
- package/corpus/templates/crm/.agents/skills/upgrade-agent-native/SKILL.md +122 -0
- package/corpus/templates/crm/.env.example +5 -0
- package/corpus/templates/crm/AGENTS.md +82 -0
- package/corpus/templates/crm/CHANGELOG.md +25 -0
- package/corpus/templates/crm/DEVELOPING.md +66 -0
- package/corpus/templates/crm/README.md +122 -0
- package/corpus/templates/crm/_gitignore +12 -0
- package/corpus/templates/crm/actions/_crm-action-utils.ts +98 -0
- package/corpus/templates/crm/actions/_crm-attribute-utils.ts +219 -0
- package/corpus/templates/crm/actions/_crm-dashboard.ts +69 -0
- package/corpus/templates/crm/actions/_crm-data-program-actions.ts +15 -0
- package/corpus/templates/crm/actions/_crm-list-utils.ts +775 -0
- package/corpus/templates/crm/actions/_crm-signal-utils.ts +79 -0
- package/corpus/templates/crm/actions/add-crm-record-to-list.ts +164 -0
- package/corpus/templates/crm/actions/apply-crm-proposals.ts +291 -0
- package/corpus/templates/crm/actions/archive-crm-attribute.ts +69 -0
- package/corpus/templates/crm/actions/attach-call-evidence.ts +170 -0
- package/corpus/templates/crm/actions/configure-crm-connection.ts +126 -0
- package/corpus/templates/crm/actions/configure-native-crm.ts +44 -0
- package/corpus/templates/crm/actions/create-crm-attribute.ts +350 -0
- package/corpus/templates/crm/actions/create-crm-list.ts +194 -0
- package/corpus/templates/crm/actions/create-crm-record.ts +148 -0
- package/corpus/templates/crm/actions/create-crm-signal-tracker.ts +58 -0
- package/corpus/templates/crm/actions/delete-crm-saved-view.ts +68 -0
- package/corpus/templates/crm/actions/delete-staged-dataset.ts +14 -0
- package/corpus/templates/crm/actions/estimate-crm-enrichment.ts +229 -0
- package/corpus/templates/crm/actions/find-crm-duplicates.ts +87 -0
- package/corpus/templates/crm/actions/get-crm-automation-recipe.ts +36 -0
- package/corpus/templates/crm/actions/get-crm-dashboard-panel.ts +35 -0
- package/corpus/templates/crm/actions/get-crm-dashboard.ts +14 -0
- package/corpus/templates/crm/actions/get-crm-overview.ts +13 -0
- package/corpus/templates/crm/actions/get-crm-pipeline-data.ts +61 -0
- package/corpus/templates/crm/actions/get-crm-record-page.ts +287 -0
- package/corpus/templates/crm/actions/get-crm-record.ts +75 -0
- package/corpus/templates/crm/actions/get-crm-workspace.ts +364 -0
- package/corpus/templates/crm/actions/install-crm-pipeline-dashboard.ts +81 -0
- package/corpus/templates/crm/actions/list-crm-attributes.ts +71 -0
- package/corpus/templates/crm/actions/list-crm-connections.ts +68 -0
- package/corpus/templates/crm/actions/list-crm-dashboard-revisions.ts +15 -0
- package/corpus/templates/crm/actions/list-crm-dashboards.ts +15 -0
- package/corpus/templates/crm/actions/list-crm-enrichment-slots.ts +28 -0
- package/corpus/templates/crm/actions/list-crm-list-entries.ts +192 -0
- package/corpus/templates/crm/actions/list-crm-lists.ts +80 -0
- package/corpus/templates/crm/actions/list-crm-proposals.ts +55 -0
- package/corpus/templates/crm/actions/list-crm-record-field-history.ts +201 -0
- package/corpus/templates/crm/actions/list-crm-record-values.ts +200 -0
- package/corpus/templates/crm/actions/list-crm-records.ts +103 -0
- package/corpus/templates/crm/actions/list-crm-saved-views.ts +66 -0
- package/corpus/templates/crm/actions/list-crm-signal-hits.ts +43 -0
- package/corpus/templates/crm/actions/list-crm-signal-trackers.ts +32 -0
- package/corpus/templates/crm/actions/list-crm-tasks.ts +22 -0
- package/corpus/templates/crm/actions/list-staged-datasets.ts +14 -0
- package/corpus/templates/crm/actions/list-workspace-connections.ts +47 -0
- package/corpus/templates/crm/actions/manage-crm-attribute-option.ts +272 -0
- package/corpus/templates/crm/actions/manage-crm-signal-tracker.ts +87 -0
- package/corpus/templates/crm/actions/manage-crm-task.ts +132 -0
- package/corpus/templates/crm/actions/merge-crm-records.ts +691 -0
- package/corpus/templates/crm/actions/navigate.ts +54 -0
- package/corpus/templates/crm/actions/provider-api-catalog.ts +22 -0
- package/corpus/templates/crm/actions/provider-api-docs.ts +54 -0
- package/corpus/templates/crm/actions/provider-api-request.ts +92 -0
- package/corpus/templates/crm/actions/query-staged-dataset.ts +44 -0
- package/corpus/templates/crm/actions/record-crm-call-insight.ts +160 -0
- package/corpus/templates/crm/actions/record-crm-smart-signal.ts +150 -0
- package/corpus/templates/crm/actions/remove-crm-list-entry.ts +79 -0
- package/corpus/templates/crm/actions/restore-crm-dashboard-revision.ts +23 -0
- package/corpus/templates/crm/actions/review-crm-signal.ts +31 -0
- package/corpus/templates/crm/actions/run-crm-attribute-fill.ts +443 -0
- package/corpus/templates/crm/actions/run-crm-enrichment.ts +647 -0
- package/corpus/templates/crm/actions/run-crm-saved-view-program.ts +103 -0
- package/corpus/templates/crm/actions/run-crm-signal-trackers.ts +265 -0
- package/corpus/templates/crm/actions/run.ts +7 -0
- package/corpus/templates/crm/actions/save-crm-dashboard.ts +51 -0
- package/corpus/templates/crm/actions/save-crm-saved-view.ts +296 -0
- package/corpus/templates/crm/actions/sync-crm.ts +146 -0
- package/corpus/templates/crm/actions/update-crm-attribute.ts +111 -0
- package/corpus/templates/crm/actions/update-crm-list-entry.ts +102 -0
- package/corpus/templates/crm/actions/update-crm-list.ts +97 -0
- package/corpus/templates/crm/actions/update-crm-record.ts +543 -0
- package/corpus/templates/crm/actions/view-screen.ts +324 -0
- package/corpus/templates/crm/agent-native.app-skill.json +69 -0
- package/corpus/templates/crm/app/components/crm/CreateCrmRecordDialog.tsx +158 -0
- package/corpus/templates/crm/app/components/crm/CrmDashboardPanel.tsx +78 -0
- package/corpus/templates/crm/app/components/crm/CrmSignalsPanel.tsx +220 -0
- package/corpus/templates/crm/app/components/crm/IntelligenceSettings.tsx +414 -0
- package/corpus/templates/crm/app/components/crm/RecordActions.tsx +648 -0
- package/corpus/templates/crm/app/components/crm/RecordGrid.tsx +488 -0
- package/corpus/templates/crm/app/components/crm/RecordWorkspace.tsx +232 -0
- package/corpus/templates/crm/app/components/crm/SavedViewDataProgram.tsx +93 -0
- package/corpus/templates/crm/app/components/crm/Surface.tsx +97 -0
- package/corpus/templates/crm/app/components/crm/WorkOverview.tsx +180 -0
- package/corpus/templates/crm/app/components/crm/board/CrmBoard.tsx +988 -0
- package/corpus/templates/crm/app/components/crm/board/board-model.ts +399 -0
- package/corpus/templates/crm/app/components/crm/board/entry-filter.ts +150 -0
- package/corpus/templates/crm/app/components/crm/board/view-draft.ts +227 -0
- package/corpus/templates/crm/app/components/crm/grid/CrmGrid.tsx +1033 -0
- package/corpus/templates/crm/app/components/crm/grid/GridCell.tsx +620 -0
- package/corpus/templates/crm/app/components/crm/grid/clipboard.ts +84 -0
- package/corpus/templates/crm/app/components/crm/grid/model.ts +304 -0
- package/corpus/templates/crm/app/components/crm/grid/navigation.ts +220 -0
- package/corpus/templates/crm/app/components/crm/grid/query.ts +214 -0
- package/corpus/templates/crm/app/components/crm/record/AttributePanel.tsx +192 -0
- package/corpus/templates/crm/app/components/crm/record/FieldHistory.tsx +179 -0
- package/corpus/templates/crm/app/components/crm/record/RecordHeader.tsx +103 -0
- package/corpus/templates/crm/app/components/crm/record/RecordLists.tsx +235 -0
- package/corpus/templates/crm/app/components/crm/record/RecordTabs.tsx +206 -0
- package/corpus/templates/crm/app/components/crm/record/field-editors.tsx +245 -0
- package/corpus/templates/crm/app/components/crm/record/record-data.ts +603 -0
- package/corpus/templates/crm/app/components/crm/settings/AdvancedSettings.tsx +49 -0
- package/corpus/templates/crm/app/components/crm/settings/AttributeOptionsEditor.tsx +441 -0
- package/corpus/templates/crm/app/components/crm/settings/ConnectionSettings.tsx +169 -0
- package/corpus/templates/crm/app/components/crm/settings/FieldsSettings.tsx +935 -0
- package/corpus/templates/crm/app/components/crm/settings/ListsSettings.tsx +339 -0
- package/corpus/templates/crm/app/components/crm/settings/settings-admin.ts +377 -0
- package/corpus/templates/crm/app/components/crm/shared/AttributeValueParts.tsx +69 -0
- package/corpus/templates/crm/app/components/crm/shared/attribute-value.ts +591 -0
- package/corpus/templates/crm/app/components/layout/CrmCommandMenu.tsx +556 -0
- package/corpus/templates/crm/app/components/layout/CrmLayout.tsx +130 -0
- package/corpus/templates/crm/app/components/layout/CrmSidebar.tsx +407 -0
- package/corpus/templates/crm/app/components/layout/command-palette-search.ts +126 -0
- package/corpus/templates/crm/app/components/layout/crm-ui-intents.ts +41 -0
- package/corpus/templates/crm/app/components/layout/sidebar-collapse.ts +40 -0
- package/corpus/templates/crm/app/components/layout/sidebar-lists.ts +109 -0
- package/corpus/templates/crm/app/components/ui/alert-dialog.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/badge.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/button.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/card.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/checkbox.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/dialog.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/dropdown-menu.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/hover-card.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/input.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/label.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/popover.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/select.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/sheet.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/skeleton.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/switch.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/table.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/tabs.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/textarea.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/toolkit-provider.tsx +17 -0
- package/corpus/templates/crm/app/components/ui/tooltip.tsx +1 -0
- package/corpus/templates/crm/app/design-system.ts +3 -0
- package/corpus/templates/crm/app/entry.client.tsx +19 -0
- package/corpus/templates/crm/app/entry.server.tsx +10 -0
- package/corpus/templates/crm/app/global.css +167 -0
- package/corpus/templates/crm/app/hooks/use-keyboard-shortcuts.ts +206 -0
- package/corpus/templates/crm/app/hooks/use-navigation-state.ts +48 -0
- package/corpus/templates/crm/app/i18n/en-US.ts +684 -0
- package/corpus/templates/crm/app/i18n/index.ts +34 -0
- package/corpus/templates/crm/app/lib/dashboard.ts +13 -0
- package/corpus/templates/crm/app/lib/navigation.ts +17 -0
- package/corpus/templates/crm/app/lib/tab-id.ts +1 -0
- package/corpus/templates/crm/app/lib/types.ts +172 -0
- package/corpus/templates/crm/app/lib/utils.ts +1 -0
- package/corpus/templates/crm/app/root.tsx +93 -0
- package/corpus/templates/crm/app/routes/_index.tsx +26 -0
- package/corpus/templates/crm/app/routes/accounts.tsx +41 -0
- package/corpus/templates/crm/app/routes/agent.tsx +5 -0
- package/corpus/templates/crm/app/routes/ask.tsx +53 -0
- package/corpus/templates/crm/app/routes/dashboard.tsx +118 -0
- package/corpus/templates/crm/app/routes/lists.tsx +228 -0
- package/corpus/templates/crm/app/routes/opportunities.tsx +41 -0
- package/corpus/templates/crm/app/routes/people.tsx +41 -0
- package/corpus/templates/crm/app/routes/proposals.tsx +388 -0
- package/corpus/templates/crm/app/routes/records.$recordId.tsx +53 -0
- package/corpus/templates/crm/app/routes/records.tsx +64 -0
- package/corpus/templates/crm/app/routes/settings.tsx +118 -0
- package/corpus/templates/crm/app/routes/setup.tsx +308 -0
- package/corpus/templates/crm/app/routes/tasks.tsx +252 -0
- package/corpus/templates/crm/app/routes/views.tsx +683 -0
- package/corpus/templates/crm/app/routes.ts +19 -0
- package/corpus/templates/crm/app/vite-env.d.ts +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-any-list-or-view-can-be-shown-as-a-board-grouped-by-stage-so.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-crm-now-finds-likely-duplicate-records-and-tells-you-exactly.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-enrichment-now-shows-what-a-run-will-cost-before-it-starts-g.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-lists-turn-any-set-of-records-into-a-pipeline-with-its-own-s.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-moving-a-record-or-list-entry-into-a-stage-that-was-retired-.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-opening-a-record-now-shows-one-page-with-its-fields-the-list.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-press-cmd-k-to-jump-to-any-record-list-view-or-setting-and-u.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-provider-record-edits-now-show-an-exact-before-after-diff-an.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-record-page-attribute-labels-now-read-in-full-instead-of-bei.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-records-now-use-typed-fields-currency-dates-ratings-status-s.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-retyping-a-value-on-the-record-page-now-replaces-it-instead-.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-settings-now-has-fields-and-lists-tabs-for-adding-fields-edi.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-the-proposal-review-now-shows-the-field-that-actually-change.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-the-record-grid-is-now-a-real-spreadsheet-filter-sort-and-pa.md +6 -0
- package/corpus/templates/crm/components.json +20 -0
- package/corpus/templates/crm/docs/architecture/crm-contract.md +214 -0
- package/corpus/templates/crm/docs/features/README.md +55 -0
- package/corpus/templates/crm/docs/features/f1-records-and-fields.mdx +52 -0
- package/corpus/templates/crm/docs/features/f2-lists-pipelines-and-views.mdx +48 -0
- package/corpus/templates/crm/docs/features/f3-work-and-record-quality.mdx +40 -0
- package/corpus/templates/crm/docs/features/f4-evidence-and-chat.mdx +47 -0
- package/corpus/templates/crm/learnings.defaults.md +5 -0
- package/corpus/templates/crm/netlify.toml +11 -0
- package/corpus/templates/crm/package.json +61 -0
- package/corpus/templates/crm/public/favicon.svg +1 -0
- package/corpus/templates/crm/public/icon-180.svg +1 -0
- package/corpus/templates/crm/public/manifest.json +11 -0
- package/corpus/templates/crm/react-router.config.ts +7 -0
- package/corpus/templates/crm/server/crm/adapter.ts +32 -0
- package/corpus/templates/crm/server/crm/crm-field-firewall.ts +64 -0
- package/corpus/templates/crm/server/crm/crm-mirror.ts +721 -0
- package/corpus/templates/crm/server/crm/field-policy-attributes.ts +48 -0
- package/corpus/templates/crm/server/crm/hubspot-adapter.ts +1146 -0
- package/corpus/templates/crm/server/crm/native-adapter.ts +1810 -0
- package/corpus/templates/crm/server/crm/provider-record-link.ts +264 -0
- package/corpus/templates/crm/server/crm/read-through.ts +207 -0
- package/corpus/templates/crm/server/crm/salesforce-adapter.ts +1255 -0
- package/corpus/templates/crm/server/db/crm-store.ts +1112 -0
- package/corpus/templates/crm/server/db/index.ts +191 -0
- package/corpus/templates/crm/server/db/schema.ts +647 -0
- package/corpus/templates/crm/server/lib/crm-query.ts +1558 -0
- package/corpus/templates/crm/server/lib/dedupe.ts +714 -0
- package/corpus/templates/crm/server/lib/enrichment-cost.ts +381 -0
- package/corpus/templates/crm/server/lib/enrichment-slots.ts +519 -0
- package/corpus/templates/crm/server/lib/intelligence/default-detectors.ts +65 -0
- package/corpus/templates/crm/server/lib/intelligence/evidence.ts +105 -0
- package/corpus/templates/crm/server/lib/intelligence/keyword-detector.ts +94 -0
- package/corpus/templates/crm/server/lib/intelligence/smart-detector.ts +39 -0
- package/corpus/templates/crm/server/lib/intelligence/summary.ts +19 -0
- package/corpus/templates/crm/server/lib/lifecycle.ts +634 -0
- package/corpus/templates/crm/server/lib/provider-api.ts +64 -0
- package/corpus/templates/crm/server/middleware/auth.ts +4 -0
- package/corpus/templates/crm/server/plugins/agent-chat.ts +65 -0
- package/corpus/templates/crm/server/plugins/auth.ts +14 -0
- package/corpus/templates/crm/server/plugins/core-routes.ts +17 -0
- package/corpus/templates/crm/server/plugins/db.ts +738 -0
- package/corpus/templates/crm/server/routes/[...page].get.ts +5 -0
- package/corpus/templates/crm/shared/crm-attributes.ts +469 -0
- package/corpus/templates/crm/shared/crm-automation-recipes.ts +132 -0
- package/corpus/templates/crm/shared/crm-contract.ts +417 -0
- package/corpus/templates/crm/shared/crm-navigation.ts +190 -0
- package/corpus/templates/crm/shared/crm-sales-config.ts +63 -0
- package/corpus/templates/crm/ssr-entry.ts +11 -0
- package/corpus/templates/crm/tsconfig.json +24 -0
- package/corpus/templates/crm/vite.config.ts +15 -0
- package/corpus/templates/crm/vitest.config.ts +5 -0
- package/corpus/templates/design/app/i18n-data.ts +12 -12
- package/corpus/templates/design/changelog/2026-07-26-apply-design-updates-from-a-centered-top-toolbar-without-cov.md +6 -0
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +12 -0
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +1 -1
- package/src/cli/templates-meta.ts +12 -0
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saved views: the index, and the table/board surface for one view.
|
|
3
|
+
*
|
|
4
|
+
* Unsaved filter, sort, grouping, and presentation changes live in the URL
|
|
5
|
+
* search params and nowhere else — a reload reverts to the stored view, and a
|
|
6
|
+
* shared view is never autosaved. Committing a change is an explicit three-way
|
|
7
|
+
* fork: save it, fork it into a new view, or discard it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
useActionMutation,
|
|
12
|
+
useActionQuery,
|
|
13
|
+
} from "@agent-native/core/client/hooks";
|
|
14
|
+
import { useT } from "@agent-native/core/client/i18n";
|
|
15
|
+
import {
|
|
16
|
+
IconArrowLeft,
|
|
17
|
+
IconBookmark,
|
|
18
|
+
IconLayoutKanban,
|
|
19
|
+
IconLock,
|
|
20
|
+
IconPlus,
|
|
21
|
+
IconTable,
|
|
22
|
+
IconUsers,
|
|
23
|
+
} from "@tabler/icons-react";
|
|
24
|
+
import { useCallback, useState } from "react";
|
|
25
|
+
import { Link, useNavigate, useSearchParams } from "react-router";
|
|
26
|
+
import { toast } from "sonner";
|
|
27
|
+
|
|
28
|
+
import { CrmBoard, type CrmBoardTarget } from "@/components/crm/board/CrmBoard";
|
|
29
|
+
import {
|
|
30
|
+
buildSaveFork,
|
|
31
|
+
clearBoardDraft,
|
|
32
|
+
draftIsDirty,
|
|
33
|
+
effectiveView,
|
|
34
|
+
groupSavedViews,
|
|
35
|
+
readBoardDraft,
|
|
36
|
+
writeBoardDraft,
|
|
37
|
+
type BoardDraft,
|
|
38
|
+
type SavedViewShape,
|
|
39
|
+
} from "@/components/crm/board/view-draft";
|
|
40
|
+
import {
|
|
41
|
+
LoadingRows,
|
|
42
|
+
PageHeader,
|
|
43
|
+
SetupEmptyState,
|
|
44
|
+
} from "@/components/crm/Surface";
|
|
45
|
+
import { Badge } from "@/components/ui/badge";
|
|
46
|
+
import { Button } from "@/components/ui/button";
|
|
47
|
+
import {
|
|
48
|
+
Dialog,
|
|
49
|
+
DialogContent,
|
|
50
|
+
DialogDescription,
|
|
51
|
+
DialogFooter,
|
|
52
|
+
DialogHeader,
|
|
53
|
+
DialogTitle,
|
|
54
|
+
DialogTrigger,
|
|
55
|
+
} from "@/components/ui/dialog";
|
|
56
|
+
import { Input } from "@/components/ui/input";
|
|
57
|
+
import { Label } from "@/components/ui/label";
|
|
58
|
+
import {
|
|
59
|
+
Select,
|
|
60
|
+
SelectContent,
|
|
61
|
+
SelectItem,
|
|
62
|
+
SelectTrigger,
|
|
63
|
+
SelectValue,
|
|
64
|
+
} from "@/components/ui/select";
|
|
65
|
+
|
|
66
|
+
interface SavedViewsResponse {
|
|
67
|
+
views: SavedViewShape[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface ListsResponse {
|
|
71
|
+
lists: Array<{
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
parentObjectType: string;
|
|
75
|
+
defaultViewId: string | null;
|
|
76
|
+
archived: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const OBJECT_TYPE_BY_KIND: Record<string, string> = {
|
|
81
|
+
account: "accounts",
|
|
82
|
+
person: "people",
|
|
83
|
+
opportunity: "opportunities",
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
function objectTypeFor(view: SavedViewShape): string {
|
|
87
|
+
if (view.targetId) return view.targetId;
|
|
88
|
+
return OBJECT_TYPE_BY_KIND[view.kind ?? ""] ?? "accounts";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function boardTargetFor(view: SavedViewShape): CrmBoardTarget {
|
|
92
|
+
if (view.targetKind === "list" && view.targetId) {
|
|
93
|
+
return { kind: "list", id: view.targetId };
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
kind: "object",
|
|
97
|
+
id: objectTypeFor(view),
|
|
98
|
+
recordKind: view.kind,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default function SavedViewsRoute() {
|
|
103
|
+
const [params] = useSearchParams();
|
|
104
|
+
const viewsQuery = useActionQuery<SavedViewsResponse>(
|
|
105
|
+
"list-crm-saved-views" as never,
|
|
106
|
+
{ limit: 100 } as never,
|
|
107
|
+
);
|
|
108
|
+
const listsQuery = useActionQuery<ListsResponse>(
|
|
109
|
+
"list-crm-lists" as never,
|
|
110
|
+
{ limit: 100 } as never,
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const viewId = params.get("view");
|
|
114
|
+
const listId = params.get("list");
|
|
115
|
+
const views = viewsQuery.data?.views ?? [];
|
|
116
|
+
const lists = listsQuery.data?.lists ?? [];
|
|
117
|
+
|
|
118
|
+
if (viewsQuery.isLoading || listsQuery.isLoading)
|
|
119
|
+
return <LoadingRows rows={6} />;
|
|
120
|
+
|
|
121
|
+
if (viewId) {
|
|
122
|
+
const view = views.find((entry) => entry.id === viewId);
|
|
123
|
+
return view ? (
|
|
124
|
+
<SavedViewSurface view={view} onSaved={() => void viewsQuery.refetch()} />
|
|
125
|
+
) : (
|
|
126
|
+
<MissingSurface kind="view" />
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
if (listId) {
|
|
130
|
+
const list = lists.find((entry) => entry.id === listId);
|
|
131
|
+
if (!list) return <MissingSurface kind="list" />;
|
|
132
|
+
const defaultView = list.defaultViewId
|
|
133
|
+
? views.find((entry) => entry.id === list.defaultViewId)
|
|
134
|
+
: undefined;
|
|
135
|
+
return defaultView ? (
|
|
136
|
+
<SavedViewSurface
|
|
137
|
+
view={defaultView}
|
|
138
|
+
onSaved={() => void viewsQuery.refetch()}
|
|
139
|
+
/>
|
|
140
|
+
) : (
|
|
141
|
+
<AdHocListSurface listId={list.id} name={list.name} />
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
return <ViewsIndex views={views} lists={lists} />;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
// Index
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
|
|
151
|
+
function ViewsIndex({
|
|
152
|
+
views,
|
|
153
|
+
lists,
|
|
154
|
+
}: {
|
|
155
|
+
views: SavedViewShape[];
|
|
156
|
+
lists: ListsResponse["lists"];
|
|
157
|
+
}) {
|
|
158
|
+
const t = useT();
|
|
159
|
+
const groups = groupSavedViews(views);
|
|
160
|
+
const listNames = new Map(lists.map((list) => [list.id, list.name]));
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<>
|
|
164
|
+
<PageHeader
|
|
165
|
+
eyebrow={t("views.eyebrow")}
|
|
166
|
+
title={t("views.title")}
|
|
167
|
+
description={t("views.description")}
|
|
168
|
+
actions={<CreateSavedViewDialog />}
|
|
169
|
+
/>
|
|
170
|
+
{groups.length ? (
|
|
171
|
+
<div className="grid gap-6 p-5 sm:p-7">
|
|
172
|
+
{groups.map((group) => (
|
|
173
|
+
<section key={`${group.targetKind}:${group.targetId}`}>
|
|
174
|
+
<h2 className="mb-2 text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground">
|
|
175
|
+
{group.targetKind === "list"
|
|
176
|
+
? (listNames.get(group.targetId) ??
|
|
177
|
+
t("views.groupList", { target: group.targetId }))
|
|
178
|
+
: t("views.groupObject", { target: group.targetId })}
|
|
179
|
+
</h2>
|
|
180
|
+
<div className="grid gap-2 sm:grid-cols-2 xl:grid-cols-3">
|
|
181
|
+
{group.views.map((view) => (
|
|
182
|
+
<Link
|
|
183
|
+
key={view.id}
|
|
184
|
+
to={`/views?view=${encodeURIComponent(view.id)}`}
|
|
185
|
+
className="group rounded-lg border border-border/70 bg-card p-4 transition-colors hover:bg-muted/50"
|
|
186
|
+
>
|
|
187
|
+
<div className="flex items-start gap-3">
|
|
188
|
+
{view.viewKind === "board" ? (
|
|
189
|
+
<IconLayoutKanban className="mt-0.5 size-4 text-muted-foreground" />
|
|
190
|
+
) : (
|
|
191
|
+
<IconTable className="mt-0.5 size-4 text-muted-foreground" />
|
|
192
|
+
)}
|
|
193
|
+
<div className="min-w-0">
|
|
194
|
+
<p className="truncate text-sm font-medium">
|
|
195
|
+
{view.name}
|
|
196
|
+
</p>
|
|
197
|
+
{view.description ? (
|
|
198
|
+
<p className="mt-1 line-clamp-2 text-sm text-muted-foreground">
|
|
199
|
+
{view.description}
|
|
200
|
+
</p>
|
|
201
|
+
) : null}
|
|
202
|
+
<div className="mt-3 flex flex-wrap gap-2">
|
|
203
|
+
<AudienceBadge audience={view.audience} />
|
|
204
|
+
{view.dataProgramId ? (
|
|
205
|
+
<Badge variant="outline" className="font-normal">
|
|
206
|
+
{t("views.dataProgram")}
|
|
207
|
+
</Badge>
|
|
208
|
+
) : null}
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
</Link>
|
|
213
|
+
))}
|
|
214
|
+
</div>
|
|
215
|
+
</section>
|
|
216
|
+
))}
|
|
217
|
+
</div>
|
|
218
|
+
) : (
|
|
219
|
+
<SetupEmptyState
|
|
220
|
+
title={t("views.emptyTitle")}
|
|
221
|
+
description={t("views.emptyDescription")}
|
|
222
|
+
/>
|
|
223
|
+
)}
|
|
224
|
+
</>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function AudienceBadge({ audience }: { audience: "personal" | "shared" }) {
|
|
229
|
+
const t = useT();
|
|
230
|
+
return (
|
|
231
|
+
<Badge variant="secondary" className="gap-1 font-normal">
|
|
232
|
+
{audience === "shared" ? (
|
|
233
|
+
<IconUsers className="size-3.5" />
|
|
234
|
+
) : (
|
|
235
|
+
<IconLock className="size-3.5" />
|
|
236
|
+
)}
|
|
237
|
+
{t(`views.audience.${audience}`)}
|
|
238
|
+
</Badge>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function MissingSurface({ kind }: { kind: "view" | "list" }) {
|
|
243
|
+
const t = useT();
|
|
244
|
+
return (
|
|
245
|
+
<>
|
|
246
|
+
<PageHeader
|
|
247
|
+
eyebrow={t("views.eyebrow")}
|
|
248
|
+
title={t(`views.missing.${kind}Title`)}
|
|
249
|
+
description={t(`views.missing.${kind}Description`)}
|
|
250
|
+
actions={<BackToViews />}
|
|
251
|
+
/>
|
|
252
|
+
</>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function BackToViews() {
|
|
257
|
+
const t = useT();
|
|
258
|
+
return (
|
|
259
|
+
<Button asChild variant="outline" size="sm" className="gap-1.5">
|
|
260
|
+
<Link to="/views">
|
|
261
|
+
<IconArrowLeft className="size-4" />
|
|
262
|
+
{t("views.backToViews")}
|
|
263
|
+
</Link>
|
|
264
|
+
</Button>
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// ---------------------------------------------------------------------------
|
|
269
|
+
// One saved view
|
|
270
|
+
// ---------------------------------------------------------------------------
|
|
271
|
+
|
|
272
|
+
function SavedViewSurface({
|
|
273
|
+
view,
|
|
274
|
+
onSaved,
|
|
275
|
+
}: {
|
|
276
|
+
view: SavedViewShape;
|
|
277
|
+
onSaved: () => void;
|
|
278
|
+
}) {
|
|
279
|
+
const t = useT();
|
|
280
|
+
const navigate = useNavigate();
|
|
281
|
+
const [params, setParams] = useSearchParams();
|
|
282
|
+
const [resolvedGroupId, setResolvedGroupId] = useState<string | null>(null);
|
|
283
|
+
const [statusAttributes, setStatusAttributes] = useState<
|
|
284
|
+
Array<{ id: string; label: string }>
|
|
285
|
+
>([]);
|
|
286
|
+
const save = useActionMutation<{ id: string }, Record<string, unknown>>(
|
|
287
|
+
"save-crm-saved-view" as never,
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
const onGrouping = useCallback(
|
|
291
|
+
(state: {
|
|
292
|
+
statusAttributes: Array<{ id: string; label: string }>;
|
|
293
|
+
groupAttributeId: string | null;
|
|
294
|
+
}) => {
|
|
295
|
+
setStatusAttributes(state.statusAttributes);
|
|
296
|
+
setResolvedGroupId(state.groupAttributeId);
|
|
297
|
+
},
|
|
298
|
+
[],
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
let draft: BoardDraft;
|
|
302
|
+
try {
|
|
303
|
+
draft = readBoardDraft(params);
|
|
304
|
+
} catch (error) {
|
|
305
|
+
return (
|
|
306
|
+
<>
|
|
307
|
+
<PageHeader
|
|
308
|
+
eyebrow={t("views.eyebrow")}
|
|
309
|
+
title={view.name}
|
|
310
|
+
description={
|
|
311
|
+
error instanceof Error ? error.message : t("views.draftUnreadable")
|
|
312
|
+
}
|
|
313
|
+
actions={
|
|
314
|
+
<Button
|
|
315
|
+
size="sm"
|
|
316
|
+
variant="outline"
|
|
317
|
+
onClick={() =>
|
|
318
|
+
setParams(clearBoardDraft(params), { replace: true })
|
|
319
|
+
}
|
|
320
|
+
>
|
|
321
|
+
{t("views.resetToSaved")}
|
|
322
|
+
</Button>
|
|
323
|
+
}
|
|
324
|
+
/>
|
|
325
|
+
</>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const effective = effectiveView(view, draft);
|
|
330
|
+
const dirty = draftIsDirty(view, draft);
|
|
331
|
+
// A board view must persist an explicit grouping, so a mode switch carries
|
|
332
|
+
// whatever the board actually grouped by.
|
|
333
|
+
const saveDraft: BoardDraft = {
|
|
334
|
+
...draft,
|
|
335
|
+
...(effective.viewKind === "board"
|
|
336
|
+
? {
|
|
337
|
+
groupByAttributeId:
|
|
338
|
+
draft.groupByAttributeId ??
|
|
339
|
+
view.groupByAttributeId ??
|
|
340
|
+
resolvedGroupId ??
|
|
341
|
+
undefined,
|
|
342
|
+
}
|
|
343
|
+
: {}),
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
function updateDraft(next: BoardDraft) {
|
|
347
|
+
setParams(writeBoardDraft(params, { ...draft, ...next }), {
|
|
348
|
+
replace: true,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
async function commitFork(branch: "update" | "new", name?: string) {
|
|
353
|
+
const mutation = buildSaveFork(branch, {
|
|
354
|
+
view,
|
|
355
|
+
draft: saveDraft,
|
|
356
|
+
...(name === undefined ? {} : { name }),
|
|
357
|
+
});
|
|
358
|
+
if (!mutation) return;
|
|
359
|
+
try {
|
|
360
|
+
const saved = await save.mutateAsync(mutation.input);
|
|
361
|
+
onSaved();
|
|
362
|
+
toast.success(t("views.savedToast"));
|
|
363
|
+
if (branch === "new") {
|
|
364
|
+
navigate(`/views?view=${encodeURIComponent(saved.id)}`);
|
|
365
|
+
} else {
|
|
366
|
+
setParams(clearBoardDraft(params), { replace: true });
|
|
367
|
+
}
|
|
368
|
+
} catch (error) {
|
|
369
|
+
toast.error(
|
|
370
|
+
error instanceof Error ? error.message : t("views.saveFailedToast"),
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return (
|
|
376
|
+
<>
|
|
377
|
+
<PageHeader
|
|
378
|
+
eyebrow={t("views.eyebrow")}
|
|
379
|
+
title={view.name}
|
|
380
|
+
{...(view.description ? { description: view.description } : {})}
|
|
381
|
+
actions={
|
|
382
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
383
|
+
<AudienceBadge audience={view.audience} />
|
|
384
|
+
<ModeToggle
|
|
385
|
+
mode={effective.viewKind}
|
|
386
|
+
onChange={(mode) => updateDraft({ mode })}
|
|
387
|
+
/>
|
|
388
|
+
<BackToViews />
|
|
389
|
+
</div>
|
|
390
|
+
}
|
|
391
|
+
/>
|
|
392
|
+
{effective.viewKind === "board" && statusAttributes.length > 1 ? (
|
|
393
|
+
<div className="flex items-center gap-2 border-b border-border/70 px-5 py-2 sm:px-7">
|
|
394
|
+
<span className="text-xs text-muted-foreground">
|
|
395
|
+
{t("views.groupBy")}
|
|
396
|
+
</span>
|
|
397
|
+
<Select
|
|
398
|
+
value={saveDraft.groupByAttributeId ?? ""}
|
|
399
|
+
onValueChange={(next) => updateDraft({ groupByAttributeId: next })}
|
|
400
|
+
>
|
|
401
|
+
<SelectTrigger className="h-8 w-56">
|
|
402
|
+
<SelectValue />
|
|
403
|
+
</SelectTrigger>
|
|
404
|
+
<SelectContent>
|
|
405
|
+
{statusAttributes.map((attribute) => (
|
|
406
|
+
<SelectItem key={attribute.id} value={attribute.id}>
|
|
407
|
+
{attribute.label}
|
|
408
|
+
</SelectItem>
|
|
409
|
+
))}
|
|
410
|
+
</SelectContent>
|
|
411
|
+
</Select>
|
|
412
|
+
</div>
|
|
413
|
+
) : null}
|
|
414
|
+
{dirty ? (
|
|
415
|
+
<SaveFork
|
|
416
|
+
audience={view.audience}
|
|
417
|
+
isSaving={save.isPending}
|
|
418
|
+
onUpdate={() => void commitFork("update")}
|
|
419
|
+
onSaveAsNew={(name) => void commitFork("new", name)}
|
|
420
|
+
onDiscard={() =>
|
|
421
|
+
setParams(clearBoardDraft(params), { replace: true })
|
|
422
|
+
}
|
|
423
|
+
/>
|
|
424
|
+
) : null}
|
|
425
|
+
<CrmBoard
|
|
426
|
+
target={boardTargetFor(view)}
|
|
427
|
+
{...(effective.groupByAttributeId
|
|
428
|
+
? { groupByAttributeId: effective.groupByAttributeId }
|
|
429
|
+
: {})}
|
|
430
|
+
filter={effective.filter}
|
|
431
|
+
mode={effective.viewKind}
|
|
432
|
+
columnAttributeIds={(view.columns ?? []).flatMap((column) =>
|
|
433
|
+
typeof column === "string"
|
|
434
|
+
? [column]
|
|
435
|
+
: typeof (column as { attributeId?: unknown }).attributeId ===
|
|
436
|
+
"string"
|
|
437
|
+
? [(column as { attributeId: string }).attributeId]
|
|
438
|
+
: [],
|
|
439
|
+
)}
|
|
440
|
+
onGrouping={onGrouping}
|
|
441
|
+
/>
|
|
442
|
+
</>
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function ModeToggle({
|
|
447
|
+
mode,
|
|
448
|
+
onChange,
|
|
449
|
+
}: {
|
|
450
|
+
mode: "table" | "board";
|
|
451
|
+
onChange: (mode: "table" | "board") => void;
|
|
452
|
+
}) {
|
|
453
|
+
const t = useT();
|
|
454
|
+
return (
|
|
455
|
+
<div className="flex items-center gap-1 rounded-md border border-border/70 p-0.5">
|
|
456
|
+
<Button
|
|
457
|
+
size="sm"
|
|
458
|
+
variant={mode === "table" ? "secondary" : "ghost"}
|
|
459
|
+
className="h-7 gap-1.5"
|
|
460
|
+
onClick={() => onChange("table")}
|
|
461
|
+
>
|
|
462
|
+
<IconTable className="size-4" />
|
|
463
|
+
{t("views.table")}
|
|
464
|
+
</Button>
|
|
465
|
+
<Button
|
|
466
|
+
size="sm"
|
|
467
|
+
variant={mode === "board" ? "secondary" : "ghost"}
|
|
468
|
+
className="h-7 gap-1.5"
|
|
469
|
+
onClick={() => onChange("board")}
|
|
470
|
+
>
|
|
471
|
+
<IconLayoutKanban className="size-4" />
|
|
472
|
+
{t("views.board")}
|
|
473
|
+
</Button>
|
|
474
|
+
</div>
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function SaveFork({
|
|
479
|
+
audience,
|
|
480
|
+
isSaving,
|
|
481
|
+
onUpdate,
|
|
482
|
+
onSaveAsNew,
|
|
483
|
+
onDiscard,
|
|
484
|
+
}: {
|
|
485
|
+
audience: "personal" | "shared";
|
|
486
|
+
isSaving: boolean;
|
|
487
|
+
onUpdate: () => void;
|
|
488
|
+
onSaveAsNew: (name: string) => void;
|
|
489
|
+
onDiscard: () => void;
|
|
490
|
+
}) {
|
|
491
|
+
const t = useT();
|
|
492
|
+
const [open, setOpen] = useState(false);
|
|
493
|
+
const [name, setName] = useState("");
|
|
494
|
+
|
|
495
|
+
return (
|
|
496
|
+
<div className="flex flex-wrap items-center gap-2 border-b border-border/70 bg-muted/40 px-5 py-2.5 sm:px-7">
|
|
497
|
+
<span className="mr-auto text-sm text-muted-foreground">
|
|
498
|
+
{t("views.unsavedChanges")}
|
|
499
|
+
</span>
|
|
500
|
+
<Button size="sm" disabled={isSaving} onClick={onUpdate}>
|
|
501
|
+
{audience === "shared" ? t("views.saveForEveryone") : t("views.save")}
|
|
502
|
+
</Button>
|
|
503
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
504
|
+
<DialogTrigger asChild>
|
|
505
|
+
<Button size="sm" variant="outline" className="gap-1.5">
|
|
506
|
+
<IconPlus className="size-4" />
|
|
507
|
+
{t("views.saveAsNew")}
|
|
508
|
+
</Button>
|
|
509
|
+
</DialogTrigger>
|
|
510
|
+
<DialogContent className="sm:max-w-md">
|
|
511
|
+
<DialogHeader>
|
|
512
|
+
<DialogTitle>{t("views.saveAsNewTitle")}</DialogTitle>
|
|
513
|
+
<DialogDescription>
|
|
514
|
+
{t("views.saveAsNewDescription")}
|
|
515
|
+
</DialogDescription>
|
|
516
|
+
</DialogHeader>
|
|
517
|
+
<div className="grid gap-2 py-2">
|
|
518
|
+
<Label htmlFor="new-view-name">{t("views.nameLabel")}</Label>
|
|
519
|
+
<Input
|
|
520
|
+
id="new-view-name"
|
|
521
|
+
value={name}
|
|
522
|
+
maxLength={120}
|
|
523
|
+
onChange={(event) => setName(event.target.value)}
|
|
524
|
+
/>
|
|
525
|
+
</div>
|
|
526
|
+
<DialogFooter>
|
|
527
|
+
<Button
|
|
528
|
+
disabled={!name.trim() || isSaving}
|
|
529
|
+
onClick={() => {
|
|
530
|
+
setOpen(false);
|
|
531
|
+
onSaveAsNew(name.trim());
|
|
532
|
+
}}
|
|
533
|
+
>
|
|
534
|
+
{t("views.createView")}
|
|
535
|
+
</Button>
|
|
536
|
+
</DialogFooter>
|
|
537
|
+
</DialogContent>
|
|
538
|
+
</Dialog>
|
|
539
|
+
<Button size="sm" variant="ghost" onClick={onDiscard}>
|
|
540
|
+
{t("views.discard")}
|
|
541
|
+
</Button>
|
|
542
|
+
</div>
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// ---------------------------------------------------------------------------
|
|
547
|
+
// A list with no default view yet
|
|
548
|
+
// ---------------------------------------------------------------------------
|
|
549
|
+
|
|
550
|
+
function AdHocListSurface({ listId, name }: { listId: string; name: string }) {
|
|
551
|
+
const t = useT();
|
|
552
|
+
const [params, setParams] = useSearchParams();
|
|
553
|
+
const mode = params.get("mode") === "table" ? "table" : "board";
|
|
554
|
+
|
|
555
|
+
return (
|
|
556
|
+
<>
|
|
557
|
+
<PageHeader
|
|
558
|
+
eyebrow={t("views.eyebrow")}
|
|
559
|
+
title={name}
|
|
560
|
+
description={t("views.listNoDefaultView")}
|
|
561
|
+
actions={
|
|
562
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
563
|
+
<ModeToggle
|
|
564
|
+
mode={mode}
|
|
565
|
+
onChange={(next) => {
|
|
566
|
+
const updated = new URLSearchParams(params);
|
|
567
|
+
updated.set("mode", next);
|
|
568
|
+
setParams(updated, { replace: true });
|
|
569
|
+
}}
|
|
570
|
+
/>
|
|
571
|
+
<Button asChild variant="outline" size="sm" className="gap-1.5">
|
|
572
|
+
<Link to="/lists">
|
|
573
|
+
<IconBookmark className="size-4" />
|
|
574
|
+
{t("views.allLists")}
|
|
575
|
+
</Link>
|
|
576
|
+
</Button>
|
|
577
|
+
</div>
|
|
578
|
+
}
|
|
579
|
+
/>
|
|
580
|
+
<CrmBoard target={{ kind: "list", id: listId }} mode={mode} />
|
|
581
|
+
</>
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// ---------------------------------------------------------------------------
|
|
586
|
+
// Create
|
|
587
|
+
// ---------------------------------------------------------------------------
|
|
588
|
+
|
|
589
|
+
function CreateSavedViewDialog() {
|
|
590
|
+
const t = useT();
|
|
591
|
+
const navigate = useNavigate();
|
|
592
|
+
const [open, setOpen] = useState(false);
|
|
593
|
+
const [name, setName] = useState("");
|
|
594
|
+
const [description, setDescription] = useState("");
|
|
595
|
+
const [kind, setKind] = useState("account");
|
|
596
|
+
const save = useActionMutation<{ id: string }, Record<string, unknown>>(
|
|
597
|
+
"save-crm-saved-view" as never,
|
|
598
|
+
);
|
|
599
|
+
|
|
600
|
+
async function createView() {
|
|
601
|
+
try {
|
|
602
|
+
const saved = await save.mutateAsync({
|
|
603
|
+
name: name.trim(),
|
|
604
|
+
...(description.trim() ? { description: description.trim() } : {}),
|
|
605
|
+
kind,
|
|
606
|
+
viewKind: "table",
|
|
607
|
+
targetKind: "object",
|
|
608
|
+
targetId: OBJECT_TYPE_BY_KIND[kind] ?? "accounts",
|
|
609
|
+
audience: "personal",
|
|
610
|
+
});
|
|
611
|
+
setOpen(false);
|
|
612
|
+
navigate(`/views?view=${encodeURIComponent(saved.id)}`);
|
|
613
|
+
} catch (error) {
|
|
614
|
+
toast.error(
|
|
615
|
+
error instanceof Error ? error.message : t("views.saveFailedToast"),
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return (
|
|
621
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
622
|
+
<DialogTrigger asChild>
|
|
623
|
+
<Button size="sm" className="gap-2">
|
|
624
|
+
<IconPlus className="size-4" />
|
|
625
|
+
{t("views.newView")}
|
|
626
|
+
</Button>
|
|
627
|
+
</DialogTrigger>
|
|
628
|
+
<DialogContent className="sm:max-w-lg">
|
|
629
|
+
<DialogHeader>
|
|
630
|
+
<DialogTitle>{t("views.createTitle")}</DialogTitle>
|
|
631
|
+
<DialogDescription>{t("views.createDescription")}</DialogDescription>
|
|
632
|
+
</DialogHeader>
|
|
633
|
+
<div className="grid gap-4 py-2">
|
|
634
|
+
<div className="grid gap-2">
|
|
635
|
+
<Label htmlFor="view-name">{t("views.nameLabel")}</Label>
|
|
636
|
+
<Input
|
|
637
|
+
id="view-name"
|
|
638
|
+
value={name}
|
|
639
|
+
maxLength={120}
|
|
640
|
+
onChange={(event) => setName(event.target.value)}
|
|
641
|
+
/>
|
|
642
|
+
</div>
|
|
643
|
+
<div className="grid gap-2">
|
|
644
|
+
<Label htmlFor="view-description">
|
|
645
|
+
{t("views.descriptionLabel")}
|
|
646
|
+
</Label>
|
|
647
|
+
<Input
|
|
648
|
+
id="view-description"
|
|
649
|
+
value={description}
|
|
650
|
+
maxLength={500}
|
|
651
|
+
onChange={(event) => setDescription(event.target.value)}
|
|
652
|
+
/>
|
|
653
|
+
</div>
|
|
654
|
+
<div className="grid gap-2">
|
|
655
|
+
<Label htmlFor="view-kind">{t("views.recordTypeLabel")}</Label>
|
|
656
|
+
<Select value={kind} onValueChange={setKind}>
|
|
657
|
+
<SelectTrigger id="view-kind">
|
|
658
|
+
<SelectValue />
|
|
659
|
+
</SelectTrigger>
|
|
660
|
+
<SelectContent>
|
|
661
|
+
<SelectItem value="account">
|
|
662
|
+
{t("navigation.accounts")}
|
|
663
|
+
</SelectItem>
|
|
664
|
+
<SelectItem value="person">{t("navigation.people")}</SelectItem>
|
|
665
|
+
<SelectItem value="opportunity">
|
|
666
|
+
{t("navigation.opportunities")}
|
|
667
|
+
</SelectItem>
|
|
668
|
+
</SelectContent>
|
|
669
|
+
</Select>
|
|
670
|
+
</div>
|
|
671
|
+
</div>
|
|
672
|
+
<DialogFooter>
|
|
673
|
+
<Button
|
|
674
|
+
disabled={!name.trim() || save.isPending}
|
|
675
|
+
onClick={() => void createView()}
|
|
676
|
+
>
|
|
677
|
+
{t("views.createView")}
|
|
678
|
+
</Button>
|
|
679
|
+
</DialogFooter>
|
|
680
|
+
</DialogContent>
|
|
681
|
+
</Dialog>
|
|
682
|
+
);
|
|
683
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type RouteConfig, index, route } from "@react-router/dev/routes";
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
index("./routes/_index.tsx"),
|
|
5
|
+
route("accounts", "./routes/accounts.tsx"),
|
|
6
|
+
route("people", "./routes/people.tsx"),
|
|
7
|
+
route("opportunities", "./routes/opportunities.tsx"),
|
|
8
|
+
route("lists", "./routes/lists.tsx"),
|
|
9
|
+
route("records", "./routes/records.tsx"),
|
|
10
|
+
route("records/:recordId", "./routes/records.$recordId.tsx"),
|
|
11
|
+
route("tasks", "./routes/tasks.tsx"),
|
|
12
|
+
route("proposals", "./routes/proposals.tsx"),
|
|
13
|
+
route("views", "./routes/views.tsx"),
|
|
14
|
+
route("dashboard", "./routes/dashboard.tsx"),
|
|
15
|
+
route("ask", "./routes/ask.tsx"),
|
|
16
|
+
route("setup", "./routes/setup.tsx"),
|
|
17
|
+
route("settings/*", "./routes/settings.tsx"),
|
|
18
|
+
route("agent", "./routes/agent.tsx"),
|
|
19
|
+
] satisfies RouteConfig;
|