diff --git a/src/App.tsx b/src/App.tsx index 8b88c0d..e44ab26 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,7 +5,6 @@ import { GlobalStyle } from "./styles/global"; import theme from "./styles/theme"; import Home from "./screens/Home"; - const App = () => { return ( diff --git a/src/components/CardResult/index.tsx b/src/components/CardResult/index.tsx index 0c7f24e..fdb416c 100644 --- a/src/components/CardResult/index.tsx +++ b/src/components/CardResult/index.tsx @@ -9,7 +9,7 @@ const CardResult = ({ title, phrase, flag }: CardType) => { {!flag ? ( <> ) : ( - + )} {!phrase || phrase == undefined + "-" + undefined || undefined diff --git a/src/components/SearchMap/index.tsx b/src/components/SearchMap/index.tsx new file mode 100644 index 0000000..f06a212 --- /dev/null +++ b/src/components/SearchMap/index.tsx @@ -0,0 +1,42 @@ +import { SearchMapProps, ViewPort } from "../../types"; +import { useState, useEffect } from "react"; +import Map from "react-map-gl"; + +export const SearchMap = ({ longitude, latitude }: SearchMapProps) => { + const [viewPort, setViewPort] = useState({ + attributionControl: false, + longitude: longitude, + latitude: latitude, + zoom: 5, + }); + + const [screenWidth, setScreenWidth] = useState(); + + useEffect(() => { + setScreenWidth(() => { + let width = window.innerWidth; + const getWidth = width >= 768 ? 1280 : 420; + + return getWidth; + }) + }); + + useEffect(() => { + setViewPort({ + attributionControl: false, + longitude: longitude, + latitude: latitude, + zoom: viewPort.zoom, + }); + }, [longitude, latitude]); + + return ( + + ); +}; + diff --git a/src/contexts/ip-search.tsx b/src/contexts/ip-search.tsx index 00ec689..143f290 100644 --- a/src/contexts/ip-search.tsx +++ b/src/contexts/ip-search.tsx @@ -7,6 +7,7 @@ import { } from "react"; import serviceIpApi from "../services/service-ip-api"; import { Data, ipSearchType } from "../types"; +import searchIp from "../services/search-ip"; export const IpSearchContext = createContext({} as ipSearchType); @@ -15,8 +16,9 @@ export const IpSearchProvider = ({ children }: PropsWithChildren) => { const [search, setSearch] = useState(""); const settingIpApi = async () => { - const getServiceIpApi = await serviceIpApi(search); - console.log("olá"); + const query = await searchIp(); + const requestDomainAndIp = search || query; + const getServiceIpApi = await serviceIpApi(requestDomainAndIp); setData({ continent: getServiceIpApi.continent, flag: getServiceIpApi.countryCode, @@ -46,4 +48,4 @@ export const IpSearchProvider = ({ children }: PropsWithChildren) => { {children} ); -}; +}; \ No newline at end of file diff --git a/src/screens/Home/index.tsx b/src/screens/Home/index.tsx index 6d241a3..0b92191 100644 --- a/src/screens/Home/index.tsx +++ b/src/screens/Home/index.tsx @@ -1,6 +1,7 @@ import Header from '../../templates/Header'; import Hero from '../../templates/Hero'; import Main from '../../templates/Main'; +import Footer from '../../templates/Footer'; const Home = () => { return ( @@ -8,6 +9,7 @@ const Home = () => {
+