Skip to content

Instantly share code, notes, and snippets.

@CodeAkinori
Created May 22, 2024 14:09
Show Gist options
  • Select an option

  • Save CodeAkinori/b0e4e76e7df2b0ec72f7f4f70ed7b257 to your computer and use it in GitHub Desktop.

Select an option

Save CodeAkinori/b0e4e76e7df2b0ec72f7f4f70ed7b257 to your computer and use it in GitHub Desktop.

Revisions

  1. CodeAkinori created this gist May 22, 2024.
    49 changes: 49 additions & 0 deletions index.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    import { useEffect, useState } from "react"
    import { useParams } from "react-router-dom"

    import HeaderProfile from "../../components/HeaderProfile"
    import BannerDish from "../../components/BannerDish"
    import DishCard from "../../components/DishCard"

    import { ContainerList } from "./styles"

    export type dish =
    {
    id: number
    foto: string
    preco: number
    nome: string
    descricao: string
    porcao: string
    }

    export type Cardapio = {
    id?: number,
    titulo?: string,
    capa?: string,
    tipo?: string,
    cardapio: dish[]
    }

    const Profile = () => {
    const { id } = useParams()
    const [perfil, setPerfil] = useState<Cardapio>({} as Cardapio)

    useEffect(() => {
    fetch(`https://fake-api-tau.vercel.app/api/efood/restaurantes/${id}`)
    .then((res) => res.json())
    .then((res) => setPerfil(res))
    }, [id])

    return (
    <>
    <HeaderProfile />
    <BannerDish nome={perfil.titulo} tipo={perfil.tipo} urlImage={perfil.capa} />
    <ContainerList>
    <DishCard cardapio={perfil.cardapio} />
    </ContainerList>
    </>
    )
    }

    export default Profile