@jsb188/app 1.1.3 → 1.1.5
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 +37 -4
- package/constants/organization.ts +12 -0
- package/i18n/{user.ts → account.ts} +11 -33
- package/i18n/app.ts +14 -20
- package/i18n/auth.ts +56 -20
- package/i18n/error.ts +24 -14
- package/i18n/form.ts +41 -3
- package/main.ts +2 -2
- package/package.json +6 -6
- package/types/account.d.ts +62 -0
- package/types/ai.d.ts +3 -0
- package/types/app.d.ts +2 -1
- package/types/auth.d.ts +7 -1
- package/types/form.d.ts +9 -3
- package/types/organization.d.ts +76 -20
- package/utils/api.ts +0 -1
- package/utils/datetime.ts +128 -29
- package/utils/logic.ts +23 -9
- package/utils/number.ts +86 -7
- package/utils/object.ts +139 -67
- package/utils/organization.ts +102 -0
- package/utils/string.ts +55 -9
- package/utils/timeZone.ts +497 -4
- package/utils/url_client.ts +17 -22
- package/utils/user.ts +0 -105
- package/constants/journal.ts +0 -118
- package/types/journal.d.ts +0 -35
- package/types/user.d.ts +0 -52
- package/utils/journal.ts +0 -20
package/utils/user.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import i18n from '../i18n/';
|
|
2
1
|
|
|
3
2
|
/**
|
|
4
3
|
* Types
|
|
@@ -93,110 +92,6 @@ export function resolveOnlineStatus(user: object, viewerUserId: number) {
|
|
|
93
92
|
return 'APPEAR_OFFLINE';
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
/**
|
|
97
|
-
* Get friend status between 2 users
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
export function getFriendOptions(friend?: FriendFragment | null): FriendOptionsObj {
|
|
101
|
-
const { myStatus, otherStatus } = friend || {};
|
|
102
|
-
if (myStatus === 'BLOCKED') {
|
|
103
|
-
// Blocked by user
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
friendButtonText: i18n.t('user.blocked'),
|
|
107
|
-
friendStatusText: i18n.t('user.blocked_by_me'),
|
|
108
|
-
friendButtonIconName: 'user-x',
|
|
109
|
-
messageAllowed: false,
|
|
110
|
-
options: [{
|
|
111
|
-
value: 'DECLINED',
|
|
112
|
-
iconName: 'user',
|
|
113
|
-
text: i18n.t('user.unblock'),
|
|
114
|
-
}],
|
|
115
|
-
};
|
|
116
|
-
} else if (otherStatus === 'BLOCKED') {
|
|
117
|
-
// Blocked by "other" user
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
friendButtonText: i18n.t('user.blocked'),
|
|
121
|
-
friendStatusText: i18n.t('user.blocked_by_other'),
|
|
122
|
-
friendButtonIconName: 'user-x',
|
|
123
|
-
messageAllowed: false,
|
|
124
|
-
options: [],
|
|
125
|
-
};
|
|
126
|
-
} else if (myStatus === 'ACCEPTED' && otherStatus === 'ACCEPTED') {
|
|
127
|
-
// Friends
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
friendButtonText: i18n.t('user.friends'),
|
|
131
|
-
friendStatusText: i18n.t('user.friends_msg'),
|
|
132
|
-
friendButtonIconName: 'user-check',
|
|
133
|
-
messageAllowed: true,
|
|
134
|
-
options: [{
|
|
135
|
-
value: 'DECLINED',
|
|
136
|
-
iconName: 'user-cancel',
|
|
137
|
-
text: i18n.t('user.remove_friend'),
|
|
138
|
-
}, {
|
|
139
|
-
value: 'BLOCKED',
|
|
140
|
-
iconName: 'user-x',
|
|
141
|
-
text: i18n.t('user.block'),
|
|
142
|
-
}],
|
|
143
|
-
};
|
|
144
|
-
} else if (myStatus === 'PENDING') {
|
|
145
|
-
// Pending request from other user
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
friendButtonText: i18n.t('user.friend_request'),
|
|
149
|
-
friendStatusText: i18n.t('user.add_friend_msg'),
|
|
150
|
-
friendButtonIconName: 'user-plus',
|
|
151
|
-
messageAllowed: false,
|
|
152
|
-
options: [{
|
|
153
|
-
value: 'ACCEPTED',
|
|
154
|
-
iconName: 'user-check',
|
|
155
|
-
text: i18n.t('user.accept_friend'),
|
|
156
|
-
}, {
|
|
157
|
-
value: 'DECLINED',
|
|
158
|
-
iconName: 'user-cancel',
|
|
159
|
-
text: i18n.t('user.ignore_friend'),
|
|
160
|
-
}, {
|
|
161
|
-
value: 'BLOCKED',
|
|
162
|
-
iconName: 'user-x',
|
|
163
|
-
text: i18n.t('user.block'),
|
|
164
|
-
}],
|
|
165
|
-
};
|
|
166
|
-
} else if (otherStatus === 'PENDING') {
|
|
167
|
-
// Sent a friend request; now waiting
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
friendButtonText: i18n.t('user.friend_requested'),
|
|
171
|
-
friendStatusText: i18n.t('user.sent_friend_msg'),
|
|
172
|
-
friendButtonIconName: 'mail',
|
|
173
|
-
messageAllowed: false,
|
|
174
|
-
options: [{
|
|
175
|
-
value: 'DECLINED',
|
|
176
|
-
iconName: 'user-cancel',
|
|
177
|
-
text: i18n.t('user.cancel_friend'),
|
|
178
|
-
}],
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// No actions taken, user can/should send request
|
|
183
|
-
return {
|
|
184
|
-
friendButtonText: i18n.t('user.add_friend'),
|
|
185
|
-
friendStatusText: i18n.t('user.add_friend_msg'),
|
|
186
|
-
friendButtonIconName: 'user-plus',
|
|
187
|
-
messageAllowed: false,
|
|
188
|
-
options: [{
|
|
189
|
-
value: 'PENDING',
|
|
190
|
-
iconName: 'mail',
|
|
191
|
-
text: i18n.t('user.send_friend'),
|
|
192
|
-
}, {
|
|
193
|
-
value: 'BLOCKED',
|
|
194
|
-
iconName: 'user-x',
|
|
195
|
-
text: i18n.t('user.block'),
|
|
196
|
-
}],
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
|
|
200
95
|
/**
|
|
201
96
|
* Get user subscription type
|
|
202
97
|
*/
|
package/constants/journal.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Journal types
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export const JOURNAL_TYPE_ENUMS = [
|
|
6
|
-
'SEED',
|
|
7
|
-
'FIELD',
|
|
8
|
-
'HARVEST',
|
|
9
|
-
'POST_HARVEST',
|
|
10
|
-
'SALES',
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
export const JOURNAL_TYPES_TO_TEXT = {
|
|
14
|
-
SEED: 'seed purchases',
|
|
15
|
-
FIELD: 'field activities',
|
|
16
|
-
HARVEST: 'harvest activities',
|
|
17
|
-
POST_HARVEST: 'handling, washing, sorting, grading, packaging after harvest',
|
|
18
|
-
SALES: 'sales',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const TEXT_TO_JOURNAL_TYPES = Object.fromEntries(
|
|
22
|
-
Object.entries(JOURNAL_TYPES_TO_TEXT).map(([key, value]) => [value, key]),
|
|
23
|
-
) as Record<string, string>;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Activities for each journal types
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
export const SEED_LOG_ACTIVITY_ENUMS = [
|
|
30
|
-
'SEED_PURCHASE_INFO',
|
|
31
|
-
'SEED_COMPLIANCE_NOTE',
|
|
32
|
-
'OTHER_SEED_ACTIVITY',
|
|
33
|
-
] as const;
|
|
34
|
-
|
|
35
|
-
export const FIELD_LOG_ACTIVITY_ENUMS = [
|
|
36
|
-
'PREPARE_SOIL',
|
|
37
|
-
'PLANTING',
|
|
38
|
-
'IRRIGATION',
|
|
39
|
-
'FERTILIZATION_COMPOST',
|
|
40
|
-
'PROTECT_CROP',
|
|
41
|
-
'MONITOR_CROP',
|
|
42
|
-
'PRUNING',
|
|
43
|
-
'STRUCTURE_MAINTENANCE',
|
|
44
|
-
'PREPARE_HARVEST',
|
|
45
|
-
'OTHER_FIELD_ACTIVITY',
|
|
46
|
-
] as const;
|
|
47
|
-
|
|
48
|
-
export const HARVEST_LOG_ACTIVITY_ENUMS = [
|
|
49
|
-
'HARVEST_CROP',
|
|
50
|
-
'HARVEST_COUNT',
|
|
51
|
-
'SORT_GRADE',
|
|
52
|
-
'YIELD_LOSS_ESTIMATE',
|
|
53
|
-
'OTHER_HARVEST_ACTIVITY',
|
|
54
|
-
] as const;
|
|
55
|
-
|
|
56
|
-
export const POST_HARVEST_LOG_ACTIVITY_ENUMS = [
|
|
57
|
-
'POST_HARVEST_HANDLING',
|
|
58
|
-
'POST_HARVEST_PACKAGING',
|
|
59
|
-
'OTHER_POST_HARVEST_ACTIVITY',
|
|
60
|
-
] as const;
|
|
61
|
-
|
|
62
|
-
export const SALES_LOG_ACTIVITY_ENUMS = [
|
|
63
|
-
'SALE_TRANSACTION',
|
|
64
|
-
'SALE_DETAILS',
|
|
65
|
-
'SALE_FEEDBACK',
|
|
66
|
-
'OTHER_SALES_ACTIVITY',
|
|
67
|
-
] as const;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Activity enums to text
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
export const JOURNAL_ACTIVITIES_TO_TEXT = {
|
|
74
|
-
// # Seed log activities
|
|
75
|
-
SEED_PURCHASE_INFO: 'seed purchase information',
|
|
76
|
-
SEED_COMPLIANCE_NOTE: 'seed compliance notes',
|
|
77
|
-
OTHER_SEED_ACTIVITY: 'other seed purchase related notes',
|
|
78
|
-
|
|
79
|
-
// # Field log activities
|
|
80
|
-
PREPARE_SOIL: 'soil, beds preparation',
|
|
81
|
-
PLANTING: 'seeding, transplanting',
|
|
82
|
-
IRRIGATION: 'irrigation management',
|
|
83
|
-
FERTILIZATION_COMPOST: 'fertilization, compost application',
|
|
84
|
-
PROTECT_CROP: 'weed, pest, disease management',
|
|
85
|
-
MONITOR_CROP: 'crop monitoring',
|
|
86
|
-
PRUNING: 'pruning',
|
|
87
|
-
STRUCTURE_MAINTENANCE: 'trellising, structure maintenance',
|
|
88
|
-
PREPARE_HARVEST: 'preparing crops for harvest',
|
|
89
|
-
OTHER_FIELD_ACTIVITY: 'other field activities',
|
|
90
|
-
|
|
91
|
-
// # Harvest log activities
|
|
92
|
-
HARVEST_CROP: 'harvesting crops',
|
|
93
|
-
HARVEST_COUNT: 'counting, weighing harvested crops',
|
|
94
|
-
SORT_GRADE: 'sorting, grading crops',
|
|
95
|
-
YIELD_LOSS_ESTIMATE: 'estimating yield or loss',
|
|
96
|
-
OTHER_HARVEST_ACTIVITY: 'other harvest activities',
|
|
97
|
-
|
|
98
|
-
// # Post-harvest log activities
|
|
99
|
-
POST_HARVEST_HANDLING: 'washing, drying, trimming, sorting, or grading produce',
|
|
100
|
-
POST_HARVEST_PACKAGING: 'packaging, cooling, or moving produce to storage',
|
|
101
|
-
OTHER_POST_HARVEST_ACTIVITY: 'other post-harvest activities',
|
|
102
|
-
|
|
103
|
-
// # Sales log activities
|
|
104
|
-
SALE_TRANSACTION: 'sale transactions',
|
|
105
|
-
SALE_DETAILS: 'sale details',
|
|
106
|
-
SALE_FEEDBACK: 'sale feedback or issues',
|
|
107
|
-
OTHER_SALES_ACTIVITY: 'other sales related notes',
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export const TEXT_TO_JOURNAL_ACTIVITIES = Object.fromEntries(
|
|
111
|
-
Object.entries(JOURNAL_ACTIVITIES_TO_TEXT).map(([key, value]) => [value, key]),
|
|
112
|
-
) as Record<string, string>;
|
|
113
|
-
|
|
114
|
-
// Moved to walk-in
|
|
115
|
-
// Hydrocooled immediately after harvest
|
|
116
|
-
// Bagged and labeled greens
|
|
117
|
-
// Packed in clamshells
|
|
118
|
-
// Stickered with farm logo
|
package/types/journal.d.ts
DELETED
|
@@ -1,35 +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;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Filters for search
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
export interface FilterJournalEntriesArgs {
|
|
31
|
-
type?: JournalTypeEnum | null;
|
|
32
|
-
startDate?: string | null;
|
|
33
|
-
endDate?: string | null;
|
|
34
|
-
query?: string;
|
|
35
|
-
}
|
package/types/user.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { PersonaObj } from './chat';
|
|
2
|
-
|
|
3
|
-
type OnlineStatusEnum = null | 'AWAY' | 'BUSY' | 'APPEAR_OFFLINE';
|
|
4
|
-
type PlusStatusEnum = 'PRO' | 'PLUS' | 'PERKS' | 'NORMAL';
|
|
5
|
-
|
|
6
|
-
export interface AppUser {
|
|
7
|
-
id: string;
|
|
8
|
-
username: string;
|
|
9
|
-
displayName: string;
|
|
10
|
-
|
|
11
|
-
moderator: boolean;
|
|
12
|
-
activated: boolean;
|
|
13
|
-
|
|
14
|
-
plusStatus: PlusStatusEnum;
|
|
15
|
-
onlineStatus: OnlineStatusEnum;
|
|
16
|
-
|
|
17
|
-
plus: {
|
|
18
|
-
id: string;
|
|
19
|
-
expireAt: string;
|
|
20
|
-
cancelled: boolean;
|
|
21
|
-
type: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
theme: {
|
|
25
|
-
id: string;
|
|
26
|
-
name: string;
|
|
27
|
-
backgroundPhotoUri: string;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
profile: {
|
|
31
|
-
id: string;
|
|
32
|
-
description: string;
|
|
33
|
-
pronouns: string;
|
|
34
|
-
photoUri: string;
|
|
35
|
-
backgroundPhotoUri: string;
|
|
36
|
-
adult: boolean;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
email: {
|
|
40
|
-
id: string;
|
|
41
|
-
address: string;
|
|
42
|
-
verified: boolean;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
phone: {
|
|
46
|
-
id: string;
|
|
47
|
-
number: string;
|
|
48
|
-
verified: boolean;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
personas: PersonaObj[];
|
|
52
|
-
}
|
package/utils/journal.ts
DELETED
|
@@ -1,20 +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
|
-
SEED: 'brown',
|
|
11
|
-
FIELD: 'yellow',
|
|
12
|
-
HARVEST: 'green',
|
|
13
|
-
POST_HARVEST: 'cyan',
|
|
14
|
-
SALES: 'blue',
|
|
15
|
-
} as Record<JournalTypeEnum, ColorEnum>;
|
|
16
|
-
|
|
17
|
-
// Default to zinc if type is not found
|
|
18
|
-
const color = journalTypeToColor[type] || 'zinc';
|
|
19
|
-
return color;
|
|
20
|
-
}
|