update select
This commit is contained in:
@@ -27,7 +27,7 @@ export function DataTableColumnHeader<TData, TValue>({
|
|||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className={cn('-ml-3 h-8 cursor-pointer', className)}
|
className={cn('-ml-3 cursor-pointer', className)}
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
>
|
>
|
||||||
<span>{title}</span>
|
<span>{title}</span>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import {
|
import {
|
||||||
flexRender,
|
flexRender,
|
||||||
getCoreRowModel,
|
getCoreRowModel,
|
||||||
getSortedRowModel,
|
|
||||||
useReactTable,
|
useReactTable,
|
||||||
type ColumnDef,
|
type ColumnDef,
|
||||||
type ColumnSort,
|
type ColumnSort,
|
||||||
@@ -89,6 +88,8 @@ export function DataTable<TData, TValue>({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// table.getSelectedRowModel().flatRows.map((row) => row.original)
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data,
|
data,
|
||||||
columns,
|
columns,
|
||||||
@@ -105,6 +106,7 @@ export function DataTable<TData, TValue>({
|
|||||||
manualSorting: true,
|
manualSorting: true,
|
||||||
manualPagination: true,
|
manualPagination: true,
|
||||||
enableRowSelection: true,
|
enableRowSelection: true,
|
||||||
|
getRowId: (row: any) => row.id,
|
||||||
getCoreRowModel: getCoreRowModel(),
|
getCoreRowModel: getCoreRowModel(),
|
||||||
onRowSelectionChange: setRowSelection,
|
onRowSelectionChange: setRowSelection,
|
||||||
onSortingChange: setSorting,
|
onSortingChange: setSorting,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { type Table } from '@tanstack/react-table'
|
import { type Table } from '@tanstack/react-table'
|
||||||
import { ChevronLeft, ChevronRight } from 'lucide-react'
|
import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react'
|
||||||
|
|
||||||
import { Button } from '@repo/ui/components/ui/button'
|
import { Button } from '@repo/ui/components/ui/button'
|
||||||
import {
|
import {
|
||||||
@@ -21,19 +21,11 @@ export function DataTablePagination<TData>({
|
|||||||
const rowCount = table.getRowCount()
|
const rowCount = table.getRowCount()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center">
|
<div className="flex items-center justify-end gap-3 lg:gap-6">
|
||||||
<div className="text-muted-foreground flex-1 text-sm">
|
<div className="flex items-center gap-2">
|
||||||
{table.getFilteredSelectedRowModel().rows.length} de{' '}
|
<p className="text-sm font-medium hidden lg:block">Itens por página</p>
|
||||||
{table.getFilteredRowModel().rows.length} linha(s) selecionada(s).
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-3 lg:gap-6">
|
|
||||||
<div className="flex items-center space-x-2">
|
|
||||||
<p className="text-sm font-medium hidden lg:block">
|
|
||||||
Itens por página
|
|
||||||
</p>
|
|
||||||
<Select
|
<Select
|
||||||
value={`${table.getState().pagination.pageSize}`}
|
value={String(table.getState().pagination.pageSize)}
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
table.setPageSize(Number(value))
|
table.setPageSize(Number(value))
|
||||||
}}
|
}}
|
||||||
@@ -43,7 +35,7 @@ export function DataTablePagination<TData>({
|
|||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent side="top">
|
<SelectContent side="top">
|
||||||
{[12, 25, 50, 100].map((pageSize) => (
|
{[12, 25, 50, 100].map((pageSize) => (
|
||||||
<SelectItem key={pageSize} value={`${pageSize}`}>
|
<SelectItem key={pageSize} value={String(pageSize)}>
|
||||||
{pageSize}
|
{pageSize}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
@@ -65,7 +57,7 @@ export function DataTablePagination<TData>({
|
|||||||
disabled={!table.getCanPreviousPage()}
|
disabled={!table.getCanPreviousPage()}
|
||||||
>
|
>
|
||||||
<span className="sr-only">Ir para a página anterior</span>
|
<span className="sr-only">Ir para a página anterior</span>
|
||||||
<ChevronLeft />
|
<ChevronLeftIcon />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
@@ -75,10 +67,9 @@ export function DataTablePagination<TData>({
|
|||||||
disabled={!table.getCanNextPage()}
|
disabled={!table.getCanNextPage()}
|
||||||
>
|
>
|
||||||
<span className="sr-only">Ir para a próxima página</span>
|
<span className="sr-only">Ir para a próxima página</span>
|
||||||
<ChevronRight />
|
<ChevronRightIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { CalendarIcon } from 'lucide-react'
|
import { EllipsisIcon } from 'lucide-react'
|
||||||
import { useState, type ReactNode } from 'react'
|
import { useState } from 'react'
|
||||||
import { type DateRange } from 'react-day-picker'
|
import { type DateRange } from 'react-day-picker'
|
||||||
import { ptBR } from 'react-day-picker/locale'
|
import { ptBR } from 'react-day-picker/locale'
|
||||||
|
|
||||||
import { Badge } from '@repo/ui/components/ui/badge'
|
import { Badge } from '@repo/ui/components/ui/badge'
|
||||||
import { Button } from '@repo/ui/components/ui/button'
|
import { Button } from '@repo/ui/components/ui/button'
|
||||||
import { Calendar } from '@repo/ui/components/ui/calendar'
|
import { Calendar } from '@repo/ui/components/ui/calendar'
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuRadioGroup,
|
||||||
|
DropdownMenuRadioItem,
|
||||||
|
DropdownMenuTrigger
|
||||||
|
} from '@repo/ui/components/ui/dropdown-menu'
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
@@ -23,38 +30,61 @@ const formatted = new Intl.DateTimeFormat('pt-BR', {
|
|||||||
year: '2-digit'
|
year: '2-digit'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
type FilterProps = {
|
||||||
|
rangeField?: string
|
||||||
|
dateRange?: DateRange
|
||||||
|
}
|
||||||
|
|
||||||
type RangeCalendarFilterProps = {
|
type RangeCalendarFilterProps = {
|
||||||
children?: ReactNode
|
title: string
|
||||||
value?: DateRange
|
icon: React.ComponentType
|
||||||
|
value?: FilterProps
|
||||||
|
options: { value: string; label: string }[]
|
||||||
className?: string
|
className?: string
|
||||||
onChange?: (values: DateRange | undefined) => void
|
onChange?: (values: FilterProps | undefined) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RangeCalendarFilter({
|
export function RangeCalendarFilter({
|
||||||
children,
|
title,
|
||||||
|
icon: Icon,
|
||||||
value = undefined,
|
value = undefined,
|
||||||
|
options = [],
|
||||||
className,
|
className,
|
||||||
onChange
|
onChange
|
||||||
}: RangeCalendarFilterProps) {
|
}: RangeCalendarFilterProps) {
|
||||||
const [dateRange, setDateRange] = useState<DateRange | undefined>(value)
|
const [rangeField, setRangeField] = useState<string | undefined>(
|
||||||
|
value?.rangeField || options?.[0]?.value
|
||||||
|
)
|
||||||
|
|
||||||
|
const [dateRange, setDateRange] = useState<DateRange | undefined>(
|
||||||
|
value?.dateRange
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover>
|
<Popover>
|
||||||
<PopoverTrigger asChild>
|
<div
|
||||||
<Button
|
className={cn(
|
||||||
variant="outline"
|
'h-9 border rounded-md bg-muted border-dashed flex items-center',
|
||||||
size="sm"
|
className
|
||||||
className={cn('h-9 border-dashed cursor-pointer', className)}
|
)}
|
||||||
>
|
>
|
||||||
<CalendarIcon /> Período
|
<PopoverTrigger asChild>
|
||||||
|
<Button variant="ghost" size="sm" className="cursor-pointer">
|
||||||
|
<Icon /> {title}
|
||||||
{dateRange && (
|
{dateRange && (
|
||||||
<>
|
<>
|
||||||
<Separator orientation="vertical" className="mx-2 h-4" />
|
<Separator orientation="vertical" className="mx-0.5 h-4" />
|
||||||
<div className="gap-1 flex">
|
<div className="gap-1 flex">
|
||||||
<Badge variant="outline" className="rounded-sm px-1 font-mono">
|
<Badge
|
||||||
|
variant="outline"
|
||||||
|
className="rounded-sm px-1 font-mono"
|
||||||
|
>
|
||||||
{formatted.format(dateRange.from)}
|
{formatted.format(dateRange.from)}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Badge variant="outline" className="rounded-sm px-1 font-mono">
|
<Badge
|
||||||
|
variant="outline"
|
||||||
|
className="rounded-sm px-1 font-mono"
|
||||||
|
>
|
||||||
{formatted.format(dateRange.to)}
|
{formatted.format(dateRange.to)}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
@@ -62,14 +92,38 @@ export function RangeCalendarFilter({
|
|||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="w-full p-0" align="start">
|
|
||||||
{children && (
|
{dateRange && (
|
||||||
<>
|
<>
|
||||||
{children}
|
<Separator orientation="vertical" className="h-4" />
|
||||||
<Separator />
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button variant="ghost" size="sm" className="cursor-pointer">
|
||||||
|
<EllipsisIcon />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent className="w-46" align="end">
|
||||||
|
<DropdownMenuRadioGroup
|
||||||
|
value={rangeField}
|
||||||
|
onValueChange={(rangeField) => {
|
||||||
|
setRangeField(rangeField)
|
||||||
|
onChange?.({ rangeField, dateRange })
|
||||||
|
}}
|
||||||
|
className="*:cursor-pointer"
|
||||||
|
>
|
||||||
|
{options.map(({ label, value }, idx) => (
|
||||||
|
<DropdownMenuRadioItem value={value} key={idx}>
|
||||||
|
{label}
|
||||||
|
</DropdownMenuRadioItem>
|
||||||
|
))}
|
||||||
|
</DropdownMenuRadioGroup>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<PopoverContent className="w-full p-0" align="start">
|
||||||
<Calendar
|
<Calendar
|
||||||
mode="range"
|
mode="range"
|
||||||
locale={ptBR}
|
locale={ptBR}
|
||||||
@@ -91,7 +145,7 @@ export function RangeCalendarFilter({
|
|||||||
dateRange.to = nextDay
|
dateRange.to = nextDay
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange?.(dateRange)
|
onChange?.({ rangeField, dateRange })
|
||||||
setDateRange(dateRange)
|
setDateRange(dateRange)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export const columns: ColumnDef<Enrollment>[] = [
|
|||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={row.getIsSelected()}
|
checked={row.getIsSelected()}
|
||||||
|
disabled={!row.getCanSelect()}
|
||||||
onCheckedChange={(value) => row.toggleSelected(!!value)}
|
onCheckedChange={(value) => row.toggleSelected(!!value)}
|
||||||
aria-label="Selecionar linha"
|
aria-label="Selecionar linha"
|
||||||
/>
|
/>
|
||||||
@@ -149,9 +150,9 @@ export const columns: ColumnDef<Enrollment>[] = [
|
|||||||
{
|
{
|
||||||
accessorKey: 'completed_at',
|
accessorKey: 'completed_at',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<DataTableColumnHeader column={column} title="Aprovado em" />
|
<DataTableColumnHeader column={column} title="Concluído em" />
|
||||||
),
|
),
|
||||||
meta: { title: 'Aprovado em' },
|
meta: { title: 'Concluído em' },
|
||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
enableHiding: true,
|
enableHiding: true,
|
||||||
cell: cellDate
|
cell: cellDate
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const statuses: Record<
|
|||||||
COMPLETED: {
|
COMPLETED: {
|
||||||
icon: CircleCheckIcon,
|
icon: CircleCheckIcon,
|
||||||
color: 'text-green-400 [&_svg]:text-background [&_svg]:fill-green-500',
|
color: 'text-green-400 [&_svg]:text-background [&_svg]:fill-green-500',
|
||||||
label: 'Aprovado'
|
label: 'Concluído'
|
||||||
},
|
},
|
||||||
FAILED: {
|
FAILED: {
|
||||||
icon: CircleXIcon,
|
icon: CircleXIcon,
|
||||||
@@ -44,3 +44,11 @@ export const labels: Record<string, string> = {
|
|||||||
FAILED: 'Reprovado',
|
FAILED: 'Reprovado',
|
||||||
CANCELED: 'Cancelado'
|
CANCELED: 'Cancelado'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const sortings: Record<string, string> = {
|
||||||
|
created_at: 'Matriculado em',
|
||||||
|
started_at: 'Iniciado em',
|
||||||
|
completed_at: 'Concluído em',
|
||||||
|
failed_at: 'Reprovado em',
|
||||||
|
canceled_at: 'Cancelado em'
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import type { Route } from './+types'
|
import type { Route } from './+types'
|
||||||
|
|
||||||
import { PlusCircleIcon, PlusIcon } from 'lucide-react'
|
import { CalendarIcon, PlusCircleIcon, PlusIcon } from 'lucide-react'
|
||||||
import { MeiliSearchFilterBuilder } from 'meilisearch-helper'
|
import { MeiliSearchFilterBuilder } from 'meilisearch-helper'
|
||||||
import { Suspense, useState } from 'react'
|
import { Suspense } from 'react'
|
||||||
import { Await, Link, useSearchParams } from 'react-router'
|
import { Await, Link, useSearchParams } from 'react-router'
|
||||||
|
|
||||||
import { DataTable, DataTableViewOptions } from '@/components/data-table'
|
import { DataTable, DataTableViewOptions } from '@/components/data-table'
|
||||||
@@ -14,16 +14,8 @@ import { SearchForm } from '@repo/ui/components/search-form'
|
|||||||
import { Skeleton } from '@repo/ui/components/skeleton'
|
import { Skeleton } from '@repo/ui/components/skeleton'
|
||||||
import { Button } from '@repo/ui/components/ui/button'
|
import { Button } from '@repo/ui/components/ui/button'
|
||||||
import { Kbd } from '@repo/ui/components/ui/kbd'
|
import { Kbd } from '@repo/ui/components/ui/kbd'
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectGroup,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue
|
|
||||||
} from '@repo/ui/components/ui/select'
|
|
||||||
import { columns, type Enrollment } from './columns'
|
import { columns, type Enrollment } from './columns'
|
||||||
import { statuses } from './data'
|
import { sortings, statuses } from './data'
|
||||||
|
|
||||||
export function meta({}: Route.MetaArgs) {
|
export function meta({}: Route.MetaArgs) {
|
||||||
return [{ title: 'Matrículas' }]
|
return [{ title: 'Matrículas' }]
|
||||||
@@ -33,17 +25,17 @@ export async function loader({ params, context, request }: Route.LoaderArgs) {
|
|||||||
const { searchParams } = new URL(request.url)
|
const { searchParams } = new URL(request.url)
|
||||||
const { orgid } = params
|
const { orgid } = params
|
||||||
const query = searchParams.get('q') || ''
|
const query = searchParams.get('q') || ''
|
||||||
const from = searchParams.get('from') || ''
|
const from = searchParams.get('from')
|
||||||
const to = searchParams.get('to') || ''
|
const to = searchParams.get('to')
|
||||||
const sort = searchParams.get('sort') || 'created_at:desc'
|
const sort = searchParams.get('sort') || 'created_at:desc'
|
||||||
const status = searchParams.getAll('status') || []
|
const status = searchParams.get('status')
|
||||||
const page = Number(searchParams.get('p')) + 1
|
const page = Number(searchParams.get('p')) + 1
|
||||||
const hitsPerPage = Number(searchParams.get('perPage')) || 25
|
const hitsPerPage = Number(searchParams.get('perPage')) || 25
|
||||||
|
|
||||||
let builder = new MeiliSearchFilterBuilder().where('org_id', '=', orgid)
|
let builder = new MeiliSearchFilterBuilder().where('org_id', '=', orgid)
|
||||||
|
|
||||||
if (status.length) {
|
if (status) {
|
||||||
builder = builder.where('status', 'in', status)
|
builder = builder.where('status', 'in', status.split(','))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from && to) {
|
if (from && to) {
|
||||||
@@ -72,8 +64,8 @@ const formatted = new Intl.DateTimeFormat('en-CA', {
|
|||||||
|
|
||||||
export default function Route({ loaderData: { data } }) {
|
export default function Route({ loaderData: { data } }) {
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
const [searchParams, setSearchParams] = useSearchParams()
|
||||||
// const [rangeField, setRangeField] = useState<string>('created_at')
|
const status = searchParams.get('status')
|
||||||
const { rangeField, dateRange } = useRangeParams('created_at')
|
const rangeParams = useRangeParams()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={<Skeleton />}>
|
<Suspense fallback={<Skeleton />}>
|
||||||
@@ -126,26 +118,22 @@ export default function Route({ loaderData: { data } }) {
|
|||||||
<div className="flex gap-2.5 max-lg:flex-col w-full">
|
<div className="flex gap-2.5 max-lg:flex-col w-full">
|
||||||
<div className="flex gap-2.5 max-lg:flex-col">
|
<div className="flex gap-2.5 max-lg:flex-col">
|
||||||
<FacetedFilter
|
<FacetedFilter
|
||||||
|
title="Status"
|
||||||
icon={PlusCircleIcon}
|
icon={PlusCircleIcon}
|
||||||
className="lg:flex-1"
|
className="lg:flex-1"
|
||||||
value={searchParams.getAll('status')}
|
value={status ? status.split(',') : []}
|
||||||
onChange={(statuses) => {
|
onChange={(statuses) => {
|
||||||
setSearchParams((searchParams) => {
|
setSearchParams((searchParams) => {
|
||||||
searchParams.delete('status')
|
searchParams.delete('status')
|
||||||
searchParams.delete('p')
|
searchParams.delete('p')
|
||||||
|
|
||||||
if (statuses.length) {
|
if (statuses.length) {
|
||||||
statuses.forEach((s) =>
|
searchParams.set('status', statuses.join(','))
|
||||||
searchParams.has('status', s)
|
|
||||||
? null
|
|
||||||
: searchParams.append('status', s)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return searchParams
|
return searchParams
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
title="Status"
|
|
||||||
options={Object.entries(statuses).map(([key, value]) => ({
|
options={Object.entries(statuses).map(([key, value]) => ({
|
||||||
value: key,
|
value: key,
|
||||||
...value
|
...value
|
||||||
@@ -153,69 +141,39 @@ export default function Route({ loaderData: { data } }) {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<RangeCalendarFilter
|
<RangeCalendarFilter
|
||||||
|
title="Período"
|
||||||
|
icon={CalendarIcon}
|
||||||
|
value={rangeParams}
|
||||||
className="lg:flex-1"
|
className="lg:flex-1"
|
||||||
value={dateRange}
|
options={Object.entries(sortings).map(
|
||||||
onChange={(dateRange) => {
|
([value, label]) => ({
|
||||||
|
value,
|
||||||
|
label
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
onChange={(props) => {
|
||||||
setSearchParams((searchParams) => {
|
setSearchParams((searchParams) => {
|
||||||
if (dateRange) {
|
if (!props) {
|
||||||
|
searchParams.delete('from')
|
||||||
|
searchParams.delete('to')
|
||||||
|
return searchParams
|
||||||
|
}
|
||||||
|
|
||||||
|
const { rangeField, dateRange } = props
|
||||||
|
|
||||||
searchParams.set(
|
searchParams.set(
|
||||||
'from',
|
'from',
|
||||||
`${rangeField}:${formatted.format(dateRange.from)}`
|
`${rangeField}:${formatted.format(dateRange?.from)}`
|
||||||
)
|
)
|
||||||
searchParams.set(
|
searchParams.set(
|
||||||
'to',
|
'to',
|
||||||
formatted.format(dateRange.to)
|
formatted.format(dateRange?.to)
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
searchParams.delete('from')
|
|
||||||
searchParams.delete('to')
|
|
||||||
}
|
|
||||||
|
|
||||||
return searchParams
|
return searchParams
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<div className="p-2.5">
|
|
||||||
<Select
|
|
||||||
defaultValue={rangeField}
|
|
||||||
onValueChange={(value) => {
|
|
||||||
setSearchParams((searchParams) => {
|
|
||||||
if (searchParams.has('from')) {
|
|
||||||
searchParams.set(
|
|
||||||
'from',
|
|
||||||
`${value}:${dateRange?.from?.getTime()}`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return searchParams
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SelectTrigger className="w-full">
|
|
||||||
<SelectValue />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectGroup>
|
|
||||||
<SelectItem value="created_at">
|
|
||||||
Matriculado em
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="started_at">
|
|
||||||
Iniciado em
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="completed_at">
|
|
||||||
Aprovado em
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="failed_at">
|
|
||||||
Reprovado em
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="canceled_at">
|
|
||||||
Cancelado em
|
|
||||||
</SelectItem>
|
|
||||||
</SelectGroup>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
</RangeCalendarFilter>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="lg:ml-auto flex gap-2.5">
|
<div className="lg:ml-auto flex gap-2.5">
|
||||||
@@ -237,12 +195,12 @@ export default function Route({ loaderData: { data } }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function useRangeParams(initRangeField: string) {
|
function useRangeParams() {
|
||||||
const [searchParams] = useSearchParams()
|
const [searchParams] = useSearchParams()
|
||||||
const [from, to] = [searchParams.get('from'), searchParams.get('to')]
|
const [from, to] = [searchParams.get('from'), searchParams.get('to')]
|
||||||
|
|
||||||
if (!from || !to) {
|
if (!from || !to) {
|
||||||
return { rangeField: initRangeField, dateRange: undefined }
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [rangeField, from_] = from.split(':')
|
const [rangeField, from_] = from.split(':')
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ private_jwk = JsonWebKey.import_key(private_key)
|
|||||||
# https://docs.authlib.org/en/v0.12/specs/rfc6750.html#authlib.oauth2.rfc6750.BearerToken.GRANT_TYPES_EXPIRES_IN
|
# https://docs.authlib.org/en/v0.12/specs/rfc6750.html#authlib.oauth2.rfc6750.BearerToken.GRANT_TYPES_EXPIRES_IN
|
||||||
GRANT_TYPES_EXPIRES_IN = {
|
GRANT_TYPES_EXPIRES_IN = {
|
||||||
'authorization_code': 60 * 3, # 3 minutes
|
'authorization_code': 60 * 3, # 3 minutes
|
||||||
'refresh_token': 60 * 3, # 3 minutes
|
'refresh_token': 3600, # 1 hour
|
||||||
# 'refresh_token': 3600, # 1 hour
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import { Separator } from '@repo/ui/components/ui/separator'
|
|||||||
import { cn } from '@repo/ui/lib/utils'
|
import { cn } from '@repo/ui/lib/utils'
|
||||||
|
|
||||||
interface FacetedFilterProps<TData, TValue> {
|
interface FacetedFilterProps<TData, TValue> {
|
||||||
value?: string[]
|
|
||||||
title?: string
|
title?: string
|
||||||
|
value?: string[]
|
||||||
icon: React.ComponentType
|
icon: React.ComponentType
|
||||||
className?: string
|
className?: string
|
||||||
options: {
|
options: {
|
||||||
@@ -55,7 +55,7 @@ export function FacetedFilter<TData, TValue>({
|
|||||||
{title}
|
{title}
|
||||||
{selectedValues?.size > 0 && (
|
{selectedValues?.size > 0 && (
|
||||||
<>
|
<>
|
||||||
<Separator orientation="vertical" className="mx-2 h-4" />
|
<Separator orientation="vertical" className="mx-0.5 h-4" />
|
||||||
<div className="gap-1 flex">
|
<div className="gap-1 flex">
|
||||||
{selectedValues.size > 2 ? (
|
{selectedValues.size > 2 ? (
|
||||||
<Badge
|
<Badge
|
||||||
|
|||||||
Reference in New Issue
Block a user