@jsb188/app 1.1.1 → 1.1.4
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/constants/app.ts +2 -4
- package/constants/organization.ts +8 -0
- package/i18n/app.ts +11 -20
- package/i18n/auth.ts +44 -18
- package/i18n/error.ts +5 -2
- package/i18n/form.ts +3 -0
- package/i18n/user.ts +3 -1
- package/package.json +3 -4
- package/types/app.d.ts +1 -1
- package/types/organization.d.ts +3 -1
- package/utils/api.ts +0 -1
- package/utils/datetime.ts +87 -47
- package/utils/object.ts +41 -41
- package/utils/string.ts +54 -33
- package/utils/timeZone.ts +493 -451
- package/constants/journal.ts +0 -74
- package/types/journal.d.ts +0 -24
- package/utils/journal.ts +0 -17
package/constants/journal.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Journal types
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export const JOURNAL_TYPE_ENUMS = [
|
|
7
|
-
'FIELD',
|
|
8
|
-
'HARVEST',
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
export const JOURNAL_TYPES_TO_TEXT = {
|
|
12
|
-
FIELD: 'field activities',
|
|
13
|
-
HARVEST: 'harvest activities',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const TEXT_TO_JOURNAL_TYPES = Object.fromEntries(
|
|
17
|
-
Object.entries(JOURNAL_TYPES_TO_TEXT).map(([key, value]) => [value, key]),
|
|
18
|
-
) as Record<string, string>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Activities for each journal types
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
export const FIELD_LOG_ACTIVITY_ENUMS = [
|
|
25
|
-
'PREPARE_SOIL',
|
|
26
|
-
'PLANTING',
|
|
27
|
-
'IRRIGATION',
|
|
28
|
-
'FERTILIZATION_COMPOST',
|
|
29
|
-
'PROTECT_CROP',
|
|
30
|
-
'MONITOR_CROP',
|
|
31
|
-
'PRUNING',
|
|
32
|
-
'STRUCTURE_MAINTENANCE',
|
|
33
|
-
'PREPARE_HARVEST',
|
|
34
|
-
'OTHER_FIELD_ACTIVITY',
|
|
35
|
-
] as const;
|
|
36
|
-
|
|
37
|
-
export const HARVEST_LOG_ACTIVITY_ENUMS = [
|
|
38
|
-
'HARVEST_CROP',
|
|
39
|
-
'HARVEST_COUNT',
|
|
40
|
-
'SORT_GRADE',
|
|
41
|
-
'YIELD_LOSS_ESTIMATE',
|
|
42
|
-
'TRANSFER_TO_STORAGE',
|
|
43
|
-
'OTHER_HARVEST_ACTIVITY',
|
|
44
|
-
] as const;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Activity enums to text
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
export const JOURNAL_ACTIVITIES_TO_TEXT = {
|
|
51
|
-
// # Field log activities
|
|
52
|
-
PREPARE_SOIL: 'soil, beds preparation',
|
|
53
|
-
PLANTING: 'seeding, transplanting',
|
|
54
|
-
IRRIGATION: 'irrigation management',
|
|
55
|
-
FERTILIZATION_COMPOST: 'fertilization, compost application',
|
|
56
|
-
PROTECT_CROP: 'weed, pest, disease management',
|
|
57
|
-
MONITOR_CROP: 'crop monitoring',
|
|
58
|
-
PRUNING: 'pruning',
|
|
59
|
-
STRUCTURE_MAINTENANCE: 'trellising, structure maintenance',
|
|
60
|
-
PREPARE_HARVEST: 'preparing crops for harvest',
|
|
61
|
-
OTHER_FIELD_ACTIVITY: 'other field activities',
|
|
62
|
-
|
|
63
|
-
// # Harvest log activities
|
|
64
|
-
HARVEST_CROP: 'harvesting crops',
|
|
65
|
-
HARVEST_COUNT: 'counting, weighing harvested crops',
|
|
66
|
-
SORT_GRADE: 'sorting, grading crops',
|
|
67
|
-
YIELD_LOSS_ESTIMATE: 'estimating yield or loss',
|
|
68
|
-
TRANSFER_TO_STORAGE: 'transferring crops to storage',
|
|
69
|
-
OTHER_HARVEST_ACTIVITY: 'other harvest activities',
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const TEXT_TO_JOURNAL_ACTIVITIES = Object.fromEntries(
|
|
73
|
-
Object.entries(JOURNAL_ACTIVITIES_TO_TEXT).map(([key, value]) => [value, key]),
|
|
74
|
-
) as Record<string, string>;
|
package/types/journal.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { FIELD_LOG_ACTIVITY_ENUMS, HARVEST_LOG_ACTIVITY_ENUMS, JOURNAL_TYPE_ENUMS } from '../constants/journal.ts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Journal entry object
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export interface JournalEntryObj {
|
|
8
|
-
id: string
|
|
9
|
-
accountId: string
|
|
10
|
-
type: JournalTypeEnum
|
|
11
|
-
notes: string
|
|
12
|
-
date: string // ISO date string
|
|
13
|
-
editAt: string // ISO date string
|
|
14
|
-
|
|
15
|
-
activity: JournalEntryActivityEnum
|
|
16
|
-
item: string
|
|
17
|
-
quantity: number
|
|
18
|
-
unit: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type JournalTypeEnum = typeof JOURNAL_TYPE_ENUMS[number];
|
|
22
|
-
export type FieldLogActivityEnum = typeof FIELD_LOG_ACTIVITY_ENUMS[number];
|
|
23
|
-
export type HarvestLogActivityEnum = typeof HARVEST_LOG_ACTIVITY_ENUMS[number];
|
|
24
|
-
export type JournalEntryActivityEnum = FieldLogActivityEnum | HarvestLogActivityEnum;
|
package/utils/journal.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ColorEnum } from '../types/app.d';
|
|
2
|
-
import type { JournalTypeEnum } from '../types/journal.d';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Map journal type to a color
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export function getJournalTypeColor(type: JournalTypeEnum): ColorEnum {
|
|
9
|
-
const journalTypeToColor = {
|
|
10
|
-
FIELD: 'yellow',
|
|
11
|
-
HARVEST: 'green',
|
|
12
|
-
} as Record<JournalTypeEnum, ColorEnum>;
|
|
13
|
-
|
|
14
|
-
// Default to zinc if type is not found
|
|
15
|
-
const color = journalTypeToColor[type] || 'zinc';
|
|
16
|
-
return color;
|
|
17
|
-
}
|