'use client'; import { Airport } from '@/app/_api/airport.types'; import { Metar } from '@/app/_api/metar.types'; import { FaArrowsSpin, FaLocationArrow } from 'react-icons/fa6'; import { Modal } from 'antd'; import Link from 'next/link'; import { AiFillStar, AiOutlineStar } from 'react-icons/ai'; import { useState } from 'react'; interface MetarDialogProps { airport: Airport; isOpen: boolean; onClose(): void; } export default function MetarDialog({ airport, isOpen, onClose }: MetarDialogProps) { const [isFavorite, setIsFavorite] = useState(false); function handleFavorite(value: boolean) { setIsFavorite(value); } function metarBGColor(metar: Metar | undefined) { if (metar?.flight_category == 'VFR') { return 'bg-emerald-600'; } else if (metar?.flight_category == 'MVFR') { return 'bg-blue-600'; } else if (metar?.flight_category == 'IFR') { return 'bg-red-600'; } else if (metar?.flight_category == 'LIFR') { return 'bg-purple-600'; } else { return 'bg-black'; } } function windColor(metar: Metar | undefined) { if (metar) { if (Number(metar.wind_speed_kt) <= 9) { return 'bg-green-300'; } else if (Number(metar.wind_speed_kt) <= 12) { return 'bg-orange-300'; } else { return 'bg-red-300'; } } else { return 'gb-gray-100'; } } return ( {airport.icao} {airport.full_name} {isFavorite ? ( handleFavorite(false)} /> ) : ( handleFavorite(true)} /> )} } open={isOpen} onCancel={onClose} closable={false} footer={[]} className='select-none' >

{airport.metar?.raw_text}

{airport.metar?.flight_category ? airport.metar?.flight_category : 'UNKN'}
{airport.metar && airport.metar.wind_dir_degrees && Number(airport.metar.wind_dir_degrees) > 0 ? ( ) : ( <> )} {airport.metar && airport.metar.wind_dir_degrees && airport.metar.wind_dir_degrees == 'VRB' ? ( ) : ( <> )} {airport.metar?.wind_speed_kt != undefined && airport.metar?.wind_speed_kt > 0 ? `${airport.metar?.wind_speed_kt} KT` : 'CALM'}
); }