From 725932c55de9614e7ec12d62b86ffcad2c27ed31 Mon Sep 17 00:00:00 2001 From: Gustavo Nogueira <83383362+Gugahnstn@users.noreply.github.com> Date: Tue, 25 Apr 2023 02:08:35 -0300 Subject: [PATCH 1/5] Update index.tsx --- src/templates/Header/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/Header/index.tsx b/src/templates/Header/index.tsx index 179d40b..4319cd5 100644 --- a/src/templates/Header/index.tsx +++ b/src/templates/Header/index.tsx @@ -23,7 +23,7 @@ const Header = () => { - IP: { !query ? query : "000.000.000" } + IP: { !query ? "000.000.000" : query } From 5b5a8dad9dfbd47bfe0772c7354c0b6aa436755f Mon Sep 17 00:00:00 2001 From: Gustavo Nogueira <83383362+Gugahnstn@users.noreply.github.com> Date: Mon, 2 Oct 2023 00:37:57 -0300 Subject: [PATCH 2/5] Development (#8) * feat: adicionando 'search-ip' ao projeto. * feat: adicionando a variavel 'requestQuery'. * feat: Adding a new link to capture the flags of the countries. * feat: Adding the 'requestDomainAndIp' variable and passing it as a parameter to the 'serviceIpApi' function. * feat: adding app.tsx * feat: adding types to SearchMap * feat: modifying types of the Data interface. * feat: adding a Footer to the project. * feat: adding style to the Footer. * style: adding z-index to the 'HeaderComponent' * feat: capitalizing the first letter of 'world connection'. * fix: removing the 'SearchMap' file and adding 'index.tsx'. * style: main style * feat: adding Footer * fix: removing the 'SearchMap' file and adding 'index.tsx'. --- src/App.tsx | 1 - src/components/CardResult/index.tsx | 2 +- src/components/SearchMap/index.tsx | 42 +++++++++++++++++++++++++++++ src/contexts/ip-search.tsx | 8 +++--- src/screens/Home/index.tsx | 2 ++ src/services/search-ip.ts | 4 +-- src/services/service-ip-api.ts | 8 ++++-- src/templates/Footer/index.tsx | 28 +++++++++++++++++++ src/templates/Footer/style.ts | 35 ++++++++++++++++++++++++ src/templates/Header/style.ts | 1 + src/templates/Hero/index.tsx | 4 +-- src/templates/Main/index.tsx | 13 +++++---- src/templates/Main/style.ts | 13 ++++++++- src/types/components.ts | 12 +++++++++ src/types/user.ts | 18 ++++++------- 15 files changed, 163 insertions(+), 28 deletions(-) create mode 100644 src/components/SearchMap/index.tsx create mode 100644 src/templates/Footer/index.tsx create mode 100644 src/templates/Footer/style.ts 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 = () => {
+