From 7d9d32558f327e6ee3ff70af47297249615ec74c Mon Sep 17 00:00:00 2001 From: Ben Sherriff Date: Fri, 15 Sep 2023 09:27:55 -0400 Subject: [PATCH] started working on favorites --- .../app/_components/Metars/MetarDialog.tsx | 45 ++++++++++++++-- .../src/app/_components/Topbar/index.tsx | 51 +++++-------------- 2 files changed, 56 insertions(+), 40 deletions(-) diff --git a/weather-ui/src/app/_components/Metars/MetarDialog.tsx b/weather-ui/src/app/_components/Metars/MetarDialog.tsx index 910457c..083896d 100644 --- a/weather-ui/src/app/_components/Metars/MetarDialog.tsx +++ b/weather-ui/src/app/_components/Metars/MetarDialog.tsx @@ -1,7 +1,12 @@ +'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; @@ -10,6 +15,12 @@ interface MetarDialogProps { } 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'; @@ -34,13 +45,41 @@ export default function MetarDialog({ airport, isOpen, onClose }: MetarDialogPro } } 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'} diff --git a/weather-ui/src/app/_components/Topbar/index.tsx b/weather-ui/src/app/_components/Topbar/index.tsx index b280d2e..067cd44 100644 --- a/weather-ui/src/app/_components/Topbar/index.tsx +++ b/weather-ui/src/app/_components/Topbar/index.tsx @@ -1,9 +1,8 @@ 'use client'; -import { AutoComplete, Avatar, Modal } from 'antd'; +import { AutoComplete, Avatar } from 'antd'; import Link from 'next/link'; -import { AiOutlineSearch, AiOutlineUser } from 'react-icons/ai'; -import { Button } from '@blueprintjs/core'; +import { AiOutlineUser } from 'react-icons/ai'; import { useState } from 'react'; import { getAirports } from '@/app/_api/airport'; import { useRouter } from 'next/navigation'; @@ -11,7 +10,6 @@ import { useRouter } from 'next/navigation'; const DEFAULT_ICON_SIZE = 40; export default function Topbar() { - const [modalOpen, setModalOpen] = useState(false); const [searchValue, setSearchValue] = useState(''); const [airports, setAirports] = useState<{ key: string; value: string; label: string }[]>([]); const router = useRouter(); @@ -29,49 +27,28 @@ export default function Topbar() { } function onSelect(value: string) { - setModalOpen(false); setSearchValue(''); router.push(`/airport/${value}`); } - function onClose() { - setModalOpen(false); - setSearchValue(''); - } - return ( <> - - -