@jsb188/mday 1.1.5 → 1.1.7

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.
@@ -0,0 +1,54 @@
1
+ // Organization constants
2
+ // IMPORTANT NOTE: Array order must *never* change, indexes are used to create PDF URLs
3
+
4
+ export const OPERATION_ENUMS = [
5
+ // Farms
6
+ 'ARABLE',
7
+ 'LIVESTOCK',
8
+
9
+ // Umbrella orgs
10
+ 'FARMERS_MARKET',
11
+ 'GROWER_NETWORK',
12
+
13
+ // External orgs
14
+ 'VENDOR',
15
+ ];
16
+
17
+ export const PARENT_ORG_OPERATIONS = [
18
+ 'FARMERS_MARKET',
19
+ 'GROWER_NETWORK',
20
+ ];
21
+
22
+ // Employee ACL
23
+
24
+ export const ROLE_ENUMS = ['MEMBER', 'MANAGER', 'ADMIN', 'OWNER', 'GUEST']; // first is default value
25
+
26
+ // Role categories (used for reminders)
27
+
28
+ export const ROLE_CATEGORY_ENUMS = ['EMPLOYEES_ONLY', 'MANAGERS_ONLY'];
29
+
30
+ // Org departments
31
+
32
+ export const ORG_CONTACTS = [
33
+ 'PRIMARY_CONTACT',
34
+ 'ACCOUNTS_RECEIVABLE',
35
+ 'SALES',
36
+ 'CUSTOMER_SERVICE',
37
+ 'SHIPPING_RECEIVING',
38
+ 'OTHER',
39
+ ];
40
+
41
+ // Compliance
42
+
43
+ export const COMPLIANCE_DOCUMENT_TYPE_MAP = {
44
+ 'Organic Certificate': 'ORGANIC',
45
+ 'Insurance Policy/Insurance Certificate': 'INSURANCE',
46
+ "Producer's Certificate": 'PRODUCERS_CERTIFICATE',
47
+ 'Milk Handler License': 'MILK_HANDLER_LICENSE',
48
+ 'Egg Handler License': 'EGG_HANDLER_LICENSE',
49
+ 'Nursery License': 'NURSERY_LICENSE',
50
+ };
51
+
52
+ export const COMPLIANCE_DOCUMENT_TYPE_ENUMS = Object.values(COMPLIANCE_DOCUMENT_TYPE_MAP);
53
+
54
+ export const COMPLIANCE_DOCUMENT_TYPE_LABELS = Object.keys(COMPLIANCE_DOCUMENT_TYPE_MAP);
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Products; all types
3
+ */
4
+
5
+ export const PRODUCT_TYPES = [
6
+ 'LIVESTOCK',
7
+ 'CAL_EVENTS',
8
+ 'FOOD_SAFETY',
9
+ 'GLOBAL_GAP',
10
+ ];
11
+
12
+ /**
13
+ * Product features
14
+ */
15
+
16
+ export const FEATURES_BY_OPERATION = {
17
+ ARABLE: [
18
+ 'NORMAL_LOGGING', // First item is always the default
19
+ 'FOOD_SAFETY',
20
+ 'GLOBAL_GAP',
21
+ 'ORGANIC_CERTIFICATION',
22
+ ],
23
+ FARMERS_MARKET: [
24
+ 'NORMAL_LOGGING',
25
+ 'CAL_EVENTS',
26
+ 'CAL_EVENTS_ATTENDANCE',
27
+ 'CAL_EVENTS_LOAD_LIST',
28
+ ],
29
+ LIVESTOCK: [
30
+ 'NORMAL_LOGGING',
31
+ 'LIVESTOCK', // DEPRECATED
32
+ 'LIVESTOCK_MANAGEMENT',
33
+ ],
34
+ };
35
+
36
+ export const PRODUCT_FEATURES = [
37
+ ...FEATURES_BY_OPERATION.ARABLE,
38
+ ...FEATURES_BY_OPERATION.FARMERS_MARKET,
39
+ ...FEATURES_BY_OPERATION.LIVESTOCK,
40
+ ].filter((value, index, self) => self.indexOf(value) === index);
41
+
42
+ export const ACTIVITY_TO_FEATURE_MAP = {
43
+ CAL_EVENTS_ATTENDANCE: ['MARKET_ATTENDANCE'],
44
+ CAL_EVENTS_LOAD_LIST: ['MARKET_LOAD_LIST'],
45
+ };
46
+
47
+ /**
48
+ * Products; Livestock
49
+ */
50
+
51
+ export const PRODUCT_LIVESTOCK_TYPES = [
52
+ 'CATTLE',
53
+ 'HORSE',
54
+ 'GOAT',
55
+ 'SHEEP',
56
+ 'POULTRY',
57
+ 'PIG',
58
+ 'OTHER_LIVESTOCK',
59
+ ];
60
+
61
+ export const PRODUCT_LIVESTOCK_STATUS = [
62
+ 'ALIVE',
63
+ 'SICK',
64
+ 'SOLD',
65
+ 'DECEASED',
66
+ ];
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Reports; all types
3
+ */
4
+
5
+ export const REPORT_SORT_OPTS = [
6
+ 'PERIOD_HAPPENED',
7
+ ];
8
+
9
+ export const REPORT_TYPES = [
10
+ 'GLOBAL_GAP',
11
+ 'CLEANING',
12
+ 'ORGANIC_CERTIFICATION',
13
+ ];
14
+
15
+ export const REPORT_ROW_PRESETS = [
16
+ 'LABELS',
17
+ 'MONTH',
18
+ 'BREAK',
19
+ 'Q_AND_A',
20
+ 'TEXTS',
21
+ 'LONG_TEXTS', // Same as "TEXTS" but has a different function in <FileBrowserPlus>
22
+ 'HEADINGS',
23
+ 'REPORT_STATEMENTS_OVERVIEW',
24
+ 'EVIDENCES',
25
+ ];
@@ -0,0 +1,44 @@
1
+ import type { ChildOrgsFilterArgs, OrganizationOperationEnum } from '../types/organization.d';
2
+
3
+ /**
4
+ * Create a filter object for productsList() query from the URL search query.
5
+ * @param operationType - The organization operation type
6
+ * @param searchQuery - The search query string from the URL
7
+ * @param otherFiltersObj - Additional filter properties to merge into the result
8
+ * @returns ProductsFilterArgs - The filter object to be used in the productsList() query
9
+ */
10
+
11
+ export function getChildOrgsFilterFromURL(
12
+ _operationType: OrganizationOperationEnum | null,
13
+ searchQuery: string,
14
+ otherFiltersObj?: {
15
+ withoutPreset?: Partial<ChildOrgsFilterArgs>;
16
+ withPreset?: Partial<ChildOrgsFilterArgs>;
17
+ }
18
+ ) {
19
+ if (!searchQuery && otherFiltersObj?.withPreset) {
20
+ return otherFiltersObj.withPreset;
21
+ } else if (searchQuery === '?preset=none' && otherFiltersObj?.withoutPreset) {
22
+ return otherFiltersObj.withoutPreset;
23
+ }
24
+
25
+ const urlParams = new URLSearchParams(searchQuery);
26
+
27
+ // let startDate = urlParams.get('sd');
28
+ // let endDate = urlParams.get('ed');
29
+ // if (startDate && !endDate) {
30
+ // endDate = startDate;
31
+ // } else if (endDate && !startDate) {
32
+ // startDate = endDate;
33
+ // }
34
+
35
+ const filter: ChildOrgsFilterArgs = {
36
+ // startDate,
37
+ // endDate,
38
+ // timeZone: indexToTimeZone(urlParams.get('z')),
39
+ // query: urlParams.get('q') || '',
40
+ ...otherFiltersObj?.withoutPreset,
41
+ };
42
+
43
+ return filter;
44
+ }