@cuemath/web-utils 1.0.0-beta.14 → 1.0.0

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 (237) hide show
  1. package/.husky/pre-commit +0 -1
  2. package/dist/cookie/index.d.ts +1 -1
  3. package/dist/cookie/index.js +2 -3
  4. package/dist/cookie/index.js.map +1 -1
  5. package/dist/growth-source/index.d.ts +6 -0
  6. package/dist/growth-source/index.js +151 -0
  7. package/dist/growth-source/index.js.map +1 -0
  8. package/dist/growth-source/types.d.ts +25 -0
  9. package/dist/growth-source/types.js +3 -0
  10. package/dist/growth-source/types.js.map +1 -0
  11. package/dist/index.d.ts +1 -6
  12. package/dist/index.js +1 -6
  13. package/dist/index.js.map +1 -1
  14. package/package.json +3 -7
  15. package/src/cookie/index.ts +10 -4
  16. package/src/growth-source/index.ts +191 -0
  17. package/src/growth-source/types.ts +33 -0
  18. package/src/index.ts +1 -6
  19. package/.eslintignore +0 -2
  20. package/.huskyrc +0 -5
  21. package/.lintstagedrc.yml +0 -5
  22. package/dist/constants/country/index.d.ts +0 -2
  23. package/dist/constants/country/index.js +0 -7
  24. package/dist/constants/country/index.js.map +0 -1
  25. package/dist/constants/country/iso-country-code.d.ts +0 -248
  26. package/dist/constants/country/iso-country-code.js +0 -252
  27. package/dist/constants/country/iso-country-code.js.map +0 -1
  28. package/dist/constants/date-time/index.d.ts +0 -17
  29. package/dist/constants/date-time/index.js +0 -42
  30. package/dist/constants/date-time/index.js.map +0 -1
  31. package/dist/constants/date-time/international-timezones.d.ts +0 -7
  32. package/dist/constants/date-time/international-timezones.js +0 -155
  33. package/dist/constants/date-time/international-timezones.js.map +0 -1
  34. package/dist/constants/e-cna/index.d.ts +0 -41
  35. package/dist/constants/e-cna/index.js +0 -45
  36. package/dist/constants/e-cna/index.js.map +0 -1
  37. package/dist/constants/index.d.ts +0 -2
  38. package/dist/constants/index.js +0 -19
  39. package/dist/constants/index.js.map +0 -1
  40. package/dist/country/index.d.ts +0 -1
  41. package/dist/country/index.js +0 -13
  42. package/dist/country/index.js.map +0 -1
  43. package/dist/date-time-helper/e-cna.d.ts +0 -32
  44. package/dist/date-time-helper/e-cna.js +0 -153
  45. package/dist/date-time-helper/e-cna.js.map +0 -1
  46. package/dist/date-time-helper/index.d.ts +0 -54
  47. package/dist/date-time-helper/index.js +0 -290
  48. package/dist/date-time-helper/index.js.map +0 -1
  49. package/dist/e-cna/flow/aggregator.d.ts +0 -473
  50. package/dist/e-cna/flow/aggregator.js +0 -17
  51. package/dist/e-cna/flow/aggregator.js.map +0 -1
  52. package/dist/e-cna/flow/index.d.ts +0 -1
  53. package/dist/e-cna/flow/index.js +0 -18
  54. package/dist/e-cna/flow/index.js.map +0 -1
  55. package/dist/e-cna/flow/variants/default.d.ts +0 -734
  56. package/dist/e-cna/flow/variants/default.js +0 -95
  57. package/dist/e-cna/flow/variants/default.js.map +0 -1
  58. package/dist/e-cna/flow/variants/index.d.ts +0 -1
  59. package/dist/e-cna/flow/variants/index.js +0 -18
  60. package/dist/e-cna/flow/variants/index.js.map +0 -1
  61. package/dist/e-cna/index.d.ts +0 -43
  62. package/dist/e-cna/index.js +0 -221
  63. package/dist/e-cna/index.js.map +0 -1
  64. package/dist/e-cna/slides/child_hobbies/index.d.ts +0 -1
  65. package/dist/e-cna/slides/child_hobbies/index.js +0 -18
  66. package/dist/e-cna/slides/child_hobbies/index.js.map +0 -1
  67. package/dist/e-cna/slides/child_hobbies/variants.d.ts +0 -22
  68. package/dist/e-cna/slides/child_hobbies/variants.js +0 -26
  69. package/dist/e-cna/slides/child_hobbies/variants.js.map +0 -1
  70. package/dist/e-cna/slides/child_info/index.d.ts +0 -1
  71. package/dist/e-cna/slides/child_info/index.js +0 -18
  72. package/dist/e-cna/slides/child_info/index.js.map +0 -1
  73. package/dist/e-cna/slides/child_info/variants.d.ts +0 -17
  74. package/dist/e-cna/slides/child_info/variants.js +0 -22
  75. package/dist/e-cna/slides/child_info/variants.js.map +0 -1
  76. package/dist/e-cna/slides/child_personality/index.d.ts +0 -1
  77. package/dist/e-cna/slides/child_personality/index.js +0 -18
  78. package/dist/e-cna/slides/child_personality/index.js.map +0 -1
  79. package/dist/e-cna/slides/child_personality/variants.d.ts +0 -12
  80. package/dist/e-cna/slides/child_personality/variants.js +0 -16
  81. package/dist/e-cna/slides/child_personality/variants.js.map +0 -1
  82. package/dist/e-cna/slides/curriculum/index.d.ts +0 -1
  83. package/dist/e-cna/slides/curriculum/index.js +0 -18
  84. package/dist/e-cna/slides/curriculum/index.js.map +0 -1
  85. package/dist/e-cna/slides/curriculum/variants.d.ts +0 -12
  86. package/dist/e-cna/slides/curriculum/variants.js +0 -17
  87. package/dist/e-cna/slides/curriculum/variants.js.map +0 -1
  88. package/dist/e-cna/slides/grade/index.d.ts +0 -1
  89. package/dist/e-cna/slides/grade/index.js +0 -18
  90. package/dist/e-cna/slides/grade/index.js.map +0 -1
  91. package/dist/e-cna/slides/grade/variants.d.ts +0 -14
  92. package/dist/e-cna/slides/grade/variants.js +0 -31
  93. package/dist/e-cna/slides/grade/variants.js.map +0 -1
  94. package/dist/e-cna/slides/index.d.ts +0 -19
  95. package/dist/e-cna/slides/index.js +0 -36
  96. package/dist/e-cna/slides/index.js.map +0 -1
  97. package/dist/e-cna/slides/intro/index.d.ts +0 -1
  98. package/dist/e-cna/slides/intro/index.js +0 -18
  99. package/dist/e-cna/slides/intro/index.js.map +0 -1
  100. package/dist/e-cna/slides/intro/variants.d.ts +0 -7
  101. package/dist/e-cna/slides/intro/variants.js +0 -11
  102. package/dist/e-cna/slides/intro/variants.js.map +0 -1
  103. package/dist/e-cna/slides/key_need_l1/index.d.ts +0 -1
  104. package/dist/e-cna/slides/key_need_l1/index.js +0 -18
  105. package/dist/e-cna/slides/key_need_l1/index.js.map +0 -1
  106. package/dist/e-cna/slides/key_need_l1/variants.d.ts +0 -26
  107. package/dist/e-cna/slides/key_need_l1/variants.js +0 -57
  108. package/dist/e-cna/slides/key_need_l1/variants.js.map +0 -1
  109. package/dist/e-cna/slides/key_need_l2/index.d.ts +0 -1
  110. package/dist/e-cna/slides/key_need_l2/index.js +0 -18
  111. package/dist/e-cna/slides/key_need_l2/index.js.map +0 -1
  112. package/dist/e-cna/slides/key_need_l2/variants.d.ts +0 -67
  113. package/dist/e-cna/slides/key_need_l2/variants.js +0 -139
  114. package/dist/e-cna/slides/key_need_l2/variants.js.map +0 -1
  115. package/dist/e-cna/slides/key_need_l3/index.d.ts +0 -1
  116. package/dist/e-cna/slides/key_need_l3/index.js +0 -18
  117. package/dist/e-cna/slides/key_need_l3/index.js.map +0 -1
  118. package/dist/e-cna/slides/key_need_l3/variants.d.ts +0 -11
  119. package/dist/e-cna/slides/key_need_l3/variants.js +0 -15
  120. package/dist/e-cna/slides/key_need_l3/variants.js.map +0 -1
  121. package/dist/e-cna/slides/math-perception/index.d.ts +0 -1
  122. package/dist/e-cna/slides/math-perception/index.js +0 -18
  123. package/dist/e-cna/slides/math-perception/index.js.map +0 -1
  124. package/dist/e-cna/slides/math-perception/variants.d.ts +0 -15
  125. package/dist/e-cna/slides/math-perception/variants.js +0 -32
  126. package/dist/e-cna/slides/math-perception/variants.js.map +0 -1
  127. package/dist/e-cna/slides/other_curriculum/index.d.ts +0 -1
  128. package/dist/e-cna/slides/other_curriculum/index.js +0 -18
  129. package/dist/e-cna/slides/other_curriculum/index.js.map +0 -1
  130. package/dist/e-cna/slides/other_curriculum/variants.d.ts +0 -12
  131. package/dist/e-cna/slides/other_curriculum/variants.js +0 -17
  132. package/dist/e-cna/slides/other_curriculum/variants.js.map +0 -1
  133. package/dist/e-cna/slides/school_performance_5_12/index.d.ts +0 -1
  134. package/dist/e-cna/slides/school_performance_5_12/index.js +0 -18
  135. package/dist/e-cna/slides/school_performance_5_12/index.js.map +0 -1
  136. package/dist/e-cna/slides/school_performance_5_12/variants.d.ts +0 -15
  137. package/dist/e-cna/slides/school_performance_5_12/variants.js +0 -26
  138. package/dist/e-cna/slides/school_performance_5_12/variants.js.map +0 -1
  139. package/dist/e-cna/slides/school_performance_kg_4/index.d.ts +0 -1
  140. package/dist/e-cna/slides/school_performance_kg_4/index.js +0 -18
  141. package/dist/e-cna/slides/school_performance_kg_4/index.js.map +0 -1
  142. package/dist/e-cna/slides/school_performance_kg_4/variants.d.ts +0 -14
  143. package/dist/e-cna/slides/school_performance_kg_4/variants.js +0 -28
  144. package/dist/e-cna/slides/school_performance_kg_4/variants.js.map +0 -1
  145. package/dist/e-cna/slides/secondary_needs/index.d.ts +0 -1
  146. package/dist/e-cna/slides/secondary_needs/index.js +0 -18
  147. package/dist/e-cna/slides/secondary_needs/index.js.map +0 -1
  148. package/dist/e-cna/slides/secondary_needs/variants.d.ts +0 -14
  149. package/dist/e-cna/slides/secondary_needs/variants.js +0 -28
  150. package/dist/e-cna/slides/secondary_needs/variants.js.map +0 -1
  151. package/dist/e-cna/slides/signup/index.d.ts +0 -1
  152. package/dist/e-cna/slides/signup/index.js +0 -18
  153. package/dist/e-cna/slides/signup/index.js.map +0 -1
  154. package/dist/e-cna/slides/signup/variants.d.ts +0 -7
  155. package/dist/e-cna/slides/signup/variants.js +0 -11
  156. package/dist/e-cna/slides/signup/variants.js.map +0 -1
  157. package/dist/e-cna/slides/signup_refer/index.d.ts +0 -1
  158. package/dist/e-cna/slides/signup_refer/index.js +0 -18
  159. package/dist/e-cna/slides/signup_refer/index.js.map +0 -1
  160. package/dist/e-cna/slides/signup_refer/variants.d.ts +0 -12
  161. package/dist/e-cna/slides/signup_refer/variants.js +0 -20
  162. package/dist/e-cna/slides/signup_refer/variants.js.map +0 -1
  163. package/dist/e-cna/slides/slot_pick/index.d.ts +0 -1
  164. package/dist/e-cna/slides/slot_pick/index.js +0 -18
  165. package/dist/e-cna/slides/slot_pick/index.js.map +0 -1
  166. package/dist/e-cna/slides/slot_pick/variants.d.ts +0 -12
  167. package/dist/e-cna/slides/slot_pick/variants.js +0 -16
  168. package/dist/e-cna/slides/slot_pick/variants.js.map +0 -1
  169. package/dist/e-cna/slides/teacher_intro/index.d.ts +0 -1
  170. package/dist/e-cna/slides/teacher_intro/index.js +0 -18
  171. package/dist/e-cna/slides/teacher_intro/index.js.map +0 -1
  172. package/dist/e-cna/slides/teacher_intro/variants.d.ts +0 -78
  173. package/dist/e-cna/slides/teacher_intro/variants.js +0 -116
  174. package/dist/e-cna/slides/teacher_intro/variants.js.map +0 -1
  175. package/dist/e-cna/utils/index.d.ts +0 -4
  176. package/dist/e-cna/utils/index.js +0 -28
  177. package/dist/e-cna/utils/index.js.map +0 -1
  178. package/dist/local-storage/index.d.ts +0 -13
  179. package/dist/local-storage/index.js +0 -172
  180. package/dist/local-storage/index.js.map +0 -1
  181. package/dist/object/index.d.ts +0 -6
  182. package/dist/object/index.js +0 -24
  183. package/dist/object/index.js.map +0 -1
  184. package/src/constants/country/index.ts +0 -2
  185. package/src/constants/country/iso-country-code.ts +0 -248
  186. package/src/constants/date-time/index.ts +0 -43
  187. package/src/constants/date-time/international-timezones.ts +0 -157
  188. package/src/constants/e-cna/index.ts +0 -55
  189. package/src/constants/index.ts +0 -2
  190. package/src/country/index.ts +0 -9
  191. package/src/date-time-helper/e-cna.ts +0 -205
  192. package/src/date-time-helper/index.ts +0 -365
  193. package/src/e-cna/flow/aggregator.ts +0 -12
  194. package/src/e-cna/flow/index.ts +0 -1
  195. package/src/e-cna/flow/variants/default.ts +0 -113
  196. package/src/e-cna/flow/variants/index.ts +0 -1
  197. package/src/e-cna/index.ts +0 -249
  198. package/src/e-cna/slides/child_hobbies/index.ts +0 -1
  199. package/src/e-cna/slides/child_hobbies/variants.ts +0 -24
  200. package/src/e-cna/slides/child_info/index.ts +0 -1
  201. package/src/e-cna/slides/child_info/variants.ts +0 -18
  202. package/src/e-cna/slides/child_personality/index.ts +0 -1
  203. package/src/e-cna/slides/child_personality/variants.ts +0 -12
  204. package/src/e-cna/slides/curriculum/index.ts +0 -1
  205. package/src/e-cna/slides/curriculum/variants.ts +0 -14
  206. package/src/e-cna/slides/grade/index.ts +0 -1
  207. package/src/e-cna/slides/grade/variants.ts +0 -29
  208. package/src/e-cna/slides/index.ts +0 -19
  209. package/src/e-cna/slides/intro/index.ts +0 -1
  210. package/src/e-cna/slides/intro/variants.ts +0 -7
  211. package/src/e-cna/slides/key_need_l1/index.ts +0 -1
  212. package/src/e-cna/slides/key_need_l1/variants.ts +0 -57
  213. package/src/e-cna/slides/key_need_l2/index.ts +0 -1
  214. package/src/e-cna/slides/key_need_l2/variants.ts +0 -143
  215. package/src/e-cna/slides/key_need_l3/index.ts +0 -1
  216. package/src/e-cna/slides/key_need_l3/variants.ts +0 -13
  217. package/src/e-cna/slides/math-perception/index.ts +0 -1
  218. package/src/e-cna/slides/math-perception/variants.ts +0 -30
  219. package/src/e-cna/slides/other_curriculum/index.ts +0 -1
  220. package/src/e-cna/slides/other_curriculum/variants.ts +0 -14
  221. package/src/e-cna/slides/school_performance_5_12/index.ts +0 -1
  222. package/src/e-cna/slides/school_performance_5_12/variants.ts +0 -23
  223. package/src/e-cna/slides/school_performance_kg_4/index.ts +0 -1
  224. package/src/e-cna/slides/school_performance_kg_4/variants.ts +0 -25
  225. package/src/e-cna/slides/secondary_needs/index.ts +0 -1
  226. package/src/e-cna/slides/secondary_needs/variants.ts +0 -26
  227. package/src/e-cna/slides/signup/index.ts +0 -1
  228. package/src/e-cna/slides/signup/variants.ts +0 -7
  229. package/src/e-cna/slides/signup_refer/index.ts +0 -1
  230. package/src/e-cna/slides/signup_refer/variants.ts +0 -16
  231. package/src/e-cna/slides/slot_pick/index.ts +0 -1
  232. package/src/e-cna/slides/slot_pick/variants.ts +0 -12
  233. package/src/e-cna/slides/teacher_intro/index.ts +0 -1
  234. package/src/e-cna/slides/teacher_intro/variants.ts +0 -114
  235. package/src/e-cna/utils/index.ts +0 -32
  236. package/src/local-storage/index.ts +0 -186
  237. package/src/object/index.ts +0 -26
@@ -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
- };
@@ -1,365 +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) {
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) {
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) => {
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) {
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) {
78
- const timeStamp = convertTimeStampToSeconds(datetime);
79
-
80
- return dayjs.unix(timeStamp).format(format);
81
- }
82
-
83
- export function getTimezone() {
84
- return Intl?.DateTimeFormat().resolvedOptions().timeZone;
85
- }
86
-
87
- export function timeToX(
88
- datetime: string | number | Date | dayjs.Dayjs | null | undefined,
89
- ) {
90
- dayjs.extend(relativeTime);
91
-
92
- return dayjs().to(datetime, true);
93
- }
94
-
95
- export function getCurrentDatebyTimezone(timezone: 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
- ) {
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
- // 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) {
156
- return new Date(demoTs * 1000).toISOString().replace(/-|:|\.\d\d\d/g, '');
157
- }
158
-
159
- export function getDateAfterDays(days: number) {
160
- return formatDateTime(dayjs().add(days, 'day'), 'D MMM, YYYY').toUpperCase();
161
- }
162
-
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) => {
180
- const formattedTimezone = timezones?.filter(
181
- currentTimezone => currentTimezone?.id === selectedTimezone,
182
- );
183
-
184
- if (formattedTimezone?.length) {
185
- return formattedTimezone[0]?.value;
186
- }
187
-
188
- return selectedTimezone?.replaceAll('_', ' ');
189
- };
190
-
191
- export const getHourInTwelveHourFormat = (hour: number) => {
192
- return hour % 12 === 0 ? 12 : hour % 12;
193
- };
194
-
195
- export const getMeridiemAccordingToHourAndHourFormat = (
196
- hour: number,
197
- hourFormat: number,
198
- meridiem = '',
199
- ) => {
200
- if (hourFormat === HOUR_FORMAT.TWENTY_FOUR_HOUR_FORMAT) {
201
- return hour / 12 >= 1 ? 'PM' : 'AM';
202
- }
203
-
204
- return hour === 12 ? 'PM' : meridiem;
205
- };
206
-
207
- export const getTimeSlotDuration = (selectedTime: number, selectedTimezone: any) => {
208
- const firstHour = getHourInTwelveHourFormat(selectedTime);
209
- const firstMeridiem = getMeridiemAccordingToHourAndHourFormat(
210
- selectedTime,
211
- HOUR_FORMAT.TWENTY_FOUR_HOUR_FORMAT,
212
- );
213
-
214
- const secondHour = getHourInTwelveHourFormat(selectedTime + 1);
215
- const secondMeridiem = getMeridiemAccordingToHourAndHourFormat(
216
- selectedTime + 1,
217
- HOUR_FORMAT.TWENTY_FOUR_HOUR_FORMAT,
218
- );
219
- const currentTimeZone =
220
- convertedTimezone(selectedTimezone)?.split('(') || selectedTimezone;
221
-
222
- return `${firstHour} ${firstMeridiem.toLowerCase()} - ${secondHour} ${secondMeridiem.toLowerCase()} (${currentTimeZone})`;
223
- };
224
-
225
- export const convertSecondsToMiliseconds = (seconds: number) => {
226
- return seconds * 1000;
227
- };
228
-
229
- // convert date into Sept 01, Thursday format
230
- export const convertDate = (selectedDate: number, selectedTimezone: string) => {
231
- const slotDate = formatTimestamp(selectedDate, 'DD-MM-YYYY');
232
- const dayOfWeek = dateByTimezone(selectedDate * 1000, selectedTimezone, 'dddd');
233
- const dateArr = slotDate?.split('-');
234
- const month = dateArr?.[1];
235
- const day = dateArr?.[0];
236
-
237
- return `${monthArray[parseInt(month, 10) - 1]} ${day}, ${dayOfWeek}`;
238
- };
239
-
240
- export const getModifiedDateSlots = (dateSlotsData: { label: string }[]) => {
241
- const startWeekIndex = shorthandWeekDayArray?.indexOf(dateSlotsData?.[0]?.label);
242
-
243
- // get all days
244
- let weekDays: { label: string; removeBorder?: boolean }[] = [];
245
-
246
- // while loop to check start date's day
247
- // for eg: if first date is wednesday, it will add blank days on monday, tuesday
248
- while (weekDays.length !== startWeekIndex) {
249
- weekDays.push({
250
- label: '',
251
- removeBorder: false,
252
- });
253
- }
254
- weekDays = [...weekDays, ...dateSlotsData];
255
-
256
- // while loop to add check end date
257
- // for eg: if last date end's on friday, it will add blank days on saturday and sunday
258
- while (weekDays.length % 7 !== 0) {
259
- weekDays.push({
260
- label: '',
261
- removeBorder: false,
262
- });
263
- }
264
- const weekRows = [];
265
-
266
- // divide weekDays in weeks group
267
- while (weekDays.length !== 0) {
268
- const row =
269
- weekDays?.length >= 7
270
- ? weekDays?.splice(0, 7)
271
- : weekDays?.splice(0, weekDays?.length);
272
-
273
- weekRows.push(row);
274
- }
275
-
276
- return weekRows;
277
- };
278
-
279
- // Array of 7 days
280
- export const getDates = (timezone: string) => {
281
- const currentDate = Date.parse(getCurrentDatebyTimezone(timezone)) / 1000;
282
- const dates = [];
283
-
284
- // getting dates by adding 86400 seconds(24 hours)
285
- for (let i = 0; i < 7; i++) {
286
- dates.push({
287
- futureDate: currentDate + TWENTY_FOUR_HOURS_IN_SECONDS * i,
288
- disabled: !(i > 1),
289
- });
290
- }
291
-
292
- return dates;
293
- };
294
-
295
- export function formatDateFromTimestamp(
296
- timestamp: string | number | Date,
297
- format: string,
298
- ) {
299
- const datetime = new Date(timestamp).toLocaleString('en-US');
300
-
301
- return dayjs(datetime).format(format || 'mm/dd/yyyy');
302
- }
303
-
304
- export function getAvailableDateSlots(currentTimezone: any) {
305
- const availableDateSlots: DateSlots[] = [];
306
-
307
- getDates(currentTimezone).map(item => {
308
- const { futureDate, disabled } = item;
309
-
310
- availableDateSlots.push({
311
- key: futureDate,
312
- label: formatDateFromTimestamp(futureDate * 1000, 'dd'),
313
- subLabel: formatDateFromTimestamp(futureDate * 1000, 'DD'),
314
- disabled,
315
- });
316
-
317
- return null;
318
- });
319
-
320
- return availableDateSlots;
321
- }
322
-
323
- export const toTimestamp = (strDate: string) => {
324
- return Date.parse(strDate) / 1000;
325
- };
326
-
327
- export const getDateSlots = (timezone: any) => {
328
- return getDates(timezone).map(item => {
329
- const { futureDate, disabled } = item;
330
-
331
- return {
332
- key: futureDate,
333
- label: dateByTimestamp(futureDate * 1000, 'dd'),
334
- subLabel: dateByTimestamp(futureDate * 1000, 'DD'),
335
- disabled,
336
- };
337
- });
338
- };
339
-
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) => {
350
- const timeArr = selectedTime.split(':');
351
- const firstHour = timeArr?.[0];
352
- const meridiem = timeArr?.[1]?.split(' ')?.[1];
353
-
354
- const secondHourInTwelveHourFormat = parseInt(firstHour, 10) + 1;
355
- const secondHour = getHourInTwelveHourFormat(secondHourInTwelveHourFormat);
356
- const secondMeridiem = getMeridiemAccordingToHourAndHourFormat(
357
- secondHourInTwelveHourFormat,
358
- HOUR_FORMAT.TWELVE_HOUR_FORMAT,
359
- meridiem,
360
- );
361
-
362
- return `${firstHour} ${meridiem.toLowerCase()} - ${secondHour} ${secondMeridiem.toLowerCase()}`;
363
- };
364
-
365
- export * from './e-cna';
@@ -1,12 +0,0 @@
1
- import { DEFAULT_FLOW, TLED_FLOW,TLED_FLOW_NON_ECNA } from './variants';
2
-
3
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
- export const getFlow = (flow: string) => {
5
- console.log("flowwww",flow)
6
- if(flow==='default'){
7
- return DEFAULT_FLOW
8
- }else if(flow==='non-ecna'){
9
- return TLED_FLOW_NON_ECNA;
10
- }
11
- return TLED_FLOW;
12
- };
@@ -1 +0,0 @@
1
- export * from './aggregator';
@@ -1,113 +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
- t_led_flow,
18
- curriculum,
19
- child_info
20
- } from '../../slides';
21
-
22
- export const DEFAULT_FLOW = {
23
- intro: intro.DEFAULT,
24
- grade: grade.DEFAULT,
25
- math_perception: math_perception.DEFAULT,
26
- school_performance_5_12: school_performance_5_12.DEFAULT,
27
- school_performance_kg_4: school_performance_kg_4.DEFAULT,
28
- key_need_l1: key_need_l1.DEFAULT,
29
- strong_math_foundation: key_need_l2.STRONG_MATH_FOUNDATION,
30
- mental_math: key_need_l2.MENTAL_MATH,
31
- learning_gaps: key_need_l2.LEARNING_GAPS,
32
- more_practice: key_need_l2.MORE_PRACTICE,
33
- develop_interest: key_need_l2.DEVELOP_INTEREST,
34
- advanced_and_competitive_maths: key_need_l2.ADVANCE_AND_COMPETITIVE_MATHS,
35
- key_need_l3: key_need_l3.DEFAULT,
36
- secondary_needs: secondary_needs.DEFAULT,
37
- child_personality: child_personality.DEFAULT,
38
- child_hobbies: child_hobbies.DEFAULT,
39
- slot_pick: slot_pick.DEFAULT,
40
- parent_student_details: signup.DEFAULT,
41
- other_curriculum: other_curriculum.DEFAULT,
42
- signup_refer: signup_refer.DEFAULT,
43
- curriculum: curriculum.DEFAULT,
44
- };
45
-
46
- export const TLED_FLOW={
47
- intro: intro.DEFAULT,
48
- // grade: t_led_flow.GRADE,
49
- grade: grade.DEFAULT,
50
- pick_slot:t_led_flow.PICK_SLOT,
51
- ready_to_enroll:t_led_flow.TRIAL_SESSION_PARENT,
52
- math_perception: math_perception.DEFAULT,
53
- school_performance_5_12: school_performance_5_12.DEFAULT,
54
- school_performance_kg_4: school_performance_kg_4.DEFAULT,
55
- key_need_l1: key_need_l1.ECNA,
56
- strong_math_foundation: key_need_l2.STRONG_MATH_FOUNDATION,
57
- mental_math: key_need_l2.MENTAL_MATH,
58
- learning_gaps: key_need_l2.LEARNING_GAPS,
59
- more_practice: key_need_l2.MORE_PRACTICE,
60
- develop_interest: key_need_l2.DEVELOP_INTEREST,
61
- advanced_and_competitive_maths: key_need_l2.ADVANCE_AND_COMPETITIVE_MATHS,
62
- key_need_l3: key_need_l3.DEFAULT,
63
- secondary_needs: secondary_needs.DEFAULT,
64
- child_personality: child_personality.DEFAULT,
65
- child_hobbies: child_hobbies.WITH_ECNA,
66
- child_info:child_info.DEFAULT,
67
- loader:child_info.LOADER,
68
- teacher_unavailability: t_led_flow.TEACHER_UNAVAILABILITY,
69
- hybrid_teacher:t_led_flow.HYBRID_TEACHER,
70
- trial_session:t_led_flow.TRIAL_SESSION,
71
- date_time_slot_pick:t_led_flow.DATE_TIME_SLOT_PICK,
72
- parent_details:t_led_flow.PARENT_DETAILS,
73
- otp:t_led_flow.OTP,
74
- trial_confirmed:t_led_flow.TRIAL_CONFIRMED,
75
- slot_pick: slot_pick.DEFAULT,
76
- signup_refer: signup_refer.DEFAULT,
77
- parent_student_details: signup.DEFAULT,
78
- other_curriculum: other_curriculum.DEFAULT,
79
- }
80
-
81
- export const TLED_FLOW_NON_ECNA={
82
- intro: intro.DEFAULT,
83
- grade: t_led_flow.GRADE,
84
- pick_slot:slot_pick.NON_ECNA,
85
- ready_to_enroll:t_led_flow.TRIAL_SESSION_PARENT,
86
- math_perception: math_perception.DEFAULT,
87
- school_performance_5_12: school_performance_5_12.DEFAULT,
88
- school_performance_kg_4: school_performance_kg_4.DEFAULT,
89
- key_need_l1: key_need_l1.DEFAULT,
90
- strong_math_foundation: key_need_l2.STRONG_MATH_FOUNDATION,
91
- child_info:child_info.CHILD_INFO,
92
- loader:child_info.LOADER,
93
- teacher_unavailability: t_led_flow.TEACHER_UNAVAILABILITY,
94
- hybrid_teacher:t_led_flow.HYBRID_TEACHER,
95
- trial_session:t_led_flow.TRIAL_SESSION,
96
- date_time_slot_pick:t_led_flow.DATE_TIME_SLOT_PICK,
97
- parent_details:t_led_flow.PARENT_DETAILS,
98
- otp:t_led_flow.OTP,
99
- trial_confirmed:t_led_flow.TRIAL_CONFIRMED,
100
- mental_math: key_need_l2.MENTAL_MATH,
101
- learning_gaps: key_need_l2.LEARNING_GAPS,
102
- more_practice: key_need_l2.MORE_PRACTICE,
103
- develop_interest: key_need_l2.DEVELOP_INTEREST,
104
- advanced_and_competitive_maths: key_need_l2.ADVANCE_AND_COMPETITIVE_MATHS,
105
- key_need_l3: key_need_l3.DEFAULT,
106
- secondary_needs: secondary_needs.DEFAULT,
107
- child_personality: child_personality.DEFAULT,
108
- child_hobbies: child_hobbies.DEFAULT,
109
- slot_pick: slot_pick.DEFAULT,
110
- signup_refer: signup_refer.DEFAULT,
111
- parent_student_details: signup.DEFAULT,
112
- other_curriculum: other_curriculum.DEFAULT,
113
- }
@@ -1 +0,0 @@
1
- export * from './default';