From 8fbaca0d8ec9dc1323facb7f4c0029e32cfe5223 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 16 Jul 2023 00:38:39 -0400 Subject: Working travel advisor* --- app/travel-advisory/page.js | 62 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 13 deletions(-) (limited to 'app/travel-advisory/page.js') diff --git a/app/travel-advisory/page.js b/app/travel-advisory/page.js index 5db351c..f1442aa 100644 --- a/app/travel-advisory/page.js +++ b/app/travel-advisory/page.js @@ -1,4 +1,4 @@ -import { readFileSync } from "fs"; +import countriesData from './countries.json' assert { type: 'json' }; export const metadata = { title: 'Travel Advisory', @@ -6,12 +6,53 @@ export const metadata = { } export async function getCountries(){ - const files = readdirSync('./countries.json'); + const countries = countriesData.countries; + return countries.map((country) => { + let dangerLevel; + switch (country.status) { + case 0: + dangerLevel = "Take normal security precautions" + break; + case 1: + dangerLevel = "Exercise a high degree of caution" + break; + case 2: + dangerLevel = "Avoid non-essential travel" + break; + case 3: + dangerLevel = "Avoid all travel" + break; + } + return ( +
+
+

{country.name}

+

{dangerLevel}

+
+ + +
+

City 1

+

Take normal security precautions

+

City 2

+

Take normal security precautions

+

City 3

+

Take normal security precautions

+

City 4

+

Take normal security precautions

+
+
+
+
+ ) + }) } export default async function TravelAdvisory(){ + const countries = await getCountries(); return (
@@ -43,21 +84,16 @@ export default async function TravelAdvisory(){

This page may be inaccurate at times, refer to the Minecraft General Announcements channel for the latest updates

-
-
+ { /*
+

Country name

Take normal security precautions

-

City 1

-

Take normal security precautions

-

City 2

-

Take normal security precautions

-

City 3

-

Take normal security precautions

-

City 4

-

Take normal security precautions

+
+
-
+
*/ } + {countries}
) } -- cgit v1.2.3