Created
February 5, 2025 22:43
-
-
Save leidison/bcfd9c164f59ebb9fe35d9a558938c56 to your computer and use it in GitHub Desktop.
Apresentando tabs ocultas em dropdown com Shadcn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ErrorDisplay from '@/base/components/error-display' | |
import { Loading } from '@/base/components/loading' | |
import { NavigationHistory } from '@/base/components/navigation-history' | |
import { NavigationTabs } from '@/base/components/navigation-tabs' | |
import { PageHeader } from '@/base/components/page-header' | |
import { useFindOneEmployee } from '@/base/http/generated' | |
import { useEmployee } from '@/employee/context/employee' | |
import { useEffect, useMemo } from 'react' | |
import { Outlet, useParams } from 'react-router' | |
export function Component() { | |
const { employeeId } = useParams() | |
const { employee, setEmployee } = useEmployee() | |
const { data, error, isLoading, refetch }: any = useFindOneEmployee( | |
employeeId!, | |
) | |
const tabs = useMemo( | |
() => [ | |
{ title: 'Dados', to: `/colaboradores/${employeeId}` }, | |
{ | |
title: 'Documentos', | |
to: `/colaboradores/${employeeId}/documentos`, | |
}, | |
{ title: 'Unidades', to: `/colaboradores/${employeeId}/unidades` }, | |
{ title: 'Escala', to: `/colaboradores/${employeeId}/escala` }, | |
], | |
[employeeId], | |
) | |
useEffect(() => { | |
setEmployee(data) | |
}, [data, setEmployee]) | |
if (error) { | |
return <ErrorDisplay error={error} refetch={refetch} /> | |
} | |
if (isLoading || !employee) { | |
return ( | |
<div className="flex justify-center items-center h-full"> | |
<Loading /> | |
</div> | |
) | |
} | |
return ( | |
<> | |
<NavigationHistory | |
items={[ | |
{ title: 'Listagem de colaboradores', to: '/colaboradores' }, | |
{ title: 'Editar' }, | |
]} | |
/> | |
<PageHeader title={employee.name + ''} descriptionElipsis={true}> | |
{employee?.data?.description} | |
</PageHeader> | |
<NavigationTabs items={tabs} /> | |
<Outlet /> | |
</> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exemplo não expandido (mobile)
Exemplo expandido (mobile)
Exemplo com todos a mostra
OBS
O scroll horizontal continua funcionando.