@cuemath/web-utils 1.0.6-beta.0 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuemath/web-utils",
3
- "version": "1.0.6-beta.0",
3
+ "version": "1.0.6",
4
4
  "description": "Shared web utils package",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -41,7 +41,6 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@types/node": "^18.11.18",
44
- "dayjs": "^1.11.7",
45
- "moment-timezone": "^0.5.42"
44
+ "dayjs": "^1.11.7"
46
45
  }
47
46
  }
@@ -35,70 +35,6 @@ export const weekDayArray: string[] = [
35
35
  'Saturday',
36
36
  ];
37
37
 
38
- export const TIME_SLOT_BOOK_DATA = [
39
- [
40
- {
41
- key: '10:00 AM',
42
- label: '10 am',
43
- disabled: false,
44
- },
45
- {
46
- key: '11:00 AM',
47
- label: '11 am',
48
- disabled: false,
49
- },
50
- {
51
- key: '12:00 PM',
52
- label: '12 pm',
53
- disabled: false,
54
- },
55
- ],
56
- [
57
- {
58
- key: '1:00 PM',
59
- label: '1 pm',
60
- disabled: false,
61
- },
62
- {
63
- key: '2:00 PM',
64
- label: '2 pm',
65
- disabled: false,
66
- },
67
- {
68
- key: '3:00 PM',
69
- label: '3 pm',
70
- disabled: false,
71
- },
72
- {
73
- key: '4:00 PM',
74
- label: '4 pm',
75
- disabled: false,
76
- },
77
- ],
78
- [
79
- {
80
- key: '5:00 PM',
81
- label: '5 pm',
82
- disabled: false,
83
- },
84
- {
85
- key: '6:00 PM',
86
- label: '6 pm',
87
- disabled: false,
88
- },
89
- {
90
- key: '7:00 PM',
91
- label: '7 pm',
92
- disabled: false,
93
- },
94
- {
95
- key: '8:00 PM',
96
- label: '8 pm',
97
- disabled: false,
98
- },
99
- ],
100
- ];
101
-
102
38
  export const TWENTY_FOUR_HOURS_IN_SECONDS: number = 24 * 60 * 60; // 86400
103
39
 
104
40
  export const HOUR_FORMAT = {
@@ -137,32 +137,3 @@ export const convertedTimezone = (selectedTimezone: string): string => {
137
137
  export const convertSecondsToMiliseconds = (seconds: number) => {
138
138
  return seconds * 1000;
139
139
  };
140
-
141
- const toTimestamp = (strDate: string) => {
142
- return Date.parse(strDate) / 1000;
143
- };
144
-
145
- export function convertTZ(date: string, tzString: string) {
146
- return new Date(
147
- (typeof date === 'string' ? new Date(date) : date).toLocaleString('en-US', {
148
- timeZone: tzString,
149
- }),
150
- );
151
- }
152
-
153
- export function getUtcTimestamp(timezone: string, date: string) {
154
- const time = convertTZ(date, timezone);
155
-
156
- const parsedDate = Date.parse(time.toISOString());
157
-
158
- return parsedDate / 1000;
159
- }
160
-
161
- export const getUtcUnixTimestamp = (date: number, time: string, timezone: string) => {
162
- const formatDate = formatTimestamp(date, 'MM/DD/YYYY');
163
- const convertedDatTime = dateTimeByTimezone(
164
- toTimestamp(`${formatDate} ${time}`) * 1000,
165
- );
166
-
167
- return getUtcTimestamp(timezone, convertedDatTime);
168
- };
@@ -1,15 +1,5 @@
1
- import momentTz from 'moment-timezone';
2
-
3
- import {
4
- TWENTY_FOUR_HOURS_IN_SECONDS,
5
- TIME_SLOT_BOOK_DATA,
6
- } from '../constants/date-time';
7
- import {
8
- getCurrentDatebyTimezone,
9
- convertSecondsToMiliseconds,
10
- dateByTimestamp,
11
- getUtcUnixTimestamp,
12
- } from '../date-time-helper/index';
1
+ import { TWENTY_FOUR_HOURS_IN_SECONDS } from '../constants/date-time';
2
+ import { getCurrentDatebyTimezone } from '../date-time-helper/index';
13
3
 
14
4
  // if adding any change in this function, then need update at all the places where we are using this function in website and astro
15
5
  export const getDates = (
@@ -31,44 +21,3 @@ export const getDates = (
31
21
 
32
22
  return dates;
33
23
  };
34
-
35
- export const getDateSlots = (activeDate: string, timezone: string) => {
36
- return getDates(timezone).map(item => {
37
- const { futureDate, disabled } = item;
38
-
39
- const miliseconds = convertSecondsToMiliseconds(futureDate);
40
-
41
- return {
42
- key: futureDate,
43
- label: dateByTimestamp(miliseconds, 'dd'),
44
- subLabel: dateByTimestamp(miliseconds, 'DD'),
45
- disabled,
46
- alreadySelected: activeDate === dateByTimestamp(miliseconds, 'DD'),
47
- };
48
- });
49
- };
50
-
51
- export const appSlots = (timezone: string) => {
52
- const allSlots = getDateSlots('', timezone).map(data => {
53
- return {
54
- date: momentTz.unix(data.key).tz(timezone, true),
55
- time_slots: TIME_SLOT_BOOK_DATA.flatMap(slot => {
56
- return slot.map(slotObj => {
57
- const utcUnixTimestamp = getUtcUnixTimestamp(data.key, slotObj.key, timezone);
58
-
59
- return {
60
- time: momentTz.unix(utcUnixTimestamp).tz(timezone, true),
61
- disabled: data.disabled,
62
- type: 'STATIC',
63
- };
64
- });
65
- }),
66
- };
67
- });
68
-
69
- const availableSlots = allSlots.filter(data =>
70
- data.time_slots.some(value => value?.disabled === false),
71
- );
72
-
73
- return availableSlots;
74
- };