@cuemath/web-utils 0.0.1-beta.6 → 0.0.1

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 (213) hide show
  1. package/.husky/pre-commit +0 -1
  2. package/dist/index.js +0 -6
  3. package/package.json +5 -18
  4. package/src/cookie/index.ts +1 -33
  5. package/src/index.ts +0 -6
  6. package/.eslintignore +0 -2
  7. package/.huskyrc +0 -5
  8. package/.lintstagedrc.yml +0 -5
  9. package/dist/constants/country/index.d.ts +0 -2
  10. package/dist/constants/country/index.js +0 -7
  11. package/dist/constants/country/index.js.map +0 -1
  12. package/dist/constants/country/iso-country-code.d.ts +0 -248
  13. package/dist/constants/country/iso-country-code.js +0 -252
  14. package/dist/constants/country/iso-country-code.js.map +0 -1
  15. package/dist/constants/date-time/index.d.ts +0 -17
  16. package/dist/constants/date-time/index.js +0 -42
  17. package/dist/constants/date-time/index.js.map +0 -1
  18. package/dist/constants/date-time/international-timezones.d.ts +0 -7
  19. package/dist/constants/date-time/international-timezones.js +0 -155
  20. package/dist/constants/date-time/international-timezones.js.map +0 -1
  21. package/dist/constants/e-cna/index.d.ts +0 -35
  22. package/dist/constants/e-cna/index.js +0 -39
  23. package/dist/constants/e-cna/index.js.map +0 -1
  24. package/dist/constants/index.d.ts +0 -2
  25. package/dist/constants/index.js +0 -19
  26. package/dist/constants/index.js.map +0 -1
  27. package/dist/cookie/index.d.ts +0 -4
  28. package/dist/cookie/index.js +0 -46
  29. package/dist/cookie/index.js.map +0 -1
  30. package/dist/country/index.d.ts +0 -1
  31. package/dist/country/index.js +0 -13
  32. package/dist/country/index.js.map +0 -1
  33. package/dist/date-time-helper/e-cna.d.ts +0 -32
  34. package/dist/date-time-helper/e-cna.js +0 -153
  35. package/dist/date-time-helper/e-cna.js.map +0 -1
  36. package/dist/date-time-helper/index.d.ts +0 -51
  37. package/dist/date-time-helper/index.js +0 -233
  38. package/dist/date-time-helper/index.js.map +0 -1
  39. package/dist/e-cna/flow/aggregator.d.ts +0 -219
  40. package/dist/e-cna/flow/aggregator.js +0 -16
  41. package/dist/e-cna/flow/aggregator.js.map +0 -1
  42. package/dist/e-cna/flow/index.d.ts +0 -1
  43. package/dist/e-cna/flow/index.js +0 -18
  44. package/dist/e-cna/flow/index.js.map +0 -1
  45. package/dist/e-cna/flow/variants/default.d.ts +0 -219
  46. package/dist/e-cna/flow/variants/default.js +0 -28
  47. package/dist/e-cna/flow/variants/default.js.map +0 -1
  48. package/dist/e-cna/flow/variants/index.d.ts +0 -1
  49. package/dist/e-cna/flow/variants/index.js +0 -18
  50. package/dist/e-cna/flow/variants/index.js.map +0 -1
  51. package/dist/e-cna/index.d.ts +0 -43
  52. package/dist/e-cna/index.js +0 -221
  53. package/dist/e-cna/index.js.map +0 -1
  54. package/dist/e-cna/slides/child_hobbies/index.d.ts +0 -1
  55. package/dist/e-cna/slides/child_hobbies/index.js +0 -18
  56. package/dist/e-cna/slides/child_hobbies/index.js.map +0 -1
  57. package/dist/e-cna/slides/child_hobbies/variants.d.ts +0 -12
  58. package/dist/e-cna/slides/child_hobbies/variants.js +0 -16
  59. package/dist/e-cna/slides/child_hobbies/variants.js.map +0 -1
  60. package/dist/e-cna/slides/child_personality/index.d.ts +0 -1
  61. package/dist/e-cna/slides/child_personality/index.js +0 -18
  62. package/dist/e-cna/slides/child_personality/index.js.map +0 -1
  63. package/dist/e-cna/slides/child_personality/variants.d.ts +0 -12
  64. package/dist/e-cna/slides/child_personality/variants.js +0 -16
  65. package/dist/e-cna/slides/child_personality/variants.js.map +0 -1
  66. package/dist/e-cna/slides/curriculum/index.d.ts +0 -1
  67. package/dist/e-cna/slides/curriculum/index.js +0 -18
  68. package/dist/e-cna/slides/curriculum/index.js.map +0 -1
  69. package/dist/e-cna/slides/curriculum/variants.d.ts +0 -12
  70. package/dist/e-cna/slides/curriculum/variants.js +0 -17
  71. package/dist/e-cna/slides/curriculum/variants.js.map +0 -1
  72. package/dist/e-cna/slides/grade/index.d.ts +0 -1
  73. package/dist/e-cna/slides/grade/index.js +0 -18
  74. package/dist/e-cna/slides/grade/index.js.map +0 -1
  75. package/dist/e-cna/slides/grade/variants.d.ts +0 -18
  76. package/dist/e-cna/slides/grade/variants.js +0 -31
  77. package/dist/e-cna/slides/grade/variants.js.map +0 -1
  78. package/dist/e-cna/slides/index.d.ts +0 -17
  79. package/dist/e-cna/slides/index.js +0 -34
  80. package/dist/e-cna/slides/index.js.map +0 -1
  81. package/dist/e-cna/slides/intro/index.d.ts +0 -1
  82. package/dist/e-cna/slides/intro/index.js +0 -18
  83. package/dist/e-cna/slides/intro/index.js.map +0 -1
  84. package/dist/e-cna/slides/intro/variants.d.ts +0 -7
  85. package/dist/e-cna/slides/intro/variants.js +0 -11
  86. package/dist/e-cna/slides/intro/variants.js.map +0 -1
  87. package/dist/e-cna/slides/key_need_l1/index.d.ts +0 -1
  88. package/dist/e-cna/slides/key_need_l1/index.js +0 -18
  89. package/dist/e-cna/slides/key_need_l1/index.js.map +0 -1
  90. package/dist/e-cna/slides/key_need_l1/variants.d.ts +0 -14
  91. package/dist/e-cna/slides/key_need_l1/variants.js +0 -45
  92. package/dist/e-cna/slides/key_need_l1/variants.js.map +0 -1
  93. package/dist/e-cna/slides/key_need_l2/index.d.ts +0 -1
  94. package/dist/e-cna/slides/key_need_l2/index.js +0 -18
  95. package/dist/e-cna/slides/key_need_l2/index.js.map +0 -1
  96. package/dist/e-cna/slides/key_need_l2/variants.d.ts +0 -67
  97. package/dist/e-cna/slides/key_need_l2/variants.js +0 -139
  98. package/dist/e-cna/slides/key_need_l2/variants.js.map +0 -1
  99. package/dist/e-cna/slides/key_need_l3/index.d.ts +0 -1
  100. package/dist/e-cna/slides/key_need_l3/index.js +0 -18
  101. package/dist/e-cna/slides/key_need_l3/index.js.map +0 -1
  102. package/dist/e-cna/slides/key_need_l3/variants.d.ts +0 -11
  103. package/dist/e-cna/slides/key_need_l3/variants.js +0 -15
  104. package/dist/e-cna/slides/key_need_l3/variants.js.map +0 -1
  105. package/dist/e-cna/slides/math-perception/index.d.ts +0 -1
  106. package/dist/e-cna/slides/math-perception/index.js +0 -18
  107. package/dist/e-cna/slides/math-perception/index.js.map +0 -1
  108. package/dist/e-cna/slides/math-perception/variants.d.ts +0 -15
  109. package/dist/e-cna/slides/math-perception/variants.js +0 -32
  110. package/dist/e-cna/slides/math-perception/variants.js.map +0 -1
  111. package/dist/e-cna/slides/other_curriculum/index.d.ts +0 -1
  112. package/dist/e-cna/slides/other_curriculum/index.js +0 -18
  113. package/dist/e-cna/slides/other_curriculum/index.js.map +0 -1
  114. package/dist/e-cna/slides/other_curriculum/variants.d.ts +0 -12
  115. package/dist/e-cna/slides/other_curriculum/variants.js +0 -17
  116. package/dist/e-cna/slides/other_curriculum/variants.js.map +0 -1
  117. package/dist/e-cna/slides/school_performance_5_12/index.d.ts +0 -1
  118. package/dist/e-cna/slides/school_performance_5_12/index.js +0 -18
  119. package/dist/e-cna/slides/school_performance_5_12/index.js.map +0 -1
  120. package/dist/e-cna/slides/school_performance_5_12/variants.d.ts +0 -15
  121. package/dist/e-cna/slides/school_performance_5_12/variants.js +0 -26
  122. package/dist/e-cna/slides/school_performance_5_12/variants.js.map +0 -1
  123. package/dist/e-cna/slides/school_performance_kg_4/index.d.ts +0 -1
  124. package/dist/e-cna/slides/school_performance_kg_4/index.js +0 -18
  125. package/dist/e-cna/slides/school_performance_kg_4/index.js.map +0 -1
  126. package/dist/e-cna/slides/school_performance_kg_4/variants.d.ts +0 -14
  127. package/dist/e-cna/slides/school_performance_kg_4/variants.js +0 -28
  128. package/dist/e-cna/slides/school_performance_kg_4/variants.js.map +0 -1
  129. package/dist/e-cna/slides/secondary_needs/index.d.ts +0 -1
  130. package/dist/e-cna/slides/secondary_needs/index.js +0 -18
  131. package/dist/e-cna/slides/secondary_needs/index.js.map +0 -1
  132. package/dist/e-cna/slides/secondary_needs/variants.d.ts +0 -14
  133. package/dist/e-cna/slides/secondary_needs/variants.js +0 -28
  134. package/dist/e-cna/slides/secondary_needs/variants.js.map +0 -1
  135. package/dist/e-cna/slides/signup/index.d.ts +0 -1
  136. package/dist/e-cna/slides/signup/index.js +0 -18
  137. package/dist/e-cna/slides/signup/index.js.map +0 -1
  138. package/dist/e-cna/slides/signup/variants.d.ts +0 -7
  139. package/dist/e-cna/slides/signup/variants.js +0 -11
  140. package/dist/e-cna/slides/signup/variants.js.map +0 -1
  141. package/dist/e-cna/slides/signup_refer/index.d.ts +0 -1
  142. package/dist/e-cna/slides/signup_refer/index.js +0 -18
  143. package/dist/e-cna/slides/signup_refer/index.js.map +0 -1
  144. package/dist/e-cna/slides/signup_refer/variants.d.ts +0 -12
  145. package/dist/e-cna/slides/signup_refer/variants.js +0 -20
  146. package/dist/e-cna/slides/signup_refer/variants.js.map +0 -1
  147. package/dist/e-cna/slides/slot_pick/index.d.ts +0 -1
  148. package/dist/e-cna/slides/slot_pick/index.js +0 -18
  149. package/dist/e-cna/slides/slot_pick/index.js.map +0 -1
  150. package/dist/e-cna/slides/slot_pick/variants.d.ts +0 -7
  151. package/dist/e-cna/slides/slot_pick/variants.js +0 -11
  152. package/dist/e-cna/slides/slot_pick/variants.js.map +0 -1
  153. package/dist/e-cna/utils/index.d.ts +0 -4
  154. package/dist/e-cna/utils/index.js +0 -28
  155. package/dist/e-cna/utils/index.js.map +0 -1
  156. package/dist/index.d.ts +0 -7
  157. package/dist/index.js.map +0 -1
  158. package/dist/local-storage/index.d.ts +0 -13
  159. package/dist/local-storage/index.js +0 -172
  160. package/dist/local-storage/index.js.map +0 -1
  161. package/dist/object/index.d.ts +0 -6
  162. package/dist/object/index.js +0 -24
  163. package/dist/object/index.js.map +0 -1
  164. package/src/constants/country/index.ts +0 -2
  165. package/src/constants/country/iso-country-code.ts +0 -248
  166. package/src/constants/date-time/index.ts +0 -43
  167. package/src/constants/date-time/international-timezones.ts +0 -157
  168. package/src/constants/e-cna/index.ts +0 -45
  169. package/src/constants/index.ts +0 -2
  170. package/src/country/index.ts +0 -9
  171. package/src/date-time-helper/e-cna.ts +0 -205
  172. package/src/date-time-helper/index.ts +0 -306
  173. package/src/e-cna/flow/aggregator.ts +0 -12
  174. package/src/e-cna/flow/index.ts +0 -1
  175. package/src/e-cna/flow/variants/default.ts +0 -42
  176. package/src/e-cna/flow/variants/index.ts +0 -1
  177. package/src/e-cna/index.ts +0 -249
  178. package/src/e-cna/slides/child_hobbies/index.ts +0 -1
  179. package/src/e-cna/slides/child_hobbies/variants.ts +0 -13
  180. package/src/e-cna/slides/child_personality/index.ts +0 -1
  181. package/src/e-cna/slides/child_personality/variants.ts +0 -12
  182. package/src/e-cna/slides/curriculum/index.ts +0 -1
  183. package/src/e-cna/slides/curriculum/variants.ts +0 -14
  184. package/src/e-cna/slides/grade/index.ts +0 -1
  185. package/src/e-cna/slides/grade/variants.ts +0 -29
  186. package/src/e-cna/slides/index.ts +0 -17
  187. package/src/e-cna/slides/intro/index.ts +0 -1
  188. package/src/e-cna/slides/intro/variants.ts +0 -7
  189. package/src/e-cna/slides/key_need_l1/index.ts +0 -1
  190. package/src/e-cna/slides/key_need_l1/variants.ts +0 -44
  191. package/src/e-cna/slides/key_need_l2/index.ts +0 -1
  192. package/src/e-cna/slides/key_need_l2/variants.ts +0 -143
  193. package/src/e-cna/slides/key_need_l3/index.ts +0 -1
  194. package/src/e-cna/slides/key_need_l3/variants.ts +0 -13
  195. package/src/e-cna/slides/math-perception/index.ts +0 -1
  196. package/src/e-cna/slides/math-perception/variants.ts +0 -30
  197. package/src/e-cna/slides/other_curriculum/index.ts +0 -1
  198. package/src/e-cna/slides/other_curriculum/variants.ts +0 -14
  199. package/src/e-cna/slides/school_performance_5_12/index.ts +0 -1
  200. package/src/e-cna/slides/school_performance_5_12/variants.ts +0 -23
  201. package/src/e-cna/slides/school_performance_kg_4/index.ts +0 -1
  202. package/src/e-cna/slides/school_performance_kg_4/variants.ts +0 -25
  203. package/src/e-cna/slides/secondary_needs/index.ts +0 -1
  204. package/src/e-cna/slides/secondary_needs/variants.ts +0 -26
  205. package/src/e-cna/slides/signup/index.ts +0 -1
  206. package/src/e-cna/slides/signup/variants.ts +0 -7
  207. package/src/e-cna/slides/signup_refer/index.ts +0 -1
  208. package/src/e-cna/slides/signup_refer/variants.ts +0 -16
  209. package/src/e-cna/slides/slot_pick/index.ts +0 -1
  210. package/src/e-cna/slides/slot_pick/variants.ts +0 -7
  211. package/src/e-cna/utils/index.ts +0 -32
  212. package/src/local-storage/index.ts +0 -186
  213. package/src/object/index.ts +0 -26
@@ -1,45 +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
- export const ASSESSMENT_ID = 'assessmentId';
7
-
8
- export const SLIDE_TYPES = {
9
- INTRO: 'intro',
10
- SLOT_PICK: 'slot-pick',
11
- PARENT_STUDENT_DETAILS: 'parent_student_details',
12
- CLASS_CONFIRMED: 'class_confirmed',
13
- CLASS_THANK_YOU: 'class_thankyou',
14
- QUESTION: 'question',
15
- EXIT_PARENT: 'exit-parent',
16
- EXIT_SLOTS: 'exit-slots',
17
- EXIT_THANK_YOU: 'exit-thankyou',
18
- CLASS_NOT_CONFIRMED: 'class-not-confirmed',
19
- COURSE_NOT_AVAILABLE: 'course-not-available',
20
- SCHOOL_PERFORMANCE_KG_4: 'school_performance_kg_4',
21
- SCHOOL_PERFORMANCE_5_12: 'school_performance_5_12',
22
- STUDENT_GRADE: 'student_grade',
23
- };
24
-
25
- export const QUESTION_ID = {
26
- SCHOOL_CURRICULUM: 'school_curriculum',
27
- OTHER_CURRICULUM: 'other_curriculum',
28
- };
29
-
30
- export const LOCAL_STORAGE_KEYS = {
31
- STUDENT_GRADE: 'student_grade',
32
- KEY_NEED_L1: 'key_need_l1',
33
- };
34
-
35
- export const QUESTION_TYPES = {
36
- OPTIONS: 'options',
37
- OPTIONS_GRID: 'options_grid',
38
- OPTIONS_THIN: 'options_thin',
39
- OPTIONS_MULTISELECT: 'options_multiselect',
40
- FREE_FLOWING_TEXT: 'freeFlowingText',
41
- };
42
-
43
- export const FLOWS = {
44
- DEFAULT: 'default',
45
- }
@@ -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?.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
- };
@@ -1,306 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import dayjs from 'dayjs';
3
- import relativeTime from 'dayjs/plugin/relativeTime';
4
-
5
- import {
6
- shorthandWeekDayArray,
7
- monthArray,
8
- TWENTY_FOUR_HOURS_IN_SECONDS,
9
- HOUR_FORMAT,
10
- } from '../constants/date-time';
11
- import { timezones } from '../constants/date-time/international-timezones';
12
-
13
- type Timestamp = number;
14
-
15
- export interface DateSlots {
16
- key: number;
17
- label: string;
18
- subLabel: string;
19
- disabled: boolean;
20
- }
21
-
22
- export const formatDateTime = (
23
- dateTime: string | number | Date | dayjs.Dayjs | null | undefined,
24
- format: string | undefined,
25
- ) => {
26
- const momentDate = dayjs(dateTime);
27
-
28
- return momentDate.format(format);
29
- };
30
-
31
- export function getCurrentTimestamp(): number {
32
- if (!Date.now) {
33
- Date.now = () => new Date().getTime();
34
- }
35
-
36
- return Math.floor(Date.now() / 1000);
37
- }
38
-
39
- export function dateTimeByTimezone(timestamp: Timestamp, timezone?: string): string {
40
- let options = {};
41
-
42
- if (timezone) {
43
- options = {
44
- timeZone: timezone,
45
- };
46
- }
47
-
48
- return new Date(timestamp).toLocaleString('en-US', options);
49
- }
50
-
51
- export function dateByTimezone(timestamp: number, timezone: string, format: string): string {
52
- const datetime = dateTimeByTimezone(timestamp, timezone);
53
-
54
- return dayjs(datetime).format(format || 'mm/dd/yyyy');
55
- }
56
-
57
- export const dateByTimestamp = (timestamp: Timestamp, format: string): string => {
58
- const datetime = new Date(timestamp).toLocaleString('en-US');
59
-
60
- return dayjs(datetime).format(format || 'mm/dd/yyyy');
61
- };
62
-
63
- export function convertTimeStampToSeconds(timeStamp: Timestamp): number {
64
- const demoTimeStamp = timeStamp;
65
- const currentTimeStamp = getCurrentTimestamp();
66
-
67
- if (Number.isNaN(demoTimeStamp) || Number.isNaN(currentTimeStamp)) {
68
- return timeStamp;
69
- }
70
-
71
- const demoTimeStampLength = String(demoTimeStamp).length;
72
- const currentTimeStampLength = String(currentTimeStamp).length;
73
-
74
- return demoTimeStampLength > currentTimeStampLength ? timeStamp / 1000 : timeStamp;
75
- }
76
-
77
- export function formatTimestamp(datetime: Timestamp, format: string | undefined): string {
78
- const timeStamp = convertTimeStampToSeconds(datetime);
79
-
80
- return dayjs.unix(timeStamp).format(format);
81
- }
82
-
83
- export function getTimezone(): string {
84
- return Intl?.DateTimeFormat().resolvedOptions().timeZone;
85
- }
86
-
87
- export function timeToX(
88
- datetime: string | number | Date | dayjs.Dayjs | null | undefined,
89
- ): string {
90
- dayjs.extend(relativeTime);
91
-
92
- return dayjs().to(datetime, true);
93
- }
94
-
95
- export function getCurrentDatebyTimezone(timezone: string): string {
96
- let options = {};
97
-
98
- if (timezone) {
99
- options = {
100
- timeZone: timezone,
101
- };
102
- }
103
-
104
- return new Date().toLocaleString('en-US', options);
105
- }
106
-
107
- export function getTimeDiff(
108
- date1: string | number | Date | dayjs.Dayjs | null | undefined,
109
- date2: string | number | Date | dayjs.Dayjs | null | undefined,
110
- ) : {days: any, hour: any, minute: any, seconds: any, distance: any} {
111
- const dateTime1 = dayjs(date1);
112
- const dateTime2 = dayjs(date2);
113
-
114
- return {
115
- days: dateTime1.diff(dateTime2, 'days'),
116
- hour: dateTime1.diff(dateTime2, 'hour'),
117
- minute: dateTime1.diff(dateTime2, 'minute'),
118
- seconds: dateTime1.diff(dateTime2, 'seconds'),
119
- distance: dateTime1.diff(dateTime2),
120
- };
121
- }
122
-
123
- export function getISOTimeString(demoTs: number): string {
124
- return new Date(demoTs * 1000).toISOString().replace(/-|:|\.\d\d\d/g, '');
125
- }
126
-
127
- export function getDateAfterDays(days: number): string {
128
- return formatDateTime(dayjs().add(days, 'day'), 'D MMM, YYYY').toUpperCase();
129
- }
130
-
131
- export const convertedTimezone = (selectedTimezone: string): string => {
132
- const formattedTimezone = timezones?.filter(
133
- currentTimezone => currentTimezone?.id === selectedTimezone,
134
- );
135
-
136
- if (formattedTimezone?.length) {
137
- return formattedTimezone[0]?.value;
138
- }
139
-
140
- return selectedTimezone?.replace(/_/g, ' ');
141
- };
142
-
143
- export const getHourInTwelveHourFormat = (hour: number): number => {
144
- return hour % 12 === 0 ? 12 : hour % 12;
145
- };
146
-
147
- export const getMeridiemAccordingToHourAndHourFormat = (
148
- hour: number,
149
- hourFormat: number,
150
- meridiem = '',
151
- ): string => {
152
- if (hourFormat === HOUR_FORMAT.TWENTY_FOUR_HOUR_FORMAT) {
153
- return hour / 12 >= 1 ? 'PM' : 'AM';
154
- }
155
-
156
- return hour === 12 ? 'PM' : meridiem;
157
- };
158
-
159
- export const getTimeSlotDuration = (selectedTime: number, selectedTimezone: any): string => {
160
- const firstHour = getHourInTwelveHourFormat(selectedTime);
161
- const firstMeridiem = getMeridiemAccordingToHourAndHourFormat(
162
- selectedTime,
163
- HOUR_FORMAT.TWENTY_FOUR_HOUR_FORMAT,
164
- );
165
-
166
- const secondHour = getHourInTwelveHourFormat(selectedTime + 1);
167
- const secondMeridiem = getMeridiemAccordingToHourAndHourFormat(
168
- selectedTime + 1,
169
- HOUR_FORMAT.TWENTY_FOUR_HOUR_FORMAT,
170
- );
171
- const currentTimeZone =
172
- convertedTimezone(selectedTimezone)?.split('(') || selectedTimezone;
173
-
174
- return `${firstHour} ${firstMeridiem.toLowerCase()} - ${secondHour} ${secondMeridiem.toLowerCase()} (${currentTimeZone})`;
175
- };
176
-
177
- export const convertSecondsToMiliseconds = (seconds: number) => {
178
- return seconds * 1000;
179
- };
180
-
181
- // convert date into Sept 01, Thursday format
182
- export const convertDate = (selectedDate: number, selectedTimezone: string): string => {
183
- const slotDate = formatTimestamp(selectedDate, 'DD-MM-YYYY');
184
- const dayOfWeek = dateByTimezone(selectedDate * 1000, selectedTimezone, 'dddd');
185
- const dateArr = slotDate?.split('-');
186
- const month = dateArr?.[1];
187
- const day = dateArr?.[0];
188
-
189
- return `${monthArray[parseInt(month, 10) - 1]} ${day}, ${dayOfWeek}`;
190
- };
191
-
192
- export const getModifiedDateSlots = (dateSlotsData: { label: string }[]): { label: string; removeBorder?: boolean }[][] => {
193
- const startWeekIndex = shorthandWeekDayArray?.indexOf(dateSlotsData?.[0]?.label);
194
-
195
- // get all days
196
- let weekDays: { label: string; removeBorder?: boolean }[] = [];
197
-
198
- // while loop to check start date's day
199
- // for eg: if first date is wednesday, it will add blank days on monday, tuesday
200
- while (weekDays.length !== startWeekIndex) {
201
- weekDays.push({
202
- label: '',
203
- removeBorder: false,
204
- });
205
- }
206
- weekDays = [...weekDays, ...dateSlotsData];
207
-
208
- // while loop to add check end date
209
- // for eg: if last date end's on friday, it will add blank days on saturday and sunday
210
- while (weekDays.length % 7 !== 0) {
211
- weekDays.push({
212
- label: '',
213
- removeBorder: false,
214
- });
215
- }
216
- const weekRows = [];
217
-
218
- // divide weekDays in weeks group
219
- while (weekDays.length !== 0) {
220
- const row =
221
- weekDays?.length >= 7
222
- ? weekDays?.splice(0, 7)
223
- : weekDays?.splice(0, weekDays?.length);
224
-
225
- weekRows.push(row);
226
- }
227
-
228
- return weekRows;
229
- };
230
-
231
- // Array of 7 days
232
- export const getDates = (timezone: string): { futureDate: any; disabled: any; }[] => {
233
- const currentDate = Date.parse(getCurrentDatebyTimezone(timezone)) / 1000;
234
- const dates = [];
235
-
236
- // getting dates by adding 86400 seconds(24 hours)
237
- for (let i = 0; i < 7; i++) {
238
- dates.push({
239
- futureDate: currentDate + TWENTY_FOUR_HOURS_IN_SECONDS * i,
240
- disabled: !(i > 1),
241
- });
242
- }
243
-
244
- return dates;
245
- };
246
-
247
- export function formatDateFromTimestamp(
248
- timestamp: string | number | Date,
249
- format: string,
250
- ) : string {
251
- const datetime = new Date(timestamp).toLocaleString('en-US');
252
-
253
- return dayjs(datetime).format(format || 'mm/dd/yyyy');
254
- }
255
-
256
- export function getAvailableDateSlots(currentTimezone: any): DateSlots [] {
257
- const availableDateSlots: DateSlots[] = [];
258
-
259
- getDates(currentTimezone).map((item: { futureDate: any; disabled: any; }) => {
260
- const { futureDate, disabled } = item;
261
-
262
- availableDateSlots.push({
263
- key: futureDate,
264
- label: formatDateFromTimestamp(futureDate * 1000, 'dd'),
265
- subLabel: formatDateFromTimestamp(futureDate * 1000, 'DD'),
266
- disabled,
267
- });
268
-
269
- return null;
270
- });
271
-
272
- return availableDateSlots;
273
- }
274
-
275
- export const toTimestamp = (strDate: string) => {
276
- return Date.parse(strDate) / 1000;
277
- };
278
-
279
- export const getDateSlots = (timezone: any): { [x: string]: any } => {
280
- return getDates(timezone).map((item: { futureDate: any; disabled: any; }) => {
281
- const { futureDate, disabled } = item;
282
-
283
- return {
284
- key: futureDate,
285
- label: dateByTimestamp(futureDate * 1000, 'dd'),
286
- subLabel: dateByTimestamp(futureDate * 1000, 'DD'),
287
- disabled,
288
- };
289
- });
290
- };
291
-
292
- export const getTimeSlotDurationForSlotPage = (selectedTime: string): string => {
293
- const timeArr = selectedTime.split(':');
294
- const firstHour = timeArr?.[0];
295
- const meridiem = timeArr?.[1]?.split(' ')?.[1];
296
-
297
- const secondHourInTwelveHourFormat = parseInt(firstHour, 10) + 1;
298
- const secondHour = getHourInTwelveHourFormat(secondHourInTwelveHourFormat);
299
- const secondMeridiem = getMeridiemAccordingToHourAndHourFormat(
300
- secondHourInTwelveHourFormat,
301
- HOUR_FORMAT.TWELVE_HOUR_FORMAT,
302
- meridiem,
303
- );
304
-
305
- return `${firstHour} ${meridiem.toLowerCase()} - ${secondHour} ${secondMeridiem.toLowerCase()}`;
306
- };
@@ -1,12 +0,0 @@
1
- import { DEFAULT_FLOW } from './variants';
2
- import { FLOWS } from '../../constants';
3
-
4
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
- export const getFlow = (flow: string) => {
6
- switch (flow){
7
- case FLOWS.DEFAULT:
8
- return DEFAULT_FLOW;
9
- default:
10
- return DEFAULT_FLOW;
11
- }
12
- };
@@ -1 +0,0 @@
1
- export * from './aggregator';
@@ -1,42 +0,0 @@
1
- import {
2
- intro,
3
- grade,
4
- key_need_l1,
5
- key_need_l2,
6
- math_perception,
7
- school_performance_5_12,
8
- school_performance_kg_4,
9
- child_hobbies,
10
- child_personality,
11
- key_need_l3,
12
- other_curriculum,
13
- secondary_needs,
14
- signup_refer,
15
- signup,
16
- slot_pick,
17
- curriculum,
18
- } from '../../slides';
19
-
20
- export const DEFAULT_FLOW = {
21
- intro: intro.DEFAULT,
22
- grade: grade.DEFAULT,
23
- math_perception: math_perception.DEFAULT,
24
- school_performance_5_12: school_performance_5_12.DEFAULT,
25
- school_performance_kg_4: school_performance_kg_4.DEFAULT,
26
- key_need_l1: key_need_l1.DEFAULT,
27
- strong_math_foundation: key_need_l2.STRONG_MATH_FOUNDATION,
28
- mental_math: key_need_l2.MENTAL_MATH,
29
- learning_gaps: key_need_l2.LEARNING_GAPS,
30
- more_practice: key_need_l2.MORE_PRACTICE,
31
- develop_interest: key_need_l2.DEVELOP_INTEREST,
32
- advanced_and_competitive_maths: key_need_l2.ADVANCE_AND_COMPETITIVE_MATHS,
33
- key_need_l3: key_need_l3.DEFAULT,
34
- secondary_needs: secondary_needs.DEFAULT,
35
- child_personality: child_personality.DEFAULT,
36
- child_hobbies: child_hobbies.DEFAULT,
37
- slot_pick: slot_pick.DEFAULT,
38
- parent_student_details: signup.DEFAULT,
39
- other_curriculum: other_curriculum.DEFAULT,
40
- signup_refer: signup_refer.DEFAULT,
41
- curriculum: curriculum.DEFAULT,
42
- };
@@ -1 +0,0 @@
1
- export * from './default';