diff --git a/front/src/pages/Booking.svelte b/front/src/pages/Booking.svelte index 194df16..ae9364a 100644 --- a/front/src/pages/Booking.svelte +++ b/front/src/pages/Booking.svelte @@ -4,6 +4,20 @@ import { expandOnTyping } from "../lib/utils"; import Calendar from "../components/Calendar.svelte"; + const timeSlots = { + slot0: "8am to 10am", + slot1: "10am to 12am", + slot2: "12am to 2pm", + slot3: "2pm to 4pm", + slot4: "4pm to 6pm", + slot5: "6pm to 8pm", + slot6: "8pm to 10pm", + } + const tables = { + table1: "Table 1", + table2: "Table 2", + table3: "Table 3", + } const specialRequestsMax = 300; const today = new Date(); @@ -21,6 +35,29 @@ let dateValid = true; let specialRequestsValid = true; + function formatDate(date: Date) { + let formattedDate = new Intl.DateTimeFormat( + 'en-UK', + { + year: 'numeric', + month: 'long', + day: 'numeric' + } + ).format(date); + + // Add the ordinal suffix + let day = date.getDate(); + let suffix = 'th'; + if (day % 10 === 1 && day !== 11) { + suffix = 'st'; + } else if (day % 10 === 2 && day !== 12) { + suffix = 'nd'; + } else if (day % 10 === 3 && day !== 13) { + suffix = 'rd'; + } + return formattedDate.replace(`${day}`, day + suffix); + } + function validateName() { nameValid = name.length > 1} function validateEmail() { emailValid = email.length > 1} function validateTelephone() { telephoneValid = telephone.length == 11} @@ -210,12 +247,22 @@
- I want to stay at table {tableSlot || "Table 1"}, on {date || "a pleasant day"}, {timeSlot || "during the day"}.
-
- I request "{specialRequests || "a nice stay"}".
-
- If I need to be contacted, my name is {name || "Unknown"},
- email {email || "Missing"} or alternatively call me on {telephone || "nothing"}.
+ On
+ {date ? `the ${formatDate(date)}` : "an undecided date"}
+ at
+ {timeSlot ? timeSlots[timeSlot] : "an undecided time"},
+ I want to be seated at
+ {tableSlot ? tables[tableSlot] : "a table"}.
+
+ I request
+ {specialRequests ? specialRequests : "nothing in particular"}.
+
+ My name is
+ {name ? name : "Unknown"},
+ in the event I need to be contacted by email, you can do that at
+ {email ? email : "an empty email"},
+ or alternatively call me on
+ {telephone ? telephone : "an empty phone number"}.