share route itens
This commit is contained in:
@@ -42,8 +42,7 @@ import {
|
||||
import { Progress } from '@repo/ui/components/ui/progress'
|
||||
import { Spinner } from '@repo/ui/components/ui/spinner'
|
||||
import { cn, initials } from '@repo/ui/lib/utils'
|
||||
|
||||
import { labels, statuses } from './data'
|
||||
import { labels, statuses } from '@repo/ui/routes/enrollments/data'
|
||||
|
||||
// This type is used to define the shape of our data.
|
||||
// You can use a Zod schema here if you want.
|
||||
@@ -61,14 +60,6 @@ export type Enrollment = {
|
||||
created_at: string
|
||||
}
|
||||
|
||||
const formatted = new Intl.DateTimeFormat('pt-BR', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})
|
||||
|
||||
export const columns: ColumnDef<Enrollment>[] = [
|
||||
{
|
||||
id: 'select',
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
import {
|
||||
CircleCheckIcon,
|
||||
CircleIcon,
|
||||
CircleOffIcon,
|
||||
CircleXIcon,
|
||||
TimerIcon,
|
||||
type LucideIcon
|
||||
} from 'lucide-react'
|
||||
|
||||
export const statuses: Record<
|
||||
string,
|
||||
{ icon: LucideIcon; color?: string; label: string }
|
||||
> = {
|
||||
PENDING: {
|
||||
icon: CircleIcon,
|
||||
label: 'Não iniciado'
|
||||
},
|
||||
IN_PROGRESS: {
|
||||
icon: TimerIcon,
|
||||
color: 'text-blue-400 [&_svg]:text-blue-500',
|
||||
label: 'Em andamento'
|
||||
},
|
||||
COMPLETED: {
|
||||
icon: CircleCheckIcon,
|
||||
color: 'text-green-400 [&_svg]:text-background [&_svg]:fill-green-500',
|
||||
label: 'Concluído'
|
||||
},
|
||||
FAILED: {
|
||||
icon: CircleXIcon,
|
||||
color: 'text-red-400 [&_svg]:text-red-500',
|
||||
label: 'Reprovado'
|
||||
},
|
||||
CANCELED: {
|
||||
icon: CircleOffIcon,
|
||||
color: 'text-orange-400 [&_svg]:text-orange-500',
|
||||
label: 'Cancelado'
|
||||
}
|
||||
}
|
||||
|
||||
export const labels: Record<string, string> = {
|
||||
PENDING: 'Não iniciado',
|
||||
IN_PROGRESS: 'Em andamento',
|
||||
COMPLETED: 'Concluído',
|
||||
FAILED: 'Reprovado',
|
||||
CANCELED: 'Cancelado'
|
||||
}
|
||||
|
||||
export const sortings: Record<string, string> = {
|
||||
created_at: 'Cadastrado em',
|
||||
started_at: 'Iniciado em',
|
||||
completed_at: 'Concluído em',
|
||||
failed_at: 'Reprovado em',
|
||||
canceled_at: 'Cancelado em'
|
||||
}
|
||||
|
||||
export const headers = {
|
||||
id: 'ID',
|
||||
'user.name': 'Nome',
|
||||
'user.email': 'Email',
|
||||
'user.cpf': 'CPF',
|
||||
'course.name': 'Curso',
|
||||
status: 'Status',
|
||||
progress: 'Progresso',
|
||||
created_at: 'Cadastrado em',
|
||||
started_at: 'Iniciado em',
|
||||
completed_at: 'Concluído em',
|
||||
failed_at: 'Reprovado em',
|
||||
canceled_at: 'Cancelado em'
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import type { Route } from './+types/route'
|
||||
import { CalendarIcon, PlusCircleIcon, PlusIcon } from 'lucide-react'
|
||||
import { MeiliSearchFilterBuilder } from 'meilisearch-helper'
|
||||
import { Suspense, useState } from 'react'
|
||||
import { Await, Link, Outlet, useParams, useSearchParams } from 'react-router'
|
||||
import { Await, Link, useParams, useSearchParams } from 'react-router'
|
||||
|
||||
import { DataTable, DataTableViewOptions } from '@repo/ui/components/data-table'
|
||||
import { FacetedFilter } from '@repo/ui/components/faceted-filter'
|
||||
@@ -12,12 +12,11 @@ import { SearchForm } from '@repo/ui/components/search-form'
|
||||
import { Skeleton } from '@repo/ui/components/skeleton'
|
||||
import { Button } from '@repo/ui/components/ui/button'
|
||||
import { ExportMenu } from '@repo/ui/components/export-menu'
|
||||
|
||||
import { Kbd } from '@repo/ui/components/ui/kbd'
|
||||
import { createSearch } from '@repo/util/meili'
|
||||
|
||||
import { headers, sortings, statuses } from '@repo/ui/routes/enrollments/data'
|
||||
import { columns, type Enrollment } from './columns'
|
||||
import { headers, sortings, statuses } from './data'
|
||||
|
||||
export function meta({}: Route.MetaArgs) {
|
||||
return [{ title: 'Matrículas' }]
|
||||
@@ -45,16 +44,18 @@ export async function loader({ params, context, request }: Route.LoaderArgs) {
|
||||
builder = builder.where(field, 'between', [from_, to])
|
||||
}
|
||||
|
||||
const enrollments = createSearch({
|
||||
index: 'betaeducacao-prod-enrollments',
|
||||
filter: builder.build(),
|
||||
sort: [sort],
|
||||
query,
|
||||
page,
|
||||
hitsPerPage,
|
||||
env: context.cloudflare.env
|
||||
})
|
||||
|
||||
return {
|
||||
data: createSearch({
|
||||
index: 'betaeducacao-prod-enrollments',
|
||||
filter: builder.build(),
|
||||
sort: [sort],
|
||||
query,
|
||||
page,
|
||||
hitsPerPage,
|
||||
env: context.cloudflare.env
|
||||
})
|
||||
data: enrollments
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,8 +212,6 @@ export default function Route({ loaderData: { data } }) {
|
||||
</DataTable>
|
||||
)}
|
||||
</Await>
|
||||
|
||||
<Outlet />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
'use client'
|
||||
|
||||
import {
|
||||
DataTableColumnDatetime,
|
||||
DataTableColumnCurrency,
|
||||
DataTableColumnHeader
|
||||
} from '@repo/ui/components/data-table'
|
||||
import { type ColumnDef } from '@tanstack/react-table'
|
||||
|
||||
// This type is used to define the shape of our data.
|
||||
// You can use a Zod schema here if you want.
|
||||
export type Order = {
|
||||
id: string
|
||||
total: number
|
||||
status: 'pending' | 'processing' | 'success' | 'failed'
|
||||
payment_method: 'PIX' | 'CREDIT_CARD' | 'MANUAL' | 'failed'
|
||||
name: string
|
||||
}
|
||||
|
||||
export const columns: ColumnDef<Order>[] = [
|
||||
{
|
||||
accessorKey: 'payment_method',
|
||||
header: 'Forma de pag.'
|
||||
},
|
||||
{
|
||||
accessorKey: 'status',
|
||||
header: 'Status'
|
||||
},
|
||||
{
|
||||
accessorKey: 'total',
|
||||
header: 'Valor total',
|
||||
cell: ({ row, column }) => (
|
||||
<DataTableColumnCurrency row={row} column={column} />
|
||||
)
|
||||
},
|
||||
{
|
||||
accessorKey: 'create_date',
|
||||
enableSorting: true,
|
||||
meta: { title: 'Comprado em' },
|
||||
header: ({ column }) => <DataTableColumnHeader column={column} />,
|
||||
cell: ({ row, column }) => (
|
||||
<DataTableColumnDatetime row={row} column={column} />
|
||||
)
|
||||
},
|
||||
{
|
||||
accessorKey: 'due_date',
|
||||
enableSorting: true,
|
||||
meta: { title: 'Vencimento em' },
|
||||
header: ({ column }) => <DataTableColumnHeader column={column} />,
|
||||
cell: ({ row, column }) => (
|
||||
<DataTableColumnDatetime row={row} column={column} />
|
||||
)
|
||||
},
|
||||
{
|
||||
accessorKey: 'payment_date',
|
||||
enableSorting: true,
|
||||
meta: { title: 'Pago em' },
|
||||
header: ({ column }) => <DataTableColumnHeader column={column} />,
|
||||
cell: ({ row, column }) => (
|
||||
<DataTableColumnDatetime row={row} column={column} />
|
||||
)
|
||||
}
|
||||
]
|
||||
@@ -8,7 +8,7 @@ import { DataTable } from '@repo/ui/components/data-table'
|
||||
import { Skeleton } from '@repo/ui/components/skeleton'
|
||||
import { createSearch } from '@repo/util/meili'
|
||||
|
||||
import { columns, type Order } from './columns'
|
||||
import { columns, type Order } from '@repo/ui/routes/orders/columns'
|
||||
|
||||
export function meta({}: Route.MetaArgs) {
|
||||
return [{ title: 'Histórico de compras' }]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
'use client'
|
||||
|
||||
import { formatCPF } from '@brazilian-utils/brazilian-utils'
|
||||
import { type ColumnDef } from '@tanstack/react-table'
|
||||
import { useToggle } from 'ahooks'
|
||||
import {
|
||||
|
||||
@@ -73,7 +73,7 @@ export default function Route({ loaderData }: Route.ComponentProps) {
|
||||
className="bg-background/15 backdrop-blur-sm
|
||||
px-4 py-2 lg:py-4 sticky top-0 z-5"
|
||||
>
|
||||
<div className="container mx-auto flex items-center">
|
||||
<div className="container mx-auto flex items-center max-w-7xl">
|
||||
<SidebarTrigger className="md:hidden" />
|
||||
<ThemedImage className="max-md:hidden" />
|
||||
|
||||
@@ -85,7 +85,7 @@ export default function Route({ loaderData }: Route.ComponentProps) {
|
||||
</header>
|
||||
|
||||
<div className="p-4">
|
||||
<div className="container mx-auto relative">
|
||||
<div className="container mx-auto relative max-w-7xl">
|
||||
<Outlet />
|
||||
<Toaster
|
||||
position="top-center"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable */
|
||||
// Generated by Wrangler by running `wrangler types` (hash: 1aadef19c576560a2c23acd0e7ab9b2e)
|
||||
// Runtime types generated with workerd@1.20251113.0 2025-04-04
|
||||
// Runtime types generated with workerd@1.20251118.0 2025-04-04
|
||||
declare namespace Cloudflare {
|
||||
interface GlobalProps {
|
||||
mainModule: typeof import("./workers/app");
|
||||
@@ -460,7 +460,7 @@ interface StructuredSerializeOptions {
|
||||
transfer?: any[];
|
||||
}
|
||||
declare abstract class Navigator {
|
||||
sendBeacon(url: string, body?: (ReadableStream | string | (ArrayBuffer | ArrayBufferView) | Blob | FormData | URLSearchParams | URLSearchParams)): boolean;
|
||||
sendBeacon(url: string, body?: BodyInit): boolean;
|
||||
readonly userAgent: string;
|
||||
readonly hardwareConcurrency: number;
|
||||
}
|
||||
@@ -6750,20 +6750,8 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
|
||||
} ? ReadableStream : AiModelList[Name]["postProcessedOutputs"]>;
|
||||
models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
|
||||
toMarkdown(): ToMarkdownService;
|
||||
toMarkdown(files: {
|
||||
name: string;
|
||||
blob: Blob;
|
||||
}[], options?: {
|
||||
gateway?: GatewayOptions;
|
||||
extraHeaders?: object;
|
||||
}): Promise<ConversionResponse[]>;
|
||||
toMarkdown(files: {
|
||||
name: string;
|
||||
blob: Blob;
|
||||
}, options?: {
|
||||
gateway?: GatewayOptions;
|
||||
extraHeaders?: object;
|
||||
}): Promise<ConversionResponse>;
|
||||
toMarkdown(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>;
|
||||
toMarkdown(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>;
|
||||
}
|
||||
type GatewayRetries = {
|
||||
maxAttempts?: 1 | 2 | 3 | 4 | 5;
|
||||
@@ -8415,21 +8403,22 @@ declare namespace CloudflareWorkersModule {
|
||||
protected ctx: ExecutionContext<Props>;
|
||||
protected env: Env;
|
||||
constructor(ctx: ExecutionContext, env: Env);
|
||||
email?(message: ForwardableEmailMessage): void | Promise<void>;
|
||||
fetch?(request: Request): Response | Promise<Response>;
|
||||
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
||||
scheduled?(controller: ScheduledController): void | Promise<void>;
|
||||
tail?(events: TraceItem[]): void | Promise<void>;
|
||||
tailStream?(event: TailStream.TailEvent<TailStream.Onset>): TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
|
||||
trace?(traces: TraceItem[]): void | Promise<void>;
|
||||
scheduled?(controller: ScheduledController): void | Promise<void>;
|
||||
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
||||
test?(controller: TestController): void | Promise<void>;
|
||||
trace?(traces: TraceItem[]): void | Promise<void>;
|
||||
}
|
||||
export abstract class DurableObject<Env = Cloudflare.Env, Props = {}> implements Rpc.DurableObjectBranded {
|
||||
[Rpc.__DURABLE_OBJECT_BRAND]: never;
|
||||
protected ctx: DurableObjectState<Props>;
|
||||
protected env: Env;
|
||||
constructor(ctx: DurableObjectState, env: Env);
|
||||
fetch?(request: Request): Response | Promise<Response>;
|
||||
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
||||
fetch?(request: Request): Response | Promise<Response>;
|
||||
webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
|
||||
webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
|
||||
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
|
||||
@@ -8492,36 +8481,56 @@ declare module "cloudflare:sockets" {
|
||||
function _connect(address: string | SocketAddress, options?: SocketOptions): Socket;
|
||||
export { _connect as connect };
|
||||
}
|
||||
type MarkdownDocument = {
|
||||
name: string;
|
||||
blob: Blob;
|
||||
};
|
||||
type ConversionResponse = {
|
||||
name: string;
|
||||
mimeType: string;
|
||||
} & ({
|
||||
format: "markdown";
|
||||
format: 'markdown';
|
||||
tokens: number;
|
||||
data: string;
|
||||
} | {
|
||||
format: "error";
|
||||
name: string;
|
||||
mimeType: string;
|
||||
format: 'error';
|
||||
error: string;
|
||||
});
|
||||
};
|
||||
type ImageConversionOptions = {
|
||||
descriptionLanguage?: 'en' | 'es' | 'fr' | 'it' | 'pt' | 'de';
|
||||
};
|
||||
type EmbeddedImageConversionOptions = ImageConversionOptions & {
|
||||
convert?: boolean;
|
||||
maxConvertedImages?: number;
|
||||
};
|
||||
type ConversionOptions = {
|
||||
html?: {
|
||||
images?: EmbeddedImageConversionOptions & {
|
||||
convertOGImage?: boolean;
|
||||
};
|
||||
};
|
||||
docx?: {
|
||||
images?: EmbeddedImageConversionOptions;
|
||||
};
|
||||
image?: ImageConversionOptions;
|
||||
pdf?: {
|
||||
images?: EmbeddedImageConversionOptions;
|
||||
metadata?: boolean;
|
||||
};
|
||||
};
|
||||
type ConversionRequestOptions = {
|
||||
gateway?: GatewayOptions;
|
||||
extraHeaders?: object;
|
||||
conversionOptions?: ConversionOptions;
|
||||
};
|
||||
type SupportedFileFormat = {
|
||||
mimeType: string;
|
||||
extension: string;
|
||||
};
|
||||
declare abstract class ToMarkdownService {
|
||||
transform(files: {
|
||||
name: string;
|
||||
blob: Blob;
|
||||
}[], options?: {
|
||||
gateway?: GatewayOptions;
|
||||
extraHeaders?: object;
|
||||
}): Promise<ConversionResponse[]>;
|
||||
transform(files: {
|
||||
name: string;
|
||||
blob: Blob;
|
||||
}, options?: {
|
||||
gateway?: GatewayOptions;
|
||||
extraHeaders?: object;
|
||||
}): Promise<ConversionResponse>;
|
||||
transform(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>;
|
||||
transform(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>;
|
||||
supported(): Promise<SupportedFileFormat[]>;
|
||||
}
|
||||
declare namespace TailStream {
|
||||
|
||||
Reference in New Issue
Block a user