diff options
| author | Andrew Lee <andrew@alee14.me> | 2025-01-10 09:32:09 -0500 |
|---|---|---|
| committer | Andrew Lee <andrew@alee14.me> | 2025-01-10 09:32:09 -0500 |
| commit | 35fb56c3bf8c65506363e229fb69c76a603aee62 (patch) | |
| tree | 94d1528414e75fa072dd9a1081cc8587f6194d45 /app/visas | |
| parent | 605bc321bb48a9eaf43cc272a03e59338d784610 (diff) | |
| download | alure-website-35fb56c3bf8c65506363e229fb69c76a603aee62.tar.gz alure-website-35fb56c3bf8c65506363e229fb69c76a603aee62.tar.bz2 alure-website-35fb56c3bf8c65506363e229fb69c76a603aee62.zip | |
Travel advisory, added visa page
Diffstat (limited to 'app/visas')
| -rw-r--r-- | app/visas/HistoryModal.js | 40 | ||||
| -rw-r--r-- | app/visas/ListCountries.js | 51 | ||||
| -rw-r--r-- | app/visas/page.js | 16 |
3 files changed, 107 insertions, 0 deletions
diff --git a/app/visas/HistoryModal.js b/app/visas/HistoryModal.js new file mode 100644 index 0000000..6d4df91 --- /dev/null +++ b/app/visas/HistoryModal.js @@ -0,0 +1,40 @@ +const HistoryModal = ({ isVisible, onClose, countries, dangerLevel, visaInfo }) => { + if (!isVisible) return null; + const handleClose = (e) => { + if(e.target.id === 'wrapper') onClose(); + } + + let historyList; + if (visaInfo && visaInfo.length > 0) { + historyList = visaInfo.map((event, index) => { + return ( + <li key={index}>{event}</li> + ) + }) + } else { + historyList = <li>No additional information for {countries}.</li>; + } + + return ( + <div id="wrapper" className="fixed inset-0 bg bg-opacity-25 backdrop-blur-sm flex justify-center items-center" onClick={handleClose}> + <div className="w-[700px]"> + <div className="flex flex-col"> + <div className="bg-zinc-800 p-5 rounded-lg border border-gray-700"> + <div className="divide-y space-y-3"> + <div> + <h1 className="font-medium text-3xl">{countries}</h1> + <h2 className="font-medium text-xl">{dangerLevel}</h2> + </div> + <div> + <h1 className="font-medium text-2xl pt-3">Additional Information</h1> + <ul>{historyList}</ul> + </div> + </div> + </div> + </div> + </div> + </div> + ) +} + +export default HistoryModal; diff --git a/app/visas/ListCountries.js b/app/visas/ListCountries.js new file mode 100644 index 0000000..6ca1863 --- /dev/null +++ b/app/visas/ListCountries.js @@ -0,0 +1,51 @@ +"use client" +import countriesData from '@/app/countries.json' assert { type: 'json' }; +import HistoryModal from "@/app/visas/HistoryModal"; +import { useState } from "react"; + +export function getDangerLevel(danger, override) { + if (danger === 0 && override !== undefined) { + danger = override; + } + + let dangerLevel; + switch (danger) { + case false: + dangerLevel = "Visa not required" + break; + case true: + dangerLevel = "Visa required" + break; + } + + return dangerLevel; +} + +export function Countries(){ + // eslint-disable-next-line react-hooks/rules-of-hooks + const [showModal, setShowModal] = useState(false); + const [selectedCountry, setSelectedCountry] = useState(null); + const [selectedDangerLevel, setSelectedDangerLevel] = useState(null); + const [selectedCountryHistory, setSelectedCountryHistory] = useState(null); + const countries = countriesData.countries; + + return countries.map((country) => { + let dangerLevel = getDangerLevel(country.visa); + + return ( + <div key={country.name} id={country.url} className="bg-center bg-no-repeat bg-[image:var(--image-url)] bg-gray-500 bg-blend-multiply" style={{'--image-url': `url(${country.image})`}} > + <div className="sm:px-40 px-10 py-10 space-y-3"> + <h1 className="font-medium md:text-5xl text-3xl">{country.name}</h1> + <h2 className="text-lg">{dangerLevel}</h2> + <button className="transition duration-200 ease-in-out px-4 py-2 font-medium rounded-full bg-blue-600 hover:bg-blue-700 active:bg-blue-800" onClick={()=> { + setSelectedCountry(country.name); + setSelectedDangerLevel(dangerLevel) + setSelectedCountryHistory(country.visaInfo) + setShowModal(true) + }}>Information</button> + </div> + <HistoryModal isVisible={showModal} onClose={() => setShowModal(false)} countries={selectedCountry} dangerLevel={selectedDangerLevel} visaInfo={selectedCountryHistory} /> + </div> + ) + }) +} diff --git a/app/visas/page.js b/app/visas/page.js new file mode 100644 index 0000000..eb5ba3c --- /dev/null +++ b/app/visas/page.js @@ -0,0 +1,16 @@ +import { Countries } from "./ListCountries"; +import Header from "../components/Header"; + +export const metadata = { + title: 'Visas', + description: 'Information whether a country is required a visa or not. ', +} + +export default async function TravelAdvisory(){ + return ( + <main className="flex flex-col"> + <Header title={metadata.title} description={metadata.description} /> + <Countries /> + </main> + ) +} |
