From f72c967461cee8d935b4bfa4531c9d3429c3df1a Mon Sep 17 00:00:00 2001 From: Ruidy Date: Mon, 29 Mar 2021 11:52:07 +0200 Subject: [PATCH] move state over --- src/App.tsx | 22 ++------------ src/components/Footer.tsx | 10 ++++--- src/components/Navbar.tsx | 10 +++---- src/components/SearchBar.tsx | 18 ++++++++--- src/components/SideNav.tsx | 50 +++++++++++++------------------ src/constants.ts | 1 + src/containers/Category/index.tsx | 5 ++-- src/containers/Meal/index.tsx | 2 +- src/containers/NotFound/index.tsx | 9 ++---- src/layouts/MainLayout.tsx | 24 ++------------- src/layouts/PageLayout.tsx | 2 +- src/router/AppRouter.tsx | 4 +-- 12 files changed, 60 insertions(+), 97 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 68e315d..ab0a623 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,6 @@ import { FC, useState } from "react"; import { PreLoader } from "./components/PreLoader"; +import { buttonURL } from "./constants"; import "./index.css"; import MainLayout from "./layouts/MainLayout"; import { AppRouter } from "./router"; @@ -12,23 +13,11 @@ export const App: FC = () => { const [searchString, setSearchString] = useState(""); const [searchResults, setSearchResults] = useState({ meals: [] }); const [meal, setMeal] = useState(null); - const buttonUrl = "/random"; const getRandomMeal = () => { getData("random", setMeal); }; - const getSearchResults = (e) => { - searchString === "" - ? e.preventDefault() - : getData(searchString, setSearchResults, "search"); - }; - - const handleChange = (e) => { - const { value } = e.target; - setSearchString(value); - }; - return loading ? (
@@ -36,19 +25,12 @@ export const App: FC = () => { ) : ( - + ); diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 865094d..af71ab9 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -1,9 +1,11 @@ -import React from "react"; +import { FC } from "react"; +import { links } from "../constants"; import { CopyrightText } from "./CopyrightText"; -import { GitHubLink } from "./GitHubLink"; import { FooterLink } from "./FooterLink"; +import { GitHubLink } from "./GitHubLink"; -export const Footer = ({ links }) => { +export const Footer: FC = () => { + const footerLinks = [...links, "random"]; return (