@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/app.ts
CHANGED
|
@@ -7,7 +7,7 @@ export const NOTIF_EXPIRE_DAYS = 30;
|
|
|
7
7
|
|
|
8
8
|
export const DOM_IDS = {
|
|
9
9
|
sidebarInput: 'sidebar_input',
|
|
10
|
-
mainFocusTextarea: '
|
|
10
|
+
mainFocusTextarea: 'main_tx',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// Local storage
|
|
@@ -25,9 +25,7 @@ export const STORAGE_KEYS = {
|
|
|
25
25
|
// Support e-mails
|
|
26
26
|
|
|
27
27
|
export const SUPPORT_EMAILS = {
|
|
28
|
-
|
|
29
|
-
big_planet: 'hi@kajiwoto.ai',
|
|
30
|
-
cosmic: 'hi@kajiwoto.ai',
|
|
28
|
+
marketday: 'hello@marketday.ai'
|
|
31
29
|
} as Record<string, string>;
|
|
32
30
|
|
|
33
31
|
// Social media
|
package/i18n/app.ts
CHANGED
|
@@ -6,12 +6,22 @@ export default {
|
|
|
6
6
|
privacy: 'Privacy Policy',
|
|
7
7
|
tos: 'Terms of Service',
|
|
8
8
|
|
|
9
|
-
//
|
|
9
|
+
// Routes
|
|
10
10
|
route_: 'App | %{text}',
|
|
11
11
|
route_auth: 'Log in or sign up',
|
|
12
|
+
route_auth_signup: 'Create an account',
|
|
12
13
|
route_not_found: 'Page Not Found',
|
|
13
14
|
route_not_found_desc: 'The page you are looking for does not exist.',
|
|
14
15
|
|
|
16
|
+
// Toolbar titles
|
|
17
|
+
// NOTE: If i18n.has(routeName) -> /app/ routes will show the title in the toolbar
|
|
18
|
+
toolbar_title_logs: 'Logs',
|
|
19
|
+
toolbar_title_ai_chat: 'AI',
|
|
20
|
+
|
|
21
|
+
// General
|
|
22
|
+
open_app: 'Open app',
|
|
23
|
+
home: 'Home',
|
|
24
|
+
|
|
15
25
|
// @home screen
|
|
16
26
|
hey_: 'Hey, ',
|
|
17
27
|
how_to_use_app: 'How to use this app',
|
|
@@ -40,20 +50,6 @@ export default {
|
|
|
40
50
|
message_you_3: 'Your messages are colorful.',
|
|
41
51
|
message_you_4: 'Because you are special!',
|
|
42
52
|
|
|
43
|
-
// Theme names
|
|
44
|
-
theme_terracotta: 'Terracotta',
|
|
45
|
-
theme_envy_green: 'Envy green',
|
|
46
|
-
theme_vaporwave: 'Vaporwave',
|
|
47
|
-
theme_facetious: 'Facetious',
|
|
48
|
-
theme_sebastian_garden: 'Sebastian\'s garden',
|
|
49
|
-
theme_bob_deep_sea: 'Bob\'s deep sea',
|
|
50
|
-
theme_saif_flowers: 'Saif\'s flowers',
|
|
51
|
-
theme_bona_mocha: 'Bona\'s mocha',
|
|
52
|
-
theme_naffe_heart: 'Naffe\'s heart',
|
|
53
|
-
theme_dominic_aquarium: 'Dominic\'s aquarium',
|
|
54
|
-
theme_xavii_toothpaste: 'Xavii\'s toothpaste',
|
|
55
|
-
theme_miyu_sugar_sherbet: 'Miyu\'s sugar sherbet',
|
|
56
|
-
|
|
57
53
|
// Settings
|
|
58
54
|
settings: 'Settings',
|
|
59
55
|
appearance: 'Appearance',
|
|
@@ -87,11 +83,6 @@ export default {
|
|
|
87
83
|
notif_message_CO_OWNER_ADDED: 'You became a co-owner. You have live and moderation permissions.',
|
|
88
84
|
notif_message_CO_OWNER_INVITE: 'You received an invitation to become a co-owner for this chat.',
|
|
89
85
|
|
|
90
|
-
// Homepage; Top banner
|
|
91
|
-
hp_desc_1: 'is a ',
|
|
92
|
-
hp_desc_2: 'community owned',
|
|
93
|
-
hp_desc_3: 'messaging app.',
|
|
94
|
-
|
|
95
86
|
// Homepage; Roadmap
|
|
96
87
|
roadmap: 'Roadmap',
|
|
97
88
|
|
package/i18n/auth.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
en: {
|
|
3
3
|
// Login
|
|
4
|
-
|
|
4
|
+
welcome_back: 'Welcome back',
|
|
5
|
+
log_in: 'Log in',
|
|
6
|
+
log_in_sign_up: 'Log in / Sign up',
|
|
5
7
|
open_app: 'Open app',
|
|
6
8
|
continue_with_google: 'Continue with Google',
|
|
7
9
|
continue_with_discord: 'Continue with Discord',
|
|
8
10
|
continue_with_apple: 'Continue with Apple',
|
|
9
11
|
login_opts: 'Continue with e-mail, ID, or @username',
|
|
10
12
|
login_opts_phone_email: 'Continue with phone number or e-mail',
|
|
11
|
-
|
|
13
|
+
verify_your_acc: 'Verify your account',
|
|
12
14
|
reset_password: 'Reset password',
|
|
13
15
|
forgot_password_: 'Forgot password or username?',
|
|
14
16
|
signup_email: 'Sign up using e-mail',
|
|
15
|
-
signup_using_other: '
|
|
17
|
+
signup_using_other: 'Log in with an existing account',
|
|
16
18
|
change_password: 'Change password',
|
|
17
19
|
you_are_verified_: 'You are verified!',
|
|
18
20
|
account_is_verified: 'Thank you for verifying your account with e-mail address: %{emailAddress}',
|
|
19
|
-
continue_to_login: 'Continue to
|
|
21
|
+
continue_to_login: 'Continue to log in',
|
|
20
22
|
|
|
21
23
|
// Auth
|
|
22
24
|
username_not_found: 'No one was found with that username.',
|
|
@@ -25,31 +27,47 @@ export default {
|
|
|
25
27
|
you_are_logged_in: 'You are signed in.',
|
|
26
28
|
password_changed_msg: 'Your password has been changed.',
|
|
27
29
|
request_reset_password_instr: 'Enter your e-mail address and we will send you instructions to reset your password.',
|
|
28
|
-
resend_verification_instr: 'Enter your e-mail address
|
|
30
|
+
resend_verification_instr: 'Enter your e-mail address and we will send you an e-mail to verify your account.',
|
|
29
31
|
reset_password_instr: 'Choose a new password for your account with the e-mail address: %{emailAddress}',
|
|
30
|
-
|
|
32
|
+
_verify_your_email: ' to verify your e-mail.',
|
|
33
|
+
_verify_your_phone: ' to verify your phone number.',
|
|
31
34
|
|
|
32
35
|
// Auth - check fails
|
|
33
36
|
no_account_with_phone: 'No account was found with that phone number.',
|
|
34
37
|
no_account_with_email: 'No account was found with that e-mail address.',
|
|
35
|
-
not_valid_email_or_phone: 'That is not a valid phone number or
|
|
38
|
+
not_valid_email_or_phone: 'That is not a valid phone number or e-mail address.',
|
|
36
39
|
|
|
37
40
|
// Reset password (requested)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
reset_password_requested_msg: (
|
|
42
|
+
'Check your e-mail, <strong>%{emailAddress}</strong> ' +
|
|
43
|
+
'for instructions to reset your password.'
|
|
44
|
+
),
|
|
45
|
+
if_need_more_help_email: (
|
|
46
|
+
'If you need assistance, please contact us at ' +
|
|
47
|
+
'[%{emailAddress}](mailto:%{emailAddress}).'
|
|
48
|
+
),
|
|
49
|
+
|
|
50
|
+
// Invite required
|
|
51
|
+
invite_required: 'Invite required',
|
|
52
|
+
invite_required_msg: (
|
|
53
|
+
'Account creation is currently not opened to the public. ' +
|
|
54
|
+
'Ask your team for an invite or contact us at ' +
|
|
55
|
+
'[%{emailAddress}](mailto:%{emailAddress}) to create an account.'
|
|
56
|
+
),
|
|
41
57
|
|
|
42
58
|
// Sign up
|
|
43
59
|
sign_up: 'Sign up',
|
|
60
|
+
create_account: 'Create an account',
|
|
44
61
|
agree_and_continue: 'Agree and continue',
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
62
|
+
sign_up_notice_msg: (
|
|
63
|
+
'By selecting "Agree and continue", I agree to the ' +
|
|
64
|
+
'[Terms of Service](/tos) and acknowledge the ' +
|
|
65
|
+
'[Privacy Policy](/privacy).'
|
|
66
|
+
),
|
|
48
67
|
email_sent: 'E-mail sent',
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
check_email_4: ' or re-send another verification link to your e-mail.',
|
|
68
|
+
check_email_msg: 'Please check your e-mail for instructions to verify your account.',
|
|
69
|
+
// check_email_3: 'Click "continue" to log in as ',
|
|
70
|
+
// check_email_4: ' or re-send another verification link to your e-mail.',
|
|
53
71
|
check_email: 'Check your e-mail',
|
|
54
72
|
not_verified_yet: 'Please verify your e-mail and try again.',
|
|
55
73
|
resend_change_verification: 'Re-send verification link or change e-mail',
|
|
@@ -57,7 +75,15 @@ export default {
|
|
|
57
75
|
verify_email_msg: 'Send a new verification link to your e-mail.',
|
|
58
76
|
resend_verification: 'Send verification e-mail',
|
|
59
77
|
|
|
78
|
+
// Sign up success
|
|
79
|
+
account_created: 'Account created',
|
|
80
|
+
account_created_msg: (
|
|
81
|
+
'Your account has been created successfully. Please follow the instructions ' +
|
|
82
|
+
'in the e-mail we sent you to verify your account.'
|
|
83
|
+
),
|
|
84
|
+
|
|
60
85
|
// Sign out
|
|
61
|
-
|
|
86
|
+
sign_out: 'Sign out',
|
|
87
|
+
signing_out_: 'Signing you out...'
|
|
62
88
|
},
|
|
63
89
|
};
|
package/i18n/error.ts
CHANGED
|
@@ -5,6 +5,7 @@ export default {
|
|
|
5
5
|
network_error_title: 'Network error',
|
|
6
6
|
unknown_error: 'An unknown error occured.',
|
|
7
7
|
network_error: 'Failed to connect to server. Please try again in a moment.',
|
|
8
|
+
network_or_outage_error: 'Failed to connect to server. If your internect connection is stable, our servers may be experiencing an outage.',
|
|
8
9
|
app_error_title: 'App crashed',
|
|
9
10
|
app_error: 'Uh-oh, please refresh the page and tell someone.',
|
|
10
11
|
not_allowed: 'Not allowed',
|
|
@@ -84,10 +85,12 @@ export default {
|
|
|
84
85
|
20046: 'Your new password must be different from your current password.',
|
|
85
86
|
20047: 'You must enter a valid password.',
|
|
86
87
|
20048: 'This action is forbidden because you deleted your account.',
|
|
87
|
-
20049: 'You
|
|
88
|
-
20050: '
|
|
88
|
+
20049: 'You haven\'t verified your account yet.',
|
|
89
|
+
20050: 'This page does not exist.',
|
|
89
90
|
20051: 'Could not find user with that phone number. (%{value})',
|
|
90
91
|
20052: 'You do not have access to this organization\'s data.',
|
|
92
|
+
20053: 'You haven\'t verified your account yet.',
|
|
93
|
+
20054: 'You need an invitation to create an account.',
|
|
91
94
|
|
|
92
95
|
'29999_title': 'Not ready',
|
|
93
96
|
29999: 'AI chat is not ready right now.',
|
package/i18n/form.ts
CHANGED
|
@@ -7,6 +7,8 @@ export default {
|
|
|
7
7
|
or: 'or',
|
|
8
8
|
cancel: 'Cancel',
|
|
9
9
|
continue: 'Continue',
|
|
10
|
+
apply: 'Apply',
|
|
11
|
+
apply_filters: 'Apply filters',
|
|
10
12
|
hide: 'Hide',
|
|
11
13
|
show: 'Show',
|
|
12
14
|
try_again: 'Try again',
|
|
@@ -57,6 +59,7 @@ export default {
|
|
|
57
59
|
click_here: 'Click here',
|
|
58
60
|
success: 'Success',
|
|
59
61
|
success_: 'Success!',
|
|
62
|
+
help: 'Help',
|
|
60
63
|
|
|
61
64
|
// Day periods
|
|
62
65
|
greet_MORNING: 'Good morning, %{name}.',
|
package/i18n/user.ts
CHANGED
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
phone_ph: 'e.g. 123-444-5555',
|
|
18
18
|
password: 'Password',
|
|
19
19
|
password_ph: 'Enter your password',
|
|
20
|
-
passwordRepeat: 'Password (
|
|
20
|
+
passwordRepeat: 'Password (repeat)',
|
|
21
21
|
search_ph: 'Search @ or ID',
|
|
22
22
|
no_one_found_: 'No one found: "%{query}"',
|
|
23
23
|
from_friends_list: 'From your friends list',
|
|
@@ -64,10 +64,12 @@ export default {
|
|
|
64
64
|
copy_id: 'Copy ID',
|
|
65
65
|
|
|
66
66
|
// Profile
|
|
67
|
+
your_profile: 'Your profile',
|
|
67
68
|
open_profile: 'Open profile',
|
|
68
69
|
cards_ct: '%{smart_count} Card||||%{smart_count} Cards',
|
|
69
70
|
report_user: 'Report user',
|
|
70
71
|
profile_deactivated_desc: 'This account has been deactivated.',
|
|
72
|
+
phone_numbers: 'Phone numbers',
|
|
71
73
|
|
|
72
74
|
// Friend status
|
|
73
75
|
blocked: 'Blocked',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsb188/app",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Contains all the basic requirements for all @jsb188 apps.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "jsb188",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"./utils/billing": "./utils/billing.ts",
|
|
21
21
|
"./utils/datetime": "./utils/datetime.ts",
|
|
22
22
|
"./utils/emoji": "./utils/emoji.ts",
|
|
23
|
-
"./utils/journal": "./utils/journal.ts",
|
|
24
23
|
"./utils/logic": "./utils/logic.ts",
|
|
25
24
|
"./utils/number": "./utils/number.ts",
|
|
26
25
|
"./utils/object": "./utils/object.ts",
|
|
@@ -31,12 +30,12 @@
|
|
|
31
30
|
"./types/app.d": "./types/app.d.ts",
|
|
32
31
|
"./types/auth.d": "./types/auth.d.ts",
|
|
33
32
|
"./types/form.d": "./types/form.d.ts",
|
|
34
|
-
"./types/journal.d": "./types/journal.d.ts",
|
|
35
33
|
"./types/organization.d": "./types/organization.d.ts",
|
|
36
34
|
"./types/user.d": "./types/user.d.ts"
|
|
37
35
|
},
|
|
38
36
|
"dependencies": {
|
|
39
|
-
"node-polyglot": "^2.6.0"
|
|
37
|
+
"node-polyglot": "^2.6.0",
|
|
38
|
+
"luxon": "^3.6.1"
|
|
40
39
|
},
|
|
41
40
|
"scripts": {
|
|
42
41
|
"test": "echo \"Error: no test specified\" && exit 1"
|
package/types/app.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface EditUserPlusModalProps extends EditIfaceModalProps {
|
|
|
24
24
|
|
|
25
25
|
export type DarkOrLightEnum = 'light' | 'dark';
|
|
26
26
|
|
|
27
|
-
export type ColorEnum = 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'slate' | 'zinc' | 'stone';
|
|
27
|
+
export type ColorEnum = 'red' | 'orange' | 'brown' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'slate' | 'zinc' | 'stone';
|
|
28
28
|
|
|
29
29
|
// Stripe types
|
|
30
30
|
|
package/types/organization.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { OPERATION_ENUMS, ROLE_ENUMS } from '../constants/organization.ts';
|
|
1
2
|
|
|
2
3
|
/*
|
|
3
4
|
* ACL
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
export type OrganizationRoleEnum =
|
|
7
|
+
export type OrganizationRoleEnum = typeof ROLE_ENUMS[number];
|
|
8
|
+
export type OrganizationOperationEnum = typeof OPERATION_ENUMS[number];
|
|
7
9
|
|
|
8
10
|
export interface OrganizationACL {
|
|
9
11
|
id: string;
|
package/utils/api.ts
CHANGED
package/utils/datetime.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
1
2
|
import i18n from '../i18n';
|
|
2
3
|
import { isValidTimeZone, parseDateInTimezone } from './timeZone';
|
|
3
4
|
|
|
@@ -17,7 +18,7 @@ export type DatePeriodEnum =
|
|
|
17
18
|
| 'OLDER';
|
|
18
19
|
|
|
19
20
|
export interface DatePeriodObj {
|
|
20
|
-
datePeriod: DatePeriodEnum
|
|
21
|
+
datePeriod: DatePeriodEnum;
|
|
21
22
|
date: Date;
|
|
22
23
|
item: any;
|
|
23
24
|
}
|
|
@@ -39,7 +40,7 @@ interface FullTimeParams {
|
|
|
39
40
|
hideTime: boolean;
|
|
40
41
|
textDateStyle: 'long' | 'short' | null;
|
|
41
42
|
alwaysShowYear: boolean;
|
|
42
|
-
|
|
43
|
+
includeWeekday: boolean;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -115,7 +116,7 @@ export function getFullDateTime(
|
|
|
115
116
|
hideTime,
|
|
116
117
|
textDateStyle,
|
|
117
118
|
alwaysShowYear,
|
|
118
|
-
|
|
119
|
+
includeWeekday,
|
|
119
120
|
} = params || {};
|
|
120
121
|
|
|
121
122
|
let d;
|
|
@@ -152,7 +153,7 @@ export function getFullDateTime(
|
|
|
152
153
|
return d.toLocaleDateString(locales, {
|
|
153
154
|
timeZone,
|
|
154
155
|
day: 'numeric',
|
|
155
|
-
|
|
156
|
+
weekday: includeWeekday && textDateStyle === 'long' ? 'long' : includeWeekday ? 'short' : undefined,
|
|
156
157
|
month: textDateStyle || 'numeric',
|
|
157
158
|
year: hideYear_ ? undefined : 'numeric',
|
|
158
159
|
hour: hideTime ? undefined : 'numeric',
|
|
@@ -197,30 +198,18 @@ export function getTodayStartOfDay(timeZone?: string | null) {
|
|
|
197
198
|
*/
|
|
198
199
|
|
|
199
200
|
export function getCalDate(d: Date, timeZone_?: string | null) {
|
|
200
|
-
|
|
201
|
-
if (timeZone && !isValidTimeZone(timeZone)) {
|
|
202
|
-
timeZone = undefined;
|
|
203
|
-
}
|
|
201
|
+
const timeZone = timeZone_ || undefined;
|
|
204
202
|
|
|
205
|
-
|
|
206
|
-
timeZone,
|
|
207
|
-
year: 'numeric',
|
|
208
|
-
month: '2-digit',
|
|
209
|
-
day: '2-digit',
|
|
210
|
-
});
|
|
203
|
+
let dt = DateTime.fromJSDate(d, { zone: timeZone });
|
|
211
204
|
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
205
|
+
// If timezone is invalid, fallback to system/local
|
|
206
|
+
if (!dt.isValid) {
|
|
207
|
+
dt = DateTime.fromJSDate(d); // system default zone
|
|
208
|
+
}
|
|
216
209
|
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
minute: '2-digit',
|
|
221
|
-
second: '2-digit',
|
|
222
|
-
hour12: false,
|
|
223
|
-
});
|
|
210
|
+
const calDate = dt.toFormat('yyyy-MM-dd');
|
|
211
|
+
const calDateInt = Number(dt.toFormat('yyyyMMdd'));
|
|
212
|
+
const time = dt.toFormat('HH:mm:ss');
|
|
224
213
|
|
|
225
214
|
return {
|
|
226
215
|
calDate,
|
|
@@ -229,6 +218,57 @@ export function getCalDate(d: Date, timeZone_?: string | null) {
|
|
|
229
218
|
};
|
|
230
219
|
}
|
|
231
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Convert Int cal date to String YYYY-MM-DD format
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
export function convertIntToCalDate(calDateInt: number | string): string {
|
|
226
|
+
const value = String(calDateInt);
|
|
227
|
+
if (value.length === 8) {
|
|
228
|
+
return `${value.slice(0, 4)}-${value.slice(4, 6)}-${value.slice(6, 8)}`;
|
|
229
|
+
}
|
|
230
|
+
// If not 8 digits, return as is
|
|
231
|
+
return value;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Check if cal date is valid
|
|
236
|
+
* @param calDate - Cal date in YYYYMMDD format
|
|
237
|
+
* @param minCalDate - Optional minimum cal date to check against (default is 19500101)
|
|
238
|
+
* @returns boolean - true if valid, false otherwise
|
|
239
|
+
*/
|
|
240
|
+
|
|
241
|
+
export function isValidCalDate(
|
|
242
|
+
calDate: string | number,
|
|
243
|
+
minCalDate: number = 19500101,
|
|
244
|
+
): boolean {
|
|
245
|
+
const value = Number(calDate);
|
|
246
|
+
if (!calDate || !Number.isInteger(value) || value < 10000000 || value > 90000000) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
return !minCalDate || value >= minCalDate;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Check cal date is not a future date
|
|
254
|
+
* @param calDateVal - Cal date in YYYYMMDD format
|
|
255
|
+
* @param addDays - Optional number of days to add to the current date for comparison (default is 0)
|
|
256
|
+
* @param timeZone - Optional timezone to check against
|
|
257
|
+
* @returns boolean - true if date is in the future, false otherwise
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
export function isFutureCalDate(
|
|
261
|
+
calDateVal: number | string,
|
|
262
|
+
addDays: number = 0,
|
|
263
|
+
timeZone?: string | null,
|
|
264
|
+
): boolean {
|
|
265
|
+
if (!isValidCalDate(calDateVal)) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
const today = getCalDate(new Date(), timeZone);
|
|
269
|
+
return (today.calDateInt + addDays) < Number(calDateVal);
|
|
270
|
+
}
|
|
271
|
+
|
|
232
272
|
/**
|
|
233
273
|
* Convert date time "time" ago
|
|
234
274
|
*/
|
|
@@ -409,11 +449,11 @@ export function getDateFromCalDate(calDate: string) {
|
|
|
409
449
|
*/
|
|
410
450
|
|
|
411
451
|
export function groupByDatePeriod<T>(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
452
|
+
items: T[],
|
|
453
|
+
dateKey: string,
|
|
454
|
+
groupByDate?: boolean,
|
|
455
|
+
timeZone?: string | null,
|
|
456
|
+
mapFn?: (item: any) => any,
|
|
417
457
|
): DatePeriodObj[][] {
|
|
418
458
|
const ordered = items.sort((a: any, b: any) => {
|
|
419
459
|
const valueA = a[dateKey];
|
|
@@ -430,7 +470,7 @@ export function groupByDatePeriod<T>(
|
|
|
430
470
|
|
|
431
471
|
const output = [];
|
|
432
472
|
const d = new Date();
|
|
433
|
-
|
|
473
|
+
// const timeZone = timeZone_; // || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
434
474
|
|
|
435
475
|
let group: any[] | null = [];
|
|
436
476
|
for (const item of ordered) {
|
|
@@ -440,7 +480,7 @@ export function groupByDatePeriod<T>(
|
|
|
440
480
|
|
|
441
481
|
const lastItem = group[group.length - 1];
|
|
442
482
|
const lastDatePeriod: any = lastItem?.datePeriod;
|
|
443
|
-
const date = new Date(
|
|
483
|
+
const date = new Date(item[dateKey]);
|
|
444
484
|
const datePeriod = groupByDate ? getCalDate(date, timeZone).calDate : getDatePeriod(date, d);
|
|
445
485
|
|
|
446
486
|
const dateObj = {
|
|
@@ -450,11 +490,11 @@ export function groupByDatePeriod<T>(
|
|
|
450
490
|
};
|
|
451
491
|
|
|
452
492
|
if (lastDatePeriod && lastDatePeriod !== datePeriod && group.length) {
|
|
453
|
-
|
|
454
|
-
|
|
493
|
+
output.push(group);
|
|
494
|
+
group = [];
|
|
455
495
|
}
|
|
456
496
|
|
|
457
|
-
|
|
497
|
+
group.push(dateObj);
|
|
458
498
|
}
|
|
459
499
|
|
|
460
500
|
if (group.length) {
|
|
@@ -475,11 +515,11 @@ export function groupByDatePeriod<T>(
|
|
|
475
515
|
*/
|
|
476
516
|
|
|
477
517
|
export function labelSortByDatePeriod<T>(
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
518
|
+
items: T[],
|
|
519
|
+
dateKey: string,
|
|
520
|
+
groupByDate?: boolean,
|
|
521
|
+
timeZone?: string | null,
|
|
522
|
+
mapFn?: (item: any) => any,
|
|
483
523
|
): DatePeriodObj[] {
|
|
484
524
|
const ordered = items.sort((a: any, b: any) => {
|
|
485
525
|
const valueA = a[dateKey];
|
|
@@ -500,7 +540,7 @@ export function labelSortByDatePeriod<T>(
|
|
|
500
540
|
for (const item of ordered) {
|
|
501
541
|
const lastItem = output[output.length - 1];
|
|
502
542
|
const lastDatePeriod: any = lastItem?.datePeriod;
|
|
503
|
-
const date = new Date(
|
|
543
|
+
const date = new Date(item[dateKey]);
|
|
504
544
|
const datePeriod = groupByDate ? getCalDate(date, timeZone).calDate : getDatePeriod(date, d);
|
|
505
545
|
|
|
506
546
|
const dateObj = {
|
|
@@ -513,14 +553,14 @@ export function labelSortByDatePeriod<T>(
|
|
|
513
553
|
(!output.length) ||
|
|
514
554
|
(lastDatePeriod && lastDatePeriod !== datePeriod)
|
|
515
555
|
) {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
556
|
+
output.push({
|
|
557
|
+
datePeriod,
|
|
558
|
+
date,
|
|
559
|
+
item: null,
|
|
560
|
+
});
|
|
521
561
|
}
|
|
522
562
|
|
|
523
|
-
|
|
563
|
+
output.push(dateObj);
|
|
524
564
|
}
|
|
525
565
|
|
|
526
566
|
return output;
|