@cuemath/web-utils 0.0.1-beta.2 → 0.0.1-beta.3

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,205 @@
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?.replace(/_/g, ' ');
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
+ };
@@ -8,7 +8,7 @@ import {
8
8
  TWENTY_FOUR_HOURS_IN_SECONDS,
9
9
  HOUR_FORMAT,
10
10
  } from '../constants/date-time';
11
- import { timezones } from '../constants/date-time/e-cna-international-timezones';
11
+ import { timezones } from '../constants/date-time/international-timezones';
12
12
 
13
13
  type Timestamp = number;
14
14
 
@@ -36,7 +36,7 @@ export function getCurrentTimestamp(): number {
36
36
  return Math.floor(Date.now() / 1000);
37
37
  }
38
38
 
39
- export function dateTimeByTimezone(timestamp: Timestamp, timezone?: string) {
39
+ export function dateTimeByTimezone(timestamp: Timestamp, timezone?: string): string {
40
40
  let options = {};
41
41
 
42
42
  if (timezone) {
@@ -48,19 +48,19 @@ export function dateTimeByTimezone(timestamp: Timestamp, timezone?: string) {
48
48
  return new Date(timestamp).toLocaleString('en-US', options);
49
49
  }
50
50
 
51
- export function dateByTimezone(timestamp: number, timezone: string, format: string) {
51
+ export function dateByTimezone(timestamp: number, timezone: string, format: string): string {
52
52
  const datetime = dateTimeByTimezone(timestamp, timezone);
53
53
 
54
54
  return dayjs(datetime).format(format || 'mm/dd/yyyy');
55
55
  }
56
56
 
57
- export const dateByTimestamp = (timestamp: Timestamp, format: string) => {
57
+ export const dateByTimestamp = (timestamp: Timestamp, format: string): string => {
58
58
  const datetime = new Date(timestamp).toLocaleString('en-US');
59
59
 
60
60
  return dayjs(datetime).format(format || 'mm/dd/yyyy');
61
61
  };
62
62
 
63
- export function convertTimeStampToSeconds(timeStamp: Timestamp) {
63
+ export function convertTimeStampToSeconds(timeStamp: Timestamp): number {
64
64
  const demoTimeStamp = timeStamp;
65
65
  const currentTimeStamp = getCurrentTimestamp();
66
66
 
@@ -74,25 +74,25 @@ export function convertTimeStampToSeconds(timeStamp: Timestamp) {
74
74
  return demoTimeStampLength > currentTimeStampLength ? timeStamp / 1000 : timeStamp;
75
75
  }
76
76
 
77
- export function formatTimestamp(datetime: Timestamp, format: string | undefined) {
77
+ export function formatTimestamp(datetime: Timestamp, format: string | undefined): string {
78
78
  const timeStamp = convertTimeStampToSeconds(datetime);
79
79
 
80
80
  return dayjs.unix(timeStamp).format(format);
81
81
  }
82
82
 
83
- export function getTimezone() {
83
+ export function getTimezone(): string {
84
84
  return Intl?.DateTimeFormat().resolvedOptions().timeZone;
85
85
  }
86
86
 
87
87
  export function timeToX(
88
88
  datetime: string | number | Date | dayjs.Dayjs | null | undefined,
89
- ) {
89
+ ): string {
90
90
  dayjs.extend(relativeTime);
91
91
 
92
92
  return dayjs().to(datetime, true);
93
93
  }
94
94
 
95
- export function getCurrentDatebyTimezone(timezone: string) {
95
+ export function getCurrentDatebyTimezone(timezone: string): string {
96
96
  let options = {};
97
97
 
98
98
  if (timezone) {
@@ -107,7 +107,7 @@ export function getCurrentDatebyTimezone(timezone: string) {
107
107
  export function getTimeDiff(
108
108
  date1: string | number | Date | dayjs.Dayjs | null | undefined,
109
109
  date2: string | number | Date | dayjs.Dayjs | null | undefined,
110
- ) {
110
+ ) : {days: any, hour: any, minute: any, seconds: any, distance: any} {
111
111
  const dateTime1 = dayjs(date1);
112
112
  const dateTime2 = dayjs(date2);
113
113
 
@@ -120,63 +120,15 @@ export function getTimeDiff(
120
120
  };
121
121
  }
122
122
 
123
- // function roundTime(time: Date) {
124
- // time.setHours(time.getHours() + Math.round(time.getMinutes() / 60));
125
- // time.setMinutes(0, 0, 0);
126
- // }
127
-
128
- // function getTimeString(increment: number, time: Date, timezone: string) {
129
- // const value = dateByTimezone(time, timezone, 'hh:mm a');
130
-
131
- // time.setTime(time.getTime() + increment * 60 * 1000);
132
-
133
- // return value;
134
- // }
135
-
136
- // export function getSlotsTillNextDay(interval: number, timezone: string) {
137
- // const today = new Date();
138
- // const curr = new Date();
139
-
140
- // roundTime(today);
141
- // roundTime(curr);
142
-
143
- // const slots = [];
144
-
145
- // while (getTimeDiff(today, curr).days !== -1) {
146
- // slots.push({
147
- // id: curr.getTime(),
148
- // value: getTimeString(interval, curr, timezone),
149
- // });
150
- // }
151
-
152
- // return slots;
153
- // }
154
-
155
- export function getISOTimeString(demoTs: number) {
123
+ export function getISOTimeString(demoTs: number): string {
156
124
  return new Date(demoTs * 1000).toISOString().replace(/-|:|\.\d\d\d/g, '');
157
125
  }
158
126
 
159
- export function getDateAfterDays(days: number) {
127
+ export function getDateAfterDays(days: number): string {
160
128
  return formatDateTime(dayjs().add(days, 'day'), 'D MMM, YYYY').toUpperCase();
161
129
  }
162
130
 
163
- // function convertTZ(date: string | number | Date, tzString: any){
164
- // return new Date(
165
- // (typeof date === 'string' ? new Date(date) : date).toLocaleString('en-US', {
166
- // timeZone: tzString,
167
- // }),
168
- // );
169
- // }
170
-
171
- // export function getUtcTimestamp(timeZone: any, date: string) {
172
- // const time = convertTZ(date, timeZone);
173
-
174
- // const parsedDate = Date.parse(time);
175
-
176
- // return parsedDate / 1000;
177
- // }
178
-
179
- export const convertedTimezone = (selectedTimezone: string) => {
131
+ export const convertedTimezone = (selectedTimezone: string): string => {
180
132
  const formattedTimezone = timezones?.filter(
181
133
  currentTimezone => currentTimezone?.id === selectedTimezone,
182
134
  );
@@ -185,10 +137,10 @@ export const convertedTimezone = (selectedTimezone: string) => {
185
137
  return formattedTimezone[0]?.value;
186
138
  }
187
139
 
188
- return selectedTimezone?.replaceAll('_', ' ');
140
+ return selectedTimezone?.replace(/_/g, ' ');
189
141
  };
190
142
 
191
- export const getHourInTwelveHourFormat = (hour: number) => {
143
+ export const getHourInTwelveHourFormat = (hour: number): number => {
192
144
  return hour % 12 === 0 ? 12 : hour % 12;
193
145
  };
194
146
 
@@ -196,7 +148,7 @@ export const getMeridiemAccordingToHourAndHourFormat = (
196
148
  hour: number,
197
149
  hourFormat: number,
198
150
  meridiem = '',
199
- ) => {
151
+ ): string => {
200
152
  if (hourFormat === HOUR_FORMAT.TWENTY_FOUR_HOUR_FORMAT) {
201
153
  return hour / 12 >= 1 ? 'PM' : 'AM';
202
154
  }
@@ -204,7 +156,7 @@ export const getMeridiemAccordingToHourAndHourFormat = (
204
156
  return hour === 12 ? 'PM' : meridiem;
205
157
  };
206
158
 
207
- export const getTimeSlotDuration = (selectedTime: number, selectedTimezone: any) => {
159
+ export const getTimeSlotDuration = (selectedTime: number, selectedTimezone: any): string => {
208
160
  const firstHour = getHourInTwelveHourFormat(selectedTime);
209
161
  const firstMeridiem = getMeridiemAccordingToHourAndHourFormat(
210
162
  selectedTime,
@@ -227,7 +179,7 @@ export const convertSecondsToMiliseconds = (seconds: number) => {
227
179
  };
228
180
 
229
181
  // convert date into Sept 01, Thursday format
230
- export const convertDate = (selectedDate: number, selectedTimezone: string) => {
182
+ export const convertDate = (selectedDate: number, selectedTimezone: string): string => {
231
183
  const slotDate = formatTimestamp(selectedDate, 'DD-MM-YYYY');
232
184
  const dayOfWeek = dateByTimezone(selectedDate * 1000, selectedTimezone, 'dddd');
233
185
  const dateArr = slotDate?.split('-');
@@ -237,7 +189,7 @@ export const convertDate = (selectedDate: number, selectedTimezone: string) => {
237
189
  return `${monthArray[parseInt(month, 10) - 1]} ${day}, ${dayOfWeek}`;
238
190
  };
239
191
 
240
- export const getModifiedDateSlots = (dateSlotsData: { label: string }[]) => {
192
+ export const getModifiedDateSlots = (dateSlotsData: { label: string }[]): { label: string; removeBorder?: boolean }[][] => {
241
193
  const startWeekIndex = shorthandWeekDayArray?.indexOf(dateSlotsData?.[0]?.label);
242
194
 
243
195
  // get all days
@@ -277,7 +229,7 @@ export const getModifiedDateSlots = (dateSlotsData: { label: string }[]) => {
277
229
  };
278
230
 
279
231
  // Array of 7 days
280
- export const getDates = (timezone: string) => {
232
+ export const getDates = (timezone: string): { futureDate: any; disabled: any; }[] => {
281
233
  const currentDate = Date.parse(getCurrentDatebyTimezone(timezone)) / 1000;
282
234
  const dates = [];
283
235
 
@@ -295,16 +247,16 @@ export const getDates = (timezone: string) => {
295
247
  export function formatDateFromTimestamp(
296
248
  timestamp: string | number | Date,
297
249
  format: string,
298
- ) {
250
+ ) : string {
299
251
  const datetime = new Date(timestamp).toLocaleString('en-US');
300
252
 
301
253
  return dayjs(datetime).format(format || 'mm/dd/yyyy');
302
254
  }
303
255
 
304
- export function getAvailableDateSlots(currentTimezone: any) {
256
+ export function getAvailableDateSlots(currentTimezone: any): DateSlots [] {
305
257
  const availableDateSlots: DateSlots[] = [];
306
258
 
307
- getDates(currentTimezone).map(item => {
259
+ getDates(currentTimezone).map((item: { futureDate: any; disabled: any; }) => {
308
260
  const { futureDate, disabled } = item;
309
261
 
310
262
  availableDateSlots.push({
@@ -324,8 +276,8 @@ export const toTimestamp = (strDate: string) => {
324
276
  return Date.parse(strDate) / 1000;
325
277
  };
326
278
 
327
- export const getDateSlots = (timezone: any) => {
328
- return getDates(timezone).map(item => {
279
+ export const getDateSlots = (timezone: any): { [x: string]: any } => {
280
+ return getDates(timezone).map((item: { futureDate: any; disabled: any; }) => {
329
281
  const { futureDate, disabled } = item;
330
282
 
331
283
  return {
@@ -337,16 +289,7 @@ export const getDateSlots = (timezone: any) => {
337
289
  });
338
290
  };
339
291
 
340
- // export const getUtcUnixTimestamp = (date: number, time: any, timezone: any) => {
341
- // const formatDate = formatTimestamp(date, 'MM/DD/YYYY');
342
- // const convertedDatTime = dateTimeByTimezone(
343
- // toTimestamp(`${formatDate} ${time}`) * 1000
344
- // );
345
-
346
- // return getUtcTimestamp(timezone, convertedDatTime);
347
- // };
348
-
349
- export const getTimeSlotDurationForSlotPage = (selectedTime: string) => {
292
+ export const getTimeSlotDurationForSlotPage = (selectedTime: string): string => {
350
293
  const timeArr = selectedTime.split(':');
351
294
  const firstHour = timeArr?.[0];
352
295
  const meridiem = timeArr?.[1]?.split(' ')?.[1];
@@ -360,4 +303,4 @@ export const getTimeSlotDurationForSlotPage = (selectedTime: string) => {
360
303
  );
361
304
 
362
305
  return `${firstHour} ${meridiem.toLowerCase()} - ${secondHour} ${secondMeridiem.toLowerCase()}`;
363
- };
306
+ };
@@ -1,6 +1,12 @@
1
1
  import { DEFAULT_FLOW } from './variants';
2
+ import { FLOWS } from '../../constants';
2
3
 
3
4
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
5
  export const getFlow = (flow: string) => {
5
- return DEFAULT_FLOW;
6
+ switch (flow){
7
+ case FLOWS.DEFAULT:
8
+ return DEFAULT_FLOW;
9
+ default:
10
+ return DEFAULT_FLOW;
11
+ }
6
12
  };
@@ -14,6 +14,7 @@ import {
14
14
  signup_refer,
15
15
  signup,
16
16
  slot_pick,
17
+ curriculum,
17
18
  } from '../../slides';
18
19
 
19
20
  export const DEFAULT_FLOW = {
@@ -37,4 +38,5 @@ export const DEFAULT_FLOW = {
37
38
  parent_student_details: signup.DEFAULT,
38
39
  other_curriculum: other_curriculum.DEFAULT,
39
40
  signup_refer: signup_refer.DEFAULT,
41
+ curriculum: curriculum.DEFAULT,
40
42
  };
@@ -1,14 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { ASSESSMENT_ID, CUE_COUNTRY_CODE_KEY, SLIDE_TYPES } from '../constants';
2
+ import { CUE_COUNTRY_CODE_KEY, SLIDE_TYPES } from '../constants';
3
3
  import { getCookie } from '../cookie';
4
4
  import { getTimezone, dateByTimezone, getCurrentTimestamp } from '../date-time-helper';
5
5
 
6
- // interface Timezone {
7
- // id: string;
8
- // value: string;
9
- // meta: string;
10
- // }
11
-
12
6
  const showCallModalURL: string[] = [
13
7
  SLIDE_TYPES.INTRO,
14
8
  SLIDE_TYPES.QUESTION,
@@ -230,15 +224,6 @@ export const getCounsellorSpelling = () => {
230
224
  // return uniqueTimezone;
231
225
  // });
232
226
 
233
- export const sendFieldEventToWebengage = (label: string | number, value: any) => {
234
- if (getCookie(ASSESSMENT_ID)) {
235
- const field: { [key: string]: [value: string] } = {};
236
-
237
- field[label] = value;
238
- // parentAnalytics.signupFieldFilled(field);
239
- }
240
- };
241
-
242
227
  export const isOtpRequired = (cueCountryCode: string) => {
243
228
  const noOtpCountrycodes = ['AU', 'NZ', 'SG'];
244
229
 
@@ -0,0 +1 @@
1
+ export * from './variants';
@@ -0,0 +1,14 @@
1
+ import { QUESTION_ID } from "../../../constants";
2
+
3
+ export const curriculum ={
4
+ DEFAULT: {
5
+ id: 17,
6
+ questionID: QUESTION_ID.OTHER_CURRICULUM,
7
+ type: 'freeFlowingText',
8
+ question: 'Please enter the curriculum followed at your child’s school',
9
+ description: 'This information will help us find the right tutor for your child.',
10
+ placeholderText: 'Child’s school curriculum',
11
+ questionUUID: 'ea8f4ed7-4214-4dcd-a818-701bf1843626',
12
+ textAreaHeight: '44px',
13
+ },
14
+ }
@@ -1,7 +1,9 @@
1
+ import { SLIDE_TYPES } from "../../../constants";
2
+
1
3
  export const grade = {
2
4
  DEFAULT: {
3
5
  id: 1,
4
- questionID: 'student_grade',
6
+ questionID: SLIDE_TYPES.STUDENT_GRADE,
5
7
  type: 'options_grid',
6
8
  question: 'What grade is your child in?',
7
9
  description:
@@ -19,7 +21,7 @@ export const grade = {
19
21
  { value: '1' },
20
22
  { value: '2' },
21
23
  { value: '3' },
22
- { value: 'KG' },
24
+ { label: 'KG', value: '0' },
23
25
  ], // Options
24
26
  defaultNextquestionID: 'math_perception',
25
27
  questionUUID: '3d8688bf-ad00-4cbf-a5f9-ba9cac27af46',
@@ -14,3 +14,4 @@ export * from './secondary_needs';
14
14
  export * from './signup_refer';
15
15
  export * from './signup';
16
16
  export * from './slot_pick';
17
+ export * from './curriculum';
@@ -1,4 +1,4 @@
1
- import { isUSK4Student, isAUK6Student } from '../../utils';
1
+ import { isK4Student, isK6Student } from '../../utils';
2
2
 
3
3
  const getPrimaryNeedSubcategoryOptions = (questionID: string) => {
4
4
  const mentalMathOptions = [
@@ -35,7 +35,7 @@ const getPrimaryNeedSubcategoryOptions = (questionID: string) => {
35
35
  },
36
36
  ];
37
37
 
38
- if (!isUSK4Student() && !isAUK6Student()) {
38
+ if (!isK4Student() && !isK6Student()) {
39
39
  return questionID === 'mentalMath' ? mentalMathOptions : strongMathFoundationOptions;
40
40
  }
41
41
 
@@ -57,7 +57,7 @@ const getDevelopInterestOptions = () => {
57
57
  { value: 'Improve their focus and concentration' },
58
58
  ];
59
59
 
60
- if (!isUSK4Student() && !isAUK6Student()) {
60
+ if (!isK4Student() && !isK6Student()) {
61
61
  return interestOptions;
62
62
  }
63
63
 
@@ -1,5 +1,8 @@
1
1
  import { getCookie } from '../../cookie';
2
2
  import { localStorageGet } from '../../local-storage';
3
+ import { SLIDE_TYPES, CUE_COUNTRY_CODE_KEY, LOCAL_STORAGE_KEYS } from '../../constants';
4
+
5
+ const K6Countries = ['AU', 'NZ']
3
6
 
4
7
  export function checkGradeCountry(
5
8
  country: string[],
@@ -7,7 +10,7 @@ export function checkGradeCountry(
7
10
  lessThanGrade: number,
8
11
  ): boolean {
9
12
  if (
10
- country.includes(getCookie('cue_country_code')) &&
13
+ country.includes(getCookie(CUE_COUNTRY_CODE_KEY)) &&
11
14
  (parseInt(currentGrade, 10) <= lessThanGrade || currentGrade === 'KG')
12
15
  ) {
13
16
  return true;
@@ -16,14 +19,14 @@ export function checkGradeCountry(
16
19
  return false;
17
20
  }
18
21
 
19
- export function isUSK4Student() {
20
- return checkGradeCountry(['US', 'UK'], localStorageGet('student_grade'), 4);
22
+ export function isK4Student() {
23
+ return checkGradeCountry(K6Countries, localStorageGet(LOCAL_STORAGE_KEYS.STUDENT_GRADE), 4);
21
24
  }
22
25
 
23
- export function isAUK6Student() {
24
- return checkGradeCountry(['AU', 'NZ'], localStorageGet('student_grade'), 6);
26
+ export function isK6Student() {
27
+ return checkGradeCountry(K6Countries, localStorageGet(LOCAL_STORAGE_KEYS.STUDENT_GRADE), 6);
25
28
  }
26
29
 
27
30
  export function getPerformanceQuestionAccordingToGrade() {
28
- return isUSK4Student() ? 'school_performance_kg_4' : 'school_performance_5_12';
31
+ return isK4Student() ? SLIDE_TYPES.SCHOOL_PERFORMANCE_KG_4 : SLIDE_TYPES.SCHOOL_PERFORMANCE_5_12;
29
32
  }
package/src/index.ts CHANGED
@@ -2,3 +2,6 @@ export * from './cookie';
2
2
  export * from './constants';
3
3
  export * from './local-storage';
4
4
  export * from './e-cna';
5
+ export * from './date-time-helper';
6
+ export * from './country';
7
+ export * from './object';
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  export const LOCAL_STORAGE_PRIMARY_KEY = 'CUEMATH_WEB';
3
3
 
4
- export const checkLocalStorageSupport = () => {
4
+ export const checkLocalStorageSupport = () : boolean => {
5
5
  try {
6
6
  return 'localStorage' in window && window.localStorage !== null;
7
7
  } catch (e) {
@@ -11,13 +11,8 @@ export const checkLocalStorageSupport = () => {
11
11
 
12
12
  export const removeKeyFromObject = (obj: { [x: string]: any }, keyToRemove: string) => {
13
13
  if (obj) {
14
- return Object.keys(obj)
15
- .filter(key => key !== String(keyToRemove))
16
- .reduce((accumulator: any, key: string) => {
17
- accumulator[key] = obj[key];
18
-
19
- return accumulator;
20
- }, {});
14
+ delete obj[keyToRemove];
15
+ return obj
21
16
  }
22
17
 
23
18
  return null;