Move TIME_OPTIONS outside component

- TIME_OPTIONS is now computed at module level, not inside component
- generateTimeOptions now accepts slotDurationMinutes as parameter
- Prevents unnecessary recomputation on every render
This commit is contained in:
counterweight 2025-12-21 17:53:17 +01:00
parent 02212ba478
commit 40b193238e
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C

View file

@ -29,7 +29,8 @@ function getDateRange(): Date[] {
} }
// Generate time options for dropdowns (15-min intervals) // Generate time options for dropdowns (15-min intervals)
function generateTimeOptions(): string[] { // Moved outside component since slotDurationMinutes is a constant
function generateTimeOptions(slotDurationMinutes: number): string[] {
const options: string[] = []; const options: string[] = [];
for (let h = 0; h < 24; h++) { for (let h = 0; h < 24; h++) {
for (let m = 0; m < 60; m += slotDurationMinutes) { for (let m = 0; m < 60; m += slotDurationMinutes) {
@ -41,7 +42,7 @@ function generateTimeOptions(): string[] {
return options; return options;
} }
const TIME_OPTIONS = generateTimeOptions(); const TIME_OPTIONS = generateTimeOptions(slotDurationMinutes);
interface EditSlot { interface EditSlot {
start_time: string; start_time: string;