diff --git a/next/components/atoms/GreenTab.js b/next/components/atoms/GreenTab.js index cb3819e5..3a3eff03 100644 --- a/next/components/atoms/GreenTab.js +++ b/next/components/atoms/GreenTab.js @@ -4,6 +4,7 @@ import { Tab } from "@chakra-ui/tabs"; export default function GreenTab({ children, ...style }) { return ( - - + + Deletar table Você tem certeza em deletar esse table? Uma vez deletada, todas as informações dele e de Columns serão excluídas em consequência. diff --git a/next/components/molecules/Menu.js b/next/components/molecules/Menu.js index 0b35f60e..7a06e059 100644 --- a/next/components/molecules/Menu.js +++ b/next/components/molecules/Menu.js @@ -1,12 +1,12 @@ import { Box, + Stack, HStack, VStack, Drawer, DrawerOverlay, DrawerContent, useDisclosure, - Avatar, Text, Accordion, AccordionItem, @@ -15,16 +15,20 @@ import { AccordionIcon, useBoolean, Divider, + Image, + Menu, + MenuButton, + MenuList, + MenuItem } from "@chakra-ui/react"; import { useEffect, useRef, useState } from "react"; import { useRouter } from "next/router" -import { MenuDropdown } from "./MenuDropdown"; import cookies from "js-cookie"; -import { useCheckMobile } from "../../hooks/useCheckMobile.hook" +import { MenuDropdown } from "./MenuDropdown"; +import { isMobileMod, useCheckMobile } from "../../hooks/useCheckMobile.hook" import ControlledInput from "../atoms/ControlledInput"; import Link from "../atoms/Link"; import RoundedButton from "../atoms/RoundedButton"; -import SectionText from "../atoms/SectionText"; import BDLogoProImage from "../../public/img/logos/bd_logo_pro"; import BDLogoEduImage from "../../public/img/logos/bd_logo_edu"; @@ -33,8 +37,12 @@ import FarBarsIcon from "../../public/img/icons/farBarsIcon"; import SearchIcon from "../../public/img/icons/searchIcon"; import CrossIcon from "../../public/img/icons/crossIcon"; import RedirectIcon from "../../public/img/icons/redirectIcon"; +import SettingsIcon from "../../public/img/icons/settingsIcon"; +import SignOutIcon from "../../public/img/icons/signOutIcon"; function MenuDrawer({ isOpen, onClose, links }) { + let userData = cookies.get("user") || null + return ( @@ -55,6 +63,7 @@ function MenuDrawer({ isOpen, onClose, links }) { minWidth="100px" height="38px" fontSize="20px" + borderRadius="30px" onClick={() => window.open(b.href, "_blank")} > {b.name} @@ -118,11 +127,351 @@ function MenuDrawer({ isOpen, onClose, links }) { } })} + + {userData ? + <> + : + + window.open("/user/login", "_self")} + > + Entrar + + window.open("/user/register", "_self")} + > + Cadastrar + + + } ); } +function MenuDrawerUser({ isOpen, onClose}) { + const router = useRouter() + let userData = cookies.get("user") || null + if(userData !== null) userData = JSON.parse(cookies.get("user")) + + const links = [ + {name: "Perfil público", value: "profile"}, + {name: "Conta", value: "account"}, + {name: "Senha", value: "new_password"}, + {name: "Planos e pagamento", value: "plans_and_payment"}, + {name: "Acessos", value: "accesses"}, + ] + + return ( + + + + window.open("/", "_self")} + /> + + + + + + {userData?.username ? userData?.username : "Dadinho"} + {userData?.email ? userData?.email : "dadinho@basedosdados.org"} + + + + + + + + + Configurações + + + + + + {links.map((elm, index) => { + return ( + { + onClose() + router.push({pathname: "/user/dev", query: elm.value})} + } + >{elm.name} + ) + })} + + + + + + + { + cookies.remove('user', { path: '/' }) + cookies.remove('token', { path: '/' }) + window.open("/", "_self") + }} + > + + + Sair + + + + + ) +} + +function MenuUser ({ userData, onOpen, onClose }) { + const timerRef = useRef() + const [isOpenMenu, setIsOpenMenu] = useState(false) + + const btnMouseEnterEvent = () => { + setIsOpenMenu(true) + } + const btnMouseLeaveEvent = () => { + timerRef.current = setTimeout(() => { + setIsOpenMenu(false) + }, 100) + } + const menuListMouseEnterEvent = () => { + clearTimeout(timerRef.current) + timerRef.current = undefined + setIsOpenMenu(true) + } + const menuListMouseLeaveEvent = () => { + setIsOpenMenu(false) + } + + if(useCheckMobile()) { + return ( + onOpen()} + > + + + ) + } else { + return ( + + + + + + + + + + + + + {userData?.username ? userData?.username : "dadinho"} + + + {userData?.email ? userData?.email : "dadinho@basedosdados.org"} + + + + window.open("/user/dev", "_self")} + > + + + Configurações + + + + { + cookies.remove('user', { path: '/' }) + cookies.remove('token', { path: '/' }) + window.open("/", "_self")} + } + > + + + Sair + + + + + ) + } + +} + function SearchInput ({ status }) { const router = useRouter() const { query } = router @@ -198,7 +547,99 @@ function SearchInput ({ status }) { ) } -function DesktopLinks({ links, position = false, path }) { +function SearchInputUser () { + const [search, setSearch] = useState("") + const [showSearch, setShowSearch] = useState(false) + + function openSearchLink() { + window.open(`/dataset?q=${search}`, "_self") + } + + // if(isMobileMod()) return ( + // + // setShowSearch(true)} + // /> + // + // openSearchLink()} + // /> + // } + // /> + // + // + // ) + + if(isMobileMod()) return null + + return ( + + openSearchLink()} + /> + } + /> + + ) +} + +function DesktopLinks({ links, position = false, path, userTemplate = false }) { const [statusSearch, setStatusSearch] = useState(false) let userData = cookies.get("user") || null @@ -240,9 +681,9 @@ function DesktopLinks({ links, position = false, path }) { return ( - + {Object.entries(links).map(([k, v]) => { if (k === "Button") return v.map(b => ( @@ -263,6 +704,7 @@ function DesktopLinks({ links, position = false, path }) { minWidth="80px" height="35px" fontSize="15px" + borderRadius="30px" > {b.name} @@ -317,34 +759,37 @@ function DesktopLinks({ links, position = false, path }) { + {userTemplate && !isMobileMod() && } {!statusSearch && {userData ? ( - - - + window.open("/precos", "_self")} > - {userData.username} - + BD Pro + + ) : ( <> - {/* + Entrar - + Cadastrar - */} + )} @@ -353,10 +798,11 @@ function DesktopLinks({ links, position = false, path }) { ); } -export default function Menu({}) { +export default function MenuNav({ simpleTemplate = false, userTemplate = false }) { const router = useRouter() const { route } = router - const menuDisclosure = useDisclosure(); + const menuDisclosure = useDisclosure() + const menuUserMobile = useDisclosure() const divRef = useRef() const bannerRef = useRef() const [isScrollDown, setIsScrollDown] = useState(false) @@ -372,7 +818,7 @@ export default function Menu({}) { {icon: , name: "Dados exclusivos", href: "https://info.basedosdados.org/bd-pro"}, {icon: , name: "Curso de dados", href: "https://info.basedosdados.org/bd-edu"}, {}, - {name: "Serviços", href: "/servicos"}, + {name: "Serviço", href: "/servicos"}, {}, {name: "Estudos de caso", href: "/estudos-de-caso"} ], @@ -415,6 +861,7 @@ export default function Menu({}) { return ( <> - + - - + {simpleTemplate ? + <> + : + + } + + {userTemplate && isMobileMod() && } + + {useCheckMobile() && userData && + + } + - ); + ) } diff --git a/next/components/organisms/PostDatasetForm.js b/next/components/organisms/PostDatasetForm.js index 35d8d4fb..8aa842f8 100644 --- a/next/components/organisms/PostDatasetForm.js +++ b/next/components/organisms/PostDatasetForm.js @@ -282,7 +282,7 @@ export default function PostDatasetForm({ - + Deletar dataset Você tem certeza em deletar esse dataset? Uma vez deletado, todas as informações dele e de Table e Columns serão excluídas em consequência. diff --git a/next/components/templates/main.js b/next/components/templates/main.js index 430a56ca..d43099dd 100644 --- a/next/components/templates/main.js +++ b/next/components/templates/main.js @@ -10,6 +10,8 @@ export function MainPageTemplate({ pages, children, backgroundColor = "#FFFFFF", + cleanTemplate = false, + userTemplate = false, ...style }) { @@ -18,11 +20,11 @@ export function MainPageTemplate({ - + {children} -