Skip to content

Commit 50d3113

Browse files
committed
change logic
1 parent d0d742d commit 50d3113

File tree

2 files changed

+15
-72
lines changed

2 files changed

+15
-72
lines changed

BookingPage.css

Lines changed: 8 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -187,88 +187,25 @@ th, td {
187187
margin-top: 10px;
188188
}
189189

190-
/* Main container styles */
191-
#soundbox-container {
192-
display: flex;
193-
flex-wrap: wrap;
194-
gap: 2%; /* Space between blocks */
195-
justify-content: center;
196-
padding: 2%;
197-
}
198-
199-
/* Soundbox block styles */
200-
.soundbox-block {
201-
width: 22%; /* Adjust block size (responsive) */
202-
aspect-ratio: 3/4; /* Maintain consistent proportions */
203-
display: flex;
204-
flex-direction: column;
205-
justify-content: space-between;
206-
background-color: var(--block-bg-color, lightblue);
207-
border: 2px solid #ddd;
208-
border-radius: 10px;
209-
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
210-
transition: transform 0.2s, background-color 0.2s;
211-
}
212-
213-
/* Hover effect for active blocks */
214-
.soundbox-block:hover {
215-
transform: translateY(-5px);
216-
background-color: #add8e6; /* Slightly darker blue */
217-
}
218-
219-
/* Header styles */
220-
.block-header {
221-
font-size: 1.2em;
222-
font-weight: bold;
223-
text-align: center;
224-
padding: 5%;
225-
background-color: var(--header-bg-color, #f4f4f4);
226-
border-bottom: 1px solid #ddd;
227-
border-radius: 10px 10px 0 0;
228-
}
229-
230-
/* Body styles */
231-
.block-body {
232-
flex-grow: 1;
233-
display: flex;
234-
justify-content: center;
235-
align-items: center;
236-
font-size: 1em;
237-
font-weight: normal;
238-
color: #333;
239-
}
240-
241-
/* Footer styles */
242-
.block-footer {
243-
padding: 5%;
244-
text-align: center;
245-
background-color: var(--footer-bg-color, #f9f9f9);
246-
border-radius: 0 0 10px 10px;
247-
}
248-
249-
/* Delete button */
250190
.delete-btn {
251-
padding: 5px 10px;
252-
font-size: 0.9em;
253-
background-color: #ff4d4f;
191+
background-color: #f44336;
254192
color: white;
255193
border: none;
256194
border-radius: 5px;
195+
padding: 5px 10px;
257196
cursor: pointer;
258-
transition: background-color 0.2s;
259197
}
260198

261199
.delete-btn:hover {
262-
background-color: #e63946;
200+
background-color: #d32f2f;
263201
}
264202

265-
/* No data block styles */
203+
/* No Data block styles */
266204
.no-data {
267-
background-color: #efefef;
268-
color: #aaa;
205+
background-color: lightgrey;
269206
display: flex;
270-
justify-content: center;
271207
align-items: center;
272-
font-size: 1em;
273-
border: 2px dashed #ccc;
208+
justify-content: center;
209+
color: #777;
210+
font-size: 14px;
274211
}

registedSoundBox.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ const timetable = [
1313
];
1414

1515
const container = document.getElementById('soundbox-container');
16+
function processSoundboxData(data) {
17+
return data
18+
.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp)) // Sort by time (descending)
19+
.slice(0, 6); // Select only the latest 6 entries
20+
}
1621

1722
function fetchData() {
1823
fetch('https://soundbox.v1an.xyz/getBookedSoundbox', { credentials: 'include' })
1924
.then(response => response.json())
20-
.then(data => renderSoundboxes(data))
25+
.then(data => renderSoundboxes(processSoundboxData(data)))
2126
.catch(error => console.error('Error fetching soundboxes:', error));
2227
}
2328

@@ -105,6 +110,7 @@ function handleDelete(soundboxID, date, block) {
105110
fetchData(); // Refresh data after deletion
106111
})
107112
.catch(error => console.error('Error unbooking soundbox:', error));
113+
location.reload();
108114
}
109115

110116
// Fetch and render data on page load

0 commit comments

Comments
 (0)