Skip to content

Commit c014bf1

Browse files
committed
added getBookableCallsign function
1 parent e669ec9 commit c014bf1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/components/BookingComponentv3.jsx

+12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ const BookingComponent = () => {
3939

4040
const acceptedFIRsRegex = /((EK[A-Z][A-Z]_)|(EF[A-Z][A-Z]_)|(BI[A-Z][A-Z]_)|(EN[A-Z][A-Z]_)|(ES[A-Z][A-Z]_))\w+/i;
4141

42+
function getBookableCallsign(callsign, frequency) {
43+
let correctedCallsign = callsign;
44+
positions.forEach(position => {
45+
if(position['frequency'] === frequency) {
46+
correctedCallsign = position['callsign'];
47+
}
48+
});
49+
return correctedCallsign;
50+
}
51+
4252
ControlCenterBookings.data.forEach(booking => {
4353
const bookingDate = new Date(booking.time_start).toISOString().split('T')[0];
4454
const dateIndex = dateArray.findIndex(dateObj => dateObj.date === bookingDate);
@@ -49,6 +59,8 @@ const BookingComponent = () => {
4959

5060
VATSIMNetworkData.controllers.forEach(session => {
5161
if (acceptedFIRsRegex.test(session.callsign)) {
62+
const correctedCallsign = getBookableCallsign(session.callsign, session.frequency);
63+
session.callsign = correctedCallsign;
5264
dateArray[0].data.push(session);
5365
}
5466
});

0 commit comments

Comments
 (0)