@contractspec/example.crm-pipeline 3.7.7 → 3.7.12
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/.turbo/turbo-build.log +45 -42
- package/CHANGELOG.md +72 -0
- package/README.md +2 -1
- package/dist/browser/docs/crm-pipeline.docblock.js +1 -1
- package/dist/browser/docs/index.js +1 -1
- package/dist/browser/handlers/crm.handlers.js +13 -2
- package/dist/browser/handlers/index.js +13 -2
- package/dist/browser/index.js +392 -159
- package/dist/browser/ui/CrmDashboard.js +366 -144
- package/dist/browser/ui/hooks/index.js +19 -8
- package/dist/browser/ui/hooks/useDealList.js +19 -8
- package/dist/browser/ui/index.js +391 -158
- package/dist/browser/ui/renderers/index.js +32 -10
- package/dist/browser/ui/renderers/pipeline.markdown.js +13 -2
- package/dist/browser/ui/renderers/pipeline.renderer.js +19 -8
- package/dist/browser/ui/tables/DealListTab.js +390 -0
- package/dist/docs/crm-pipeline.docblock.js +1 -1
- package/dist/docs/index.js +1 -1
- package/dist/handlers/crm.handlers.d.ts +2 -0
- package/dist/handlers/crm.handlers.js +13 -2
- package/dist/handlers/index.js +13 -2
- package/dist/index.js +392 -159
- package/dist/node/docs/crm-pipeline.docblock.js +1 -1
- package/dist/node/docs/index.js +1 -1
- package/dist/node/handlers/crm.handlers.js +13 -2
- package/dist/node/handlers/index.js +13 -2
- package/dist/node/index.js +392 -159
- package/dist/node/ui/CrmDashboard.js +366 -144
- package/dist/node/ui/hooks/index.js +19 -8
- package/dist/node/ui/hooks/useDealList.js +19 -8
- package/dist/node/ui/index.js +391 -158
- package/dist/node/ui/renderers/index.js +32 -10
- package/dist/node/ui/renderers/pipeline.markdown.js +13 -2
- package/dist/node/ui/renderers/pipeline.renderer.js +19 -8
- package/dist/node/ui/tables/DealListTab.js +390 -0
- package/dist/ui/CrmDashboard.js +366 -144
- package/dist/ui/hooks/index.js +19 -8
- package/dist/ui/hooks/useDealList.d.ts +8 -2
- package/dist/ui/hooks/useDealList.js +19 -8
- package/dist/ui/index.js +391 -158
- package/dist/ui/renderers/index.js +32 -10
- package/dist/ui/renderers/pipeline.markdown.d.ts +1 -1
- package/dist/ui/renderers/pipeline.markdown.js +13 -2
- package/dist/ui/renderers/pipeline.renderer.d.ts +1 -1
- package/dist/ui/renderers/pipeline.renderer.js +19 -8
- package/dist/ui/tables/DealListTab.d.ts +20 -0
- package/dist/ui/tables/DealListTab.js +391 -0
- package/dist/ui/tables/DealListTab.smoke.test.d.ts +1 -0
- package/package.json +29 -13
- package/src/docs/crm-pipeline.docblock.ts +1 -1
- package/src/handlers/crm.handlers.ts +18 -1
- package/src/ui/CrmDashboard.tsx +2 -71
- package/src/ui/hooks/useDealList.ts +36 -8
- package/src/ui/renderers/pipeline.markdown.ts +1 -1
- package/src/ui/renderers/pipeline.renderer.tsx +1 -1
- package/src/ui/tables/DealListTab.smoke.test.tsx +149 -0
- package/src/ui/tables/DealListTab.tsx +276 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -2,34 +2,35 @@ $ contractspec-bun-build prebuild
|
|
|
2
2
|
$ bun run prebuild && bun run build:bundle && bun run build:types
|
|
3
3
|
$ contractspec-bun-build prebuild
|
|
4
4
|
$ contractspec-bun-build transpile
|
|
5
|
-
[contractspec-bun-build] transpile target=bun root=src entries=
|
|
6
|
-
Bundled
|
|
5
|
+
[contractspec-bun-build] transpile target=bun root=src entries=45 noBundle=false
|
|
6
|
+
Bundled 45 modules in 157ms
|
|
7
7
|
|
|
8
8
|
./crm-pipeline.feature.js 2.54 KB (entry point)
|
|
9
9
|
seeders/index.js 1.00 KB (entry point)
|
|
10
10
|
shared/overlay-types.js 8 bytes (entry point)
|
|
11
|
-
./index.js
|
|
12
|
-
ui/index.js
|
|
11
|
+
./index.js 122.92 KB (entry point)
|
|
12
|
+
ui/index.js 80.58 KB (entry point)
|
|
13
13
|
ui/overlays/index.js 1.19 KB (entry point)
|
|
14
|
-
ui/renderers/index.js
|
|
15
|
-
ui/renderers/pipeline.markdown.js
|
|
16
|
-
ui/renderers/pipeline.renderer.js
|
|
17
|
-
ui/hooks/index.js
|
|
14
|
+
ui/renderers/index.js 29.47 KB (entry point)
|
|
15
|
+
ui/renderers/pipeline.markdown.js 18.13 KB (entry point)
|
|
16
|
+
ui/renderers/pipeline.renderer.js 11.35 KB (entry point)
|
|
17
|
+
ui/hooks/index.js 6.38 KB (entry point)
|
|
18
18
|
ui/modals/index.js 27.54 KB (entry point)
|
|
19
19
|
ui/overlays/demo-overlays.js 1.19 KB (entry point)
|
|
20
20
|
presentations/index.js 9.78 KB (entry point)
|
|
21
21
|
presentations/dashboard.presentation.js 1.55 KB (entry point)
|
|
22
22
|
presentations/pipeline.presentation.js 8.20 KB (entry point)
|
|
23
|
-
ui/CrmDashboard.js
|
|
24
|
-
ui/
|
|
23
|
+
ui/CrmDashboard.js 60.35 KB (entry point)
|
|
24
|
+
ui/tables/DealListTab.js 12.29 KB (entry point)
|
|
25
|
+
ui/hooks/useDealList.js 3.12 KB (entry point)
|
|
25
26
|
ui/hooks/useDealMutations.js 3.18 KB (entry point)
|
|
26
27
|
ui/modals/CreateDealModal.js 8.89 KB (entry point)
|
|
27
28
|
ui/modals/DealActionsModal.js 18.56 KB (entry point)
|
|
28
29
|
ui/CrmPipelineBoard.js 7.49 KB (entry point)
|
|
29
30
|
ui/CrmDealCard.js 2.29 KB (entry point)
|
|
30
31
|
./example.js 1.0 KB (entry point)
|
|
31
|
-
handlers/index.js
|
|
32
|
-
handlers/crm.handlers.js
|
|
32
|
+
handlers/index.js 14.00 KB (entry point)
|
|
33
|
+
handlers/crm.handlers.js 6.19 KB (entry point)
|
|
33
34
|
handlers/deal.handlers.js 7.76 KB (entry point)
|
|
34
35
|
handlers/mock-data.js 4.33 KB (entry point)
|
|
35
36
|
operations/index.js 11.35 KB (entry point)
|
|
@@ -47,37 +48,38 @@ Bundled 44 modules in 82ms
|
|
|
47
48
|
deal/deal.operation.js 11.11 KB (entry point)
|
|
48
49
|
deal/deal.schema.js 5.41 KB (entry point)
|
|
49
50
|
deal/deal.enum.js 333 bytes (entry point)
|
|
50
|
-
docs/index.js 4.
|
|
51
|
-
docs/crm-pipeline.docblock.js 4.
|
|
51
|
+
docs/index.js 4.48 KB (entry point)
|
|
52
|
+
docs/crm-pipeline.docblock.js 4.48 KB (entry point)
|
|
52
53
|
|
|
53
|
-
[contractspec-bun-build] transpile target=node root=src entries=
|
|
54
|
-
Bundled
|
|
54
|
+
[contractspec-bun-build] transpile target=node root=src entries=45 noBundle=false
|
|
55
|
+
Bundled 45 modules in 99ms
|
|
55
56
|
|
|
56
57
|
./crm-pipeline.feature.js 2.54 KB (entry point)
|
|
57
58
|
seeders/index.js 0.99 KB (entry point)
|
|
58
59
|
shared/overlay-types.js 0 KB (entry point)
|
|
59
|
-
./index.js
|
|
60
|
-
ui/index.js
|
|
60
|
+
./index.js 122.87 KB (entry point)
|
|
61
|
+
ui/index.js 80.54 KB (entry point)
|
|
61
62
|
ui/overlays/index.js 1.19 KB (entry point)
|
|
62
|
-
ui/renderers/index.js
|
|
63
|
-
ui/renderers/pipeline.markdown.js
|
|
64
|
-
ui/renderers/pipeline.renderer.js
|
|
65
|
-
ui/hooks/index.js
|
|
63
|
+
ui/renderers/index.js 29.45 KB (entry point)
|
|
64
|
+
ui/renderers/pipeline.markdown.js 18.12 KB (entry point)
|
|
65
|
+
ui/renderers/pipeline.renderer.js 11.33 KB (entry point)
|
|
66
|
+
ui/hooks/index.js 6.38 KB (entry point)
|
|
66
67
|
ui/modals/index.js 27.52 KB (entry point)
|
|
67
68
|
ui/overlays/demo-overlays.js 1.19 KB (entry point)
|
|
68
69
|
presentations/index.js 9.78 KB (entry point)
|
|
69
70
|
presentations/dashboard.presentation.js 1.55 KB (entry point)
|
|
70
71
|
presentations/pipeline.presentation.js 8.19 KB (entry point)
|
|
71
|
-
ui/CrmDashboard.js
|
|
72
|
-
ui/
|
|
72
|
+
ui/CrmDashboard.js 60.31 KB (entry point)
|
|
73
|
+
ui/tables/DealListTab.js 12.29 KB (entry point)
|
|
74
|
+
ui/hooks/useDealList.js 3.12 KB (entry point)
|
|
73
75
|
ui/hooks/useDealMutations.js 3.17 KB (entry point)
|
|
74
76
|
ui/modals/CreateDealModal.js 8.88 KB (entry point)
|
|
75
77
|
ui/modals/DealActionsModal.js 18.54 KB (entry point)
|
|
76
78
|
ui/CrmPipelineBoard.js 7.47 KB (entry point)
|
|
77
79
|
ui/CrmDealCard.js 2.28 KB (entry point)
|
|
78
80
|
./example.js 1.0 KB (entry point)
|
|
79
|
-
handlers/index.js 13.
|
|
80
|
-
handlers/crm.handlers.js
|
|
81
|
+
handlers/index.js 13.99 KB (entry point)
|
|
82
|
+
handlers/crm.handlers.js 6.18 KB (entry point)
|
|
81
83
|
handlers/deal.handlers.js 7.75 KB (entry point)
|
|
82
84
|
handlers/mock-data.js 4.32 KB (entry point)
|
|
83
85
|
operations/index.js 11.34 KB (entry point)
|
|
@@ -95,37 +97,38 @@ Bundled 44 modules in 96ms
|
|
|
95
97
|
deal/deal.operation.js 11.1 KB (entry point)
|
|
96
98
|
deal/deal.schema.js 5.40 KB (entry point)
|
|
97
99
|
deal/deal.enum.js 325 bytes (entry point)
|
|
98
|
-
docs/index.js 4.
|
|
99
|
-
docs/crm-pipeline.docblock.js 4.
|
|
100
|
+
docs/index.js 4.46 KB (entry point)
|
|
101
|
+
docs/crm-pipeline.docblock.js 4.46 KB (entry point)
|
|
100
102
|
|
|
101
|
-
[contractspec-bun-build] transpile target=browser root=src entries=
|
|
102
|
-
Bundled
|
|
103
|
+
[contractspec-bun-build] transpile target=browser root=src entries=45 noBundle=false
|
|
104
|
+
Bundled 45 modules in 119ms
|
|
103
105
|
|
|
104
106
|
./crm-pipeline.feature.js 2.54 KB (entry point)
|
|
105
107
|
seeders/index.js 0.99 KB (entry point)
|
|
106
108
|
shared/overlay-types.js 0 KB (entry point)
|
|
107
|
-
./index.js
|
|
108
|
-
ui/index.js
|
|
109
|
+
./index.js 122.87 KB (entry point)
|
|
110
|
+
ui/index.js 80.54 KB (entry point)
|
|
109
111
|
ui/overlays/index.js 1.19 KB (entry point)
|
|
110
|
-
ui/renderers/index.js
|
|
111
|
-
ui/renderers/pipeline.markdown.js
|
|
112
|
-
ui/renderers/pipeline.renderer.js
|
|
113
|
-
ui/hooks/index.js
|
|
112
|
+
ui/renderers/index.js 29.45 KB (entry point)
|
|
113
|
+
ui/renderers/pipeline.markdown.js 18.12 KB (entry point)
|
|
114
|
+
ui/renderers/pipeline.renderer.js 11.33 KB (entry point)
|
|
115
|
+
ui/hooks/index.js 6.38 KB (entry point)
|
|
114
116
|
ui/modals/index.js 27.52 KB (entry point)
|
|
115
117
|
ui/overlays/demo-overlays.js 1.19 KB (entry point)
|
|
116
118
|
presentations/index.js 9.78 KB (entry point)
|
|
117
119
|
presentations/dashboard.presentation.js 1.55 KB (entry point)
|
|
118
120
|
presentations/pipeline.presentation.js 8.19 KB (entry point)
|
|
119
|
-
ui/CrmDashboard.js
|
|
120
|
-
ui/
|
|
121
|
+
ui/CrmDashboard.js 60.31 KB (entry point)
|
|
122
|
+
ui/tables/DealListTab.js 12.29 KB (entry point)
|
|
123
|
+
ui/hooks/useDealList.js 3.12 KB (entry point)
|
|
121
124
|
ui/hooks/useDealMutations.js 3.17 KB (entry point)
|
|
122
125
|
ui/modals/CreateDealModal.js 8.88 KB (entry point)
|
|
123
126
|
ui/modals/DealActionsModal.js 18.54 KB (entry point)
|
|
124
127
|
ui/CrmPipelineBoard.js 7.47 KB (entry point)
|
|
125
128
|
ui/CrmDealCard.js 2.28 KB (entry point)
|
|
126
129
|
./example.js 1.0 KB (entry point)
|
|
127
|
-
handlers/index.js 13.
|
|
128
|
-
handlers/crm.handlers.js
|
|
130
|
+
handlers/index.js 13.99 KB (entry point)
|
|
131
|
+
handlers/crm.handlers.js 6.18 KB (entry point)
|
|
129
132
|
handlers/deal.handlers.js 7.75 KB (entry point)
|
|
130
133
|
handlers/mock-data.js 4.32 KB (entry point)
|
|
131
134
|
operations/index.js 11.34 KB (entry point)
|
|
@@ -143,7 +146,7 @@ Bundled 44 modules in 91ms
|
|
|
143
146
|
deal/deal.operation.js 11.1 KB (entry point)
|
|
144
147
|
deal/deal.schema.js 5.40 KB (entry point)
|
|
145
148
|
deal/deal.enum.js 325 bytes (entry point)
|
|
146
|
-
docs/index.js 4.
|
|
147
|
-
docs/crm-pipeline.docblock.js 4.
|
|
149
|
+
docs/index.js 4.46 KB (entry point)
|
|
150
|
+
docs/crm-pipeline.docblock.js 4.46 KB (entry point)
|
|
148
151
|
|
|
149
152
|
$ contractspec-bun-build types
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# @contractspec/example.crm-pipeline
|
|
2
2
|
|
|
3
|
+
## 3.7.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [81256ea]
|
|
8
|
+
- Updated dependencies [2619dd8]
|
|
9
|
+
- Updated dependencies [6de2f1c]
|
|
10
|
+
- Updated dependencies [81256ea]
|
|
11
|
+
- Updated dependencies [a4489bb]
|
|
12
|
+
- Updated dependencies [9cb304e]
|
|
13
|
+
- @contractspec/lib.contracts-spec@5.0.0
|
|
14
|
+
- @contractspec/lib.presentation-runtime-core@3.9.0
|
|
15
|
+
- @contractspec/lib.schema@3.7.10
|
|
16
|
+
- @contractspec/lib.design-system@3.8.5
|
|
17
|
+
- @contractspec/lib.example-shared-ui@6.0.12
|
|
18
|
+
- @contractspec/lib.identity-rbac@3.7.12
|
|
19
|
+
- @contractspec/lib.ui-kit-web@3.9.4
|
|
20
|
+
- @contractspec/module.audit-trail@3.7.12
|
|
21
|
+
- @contractspec/module.notifications@3.7.12
|
|
22
|
+
|
|
23
|
+
## 3.7.11
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- fix: release
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @contractspec/lib.example-shared-ui@6.0.11
|
|
30
|
+
- @contractspec/module.notifications@3.7.11
|
|
31
|
+
- @contractspec/lib.runtime-sandbox@2.7.10
|
|
32
|
+
- @contractspec/lib.contracts-spec@4.1.3
|
|
33
|
+
- @contractspec/module.audit-trail@3.7.11
|
|
34
|
+
- @contractspec/lib.design-system@3.8.4
|
|
35
|
+
- @contractspec/lib.identity-rbac@3.7.11
|
|
36
|
+
- @contractspec/lib.ui-kit-web@3.9.3
|
|
37
|
+
- @contractspec/lib.schema@3.7.9
|
|
38
|
+
|
|
39
|
+
## 3.7.10
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- 1a44cb6: feat: improve examples to increase coverage of Contracts type
|
|
44
|
+
- Updated dependencies [1a44cb6]
|
|
45
|
+
- @contractspec/lib.example-shared-ui@6.0.10
|
|
46
|
+
- @contractspec/module.notifications@3.7.10
|
|
47
|
+
- @contractspec/lib.runtime-sandbox@2.7.9
|
|
48
|
+
- @contractspec/lib.contracts-spec@4.1.2
|
|
49
|
+
- @contractspec/module.audit-trail@3.7.10
|
|
50
|
+
- @contractspec/lib.design-system@3.8.3
|
|
51
|
+
- @contractspec/lib.identity-rbac@3.7.10
|
|
52
|
+
- @contractspec/lib.ui-kit-web@3.9.2
|
|
53
|
+
- @contractspec/lib.schema@3.7.8
|
|
54
|
+
|
|
55
|
+
## 3.7.9
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- fix: release
|
|
60
|
+
- Updated dependencies
|
|
61
|
+
- @contractspec/lib.example-shared-ui@6.0.9
|
|
62
|
+
- @contractspec/module.notifications@3.7.9
|
|
63
|
+
- @contractspec/lib.runtime-sandbox@2.7.8
|
|
64
|
+
- @contractspec/lib.contracts-spec@4.1.1
|
|
65
|
+
- @contractspec/module.audit-trail@3.7.9
|
|
66
|
+
- @contractspec/lib.design-system@3.8.2
|
|
67
|
+
- @contractspec/lib.identity-rbac@3.7.9
|
|
68
|
+
- @contractspec/lib.ui-kit-web@3.9.1
|
|
69
|
+
- @contractspec/lib.schema@3.7.7
|
|
70
|
+
|
|
3
71
|
## 3.7.6
|
|
4
72
|
|
|
5
73
|
### Patch Changes
|
|
@@ -622,6 +690,7 @@
|
|
|
622
690
|
- 7f3203a: fix: make workspace test runs resilient when packages have no tests
|
|
623
691
|
|
|
624
692
|
Updates package test scripts to pass cleanly when no matching test files exist:
|
|
693
|
+
|
|
625
694
|
- Uses `bun test --pass-with-no-tests` in Bun-based packages that currently ship without test files.
|
|
626
695
|
- Uses `jest --passWithNoTests` for the UI kit web package.
|
|
627
696
|
- Adds `.vscode-test.mjs` for `vscode-contractspec` so VS Code extension test runs have an explicit config and stop failing on missing default configuration.
|
|
@@ -1122,14 +1191,17 @@
|
|
|
1122
1191
|
feat: Contract layers support (features, examples, app-configs)
|
|
1123
1192
|
|
|
1124
1193
|
### New CLI Commands
|
|
1194
|
+
|
|
1125
1195
|
- `contractspec list layers` - List all contract layers with filtering
|
|
1126
1196
|
|
|
1127
1197
|
### Enhanced Commands
|
|
1198
|
+
|
|
1128
1199
|
- `contractspec ci` - New `layers` check category validates features/examples/config
|
|
1129
1200
|
- `contractspec doctor` - New `layers` health checks
|
|
1130
1201
|
- `contractspec integrity` - Now shows layer statistics
|
|
1131
1202
|
|
|
1132
1203
|
### New APIs
|
|
1204
|
+
|
|
1133
1205
|
- `discoverLayers()` - Scan workspace for all layer files
|
|
1134
1206
|
- `scanExampleSource()` - Parse ExampleSpec from source code
|
|
1135
1207
|
- `isExampleFile()` - Check if file is an example spec
|
package/README.md
CHANGED
|
@@ -10,7 +10,8 @@ Website: https://contractspec.io
|
|
|
10
10
|
- Deal pipeline with stage enums, operations, and test-specs.
|
|
11
11
|
- Event-driven architecture (contact, deal, task events).
|
|
12
12
|
- Presentation layer with dashboard and pipeline views.
|
|
13
|
-
- React UI with pipeline board,
|
|
13
|
+
- React UI with pipeline board, hooks, modals, overlays, renderers, and a server-mode shared `DataTable` for deals.
|
|
14
|
+
- Shared table capabilities including sorting, pagination, multi-row selection, column visibility, pinning, resizing, and expandable deal details.
|
|
14
15
|
- Feature definition and capability pattern.
|
|
15
16
|
- Seeders and mock data.
|
|
16
17
|
|
|
@@ -81,7 +81,7 @@ var crmPipelineDocBlocks = [
|
|
|
81
81
|
- deal.created, stage.moved, task.completed, contact.updated.
|
|
82
82
|
|
|
83
83
|
## Presentations
|
|
84
|
-
- Pipelines/kanban, deal detail, contact/company profiles, task lists.
|
|
84
|
+
- Pipelines/kanban, deal detail, contact/company profiles, task lists, and a server-mode shared table for the deal list.
|
|
85
85
|
|
|
86
86
|
## Notes
|
|
87
87
|
- Stage definitions should be declarative; enforce via spec and regeneration.
|
|
@@ -81,7 +81,7 @@ var crmPipelineDocBlocks = [
|
|
|
81
81
|
- deal.created, stage.moved, task.completed, contact.updated.
|
|
82
82
|
|
|
83
83
|
## Presentations
|
|
84
|
-
- Pipelines/kanban, deal detail, contact/company profiles, task lists.
|
|
84
|
+
- Pipelines/kanban, deal detail, contact/company profiles, task lists, and a server-mode shared table for the deal list.
|
|
85
85
|
|
|
86
86
|
## Notes
|
|
87
87
|
- Stage definitions should be declarative; enforce via spec and regeneration.
|
|
@@ -22,6 +22,13 @@ function rowToDeal(row) {
|
|
|
22
22
|
updatedAt: new Date(row.updatedAt)
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
var DEAL_SORT_COLUMNS = {
|
|
26
|
+
name: "name",
|
|
27
|
+
value: "value",
|
|
28
|
+
status: "status",
|
|
29
|
+
expectedCloseDate: "expectedCloseDate",
|
|
30
|
+
updatedAt: "updatedAt"
|
|
31
|
+
};
|
|
25
32
|
function createCrmHandlers(db) {
|
|
26
33
|
async function listDeals(input) {
|
|
27
34
|
const {
|
|
@@ -32,7 +39,9 @@ function createCrmHandlers(db) {
|
|
|
32
39
|
ownerId,
|
|
33
40
|
search,
|
|
34
41
|
limit = 20,
|
|
35
|
-
offset = 0
|
|
42
|
+
offset = 0,
|
|
43
|
+
sortBy = "value",
|
|
44
|
+
sortDirection = "desc"
|
|
36
45
|
} = input;
|
|
37
46
|
let whereClause = "WHERE projectId = ?";
|
|
38
47
|
const params = [projectId];
|
|
@@ -60,7 +69,9 @@ function createCrmHandlers(db) {
|
|
|
60
69
|
const total = countResult[0]?.count ?? 0;
|
|
61
70
|
const valueResult = (await db.query(`SELECT COALESCE(SUM(value), 0) as total FROM crm_deal ${whereClause}`, params)).rows;
|
|
62
71
|
const totalValue = valueResult[0]?.total ?? 0;
|
|
63
|
-
const
|
|
72
|
+
const orderByColumn = DEAL_SORT_COLUMNS[sortBy] ?? DEAL_SORT_COLUMNS.value;
|
|
73
|
+
const orderByDirection = sortDirection === "asc" ? "ASC" : "DESC";
|
|
74
|
+
const dealRows = (await db.query(`SELECT * FROM crm_deal ${whereClause} ORDER BY ${orderByColumn} ${orderByDirection} LIMIT ? OFFSET ?`, [...params, limit, offset])).rows;
|
|
64
75
|
return {
|
|
65
76
|
deals: dealRows.map(rowToDeal),
|
|
66
77
|
total,
|
|
@@ -22,6 +22,13 @@ function rowToDeal(row) {
|
|
|
22
22
|
updatedAt: new Date(row.updatedAt)
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
var DEAL_SORT_COLUMNS = {
|
|
26
|
+
name: "name",
|
|
27
|
+
value: "value",
|
|
28
|
+
status: "status",
|
|
29
|
+
expectedCloseDate: "expectedCloseDate",
|
|
30
|
+
updatedAt: "updatedAt"
|
|
31
|
+
};
|
|
25
32
|
function createCrmHandlers(db) {
|
|
26
33
|
async function listDeals(input) {
|
|
27
34
|
const {
|
|
@@ -32,7 +39,9 @@ function createCrmHandlers(db) {
|
|
|
32
39
|
ownerId,
|
|
33
40
|
search,
|
|
34
41
|
limit = 20,
|
|
35
|
-
offset = 0
|
|
42
|
+
offset = 0,
|
|
43
|
+
sortBy = "value",
|
|
44
|
+
sortDirection = "desc"
|
|
36
45
|
} = input;
|
|
37
46
|
let whereClause = "WHERE projectId = ?";
|
|
38
47
|
const params = [projectId];
|
|
@@ -60,7 +69,9 @@ function createCrmHandlers(db) {
|
|
|
60
69
|
const total = countResult[0]?.count ?? 0;
|
|
61
70
|
const valueResult = (await db.query(`SELECT COALESCE(SUM(value), 0) as total FROM crm_deal ${whereClause}`, params)).rows;
|
|
62
71
|
const totalValue = valueResult[0]?.total ?? 0;
|
|
63
|
-
const
|
|
72
|
+
const orderByColumn = DEAL_SORT_COLUMNS[sortBy] ?? DEAL_SORT_COLUMNS.value;
|
|
73
|
+
const orderByDirection = sortDirection === "asc" ? "ASC" : "DESC";
|
|
74
|
+
const dealRows = (await db.query(`SELECT * FROM crm_deal ${whereClause} ORDER BY ${orderByColumn} ${orderByDirection} LIMIT ? OFFSET ?`, [...params, limit, offset])).rows;
|
|
64
75
|
return {
|
|
65
76
|
deals: dealRows.map(rowToDeal),
|
|
66
77
|
total,
|