Skip to content

Commit

Permalink
fixed my fucked up merge
Browse files Browse the repository at this point in the history
  • Loading branch information
blt950 committed Jul 11, 2024
1 parent 3f3f5b4 commit 11ed7fb
Showing 1 changed file with 1 addition and 87 deletions.
88 changes: 1 addition & 87 deletions src/components/BookingsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
{Object.keys(scheduleByDate).map((date) => (
<div key={date}>
<table className="w-full px-2">
<thead>
<tr>
<th className="bg-[#132834] text-white w-full h-8 pt-1" colSpan={4}>
{getDayName(date, "en-US").charAt(0).toUpperCase() +
getDayName(date, "en-US").slice(1)}
</th>
</tr>
</thead>
<tbody>
{scheduleByDate[date].map((entry) => (
<tr key={entry.id}>
<td className="font-bold">{entry.callsign}</td>
<td>{bookingType(entry)}</td>
<td>{convertZulu(entry.time_start)}</td>
<td>{convertZulu(entry.time_end)}</td>
</tr>
))}
</tbody>

</table>
</div>
))}
</div>
);
};

export default ScheduleTable;
export default ScheduleTable;

0 comments on commit 11ed7fb

Please sign in to comment.