Repository navigation
Expand file tree
/
Copy pathseed-rooms.js
More file actions
121 lines (109 loc) · 3.14 KB
/
Copy pathseed-rooms.js
File metadata and controls
121 lines (109 loc) · 3.14 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Room seeding script - run with: node seed-rooms.js
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, addDoc, serverTimestamp } from 'firebase/firestore';
// Your Firebase config
const firebaseConfig = {
apiKey: "AIzaSyCzAbp9F8HKFl4tkwR6tYFQs5g51XsDYVA",
authDomain: "room-status-dashboard.firebaseapp.com",
projectId: "room-status-dashboard",
storageBucket: "room-status-dashboard.firebasestorage.app",
messagingSenderId: "557809034013",
appId: "1:557809034013:web:270fdb30a9cda72ef7b7f4",
measurementId: "G-QPMC7LQRNY"
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
// Parse room data
const rooms = [];
// 2 Bed AC Room: 201, 206, 207, 108
[201, 206, 207, 108].forEach(num => {
rooms.push({
roomNumber: String(num),
roomType: '2 Bed AC',
floor: String(Math.floor(num / 100)),
status: 'vacant_ready',
guestName: '',
checkinTime: '',
checkoutTime: '',
previousGuest: '',
notes: '',
cleaningStarted: '',
cleaningCompleted: '',
updatedBy: 'System',
createdAt: serverTimestamp(),
updatedAt: serverTimestamp(),
});
});
// 2 Bed NON AC Room: 105-107, 301, 302, 303, 304, 306, 307, 308, 309, 311, 312
// 105-107 means 105, 106, 107
[105, 106, 107, 301, 302, 303, 304, 306, 307, 308, 309, 311, 312].forEach(num => {
rooms.push({
roomNumber: String(num),
roomType: '2 Bed Non AC',
floor: String(Math.floor(num / 100)),
status: 'vacant_ready',
guestName: '',
checkinTime: '',
checkoutTime: '',
previousGuest: '',
notes: '',
cleaningStarted: '',
cleaningCompleted: '',
updatedBy: 'System',
createdAt: serverTimestamp(),
updatedAt: serverTimestamp(),
});
});
// 4 Bed AC Room: 102, 202, 204, 205, 310
[102, 202, 204, 205, 310].forEach(num => {
rooms.push({
roomNumber: String(num),
roomType: '4 Bed AC',
floor: String(Math.floor(num / 100)),
status: 'vacant_ready',
guestName: '',
checkinTime: '',
checkoutTime: '',
previousGuest: '',
notes: '',
cleaningStarted: '',
cleaningCompleted: '',
updatedBy: 'System',
createdAt: serverTimestamp(),
updatedAt: serverTimestamp(),
});
});
// 4 Bed Non AC Room: 101, 103, 109, 305, 313
[101, 103, 109, 305, 313].forEach(num => {
rooms.push({
roomNumber: String(num),
roomType: '4 Bed Non AC',
floor: String(Math.floor(num / 100)),
status: 'vacant_ready',
guestName: '',
checkinTime: '',
checkoutTime: '',
previousGuest: '',
notes: '',
cleaningStarted: '',
cleaningCompleted: '',
updatedBy: 'System',
createdAt: serverTimestamp(),
updatedAt: serverTimestamp(),
});
});
async function seedRooms() {
const roomsRef = collection(db, 'rooms');
console.log(`Seeding ${rooms.length} rooms...`);
for (const room of rooms) {
try {
await addDoc(roomsRef, room);
console.log(`✓ Added room ${room.roomNumber} (${room.roomType}, Floor ${room.floor})`);
} catch (error) {
console.error(`✗ Failed room ${room.roomNumber}:`, error.message);
}
}
console.log('Done!');
process.exit(0);
}
seedRooms().catch(console.error);