@cuemath/web-utils 0.0.2-beta.10 → 0.0.2-beta.2

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.
Files changed (65) hide show
  1. package/.husky/pre-commit +0 -1
  2. package/.vscode/settings.json +1 -0
  3. package/dist/index.js +1 -6
  4. package/package.json +8 -19
  5. package/src/cookie/index.ts +10 -4
  6. package/src/growth-source/index.ts +172 -0
  7. package/src/growth-source/types.ts +33 -0
  8. package/src/index.ts +1 -6
  9. package/.eslintignore +0 -2
  10. package/.huskyrc +0 -5
  11. package/.lintstagedrc.yml +0 -5
  12. package/src/constants/country/index.ts +0 -2
  13. package/src/constants/country/iso-country-code.ts +0 -248
  14. package/src/constants/date-time/index.ts +0 -43
  15. package/src/constants/date-time/international-timezones.ts +0 -157
  16. package/src/constants/e-cna/index.ts +0 -55
  17. package/src/constants/index.ts +0 -2
  18. package/src/country/index.ts +0 -9
  19. package/src/date-time-helper/e-cna.ts +0 -205
  20. package/src/date-time-helper/index.ts +0 -365
  21. package/src/e-cna/flow/aggregator.ts +0 -12
  22. package/src/e-cna/flow/index.ts +0 -1
  23. package/src/e-cna/flow/variants/default.ts +0 -113
  24. package/src/e-cna/flow/variants/index.ts +0 -1
  25. package/src/e-cna/index.ts +0 -249
  26. package/src/e-cna/slides/child_hobbies/index.ts +0 -1
  27. package/src/e-cna/slides/child_hobbies/variants.ts +0 -24
  28. package/src/e-cna/slides/child_info/index.ts +0 -1
  29. package/src/e-cna/slides/child_info/variants.ts +0 -18
  30. package/src/e-cna/slides/child_personality/index.ts +0 -1
  31. package/src/e-cna/slides/child_personality/variants.ts +0 -12
  32. package/src/e-cna/slides/curriculum/index.ts +0 -1
  33. package/src/e-cna/slides/curriculum/variants.ts +0 -14
  34. package/src/e-cna/slides/grade/index.ts +0 -1
  35. package/src/e-cna/slides/grade/variants.ts +0 -29
  36. package/src/e-cna/slides/index.ts +0 -19
  37. package/src/e-cna/slides/intro/index.ts +0 -1
  38. package/src/e-cna/slides/intro/variants.ts +0 -7
  39. package/src/e-cna/slides/key_need_l1/index.ts +0 -1
  40. package/src/e-cna/slides/key_need_l1/variants.ts +0 -57
  41. package/src/e-cna/slides/key_need_l2/index.ts +0 -1
  42. package/src/e-cna/slides/key_need_l2/variants.ts +0 -143
  43. package/src/e-cna/slides/key_need_l3/index.ts +0 -1
  44. package/src/e-cna/slides/key_need_l3/variants.ts +0 -13
  45. package/src/e-cna/slides/math-perception/index.ts +0 -1
  46. package/src/e-cna/slides/math-perception/variants.ts +0 -30
  47. package/src/e-cna/slides/other_curriculum/index.ts +0 -1
  48. package/src/e-cna/slides/other_curriculum/variants.ts +0 -14
  49. package/src/e-cna/slides/school_performance_5_12/index.ts +0 -1
  50. package/src/e-cna/slides/school_performance_5_12/variants.ts +0 -23
  51. package/src/e-cna/slides/school_performance_kg_4/index.ts +0 -1
  52. package/src/e-cna/slides/school_performance_kg_4/variants.ts +0 -25
  53. package/src/e-cna/slides/secondary_needs/index.ts +0 -1
  54. package/src/e-cna/slides/secondary_needs/variants.ts +0 -26
  55. package/src/e-cna/slides/signup/index.ts +0 -1
  56. package/src/e-cna/slides/signup/variants.ts +0 -7
  57. package/src/e-cna/slides/signup_refer/index.ts +0 -1
  58. package/src/e-cna/slides/signup_refer/variants.ts +0 -16
  59. package/src/e-cna/slides/slot_pick/index.ts +0 -1
  60. package/src/e-cna/slides/slot_pick/variants.ts +0 -12
  61. package/src/e-cna/slides/teacher_intro/index.ts +0 -1
  62. package/src/e-cna/slides/teacher_intro/variants.ts +0 -114
  63. package/src/e-cna/utils/index.ts +0 -32
  64. package/src/local-storage/index.ts +0 -186
  65. package/src/object/index.ts +0 -26
@@ -1,157 +0,0 @@
1
- interface Timezone {
2
- id: string;
3
- value: string;
4
- meta: string;
5
- }
6
-
7
- export const timezones: Timezone[] = [
8
- {
9
- id: 'Pacific/Honolulu',
10
- value: 'HST(GMT-10)',
11
- meta: 'HST(GMT-10)',
12
- },
13
- {
14
- id: 'America/Anchorage',
15
- value: 'AST(GMT-9)',
16
- meta: 'AST(GMT-9)',
17
- },
18
- {
19
- id: 'America/Los_Angeles',
20
- value: 'PST(GMT-8)',
21
- meta: 'PST(GMT-8)',
22
- },
23
- {
24
- id: 'America/Denver',
25
- value: 'MST(GMT-7)',
26
- meta: 'MST(GMT-7)',
27
- },
28
- {
29
- id: 'America/Phoenix',
30
- value: 'MST(GMT-7)',
31
- meta: 'MST(GMT-7)',
32
- },
33
- {
34
- id: 'America/Matamoros',
35
- value: 'CST(GMT-6)',
36
- meta: 'CST(GMT-6)',
37
- },
38
- {
39
- id: 'America/New_York',
40
- value: 'EST(GMT-5)',
41
- meta: 'EST(GMT-5)',
42
- },
43
- {
44
- id: 'America/Glace_Bay',
45
- value: 'AST(GMT-4)',
46
- meta: 'AST(GMT-4)',
47
- },
48
- {
49
- id: 'America/St_Johns',
50
- value: 'NST(GMT-3:30)',
51
- meta: 'NST(GMT-3:30)',
52
- },
53
- {
54
- id: 'America/Noronha',
55
- value: 'FNT(GMT-2)',
56
- meta: 'FNT(GMT-2)',
57
- },
58
- {
59
- id: 'Asia/Calcutta',
60
- value: 'IST(GMT+5:30)',
61
- meta: 'IST(GMT+5:30)',
62
- },
63
- {
64
- id: 'Asia/Kolkata',
65
- value: 'IST(GMT+5:30)',
66
- meta: 'IST(GMT+5:30)',
67
- },
68
- {
69
- id: 'Asia/Dubai',
70
- value: 'GST(GMT+4)',
71
- meta: 'GST(GMT+4)',
72
- },
73
- {
74
- id: 'Asia/Singapore',
75
- value: 'SGT(GMT+8)',
76
- meta: 'SGT(GMT+8)',
77
- },
78
- {
79
- id: 'Pacific/Auckland',
80
- value: 'NZDT(GMT+13)',
81
- meta: 'NZDT(GMT+13)',
82
- },
83
- {
84
- id: 'Australia/Adelaide',
85
- value: 'ACDT(GMT+10:30)',
86
- meta: 'ACDT(GMT+10:30)',
87
- },
88
- {
89
- id: 'Australia/Perth',
90
- value: 'AWST(GMT+8)',
91
- meta: 'AWST(GMT+8)',
92
- },
93
- {
94
- id: 'Australia/Sydney',
95
- value: 'AEDT(GMT+11)',
96
- meta: 'AEDT(GMT+11)',
97
- },
98
- {
99
- id: 'Australia/Darwin',
100
- value: 'ACST(GMT+9:30)',
101
- meta: 'ACST(GMT+9:30)',
102
- },
103
- {
104
- id: 'Australia/Broken_Hill',
105
- value: 'ACDT(GMT+10:30)',
106
- meta: 'ACDT(GMT+10:30)',
107
- },
108
- {
109
- id: 'Australia/Melbourne',
110
- value: 'AEDT(GMT+11)',
111
- meta: 'AEDT(GMT+11)',
112
- },
113
- {
114
- id: 'Australia/Brisbane',
115
- value: 'AEST(GMT+10)',
116
- meta: 'AEST(GMT+10)',
117
- },
118
- {
119
- id: 'Australia/Hobart',
120
- value: 'AEDT(GMT+11)',
121
- meta: 'AEDT(GMT+11)',
122
- },
123
- {
124
- id: 'Europe/London',
125
- value: 'GMT(GMT+0)',
126
- meta: 'GMT(GMT+0)',
127
- },
128
- {
129
- id: 'Asia/Muscat',
130
- value: 'GST(GMT+4)',
131
- meta: 'GST(GMT+4)',
132
- },
133
- {
134
- id: 'Asia/Kuwait',
135
- value: 'AST(GMT+3)',
136
- meta: 'AST(GMT+3)',
137
- },
138
- {
139
- id: 'Asia/Bahrain',
140
- value: 'AST(GMT+3)',
141
- meta: 'AST(GMT+3)',
142
- },
143
- {
144
- id: 'Asia/Qatar',
145
- value: 'AST(GMT+3)',
146
- meta: 'AST(GMT+3)',
147
- },
148
- {
149
- id: 'Asia/Riyadh',
150
- value: 'AST(GMT+3)',
151
- meta: 'AST(GMT+3)',
152
- },
153
- ].map(timezone => ({
154
- ...timezone,
155
- key: timezone.id,
156
- label: timezone.meta,
157
- }));
@@ -1,55 +0,0 @@
1
- import { CUE_COUNTRY_CODE_KEY } from '../../constants/country';
2
- import { getCookie } from '../../cookie';
3
- import { getCountryCode } from '../../country';
4
- import { COUNTRY_NAME_COUNTRY_CODE_MAP as ISO_COUNTRY_CODE } from '../country/iso-country-code';
5
-
6
- interface FormLabel {
7
- label: string;
8
- value: string;
9
- }
10
-
11
- export const ECNA_HASH = {
12
- PARENT_STUDENT_DETAILS: '#/e-cna/parent_student_details',
13
- FIRST_QUESTION: '#/e-cna/question/1',
14
- CHILD_INFO: '#/e-cna/child_info',
15
- TRIAL_SESSION: '#/e-cna/trial_session',
16
- HYBRID_CLASSES: '#/e-cna/hybrid_classes',
17
- INTRO: '#/e-cna/intro',
18
- SLOT_PICK: '#/e-cna/slot-pick',
19
- START: '#/e-cna/start',
20
- EXIT_PARENT: '#/e-cna/exit-parent',
21
- EXIT_SLOTS: '#/e-cna/exit-slots',
22
- CLASS_NOT_CONFIRMED: '#/e-cna/class-not-confirmed',
23
- CLASS_THANK_YOU: '#/e-cna/class-thankyou',
24
- COURSE_NOT_AVAILABE: '#/e-cna/course-not-available',
25
- TEACHER_INTRO: '#/intent=T-LED',
26
- TEACHER_DETAIL: '#/e-cna/teacher-detail',
27
- };
28
-
29
- export const ASSESSMENT_ID = 'assessmentId';
30
-
31
- export const SLIDE_TYPES = {
32
- INTRO: 'intro',
33
- SLOT_PICK: 'slot-pick',
34
- PARENT_STUDENT_DETAILS: 'parent_student_details',
35
- CLASS_CONFIRMED: 'class_confirmed',
36
- CLASS_THANK_YOU: 'class_thankyou',
37
- QUESTION: 'question',
38
- EXIT_PARENT: 'exit-parent',
39
- EXIT_SLOTS: 'exit-slots',
40
- EXIT_THANK_YOU: 'exit-thankyou',
41
- CLASS_NOT_CONFIRMED: 'class-not-confirmed',
42
- COURSE_NOT_AVAILABLE: 'course-not-available',
43
- SCHOOL_PERFORMANCE_KG_4: 'school_performance_kg_4',
44
- SCHOOL_PERFORMANCE_5_12: 'school_performance_5_12',
45
- STUDENT_GRADE: 'student_grade',
46
- };
47
-
48
- export const QUESTION_ID = {
49
- SCHOOL_CURRICULUM: 'school_curriculum',
50
- OTHER_CURRICULUM: 'other_curriculum',
51
- };
52
-
53
- export const LOCAL_STORAGE_KEYS = {
54
- STUDENT_GRADE: 'student_grade',
55
- };
@@ -1,2 +0,0 @@
1
- export * from './e-cna';
2
- export * from './country';
@@ -1,9 +0,0 @@
1
- import { CUE_COUNTRY_CODE_KEY } from "../constants";
2
- import { getCookie } from "../cookie";
3
- import { ISO_COUNTRY_CODE } from "../constants";
4
-
5
- export const getCountryCode = () : string => {
6
- return getCookie(CUE_COUNTRY_CODE_KEY)
7
- ? getCookie(CUE_COUNTRY_CODE_KEY).toUpperCase()
8
- : ISO_COUNTRY_CODE.INDIA;
9
- }
@@ -1,205 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import dayjs from 'dayjs';
3
- import relativeTime from 'dayjs/plugin/relativeTime';
4
- import { formatTimestamp, dateByTimezone, getCurrentDatebyTimezone, dateByTimestamp } from '.';
5
-
6
- import {
7
- shorthandWeekDayArray,
8
- monthArray,
9
- TWENTY_FOUR_HOURS_IN_SECONDS,
10
- HOUR_FORMAT,
11
- } from '../constants/date-time';
12
- import { timezones } from '../constants/date-time/international-timezones';
13
-
14
- export interface DateSlots {
15
- key: number;
16
- label: string;
17
- subLabel: string;
18
- disabled: boolean;
19
- }
20
-
21
- export const convertedTimezone = (selectedTimezone: string) => {
22
- const formattedTimezone = timezones?.filter(
23
- currentTimezone => currentTimezone?.id === selectedTimezone,
24
- );
25
-
26
- if (formattedTimezone?.length) {
27
- return formattedTimezone[0]?.value;
28
- }
29
-
30
- return selectedTimezone?.replaceAll('_', ' ');
31
- };
32
-
33
- export const getHourInTwelveHourFormat = (hour: number) => {
34
- return hour % 12 === 0 ? 12 : hour % 12;
35
- };
36
-
37
- export const getMeridiemAccordingToHourAndHourFormat = (
38
- hour: number,
39
- hourFormat: number,
40
- meridiem = '',
41
- ) => {
42
- if (hourFormat === HOUR_FORMAT.TWENTY_FOUR_HOUR_FORMAT) {
43
- return hour / 12 >= 1 ? 'PM' : 'AM';
44
- }
45
-
46
- return hour === 12 ? 'PM' : meridiem;
47
- };
48
-
49
- export const getTimeSlotDuration = (selectedTime: number, selectedTimezone: any) => {
50
- const firstHour = getHourInTwelveHourFormat(selectedTime);
51
- const firstMeridiem = getMeridiemAccordingToHourAndHourFormat(
52
- selectedTime,
53
- HOUR_FORMAT.TWENTY_FOUR_HOUR_FORMAT,
54
- );
55
-
56
- const secondHour = getHourInTwelveHourFormat(selectedTime + 1);
57
- const secondMeridiem = getMeridiemAccordingToHourAndHourFormat(
58
- selectedTime + 1,
59
- HOUR_FORMAT.TWENTY_FOUR_HOUR_FORMAT,
60
- );
61
- const currentTimeZone =
62
- convertedTimezone(selectedTimezone)?.split('(') || selectedTimezone;
63
-
64
- return `${firstHour} ${firstMeridiem.toLowerCase()} - ${secondHour} ${secondMeridiem.toLowerCase()} (${currentTimeZone})`;
65
- };
66
-
67
- export const convertSecondsToMiliseconds = (seconds: number) => {
68
- return seconds * 1000;
69
- };
70
-
71
- // convert date into Sept 01, Thursday format
72
- export const convertDate = (selectedDate: number, selectedTimezone: string) => {
73
- const slotDate = formatTimestamp(selectedDate, 'DD-MM-YYYY');
74
- const dayOfWeek = dateByTimezone(selectedDate * 1000, selectedTimezone, 'dddd');
75
- const dateArr = slotDate?.split('-');
76
- const month = dateArr?.[1];
77
- const day = dateArr?.[0];
78
-
79
- return `${monthArray[parseInt(month, 10) - 1]} ${day}, ${dayOfWeek}`;
80
- };
81
-
82
- export const getModifiedDateSlots = (dateSlotsData: { label: string }[]) => {
83
- const startWeekIndex = shorthandWeekDayArray?.indexOf(dateSlotsData?.[0]?.label);
84
-
85
- // get all days
86
- let weekDays: { label: string; removeBorder?: boolean }[] = [];
87
-
88
- // while loop to check start date's day
89
- // for eg: if first date is wednesday, it will add blank days on monday, tuesday
90
- while (weekDays.length !== startWeekIndex) {
91
- weekDays.push({
92
- label: '',
93
- removeBorder: false,
94
- });
95
- }
96
- weekDays = [...weekDays, ...dateSlotsData];
97
-
98
- // while loop to add check end date
99
- // for eg: if last date end's on friday, it will add blank days on saturday and sunday
100
- while (weekDays.length % 7 !== 0) {
101
- weekDays.push({
102
- label: '',
103
- removeBorder: false,
104
- });
105
- }
106
- const weekRows = [];
107
-
108
- // divide weekDays in weeks group
109
- while (weekDays.length !== 0) {
110
- const row =
111
- weekDays?.length >= 7
112
- ? weekDays?.splice(0, 7)
113
- : weekDays?.splice(0, weekDays?.length);
114
-
115
- weekRows.push(row);
116
- }
117
-
118
- return weekRows;
119
- };
120
-
121
- // Array of 7 days
122
- export const getDates = (timezone: string) => {
123
- const currentDate = Date.parse(getCurrentDatebyTimezone(timezone)) / 1000;
124
- const dates = [];
125
-
126
- // getting dates by adding 86400 seconds(24 hours)
127
- for (let i = 0; i < 7; i++) {
128
- dates.push({
129
- futureDate: currentDate + TWENTY_FOUR_HOURS_IN_SECONDS * i,
130
- disabled: !(i > 1),
131
- });
132
- }
133
-
134
- return dates;
135
- };
136
-
137
- export function formatDateFromTimestamp(
138
- timestamp: string | number | Date,
139
- format: string,
140
- ) {
141
- const datetime = new Date(timestamp).toLocaleString('en-US');
142
-
143
- return dayjs(datetime).format(format || 'mm/dd/yyyy');
144
- }
145
-
146
- export function getAvailableDateSlots(currentTimezone: any) {
147
- const availableDateSlots: DateSlots[] = [];
148
-
149
- getDates(currentTimezone).map(item => {
150
- const { futureDate, disabled } = item;
151
-
152
- availableDateSlots.push({
153
- key: futureDate,
154
- label: formatDateFromTimestamp(futureDate * 1000, 'dd'),
155
- subLabel: formatDateFromTimestamp(futureDate * 1000, 'DD'),
156
- disabled,
157
- });
158
-
159
- return null;
160
- });
161
-
162
- return availableDateSlots;
163
- }
164
-
165
- export const toTimestamp = (strDate: string) => {
166
- return Date.parse(strDate) / 1000;
167
- };
168
-
169
- export const getDateSlots = (timezone: any) => {
170
- return getDates(timezone).map(item => {
171
- const { futureDate, disabled } = item;
172
-
173
- return {
174
- key: futureDate,
175
- label: dateByTimestamp(futureDate * 1000, 'dd'),
176
- subLabel: dateByTimestamp(futureDate * 1000, 'DD'),
177
- disabled,
178
- };
179
- });
180
- };
181
-
182
- // export const getUtcUnixTimestamp = (date: number, time: any, timezone: any) => {
183
- // const formatDate = formatTimestamp(date, 'MM/DD/YYYY');
184
- // const convertedDatTime = dateTimeByTimezone(
185
- // toTimestamp(`${formatDate} ${time}`) * 1000
186
- // );
187
-
188
- // return getUtcTimestamp(timezone, convertedDatTime);
189
- // };
190
-
191
- export const getTimeSlotDurationForSlotPage = (selectedTime: string) => {
192
- const timeArr = selectedTime.split(':');
193
- const firstHour = timeArr?.[0];
194
- const meridiem = timeArr?.[1]?.split(' ')?.[1];
195
-
196
- const secondHourInTwelveHourFormat = parseInt(firstHour, 10) + 1;
197
- const secondHour = getHourInTwelveHourFormat(secondHourInTwelveHourFormat);
198
- const secondMeridiem = getMeridiemAccordingToHourAndHourFormat(
199
- secondHourInTwelveHourFormat,
200
- HOUR_FORMAT.TWELVE_HOUR_FORMAT,
201
- meridiem,
202
- );
203
-
204
- return `${firstHour} ${meridiem.toLowerCase()} - ${secondHour} ${secondMeridiem.toLowerCase()}`;
205
- };