@jsb188/mday-web 1.1.11 → 1.1.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/package.json +15 -13
- package/src/modules/Grids.filters.ts +36 -0
- package/src/modules/Grids.tsx +115 -347
- package/src/schemas/organization.ts +128 -0
- package/src/utils/email.ts +117 -0
- package/src/utils/log-web.helpers.ts +99 -0
- package/src/utils/log-web.icons.ts +184 -0
- package/src/utils/log-web.ts +58 -458
- package/src/utils/operation-pages.ts +154 -0
- package/src/utils/route-helpers.ts +193 -258
- package/src/utils/workflow-web.ts +16 -40
- package/tests/log-web.test.ts +134 -0
- package/tests/route-helpers.test.ts +17 -0
- package/src/modules/AgentDocs.tsx +0 -800
- package/src/modules/DocAccessSettings.tsx +0 -963
- package/src/utils/account-web.ts +0 -64
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { OrganizationOperationEnum } from '@jsb188/mday/types/organization.d.ts';
|
|
2
|
+
import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
|
|
3
|
+
|
|
4
|
+
interface OperationPageDefinition {
|
|
5
|
+
slug: string;
|
|
6
|
+
titleKey: string;
|
|
7
|
+
metaTitleKey: string;
|
|
8
|
+
descriptionKey: string;
|
|
9
|
+
navigationTitleKey: string;
|
|
10
|
+
iconName: string;
|
|
11
|
+
allowedOperations: readonly OrganizationOperationEnum[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const OPERATION_PAGES = {
|
|
15
|
+
greenhouse: {
|
|
16
|
+
slug: 'greenhouse',
|
|
17
|
+
titleKey: 'log.greenhouse_seeding',
|
|
18
|
+
metaTitleKey: 'log.greenhouse_seeding',
|
|
19
|
+
descriptionKey: 'app.meta_greenhouse_desc',
|
|
20
|
+
navigationTitleKey: 'log.greenhouse_seeding',
|
|
21
|
+
iconName: COMMON_ICON_NAMES.GREENHOUSE_SEEDING,
|
|
22
|
+
allowedOperations: ['ARABLE'],
|
|
23
|
+
},
|
|
24
|
+
seeding: {
|
|
25
|
+
slug: 'seeding',
|
|
26
|
+
titleKey: 'log.seeding',
|
|
27
|
+
metaTitleKey: 'log.seeding',
|
|
28
|
+
descriptionKey: 'app.meta_seeding_desc',
|
|
29
|
+
navigationTitleKey: 'log.seeding',
|
|
30
|
+
iconName: COMMON_ICON_NAMES.seeding,
|
|
31
|
+
allowedOperations: ['ARABLE'],
|
|
32
|
+
},
|
|
33
|
+
transplanting: {
|
|
34
|
+
slug: 'transplanting',
|
|
35
|
+
titleKey: 'log.transplanting',
|
|
36
|
+
metaTitleKey: 'log.transplanting',
|
|
37
|
+
descriptionKey: 'app.meta_transplanting_desc',
|
|
38
|
+
navigationTitleKey: 'log.transplanting',
|
|
39
|
+
iconName: COMMON_ICON_NAMES.transplanting,
|
|
40
|
+
allowedOperations: ['ARABLE'],
|
|
41
|
+
},
|
|
42
|
+
'field-work': {
|
|
43
|
+
slug: 'field-work',
|
|
44
|
+
titleKey: 'log.field_work',
|
|
45
|
+
metaTitleKey: 'log.field_work',
|
|
46
|
+
descriptionKey: 'app.meta_field_work_desc',
|
|
47
|
+
navigationTitleKey: 'log.field_work',
|
|
48
|
+
iconName: COMMON_ICON_NAMES.field_work,
|
|
49
|
+
allowedOperations: ['ARABLE'],
|
|
50
|
+
},
|
|
51
|
+
harvested: {
|
|
52
|
+
slug: 'harvested',
|
|
53
|
+
titleKey: 'log.harvested',
|
|
54
|
+
metaTitleKey: 'log.harvested',
|
|
55
|
+
descriptionKey: 'app.meta_harvested_desc',
|
|
56
|
+
navigationTitleKey: 'log.harvested',
|
|
57
|
+
iconName: COMMON_ICON_NAMES.harvest,
|
|
58
|
+
allowedOperations: ['ARABLE'],
|
|
59
|
+
},
|
|
60
|
+
'post-harvest': {
|
|
61
|
+
slug: 'post-harvest',
|
|
62
|
+
titleKey: 'log.post_harvest',
|
|
63
|
+
metaTitleKey: 'log.post_harvest',
|
|
64
|
+
descriptionKey: 'app.meta_post_harvest_desc',
|
|
65
|
+
navigationTitleKey: 'log.post_harvest',
|
|
66
|
+
iconName: COMMON_ICON_NAMES.post_harvest,
|
|
67
|
+
allowedOperations: ['ARABLE'],
|
|
68
|
+
},
|
|
69
|
+
purchases: {
|
|
70
|
+
slug: 'purchases',
|
|
71
|
+
titleKey: 'log.purchases',
|
|
72
|
+
metaTitleKey: 'log.purchases',
|
|
73
|
+
descriptionKey: 'app.meta_purchases_desc',
|
|
74
|
+
navigationTitleKey: 'log.purchases',
|
|
75
|
+
iconName: COMMON_ICON_NAMES.invoice,
|
|
76
|
+
allowedOperations: ['ARABLE'],
|
|
77
|
+
},
|
|
78
|
+
orders: {
|
|
79
|
+
slug: 'orders',
|
|
80
|
+
titleKey: 'c.sales_orders',
|
|
81
|
+
metaTitleKey: 'c.sales_orders',
|
|
82
|
+
descriptionKey: 'app.meta_orders_desc',
|
|
83
|
+
navigationTitleKey: 'c.sales_orders',
|
|
84
|
+
iconName: COMMON_ICON_NAMES.receipt,
|
|
85
|
+
allowedOperations: ['ARABLE'],
|
|
86
|
+
},
|
|
87
|
+
temperature: {
|
|
88
|
+
slug: 'temperature',
|
|
89
|
+
titleKey: 'log.temperature',
|
|
90
|
+
metaTitleKey: 'log.temperature',
|
|
91
|
+
descriptionKey: 'app.meta_temperature_desc',
|
|
92
|
+
navigationTitleKey: 'log.temperature',
|
|
93
|
+
iconName: COMMON_ICON_NAMES.temperature,
|
|
94
|
+
allowedOperations: ['FOOD_MANUFACTURING'],
|
|
95
|
+
},
|
|
96
|
+
inspections: {
|
|
97
|
+
slug: 'inspections',
|
|
98
|
+
titleKey: 'log.inspections',
|
|
99
|
+
metaTitleKey: 'log.inspections',
|
|
100
|
+
descriptionKey: 'app.meta_inspections_desc',
|
|
101
|
+
navigationTitleKey: 'log.inspections',
|
|
102
|
+
iconName: COMMON_ICON_NAMES.SITE_INSPECTION,
|
|
103
|
+
allowedOperations: ['FOOD_MANUFACTURING'],
|
|
104
|
+
},
|
|
105
|
+
receipts: {
|
|
106
|
+
slug: 'receipts',
|
|
107
|
+
titleKey: 'c.receipts',
|
|
108
|
+
metaTitleKey: 'c.market_receipts',
|
|
109
|
+
descriptionKey: 'app.meta_receipts_desc',
|
|
110
|
+
navigationTitleKey: 'c.market_receipts',
|
|
111
|
+
iconName: COMMON_ICON_NAMES.market_receipt,
|
|
112
|
+
allowedOperations: ['FARMERS_MARKET'],
|
|
113
|
+
},
|
|
114
|
+
vendors: {
|
|
115
|
+
slug: 'vendors',
|
|
116
|
+
titleKey: 'c.vendors',
|
|
117
|
+
metaTitleKey: 'c.vendors',
|
|
118
|
+
descriptionKey: 'app.meta_vendors_desc',
|
|
119
|
+
navigationTitleKey: 'c.vendors',
|
|
120
|
+
iconName: COMMON_ICON_NAMES.shop_vendor,
|
|
121
|
+
allowedOperations: ['FARMERS_MARKET'],
|
|
122
|
+
},
|
|
123
|
+
growers: {
|
|
124
|
+
slug: 'growers',
|
|
125
|
+
titleKey: 'org.growers',
|
|
126
|
+
metaTitleKey: 'org.growers',
|
|
127
|
+
descriptionKey: 'app.meta_growers_desc',
|
|
128
|
+
navigationTitleKey: 'org.growers',
|
|
129
|
+
iconName: COMMON_ICON_NAMES.growers,
|
|
130
|
+
allowedOperations: ['GROWER_NETWORK'],
|
|
131
|
+
},
|
|
132
|
+
} as const satisfies Record<string, OperationPageDefinition>;
|
|
133
|
+
|
|
134
|
+
export type OperationPageSlug = keyof typeof OPERATION_PAGES;
|
|
135
|
+
export type OperationPageMetadata = (typeof OPERATION_PAGES)[OperationPageSlug];
|
|
136
|
+
|
|
137
|
+
/*
|
|
138
|
+
* Return operation-page metadata only for an exact registered slug.
|
|
139
|
+
*/
|
|
140
|
+
export function getOperationPageMetadata(page: string | null | undefined): OperationPageMetadata | null {
|
|
141
|
+
return page && Object.hasOwn(OPERATION_PAGES, page) ? OPERATION_PAGES[page as OperationPageSlug] : null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/*
|
|
145
|
+
* Resolve an exact page slug only when it supports the organization's operation.
|
|
146
|
+
*/
|
|
147
|
+
export function resolveOperationPage(
|
|
148
|
+
page: string | null | undefined,
|
|
149
|
+
operation: OrganizationOperationEnum | null | undefined,
|
|
150
|
+
): OperationPageMetadata | null {
|
|
151
|
+
const metadata = getOperationPageMetadata(page);
|
|
152
|
+
|
|
153
|
+
return metadata?.allowedOperations.some((allowedOperation) => allowedOperation === operation) ? metadata : null;
|
|
154
|
+
}
|