@jsb188/mday 1.1.7 → 1.1.10
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 +39 -20
- package/src/constants/dataTable.ts +22 -0
- package/src/constants/email.ts +28 -0
- package/src/constants/inboundContact.ts +8 -0
- package/src/constants/integration.ts +14 -0
- package/src/constants/log-activityTexts.ts +54 -28
- package/src/constants/log.ts +82 -38
- package/src/constants/organization.ts +11 -2
- package/src/constants/product.ts +9 -33
- package/src/constants/report.ts +29 -10
- package/src/constants/sheet.ts +20 -0
- package/src/constants/square.ts +16 -0
- package/src/constants/storage.ts +12 -0
- package/src/schemas/editLogEntry.ts +90 -44
- package/src/schemas/inboundContact.ts +72 -0
- package/src/schemas/logsQuery.ts +7 -272
- package/src/schemas/organization.ts +11 -174
- package/src/schemas/productsQuery.ts +2 -94
- package/src/schemas/reportsQuery.ts +8 -95
- package/src/types/account.d.ts +78 -0
- package/src/types/dataTable.d.ts +447 -0
- package/src/types/email.d.ts +71 -0
- package/src/types/inboundContact.d.ts +56 -0
- package/src/types/integration.d.ts +42 -0
- package/src/types/log.d.ts +289 -178
- package/src/types/organization.d.ts +106 -50
- package/src/types/product.d.ts +7 -96
- package/src/types/report.d.ts +239 -152
- package/src/types/sheet.d.ts +298 -0
- package/src/types/storage.d.ts +161 -0
- package/src/types/workflow.d.ts +174 -0
- package/src/utils/dataTable.ts +834 -0
- package/src/utils/email.ts +113 -0
- package/src/utils/log.ts +30 -628
- package/src/utils/organization.ts +227 -44
- package/src/utils/product-calEvent.ts +7 -60
- package/src/utils/report.ts +158 -0
- package/src/utils/sheet.ts +170 -0
- package/src/utils/square.ts +22 -0
- package/src/utils/table-route.ts +146 -0
- package/src/utils/workflow.ts +212 -0
- package/tsconfig.json +12 -0
- package/src/schemas/childOrganizationsQuery.ts +0 -44
- package/src/types/action.d.ts +0 -42
- package/src/utils/route-helpers.ts +0 -583
package/src/constants/report.ts
CHANGED
|
@@ -3,23 +3,42 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export const REPORT_SORT_OPTS = [
|
|
6
|
-
'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export const REPORT_TYPES = [
|
|
10
|
-
'GLOBAL_GAP',
|
|
11
|
-
'CLEANING',
|
|
12
|
-
'ORGANIC_CERTIFICATION',
|
|
6
|
+
'PERIOD_DESC',
|
|
7
|
+
'ACTIVITY_DESC',
|
|
13
8
|
];
|
|
14
9
|
|
|
15
10
|
export const REPORT_ROW_PRESETS = [
|
|
11
|
+
|
|
12
|
+
'REPORT_SUMMARY',
|
|
13
|
+
'LINE_TITLE',
|
|
14
|
+
'LINE_ITEMS',
|
|
15
|
+
'ORGS_LIST',
|
|
16
|
+
'TEXTS',
|
|
17
|
+
|
|
18
|
+
// All deprecated below
|
|
16
19
|
'LABELS',
|
|
17
|
-
'MONTH',
|
|
18
20
|
'BREAK',
|
|
19
21
|
'Q_AND_A',
|
|
20
|
-
'TEXTS',
|
|
21
22
|
'LONG_TEXTS', // Same as "TEXTS" but has a different function in <FileBrowserPlus>
|
|
22
23
|
'HEADINGS',
|
|
23
|
-
'REPORT_STATEMENTS_OVERVIEW',
|
|
24
24
|
'EVIDENCES',
|
|
25
25
|
];
|
|
26
|
+
|
|
27
|
+
export const REPORT_NUMBERED_PRESETS = [
|
|
28
|
+
'LINE_ITEMS',
|
|
29
|
+
'ORGS_LIST',
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export const REPORT_FREQUENCY_ENUMS = [
|
|
33
|
+
'DAILY',
|
|
34
|
+
'WEEKLY',
|
|
35
|
+
'MONTHLY',
|
|
36
|
+
'QUARTERLY',
|
|
37
|
+
'ANNUALLY',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export const REPORT_STATUS_ENUMS = [
|
|
41
|
+
'PASS',
|
|
42
|
+
'WARNING',
|
|
43
|
+
'FAIL',
|
|
44
|
+
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const SHEET_CELL_SOURCE_TYPE_ENUMS = [
|
|
2
|
+
'USER',
|
|
3
|
+
'REGION_GENERATED',
|
|
4
|
+
'REGION_OVERRIDE',
|
|
5
|
+
] as const;
|
|
6
|
+
|
|
7
|
+
export const SHEET_REGION_TYPE_ENUMS = [
|
|
8
|
+
'DATA_TABLE',
|
|
9
|
+
] as const;
|
|
10
|
+
|
|
11
|
+
export const SHEET_REGION_CONFLICT_POLICY_ENUMS = [
|
|
12
|
+
'TRUNCATE_AT_FIRST_BLOCKER',
|
|
13
|
+
] as const;
|
|
14
|
+
|
|
15
|
+
export const SHEET_DEFAULT_ROW_COUNT = 1000;
|
|
16
|
+
export const SHEET_DEFAULT_COLUMN_COUNT = 26;
|
|
17
|
+
export const SHEET_VIEWPORT_MAX_ROWS = 400;
|
|
18
|
+
export const SHEET_VIEWPORT_MAX_COLUMNS = 100;
|
|
19
|
+
export const SHEET_DEFAULT_COLUMN_WIDTH = 160;
|
|
20
|
+
export const SHEET_DEFAULT_ROW_HEIGHT = 28;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IntegrationConnectionStatusEnum } from './integration.ts';
|
|
2
|
+
import { INTEGRATION_CONNECTION_STATUSES } from './integration.ts';
|
|
3
|
+
|
|
4
|
+
export const SQUARE_OAUTH_SCOPES = [
|
|
5
|
+
'MERCHANT_PROFILE_READ',
|
|
6
|
+
'PAYMENTS_READ',
|
|
7
|
+
'ORDERS_READ',
|
|
8
|
+
'ORDERS_WRITE',
|
|
9
|
+
'PAYMENTS_WRITE',
|
|
10
|
+
] as const;
|
|
11
|
+
|
|
12
|
+
export type SquareOAuthScope = typeof SQUARE_OAUTH_SCOPES[number];
|
|
13
|
+
|
|
14
|
+
export const SQUARE_CONNECTION_STATUSES = INTEGRATION_CONNECTION_STATUSES;
|
|
15
|
+
|
|
16
|
+
export type SquareConnectionStatusEnum = IntegrationConnectionStatusEnum;
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import i18n from '@jsb188/app/i18n';
|
|
2
|
-
import { getCalDate } from '@jsb188/app/utils/datetime';
|
|
3
|
-
import { formatCurrency } from '@jsb188/app/utils/number';
|
|
4
|
-
import { getObject } from '@jsb188/app/utils/object';
|
|
5
|
-
import { textWithBrackets } from '@jsb188/app/utils/string';
|
|
6
|
-
import { getTimeZoneCode } from '@jsb188/app/utils/timeZone';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
+
import { getCalDate } from '@jsb188/app/utils/datetime.ts';
|
|
3
|
+
import { formatCurrency } from '@jsb188/app/utils/number.ts';
|
|
4
|
+
import { getObject } from '@jsb188/app/utils/object.ts';
|
|
5
|
+
import { textWithBrackets } from '@jsb188/app/utils/string.ts';
|
|
6
|
+
import { getTimeZoneCode } from '@jsb188/app/utils/timeZone.ts';
|
|
7
|
+
import {
|
|
8
|
+
ARABLE_ACTIVITIES_GROUPED,
|
|
9
|
+
FARMERS_MARKET_ACTIVITIES_GROUPED,
|
|
10
|
+
GROWER_NETWORK_ACTIVITIES_GROUPED,
|
|
11
|
+
LIVESTOCK_ACTIVITIES_GROUPED
|
|
12
|
+
} from '../constants/log.ts';
|
|
13
|
+
import type {
|
|
14
|
+
LogArableDetailsGQL,
|
|
15
|
+
LogEntryGQL,
|
|
16
|
+
LogFarmersMarketDetailsGQL,
|
|
17
|
+
LogGrowerNetworkDetailsGQL,
|
|
18
|
+
LogLivestockDetailsGQL,
|
|
19
|
+
LogTypeEnum
|
|
20
|
+
} from '../types/log.d.ts';
|
|
21
|
+
import { getLogCategoryColor, getLogTypeFromActivity } from '../utils/log.ts';
|
|
10
22
|
|
|
11
23
|
/**
|
|
12
24
|
* Get editable values based on activity & type (which is also used to display UI)
|
|
@@ -15,6 +27,7 @@ import { getLogCategoryColor, getLogTypeFromActivity } from '../utils/log';
|
|
|
15
27
|
export const LOG_TYPENAME_TO_DETAILS_INPUT_NAME = {
|
|
16
28
|
LogArable: 'arableDetails',
|
|
17
29
|
LogFarmersMarket: 'farmersMarketDetails',
|
|
30
|
+
LogGrowerNetwork: 'growerNetworkDetails',
|
|
18
31
|
LogLivestock: 'livestockDetails',
|
|
19
32
|
};
|
|
20
33
|
|
|
@@ -32,7 +45,7 @@ export function makeFormValuesFromData(logEntry: LogEntryGQL) {
|
|
|
32
45
|
|
|
33
46
|
switch (logEntry.details?.__typename) {
|
|
34
47
|
case 'LogArable': {
|
|
35
|
-
const details = logEntry.details as
|
|
48
|
+
const details = logEntry.details as LogArableDetailsGQL;
|
|
36
49
|
formValues.arableDetails = {
|
|
37
50
|
activity: details.activity,
|
|
38
51
|
quantity: details.quantity,
|
|
@@ -40,16 +53,16 @@ export function makeFormValuesFromData(logEntry: LogEntryGQL) {
|
|
|
40
53
|
unit: details.unit,
|
|
41
54
|
concentration: details.concentration,
|
|
42
55
|
concentrationUnit: details.concentrationUnit,
|
|
43
|
-
location:
|
|
44
|
-
fieldLocation: details.fieldLocation,
|
|
56
|
+
location: logEntry.location,
|
|
45
57
|
referenceNumber: details.referenceNumber,
|
|
46
58
|
otherParty: details.otherParty,
|
|
47
59
|
values: details.values,
|
|
60
|
+
voided: details.voided,
|
|
48
61
|
notes: details.notes,
|
|
49
62
|
};
|
|
50
63
|
} break;
|
|
51
64
|
case 'LogFarmersMarket': {
|
|
52
|
-
const details = logEntry.details as
|
|
65
|
+
const details = logEntry.details as LogFarmersMarketDetailsGQL;
|
|
53
66
|
formValues.farmersMarketDetails = {
|
|
54
67
|
activity: details.activity,
|
|
55
68
|
referenceNumber: details.referenceNumber,
|
|
@@ -58,8 +71,19 @@ export function makeFormValuesFromData(logEntry: LogEntryGQL) {
|
|
|
58
71
|
notes: details.notes,
|
|
59
72
|
};
|
|
60
73
|
} break;
|
|
74
|
+
case 'LogGrowerNetwork': {
|
|
75
|
+
const details = logEntry.details as LogGrowerNetworkDetailsGQL;
|
|
76
|
+
formValues.growerNetworkDetails = {
|
|
77
|
+
activity: details.activity,
|
|
78
|
+
childOrgId: logEntry.childOrgId,
|
|
79
|
+
otherParty: details.otherParty,
|
|
80
|
+
item: details.item,
|
|
81
|
+
location: logEntry.location,
|
|
82
|
+
notes: details.notes,
|
|
83
|
+
};
|
|
84
|
+
} break;
|
|
61
85
|
case 'LogLivestock': {
|
|
62
|
-
const details = logEntry.details as
|
|
86
|
+
const details = logEntry.details as LogLivestockDetailsGQL;
|
|
63
87
|
formValues.livestockDetails = {
|
|
64
88
|
activity: details.activity,
|
|
65
89
|
livestock: details.livestock,
|
|
@@ -71,19 +95,20 @@ export function makeFormValuesFromData(logEntry: LogEntryGQL) {
|
|
|
71
95
|
item: details.item,
|
|
72
96
|
quantity: details.quantity,
|
|
73
97
|
unit: details.unit,
|
|
74
|
-
location:
|
|
75
|
-
fieldLocation: details.fieldLocation,
|
|
98
|
+
location: logEntry.location,
|
|
76
99
|
price: details.price,
|
|
77
100
|
tax: details.tax,
|
|
78
101
|
notes: details.notes,
|
|
79
102
|
};
|
|
80
103
|
} break;
|
|
81
104
|
default:
|
|
105
|
+
// @ts-expect-error
|
|
82
106
|
console.log(`${logEntry.details?.__typename} is not done yet.`);
|
|
83
107
|
}
|
|
84
108
|
|
|
85
109
|
// input LogArableInput {
|
|
86
110
|
// activity: LogArableActivity
|
|
111
|
+
// voided: Boolean
|
|
87
112
|
// item: String
|
|
88
113
|
// quantity: Float
|
|
89
114
|
// unit: String
|
|
@@ -140,7 +165,13 @@ export function formatFormValuesForMutation(formValues: Record<string, any>) {
|
|
|
140
165
|
*/
|
|
141
166
|
|
|
142
167
|
export type ValidMetadataFieldName =
|
|
168
|
+
| 'break'
|
|
143
169
|
| 'activity'
|
|
170
|
+
| 'childOrgName'
|
|
171
|
+
| 'childOrgName*fill'
|
|
172
|
+
| 'location'
|
|
173
|
+
| 'location*fill'
|
|
174
|
+
| 'fieldLocation'
|
|
144
175
|
|
|
145
176
|
// ARABLE
|
|
146
177
|
| 'water_testing'
|
|
@@ -152,7 +183,6 @@ export type ValidMetadataFieldName =
|
|
|
152
183
|
| 'price'
|
|
153
184
|
| 'crop'
|
|
154
185
|
| 'purchased_item'
|
|
155
|
-
| 'fieldLocation'
|
|
156
186
|
| 'location_water'
|
|
157
187
|
| 'location_arable'
|
|
158
188
|
|
|
@@ -191,7 +221,7 @@ function makeMetadataSchema(
|
|
|
191
221
|
label: i18n.t('form.activity'),
|
|
192
222
|
item: {
|
|
193
223
|
// editable: false,
|
|
194
|
-
locked: () => true, // Conditional lock is possible
|
|
224
|
+
// locked: () => true, // Conditional lock is possible
|
|
195
225
|
focused: focusedName === (formId + '_activity'),
|
|
196
226
|
name: `${namespace}.activity`,
|
|
197
227
|
placeholder: isCreateNew ? i18n.t(`form.activity_ph`) : '',
|
|
@@ -267,6 +297,16 @@ function makeMetadataSchema(
|
|
|
267
297
|
placeholder: isCreateNew ? i18n.t('log.unit_arable_ph') : '',
|
|
268
298
|
}
|
|
269
299
|
};
|
|
300
|
+
case 'fieldLocation':
|
|
301
|
+
return {
|
|
302
|
+
__type: 'input',
|
|
303
|
+
label: i18n.t('log.fieldLocation'),
|
|
304
|
+
item: {
|
|
305
|
+
name: `${namespace}.fieldLocation`,
|
|
306
|
+
maxLength: 64,
|
|
307
|
+
placeholder: '',
|
|
308
|
+
}
|
|
309
|
+
};
|
|
270
310
|
case 'location_arable':
|
|
271
311
|
return {
|
|
272
312
|
__type: 'input',
|
|
@@ -297,16 +337,6 @@ function makeMetadataSchema(
|
|
|
297
337
|
placeholder: isCreateNew ? i18n.t('log.location_livestock_ph') : '',
|
|
298
338
|
}
|
|
299
339
|
};
|
|
300
|
-
case 'fieldLocation':
|
|
301
|
-
return {
|
|
302
|
-
__type: 'input',
|
|
303
|
-
label: i18n.t('log.fieldLocation'),
|
|
304
|
-
item: {
|
|
305
|
-
name: `${namespace}.fieldLocation`,
|
|
306
|
-
maxLength: 100,
|
|
307
|
-
placeholder: isCreateNew ? i18n.t('log.fieldLocation_ph') : '',
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
340
|
case 'price':
|
|
311
341
|
return {
|
|
312
342
|
__type: 'input',
|
|
@@ -435,7 +465,7 @@ function makeMetadataSchema(
|
|
|
435
465
|
focused: focusedName === (formId + '_void'),
|
|
436
466
|
name: `${namespace}.voided`,
|
|
437
467
|
placeholder: isCreateNew ? i18n.t(`form.void_ph`) : '',
|
|
438
|
-
getter: (value: string) => i18n.t(value ? '
|
|
468
|
+
getter: (value: string) => i18n.t(value ? 'form.voided' : 'form.valid'),
|
|
439
469
|
},
|
|
440
470
|
popOverProps: {
|
|
441
471
|
id: formId + '_void',
|
|
@@ -447,14 +477,14 @@ function makeMetadataSchema(
|
|
|
447
477
|
className: 'max_h_40vh',
|
|
448
478
|
options: [{
|
|
449
479
|
__type: 'LIST_ITEM' as const,
|
|
450
|
-
text: i18n.t('
|
|
480
|
+
text: i18n.t('form.valid'),
|
|
451
481
|
iconName: 'receipt-dollar',
|
|
452
482
|
selected: !formValues[namespace]?.voided,
|
|
453
483
|
name: `${namespace}.voided`,
|
|
454
484
|
value: false,
|
|
455
485
|
}, {
|
|
456
486
|
__type: 'LIST_ITEM' as const,
|
|
457
|
-
text: i18n.t('
|
|
487
|
+
text: i18n.t('form.voided'),
|
|
458
488
|
iconName: 'receipt-off',
|
|
459
489
|
selected: formValues[namespace]?.voided === true,
|
|
460
490
|
name: `${namespace}.voided`,
|
|
@@ -477,7 +507,7 @@ function makeMetadataSchema(
|
|
|
477
507
|
getter: (labelsAndValues: string[]) => {
|
|
478
508
|
return labelsAndValues?.map((lv: any) => {
|
|
479
509
|
return textWithBrackets(
|
|
480
|
-
`${lv.quantity ? `${lv.quantity} ` : ''}${lv.label}`,
|
|
510
|
+
`${lv.quantity ? `${lv.quantity} ` : ''}${lv.unit ? `${lv.unit} ` : ''}${lv.label}`,
|
|
481
511
|
formatCurrency(lv.value, false),
|
|
482
512
|
);
|
|
483
513
|
}).join(', ');
|
|
@@ -489,14 +519,15 @@ function makeMetadataSchema(
|
|
|
489
519
|
iface: {
|
|
490
520
|
name: 'PO_LABELS_AND_VALUES',
|
|
491
521
|
variables: {
|
|
492
|
-
gridLayoutStyle: '70px 1fr 85px',
|
|
522
|
+
gridLayoutStyle: '70px 70px 1fr 85px',
|
|
493
523
|
designClassName: 'w_400',
|
|
494
524
|
className: 'max_h_40vh',
|
|
495
525
|
// flipInputOrder: true,
|
|
496
526
|
forceNumericValues: true,
|
|
497
527
|
includeQuantity: true,
|
|
528
|
+
includeUnit: true,
|
|
498
529
|
name: `${namespace}.values`,
|
|
499
|
-
labels: [i18n.t('form.quantity'), i18n.t('log.invoice_item'), `$ ${i18n.t('form.amount')}`],
|
|
530
|
+
labels: [i18n.t('form.quantity'), i18n.t('form.unit'), i18n.t('log.invoice_item'), `$ ${i18n.t('form.amount')}`],
|
|
500
531
|
inputs: formValues[namespace]?.values || [],
|
|
501
532
|
}
|
|
502
533
|
}
|
|
@@ -562,20 +593,22 @@ export function getSchemaFieldsFromLog(__typename: string, logType: LogTypeEnum)
|
|
|
562
593
|
schemaFields = [
|
|
563
594
|
'activity',
|
|
564
595
|
isWaterTesting ? 'water_testing' : null,
|
|
565
|
-
isWaterTesting ? 'concentration_unit' : null,
|
|
566
|
-
isWaterTesting ? 'water_quantity' : isSaleOrPurchase ? null : 'quantity',
|
|
567
|
-
isWaterTesting ? 'water_unit' : isSaleOrPurchase ? null : 'unit',
|
|
596
|
+
isWaterTesting ? 'concentration_unit' : null, // unit will be ignored in view mode
|
|
568
597
|
isWaterTesting ? null : isSaleOrPurchase ? 'purchased_item' : 'crop',
|
|
598
|
+
isWaterTesting ? 'water_quantity' : isSaleOrPurchase ? null : 'quantity',
|
|
599
|
+
isWaterTesting ? 'water_unit' : isSaleOrPurchase ? null : 'unit', // unit will be ignored in view mode
|
|
569
600
|
isSaleOrPurchase ? 'otherParty' : null,
|
|
570
601
|
isSaleOrPurchase ? 'invoiceNumber' : null,
|
|
571
602
|
isSaleOrPurchase ? 'invoiceItems' : null,
|
|
572
603
|
isSaleOrPurchase ? 'tax' : null,
|
|
604
|
+
isSaleOrPurchase ? 'void' : null,
|
|
573
605
|
isSaleOrPurchase ? null : isWaterTesting ? 'location_water' : 'location_arable',
|
|
574
|
-
|
|
606
|
+
'location',
|
|
607
|
+
'fieldLocation',
|
|
575
608
|
];
|
|
576
609
|
} break;
|
|
577
610
|
case 'LogFarmersMarket': {
|
|
578
|
-
const isReceipt = ['
|
|
611
|
+
const isReceipt = ['MARKET_RECEIPT'].includes(logType);
|
|
579
612
|
|
|
580
613
|
schemaFields = [
|
|
581
614
|
'activity',
|
|
@@ -583,6 +616,17 @@ export function getSchemaFieldsFromLog(__typename: string, logType: LogTypeEnum)
|
|
|
583
616
|
// 'childOrgId', // not editable
|
|
584
617
|
isReceipt ? 'void' : null,
|
|
585
618
|
isReceipt ? 'marketCredits' : null,
|
|
619
|
+
'location*fill',
|
|
620
|
+
'fieldLocation',
|
|
621
|
+
];
|
|
622
|
+
} break;
|
|
623
|
+
case 'LogGrowerNetwork': {
|
|
624
|
+
schemaFields = [
|
|
625
|
+
'activity',
|
|
626
|
+
'childOrgName*fill',
|
|
627
|
+
// 'break',
|
|
628
|
+
'location*fill',
|
|
629
|
+
'fieldLocation'
|
|
586
630
|
];
|
|
587
631
|
} break;
|
|
588
632
|
case 'LogLivestock': {
|
|
@@ -604,7 +648,6 @@ export function getSchemaFieldsFromLog(__typename: string, logType: LogTypeEnum)
|
|
|
604
648
|
isLivestock || isSupplyPurchase ? null : 'unit',
|
|
605
649
|
!isSupplyPurchase ? 'location_livestock' : null,
|
|
606
650
|
isLivestock ? 'price' : null,
|
|
607
|
-
isLivestock ? null : 'fieldLocation',
|
|
608
651
|
];
|
|
609
652
|
} break;
|
|
610
653
|
default:
|
|
@@ -653,13 +696,13 @@ export function makeLogMetadataSchema(
|
|
|
653
696
|
const namespace = {
|
|
654
697
|
LogArable: 'arableDetails',
|
|
655
698
|
LogFarmersMarket: 'farmersMarketDetails',
|
|
699
|
+
LogGrowerNetwork: 'growerNetworkDetails',
|
|
656
700
|
LogLivestock: 'livestockDetails',
|
|
657
701
|
}[__typename] || '';
|
|
658
702
|
|
|
659
703
|
const logActivity = formValues[namespace]?.activity;
|
|
660
704
|
const logType = getLogTypeFromActivity(__typename, logActivity)!;
|
|
661
705
|
const schemaFields = getSchemaFieldsFromLog(__typename, logType);
|
|
662
|
-
const isAITask = logType === 'AI_TASK';
|
|
663
706
|
|
|
664
707
|
switch (__typename) {
|
|
665
708
|
case 'LogArable': {
|
|
@@ -670,6 +713,10 @@ export function makeLogMetadataSchema(
|
|
|
670
713
|
activitiesList = FARMERS_MARKET_ACTIVITIES_GROUPED;
|
|
671
714
|
schemaItems = makeMetadataSchema(namespace, formValues, metadataParams, basePopOverProps, schemaFields);
|
|
672
715
|
} break;
|
|
716
|
+
case 'LogGrowerNetwork': {
|
|
717
|
+
activitiesList = GROWER_NETWORK_ACTIVITIES_GROUPED;
|
|
718
|
+
schemaItems = makeMetadataSchema(namespace, formValues, metadataParams, basePopOverProps, schemaFields);
|
|
719
|
+
} break;
|
|
673
720
|
case 'LogLivestock': {
|
|
674
721
|
activitiesList = LIVESTOCK_ACTIVITIES_GROUPED;
|
|
675
722
|
schemaItems = makeMetadataSchema(namespace, formValues, metadataParams, basePopOverProps, schemaFields);
|
|
@@ -677,8 +724,8 @@ export function makeLogMetadataSchema(
|
|
|
677
724
|
default:
|
|
678
725
|
}
|
|
679
726
|
|
|
680
|
-
if (
|
|
681
|
-
activitiesList = activitiesList.filter(([type]) => type
|
|
727
|
+
if (logType) {
|
|
728
|
+
activitiesList = activitiesList.filter(([type]) => type === logType);
|
|
682
729
|
}
|
|
683
730
|
|
|
684
731
|
// Date, time, createdBy is common across all log types
|
|
@@ -733,7 +780,6 @@ export function makeLogMetadataSchema(
|
|
|
733
780
|
schemaItems[0].item.popOverProps = {
|
|
734
781
|
id: formId + '_activity',
|
|
735
782
|
...basePopOverProps,
|
|
736
|
-
disabled: isAITask, // AI tasks' activity cannot be changed
|
|
737
783
|
iface: {
|
|
738
784
|
name: 'PO_LIST',
|
|
739
785
|
variables: {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
+
import type { InboundContactGQL } from '../types/inboundContact.d.ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Length values for validation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const MIN_LEN_VALUES = {
|
|
9
|
+
email: 100,
|
|
10
|
+
memory: 750,
|
|
11
|
+
personName: 120,
|
|
12
|
+
phone: 40,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Schema; Edit inbound contact
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export function makeEditInboundContactSchema(
|
|
20
|
+
formId: string,
|
|
21
|
+
focusedName: string,
|
|
22
|
+
formValues: Partial<InboundContactGQL>, // always append with "|| nodeData"
|
|
23
|
+
) {
|
|
24
|
+
return {
|
|
25
|
+
listData: [{
|
|
26
|
+
__type: 'input',
|
|
27
|
+
item: {
|
|
28
|
+
name: 'personName',
|
|
29
|
+
maxLength: MIN_LEN_VALUES.personName,
|
|
30
|
+
label: i18n.t('form.name'),
|
|
31
|
+
placeholder: formValues.personName || '',
|
|
32
|
+
autoComplete: 'off',
|
|
33
|
+
focused: focusedName === (formId + '_personName'),
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
__type: 'input',
|
|
37
|
+
item: {
|
|
38
|
+
name: 'email',
|
|
39
|
+
maxLength: MIN_LEN_VALUES.email,
|
|
40
|
+
label: i18n.t('form.email'),
|
|
41
|
+
placeholder: formValues.email || '',
|
|
42
|
+
autoComplete: 'off',
|
|
43
|
+
type: 'email',
|
|
44
|
+
focused: focusedName === (formId + '_email'),
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
__type: 'input',
|
|
48
|
+
item: {
|
|
49
|
+
name: 'phone',
|
|
50
|
+
maxLength: MIN_LEN_VALUES.phone,
|
|
51
|
+
label: i18n.t('form.phone'),
|
|
52
|
+
placeholder: formValues.phone || '',
|
|
53
|
+
autoComplete: 'off',
|
|
54
|
+
type: 'tel',
|
|
55
|
+
focused: focusedName === (formId + '_phone'),
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
__type: 'textarea',
|
|
59
|
+
item: {
|
|
60
|
+
name: 'memory',
|
|
61
|
+
maxLength: MIN_LEN_VALUES.memory,
|
|
62
|
+
label: i18n.t('form.memories'),
|
|
63
|
+
description: i18n.t('form.ai_memories_desc'),
|
|
64
|
+
placeholder: formValues.memory || '',
|
|
65
|
+
autoComplete: 'off',
|
|
66
|
+
minHeight: 80,
|
|
67
|
+
focused: focusedName === (formId + '_memory'),
|
|
68
|
+
}
|
|
69
|
+
}],
|
|
70
|
+
rules: [],
|
|
71
|
+
};
|
|
72
|
+
}
|