diff --git a/.env.example b/.env.example
index d871cb0..b96a671 100644
--- a/.env.example
+++ b/.env.example
@@ -1,3 +1,4 @@
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=
+FLIGHT_RADAR_SANDBOX_FLAG="true"
FLIGHT_RADAR_TOKEN=
AVIATIONSTACK_API_TOKEN=
\ No newline at end of file
diff --git a/README.md b/README.md
index 8d18689..7b262d7 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,7 @@ Created by [@matiasngf](https://github.com/matiasngf) and [@delbaoliveira](https
- `NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN`: The map is generated using [Mapbox GL JS](https://docs.mapbox.com/mapbox-gl-js/api/).
- `FLIGHT_RADAR_TOKEN`: Real flight tracking data is provided by [flightradar24.com](https://www.flightradar24.com/). It requires a [subscription](https://fr24api.flightradar24.com/subscriptions-and-credits), but also provides a sandbox key.
+- `FLIGHT_RADAR_SANDBOX_FLAG`: Set this to `true` to use the sandbox environment of the FlightRadar24 API, which provides mock data for testing purposes. Set it to `false` to use the live environment.
- `AVIATIONSTACK_API_TOKEN`: The specific flight data is provided by [aviationstack.com](https://aviationstack.com/). The personal subscription is **free**. However, we found the API was unreliable, and to reduce the risk of showing an incomplete flight informationduring the keynote, we used mock data.
3. Navigate to [http://localhost:3000/explore/sfo](http://localhost:3000/explore/sfo) to see the demo.
diff --git a/app/flights/[id]/page.tsx b/app/flights/[id]/page.tsx
index fa3dd70..fece880 100644
--- a/app/flights/[id]/page.tsx
+++ b/app/flights/[id]/page.tsx
@@ -6,7 +6,9 @@ import { Suspense } from 'react';
export default async function Page({ params }) {
return (
<>
-
+ }>
+
+
}>
diff --git a/app/ui/plane-details.tsx b/app/ui/plane-details.tsx
index 5d68836..5e8deea 100644
--- a/app/ui/plane-details.tsx
+++ b/app/ui/plane-details.tsx
@@ -4,6 +4,7 @@ import Plane from './assets/plane.svg';
import Stars from './assets/stars.svg';
import { getPlaneDetails } from '../utils/get-plane-details';
import { PlaneDetailsType } from './types';
+import { Suspense } from 'react';
export async function PlaneDetails({
params,
@@ -14,60 +15,62 @@ export async function PlaneDetails({
const plane = (await getPlaneDetails(id)) as PlaneDetailsType;
return (
-
-
-
-
-
+ Loading plane details...
}>
+
+
+
-
-
-
-
-
+
+
+ {plane.model_name}/{plane.registration_number}
+
+
{plane.airline.name}
+
-
-
- {plane.model_name}/{plane.registration_number}
-
-
{plane.airline.name}
-
-
-
-
-
-
{plane.plane_age} years old
-
{plane.miles_flown} miles
+
+
+
+
{plane.plane_age} years old
+
{plane.miles_flown} miles
+
+
{plane.description}
-
{plane.description}
-
+
);
}
diff --git a/app/utils/get-flight-tracks.ts b/app/utils/get-flight-tracks.ts
index 98bc36e..431cd34 100644
--- a/app/utils/get-flight-tracks.ts
+++ b/app/utils/get-flight-tracks.ts
@@ -1,7 +1,11 @@
"use server"
export async function getFlightTracks(id: string) {
- const baseUrl = 'https://fr24api.flightradar24.com/api/flight-tracks';
+ const SANDBOX: boolean = process.env.FLIGHT_RADAR_SANDBOX_FLAG === 'true' ? true : false;
+
+ const baseUrl = SANDBOX ? 'https://fr24api.flightradar24.com/api/sandbox/flight-tracks' : 'https://fr24api.flightradar24.com/api/flight-tracks';
+
+ console.log('baseUrl', SANDBOX, baseUrl);
const query = new URLSearchParams({ flight_id: id });
diff --git a/app/utils/get-flights.ts b/app/utils/get-flights.ts
index 31dee99..bbaf36b 100644
--- a/app/utils/get-flights.ts
+++ b/app/utils/get-flights.ts
@@ -5,8 +5,11 @@ export async function getFlights(params: Promise<{ airport: string }>) {
const { airport } = await params;
const { latitude, longitude } = geocode(airport);
- const baseUrl =
- 'https://fr24api.flightradar24.com/api/live/flight-positions/full';
+ const SANDBOX: boolean = process.env.FLIGHT_RADAR_SANDBOX_FLAG === 'true' ? true : false;
+
+ const baseUrl = SANDBOX ? 'https://fr24api.flightradar24.com/api/sandbox/live/flight-positions/full' : 'https://fr24api.flightradar24.com/api/live/flight-positions/full';
+
+ console.log('baseUrl', SANDBOX, baseUrl);
const query = new URLSearchParams({
bounds: getBounds(latitude, longitude), // show planes within 60km of airport