update
This commit is contained in:
@@ -75,11 +75,15 @@ export function DataTable<TData, TValue>({
|
||||
)
|
||||
const [columnVisibility, setColumnVisibility] =
|
||||
useState<VisibilityState>(hiddenColumn_)
|
||||
const [rowSelection, setRowSelection] = useState({})
|
||||
|
||||
const table = useReactTable({
|
||||
data,
|
||||
columns,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onRowSelectionChange: setRowSelection,
|
||||
state: {
|
||||
rowSelection,
|
||||
columnVisibility,
|
||||
pagination: {
|
||||
pageIndex,
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
useSidebar
|
||||
} from '@repo/ui/components/ui/sidebar'
|
||||
import { useIsMobile } from '@repo/ui/hooks/use-mobile'
|
||||
|
||||
import { type LucideIcon } from 'lucide-react'
|
||||
import { NavLink, useParams } from 'react-router'
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
SidebarRail,
|
||||
useSidebar
|
||||
} from '@repo/ui/components/ui/sidebar'
|
||||
|
||||
import { initials } from '@repo/ui/lib/utils'
|
||||
|
||||
type Org = {
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import type { User } from '@/lib/auth'
|
||||
import { createContext } from 'react-router'
|
||||
|
||||
export const userContext = createContext<User | null>(null)
|
||||
export const requestIdContext = createContext<string | null>(null)
|
||||
@@ -92,8 +92,8 @@ export default function Route({ loaderData: { data } }) {
|
||||
<SearchForm
|
||||
placeholder={
|
||||
<>
|
||||
Pressione <Kbd className="border font-mono">/</Kbd> para
|
||||
filtrar...
|
||||
Digite <Kbd className="border font-mono">/</Kbd> para
|
||||
pesquisar
|
||||
</>
|
||||
}
|
||||
defaultValue={term}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
|
||||
import { Avatar, AvatarFallback } from '@repo/ui/components/ui/avatar'
|
||||
import { Badge } from '@repo/ui/components/ui/badge'
|
||||
import { Checkbox } from '@repo/ui/components/ui/checkbox'
|
||||
import { Progress } from '@repo/ui/components/ui/progress'
|
||||
import { cn, initials } from '@repo/ui/lib/utils'
|
||||
|
||||
@@ -83,6 +84,26 @@ const statusTranslate: Record<string, string> = {
|
||||
}
|
||||
|
||||
export const columns: ColumnDef<Enrollment>[] = [
|
||||
{
|
||||
id: 'select',
|
||||
header: ({ table }) => (
|
||||
<Checkbox
|
||||
checked={
|
||||
table.getIsAllPageRowsSelected() ||
|
||||
(table.getIsSomePageRowsSelected() && 'indeterminate')
|
||||
}
|
||||
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
|
||||
aria-label="Selecionar tudo"
|
||||
/>
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<Checkbox
|
||||
checked={row.getIsSelected()}
|
||||
onCheckedChange={(value) => row.toggleSelected(!!value)}
|
||||
aria-label="Selecionar linha"
|
||||
/>
|
||||
)
|
||||
},
|
||||
{
|
||||
header: 'Colaborador',
|
||||
enableHiding: false,
|
||||
@@ -145,30 +166,35 @@ export const columns: ColumnDef<Enrollment>[] = [
|
||||
{
|
||||
accessorKey: 'created_at',
|
||||
header: 'Matriculado em',
|
||||
enableSorting: true,
|
||||
enableHiding: true,
|
||||
cell: cellDate
|
||||
},
|
||||
{
|
||||
accessorKey: 'started_at',
|
||||
header: 'Iniciado em',
|
||||
enableSorting: true,
|
||||
enableHiding: true,
|
||||
cell: cellDate
|
||||
},
|
||||
{
|
||||
accessorKey: 'completed_at',
|
||||
header: 'Aprovado em',
|
||||
enableSorting: true,
|
||||
enableHiding: true,
|
||||
cell: cellDate
|
||||
},
|
||||
{
|
||||
accessorKey: 'failed_at',
|
||||
header: 'Reprovado em',
|
||||
enableSorting: true,
|
||||
enableHiding: true,
|
||||
cell: cellDate
|
||||
},
|
||||
{
|
||||
accessorKey: 'canceled_at',
|
||||
header: 'Cancelado em',
|
||||
enableSorting: true,
|
||||
enableHiding: true,
|
||||
cell: cellDate
|
||||
}
|
||||
|
||||
@@ -113,8 +113,8 @@ export default function Route({ loaderData: { data } }) {
|
||||
defaultValue={searchParams.get('q') || ''}
|
||||
placeholder={
|
||||
<>
|
||||
Pressione <Kbd className="border font-mono">/</Kbd> para
|
||||
pesquisar...
|
||||
Digite <Kbd className="border font-mono">/</Kbd> para
|
||||
pesquisar
|
||||
</>
|
||||
}
|
||||
onChange={(value) =>
|
||||
|
||||
@@ -72,8 +72,8 @@ export default function Route({ loaderData: { data } }) {
|
||||
<SearchForm
|
||||
placeholder={
|
||||
<>
|
||||
Pressione <Kbd className="border font-mono">/</Kbd> para
|
||||
pesquisar...
|
||||
Digite <Kbd className="border font-mono">/</Kbd> para
|
||||
pesquisar
|
||||
</>
|
||||
}
|
||||
defaultValue={searchParams.get('q') || ''}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import type { Route } from './+types'
|
||||
|
||||
import { Outlet, type ShouldRevalidateFunctionArgs } from 'react-router'
|
||||
import {
|
||||
createCookie,
|
||||
Outlet,
|
||||
type ShouldRevalidateFunctionArgs
|
||||
} from 'react-router'
|
||||
|
||||
import { AppSidebar } from '@/components/app-sidebar'
|
||||
import { request as req } from '@/lib/request'
|
||||
@@ -14,13 +18,14 @@ import {
|
||||
SidebarProvider,
|
||||
SidebarTrigger
|
||||
} from '@repo/ui/components/ui/sidebar'
|
||||
import { useIsMobile } from '@repo/ui/hooks/use-mobile'
|
||||
|
||||
export const middleware: Route.MiddlewareFunction[] = [authMiddleware]
|
||||
|
||||
export async function loader({ params, context, request }: Route.ActionArgs) {
|
||||
const rawCookie = request.headers.get('cookie')
|
||||
const user = context.get(userContext)
|
||||
|
||||
const sidebarState = await createCookie('sidebar_state').parse(rawCookie)
|
||||
const r = await req({
|
||||
url: `/users/${user.sub}/orgs?limit=25`,
|
||||
request,
|
||||
@@ -39,7 +44,7 @@ export async function loader({ params, context, request }: Route.ActionArgs) {
|
||||
const exists = orgs.some(({ id }) => id === params.orgid)
|
||||
|
||||
if (exists) {
|
||||
return { user, orgs }
|
||||
return { user, orgs, sidebarState }
|
||||
}
|
||||
|
||||
throw new Response(null, { status: 401 })
|
||||
@@ -52,12 +57,12 @@ export function shouldRevalidate({
|
||||
return currentParams.orgid !== nextParams.orgid
|
||||
}
|
||||
|
||||
export default function Layout({ loaderData }: Route.ComponentProps) {
|
||||
const { user, orgs } = loaderData
|
||||
const isMobile = useIsMobile()
|
||||
export default function Route({ loaderData }: Route.ComponentProps) {
|
||||
const { user, orgs, sidebarState } = loaderData
|
||||
console.log(sidebarState)
|
||||
|
||||
return (
|
||||
<SidebarProvider className="flex">
|
||||
<SidebarProvider defaultOpen={sidebarState === 'true'} className="flex">
|
||||
<AppSidebar orgs={orgs} />
|
||||
|
||||
<SidebarInset className="relative flex flex-col flex-1 min-w-0">
|
||||
@@ -66,7 +71,8 @@ export default function Layout({ loaderData }: Route.ComponentProps) {
|
||||
px-4 py-2 lg:py-4 sticky top-0 z-5"
|
||||
>
|
||||
<div className="container mx-auto flex items-center">
|
||||
{isMobile ? <SidebarTrigger /> : <ThemedImage />}
|
||||
<SidebarTrigger className="md:hidden" />
|
||||
<ThemedImage className="max-md:hidden" />
|
||||
|
||||
<div className="ml-auto flex gap-2.5 items-center">
|
||||
<ModeToggle />
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-router/fs-routes": "^7.9.5",
|
||||
"@repo/ui": "*",
|
||||
"@repo/auth": "*",
|
||||
"@repo/ui": "*",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"date-fns": "^4.1.0",
|
||||
"fuse.js": "^7.1.0",
|
||||
|
||||
Reference in New Issue
Block a user