diff --git a/src/components/BookingsComponent.tsx b/src/components/BookingsComponent.tsx index 287bc88..ad6a4f3 100644 --- a/src/components/BookingsComponent.tsx +++ b/src/components/BookingsComponent.tsx @@ -82,90 +82,4 @@ const ScheduleTable: React.FC = () => { ); }; -export default ScheduleTable; -======= -import convertZulu from "../utils/convertZulu"; -import bookingType from "../utils/bookingType"; - -interface ScheduleEntry { - id: number; - callsign: string; - time_start: string; - time_end: string; - training: number; - event: number; - exam: number; - created_at: string; - updated_at: string; -} - -interface ScheduleData { - data: ScheduleEntry[]; -} - - - -let headers = new Headers({ - "Accept" : "application/json", - "Content-Type" : "application/json", - "User-Agent" : "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36" -}); - -const res = await fetch('https://cc.vatsim-scandinavia.org/api/bookings',{ - method : 'GET', - headers : headers -}) -var jsonData = await res.json() - - -function getDayName(dateStr: string, locale: string) { - var date = new Date(dateStr); - return date.toLocaleDateString(locale, { weekday: "long" }); -} - -const ScheduleTable: React.FC = () => { - // Organize data by date - const scheduleByDate = jsonData.data.reduce( - (acc: { [key: string]: ScheduleEntry[] }, entry) => { - const date = entry.time_start.split(" ")[0]; - if (!acc[date]) { - acc[date] = []; - } - acc[date].push(entry); - return acc; - }, - {} - ); - - return ( -
- {Object.keys(scheduleByDate).map((date) => ( -
- - - - - - - - {scheduleByDate[date].map((entry) => ( - - - - - - - ))} - - -
- {getDayName(date, "en-US").charAt(0).toUpperCase() + - getDayName(date, "en-US").slice(1)} -
{entry.callsign}{bookingType(entry)}{convertZulu(entry.time_start)}{convertZulu(entry.time_end)}
-
- ))} -
- ); -}; - -export default ScheduleTable; +export default ScheduleTable; \ No newline at end of file