-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
48 lines (44 loc) · 1.16 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// utils.js
export const generateDate = () => {
const date = new Date();
let weekday = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
let weekdays = [];
for (let i = 0; i < 7; i++) {
let tempDate = {
date: new Date(date.getTime() + i * 24 * 60 * 60 * 1000).getDate(),
day: weekday[new Date(date.getTime() + i * 24 * 60 * 60 * 1000).getDay()],
};
weekdays.push(tempDate);
}
return weekdays;
};
export const generateSeats = () => {
let numRow = 8;
let numColumn = 3;
let rowArray = [];
let start = 1;
let reachnine = false;
for (let i = 0; i < numRow; i++) {
let columnArray = [];
for (let j = 0; j < numColumn; j++) {
let seatObject = {
number: start,
taken: Boolean(Math.round(Math.random())),
selected: false,
};
columnArray.push(seatObject);
start++;
}
if (i === 3) {
numColumn += 2;
}
if (numColumn < 9 && !reachnine) {
numColumn += 2;
} else {
reachnine = true;
numColumn -= 2;
}
rowArray.push(columnArray);
}
return rowArray;
};