import { ChartBarIcon, ClipboardListIcon } from "@heroicons/react/outline"; import React, { useState } from 'react'; import { useDispatch, useSelector } from "react-redux"; import { useHistory, useLocation } from 'react-router'; import { DashboardRoutePaths, QuestionRoutePaths } from "../../routes"; import { RootState } from "../../services/store"; import { turnOff } from "../../services/store/unsavedChanges"; import { Dialog } from '../Dialog'; export const AppbarTabs = () => { const unsavedChanges = useSelector((state: RootState) => state.unsavedChanges) const dispatch = useDispatch() const location = useLocation() const history = useHistory() const [newPath, setNewPath] = useState() const handleForcedRedirect = () => { if (!newPath) return dispatch(turnOff()) setNewPath(undefined) history.push(newPath) } const handleLinkClick = (pathname: string) => { if (unsavedChanges) { setNewPath(pathname) } else { history.push(pathname) } } const links = [{ icon: , tabel: 'Painel', pathname: DashboardRoutePaths.index, isCurrent: location.pathname.includes('dashboard'), }, { icon: , tabel: 'Edição', pathname: QuestionRoutePaths.index, isCurrent: location.pathname.includes('question'), }] return ( <> setNewPath(value ? newPath : undefined)} onConfirmation={handleForcedRedirect} title="Modificações não Salvas" text="Todas as alterações serão descartadas. Deseja continuar?" />
{links.map((link) => ( ))}
) }