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 {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable */
|
||||
// Generated by Wrangler by running `wrangler types` (hash: 20d12d2cb42a565d117b277533ca85a9)
|
||||
// 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");
|
||||
@@ -452,7 +452,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;
|
||||
}
|
||||
@@ -6742,20 +6742,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;
|
||||
@@ -8407,21 +8395,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>;
|
||||
@@ -8484,36 +8473,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 {
|
||||
|
||||
@@ -24,8 +24,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.
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
@@ -31,8 +31,8 @@ import {
|
||||
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' }]
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { columns as columns_, type Order } from '@repo/ui/routes/orders/columns'
|
||||
|
||||
import { formatCNPJ, formatCPF } from '@brazilian-utils/brazilian-utils'
|
||||
import { type ColumnDef } from '@tanstack/react-table'
|
||||
|
||||
@@ -7,23 +9,7 @@ import { Abbr } from '@repo/ui/components/abbr'
|
||||
import { Avatar, AvatarFallback } from '@repo/ui/components/ui/avatar'
|
||||
import { initials } from '@repo/ui/lib/utils'
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
const formatted = new Intl.DateTimeFormat('pt-BR', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})
|
||||
export type { Order }
|
||||
|
||||
export const columns: ColumnDef<Order>[] = [
|
||||
{
|
||||
@@ -65,54 +51,5 @@ export const columns: ColumnDef<Order>[] = [
|
||||
return <></>
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorKey: 'payment_method',
|
||||
header: 'Forma de pag.'
|
||||
},
|
||||
{
|
||||
accessorKey: 'status',
|
||||
header: 'Status'
|
||||
},
|
||||
{
|
||||
accessorKey: 'total',
|
||||
header: 'Valor total',
|
||||
cell: ({ row }) => {
|
||||
const amount = parseFloat(row.getValue('total'))
|
||||
const formatted = new Intl.NumberFormat('pt-BR', {
|
||||
style: 'currency',
|
||||
currency: 'BRL'
|
||||
}).format(amount)
|
||||
|
||||
return <div className="font-medium">{formatted}</div>
|
||||
}
|
||||
},
|
||||
{
|
||||
header: 'Comprado em',
|
||||
cell: ({ row }) => {
|
||||
const createdAt = new Date(row.original.create_date)
|
||||
return formatted.format(createdAt)
|
||||
}
|
||||
},
|
||||
{
|
||||
header: 'Vencimento em',
|
||||
cell: ({ row }) => {
|
||||
try {
|
||||
const dueDate = new Date(row.original.due_date)
|
||||
return formatted.format(dueDate)
|
||||
} catch {
|
||||
return 'N/A'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
header: 'Pago em',
|
||||
cell: ({ row }) => {
|
||||
if (row.original.payment_date) {
|
||||
const createdAt = new Date(row.original.payment_date)
|
||||
return formatted.format(createdAt)
|
||||
}
|
||||
|
||||
return <></>
|
||||
}
|
||||
}
|
||||
...columns_
|
||||
]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Route } from './+types'
|
||||
import type { Route } from './+types/route'
|
||||
|
||||
import { Suspense } from 'react'
|
||||
import { Await } from 'react-router'
|
||||
@@ -16,12 +16,13 @@ export function meta({}: Route.MetaArgs) {
|
||||
export async function loader({ context, request }: Route.LoaderArgs) {
|
||||
const { searchParams } = new URL(request.url)
|
||||
const page = Number(searchParams.get('p')) + 1
|
||||
const sort = searchParams.get('sort') || 'create_date:desc'
|
||||
const hitsPerPage = Number(searchParams.get('perPage')) || 25
|
||||
|
||||
return {
|
||||
data: createSearch({
|
||||
index: 'betaeducacao-prod-orders',
|
||||
sort: ['create_date:desc'],
|
||||
sort: [sort],
|
||||
page,
|
||||
hitsPerPage,
|
||||
env: context.cloudflare.env
|
||||
|
||||
@@ -40,7 +40,7 @@ export default function Route({ loaderData }: Route.ComponentProps) {
|
||||
px-4 py-2 lg:py-4 sticky top-0 z-5
|
||||
md:rounded-t-2xl"
|
||||
>
|
||||
<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 flex gap-1">
|
||||
<span className="text-muted-foreground text-xs">Insights</span>
|
||||
@@ -54,7 +54,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"
|
||||
|
||||
@@ -8,7 +8,9 @@ type ContainerProps = {
|
||||
export function Container({ children, className }: ContainerProps) {
|
||||
return (
|
||||
<main className="p-4">
|
||||
<div className={cn('container mx-auto', className)}>{children}</div>
|
||||
<div className={cn('container mx-auto max-w-7xl', className)}>
|
||||
{children}
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Scorm12API } from 'scorm-again/scorm12'
|
||||
import { settings, type ScormPlayerProps } from './scorm-player'
|
||||
|
||||
// https://scorm.com/scorm-explained/technical-scorm/run-time/run-time-reference/#section-2
|
||||
export function Scorm12Player({
|
||||
scormState,
|
||||
scormContentPath,
|
||||
className,
|
||||
onCommit,
|
||||
setValue
|
||||
}: ScormPlayerProps) {
|
||||
const [iframeLoaded, setIframeLoaded] = useState(false)
|
||||
const scormApiRef = useRef<Scorm12API | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const scormApi = new Scorm12API(settings)
|
||||
scormApi.loadFromFlattenedJSON(scormState)
|
||||
|
||||
scormApi.on('LMSCommit', function () {
|
||||
onCommit?.(scormApi.renderCommitCMI(true))
|
||||
})
|
||||
|
||||
scormApi.on('LMSSetValue.*', function (element: any, value: any) {
|
||||
setValue?.(element, value)
|
||||
})
|
||||
|
||||
scormApiRef.current = scormApi
|
||||
window.API = scormApi
|
||||
setIframeLoaded(true)
|
||||
|
||||
return () => {
|
||||
scormApiRef.current = null
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!scormApiRef.current) {
|
||||
return
|
||||
}
|
||||
|
||||
const scormApi = scormApiRef.current
|
||||
let unloaded = false
|
||||
|
||||
function unload() {
|
||||
if (unloaded || scormApi.isTerminated()) {
|
||||
return false
|
||||
}
|
||||
|
||||
scormApi.LMSSetValue('cmi.core.exit', 'suspend')
|
||||
scormApi.LMSCommit()
|
||||
scormApi.LMSFinish()
|
||||
|
||||
unloaded = true
|
||||
}
|
||||
|
||||
window.addEventListener('beforeunload', unload)
|
||||
window.addEventListener('unload', unload)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('beforeunload', unload)
|
||||
window.removeEventListener('unload', unload)
|
||||
}
|
||||
}, [])
|
||||
|
||||
if (iframeLoaded) {
|
||||
return <iframe src={`/proxy/${scormContentPath}`} className={className} />
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Scorm2004API } from 'scorm-again/scorm2004'
|
||||
import { settings, type ScormPlayerProps } from './scorm-player'
|
||||
|
||||
export function Scorm2004Player({
|
||||
scormState,
|
||||
scormContentPath,
|
||||
className,
|
||||
onCommit,
|
||||
setValue
|
||||
}: ScormPlayerProps) {
|
||||
const [iframeLoaded, setIframeLoaded] = useState(false)
|
||||
const scormApiRef = useRef<Scorm2004API | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const scormApi = new Scorm2004API(settings)
|
||||
scormApi.loadFromFlattenedJSON(scormState)
|
||||
|
||||
scormApi.on('LMSCommit', function () {
|
||||
onCommit?.(scormApi.renderCommitCMI(true))
|
||||
})
|
||||
|
||||
scormApi.on('LMSSetValue.*', function (element: any, value: any) {
|
||||
setValue?.(element, value)
|
||||
})
|
||||
|
||||
scormApiRef.current = scormApi
|
||||
window.API_1484_11 = scormApi
|
||||
setIframeLoaded(true)
|
||||
|
||||
return () => {
|
||||
scormApiRef.current = null
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!scormApiRef.current) {
|
||||
return
|
||||
}
|
||||
|
||||
const scormApi = scormApiRef.current
|
||||
let unloaded = false
|
||||
|
||||
function unload() {
|
||||
if (unloaded || scormApi.isTerminated()) {
|
||||
return false
|
||||
}
|
||||
|
||||
scormApi.SetValue('cmi.exit', 'suspend')
|
||||
scormApi.Commit()
|
||||
scormApi.Terminate()
|
||||
|
||||
unloaded = true
|
||||
}
|
||||
|
||||
window.addEventListener('beforeunload', unload)
|
||||
window.addEventListener('unload', unload)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('beforeunload', unload)
|
||||
window.removeEventListener('unload', unload)
|
||||
}
|
||||
}, [])
|
||||
|
||||
if (iframeLoaded) {
|
||||
return <iframe src={`/proxy/${scormContentPath}`} className={className} />
|
||||
}
|
||||
}
|
||||
@@ -22,12 +22,8 @@ import { MeiliSearchFilterBuilder } from 'meilisearch-helper'
|
||||
import { Suspense, useMemo } from 'react'
|
||||
import { Await, NavLink, useSearchParams } from 'react-router'
|
||||
|
||||
import placeholder from '@/assets/placeholder.webp'
|
||||
import { Container } from '@/components/container'
|
||||
|
||||
import type { User } from '@repo/auth/auth'
|
||||
import { userContext } from '@repo/auth/context'
|
||||
|
||||
import { FacetedFilter } from '@repo/ui/components/faceted-filter'
|
||||
import { SearchForm } from '@repo/ui/components/search-form'
|
||||
import { Skeleton } from '@repo/ui/components/skeleton'
|
||||
@@ -42,6 +38,9 @@ import { Kbd } from '@repo/ui/components/ui/kbd'
|
||||
import { Progress } from '@repo/ui/components/ui/progress'
|
||||
import { createSearch } from '@repo/util/meili'
|
||||
|
||||
import placeholder from '@/assets/placeholder.webp'
|
||||
import { Container } from '@/components/container'
|
||||
|
||||
type Course = {
|
||||
name: string
|
||||
scormset?: string
|
||||
@@ -58,7 +57,7 @@ export function meta({}: Route.MetaArgs) {
|
||||
return [{ title: 'Meus cursos' }]
|
||||
}
|
||||
|
||||
export const loader = async ({ request, context }: Route.ActionArgs) => {
|
||||
export async function loader({ request, context }: Route.ActionArgs) {
|
||||
const user = context.get(userContext) as User
|
||||
const { searchParams } = new URL(request.url)
|
||||
const status = searchParams.getAll('status') || []
|
||||
@@ -89,18 +88,18 @@ export default function Component({
|
||||
|
||||
return (
|
||||
<Container className="space-y-4">
|
||||
<div className="space-y-0.5 mb-8">
|
||||
<h1 className="text-2xl font-bold tracking-tight">Meus cursos</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Aqui você encontra todos os cursos em que está matriculado,
|
||||
organizados em um só lugar. Acompanhe seu progresso e continue de onde
|
||||
parou.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Suspense fallback={<Skeleton />}>
|
||||
<div className="space-y-0.5 mb-8">
|
||||
<h1 className="text-2xl font-bold tracking-tight">Meus cursos</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Aqui você encontra todos os cursos em que está matriculado,
|
||||
organizados em um só lugar. Acompanhe seu progresso e continue de
|
||||
onde parou.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2.5">
|
||||
<div className="w-full xl:w-93">
|
||||
<div className="w-full xl:w-1/3">
|
||||
<SearchForm
|
||||
defaultValue={term || ''}
|
||||
placeholder={
|
||||
@@ -142,13 +141,9 @@ export default function Component({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid lg:grid-cols-4 gap-5">
|
||||
<Await resolve={data}>
|
||||
{({ hits = [] }) => {
|
||||
return <List term={term} hits={hits as Enrollment[]} />
|
||||
}}
|
||||
</Await>
|
||||
</div>
|
||||
<Await resolve={data}>
|
||||
{({ hits = [] }) => <List term={term} hits={hits as Enrollment[]} />}
|
||||
</Await>
|
||||
</Suspense>
|
||||
</Container>
|
||||
)
|
||||
@@ -173,7 +168,7 @@ function List({ term, hits = [] }: { term: string; hits: Enrollment[] }) {
|
||||
|
||||
if (hits_.length === 0) {
|
||||
return (
|
||||
<Empty>
|
||||
<Empty className="border border-dashed">
|
||||
<EmptyHeader>
|
||||
<EmptyMedia variant="icon">
|
||||
<BanIcon />
|
||||
@@ -187,9 +182,13 @@ function List({ term, hits = [] }: { term: string; hits: Enrollment[] }) {
|
||||
)
|
||||
}
|
||||
|
||||
return hits_.map((props: Enrollment, idx) => {
|
||||
return <Enrollment key={idx} {...props} />
|
||||
})
|
||||
return (
|
||||
<div className="grid lg:grid-cols-4 gap-5">
|
||||
{hits_.map((props: Enrollment, idx) => {
|
||||
return <Enrollment key={idx} {...props} />
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Enrollment({ id, course, progress }: Enrollment) {
|
||||
|
||||
@@ -55,7 +55,7 @@ export default function Component({ 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">
|
||||
{/* Desktop Menu */}
|
||||
<div className="hidden lg:flex items-center gap-8">
|
||||
<Link to="/">
|
||||
|
||||
@@ -25,7 +25,7 @@ export function meta({}: Route.MetaArgs) {
|
||||
return [{ title: 'Histórico de compras' }]
|
||||
}
|
||||
|
||||
export const loader = async ({ request, context }: Route.ActionArgs) => {
|
||||
export async function loader({ request, context }: Route.ActionArgs) {
|
||||
const user = context.get(userContext) as User
|
||||
const { searchParams } = new URL(request.url)
|
||||
const status = searchParams.getAll('status') || []
|
||||
@@ -55,8 +55,8 @@ export const loader = async ({ request, context }: Route.ActionArgs) => {
|
||||
|
||||
export default function Component({ loaderData: { data } }) {
|
||||
return (
|
||||
<Suspense fallback={<Skeleton />}>
|
||||
<Container className="space-y-2.5">
|
||||
<Container className="space-y-2.5">
|
||||
<Suspense fallback={<Skeleton />}>
|
||||
<Breadcrumb>
|
||||
<BreadcrumbList>
|
||||
<BreadcrumbItem>
|
||||
@@ -95,7 +95,7 @@ export default function Component({ loaderData: { data } }) {
|
||||
)
|
||||
}}
|
||||
</Await>
|
||||
</Container>
|
||||
</Suspense>
|
||||
</Suspense>
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable */
|
||||
// Generated by Wrangler by running `wrangler types` (hash: 46c0a3878ceeb71c97bee6d456de6815)
|
||||
// Runtime types generated with workerd@1.20251113.0 2025-04-04 nodejs_compat
|
||||
// Runtime types generated with workerd@1.20251118.0 2025-04-04 nodejs_compat
|
||||
declare namespace Cloudflare {
|
||||
interface GlobalProps {
|
||||
mainModule: typeof import("./workers/app");
|
||||
@@ -469,7 +469,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;
|
||||
}
|
||||
@@ -6759,20 +6759,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;
|
||||
@@ -8424,21 +8412,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>;
|
||||
@@ -8501,36 +8490,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 {
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { Meilisearch, type SearchResponse } from 'meilisearch'
|
||||
|
||||
const MAX_HITS_PER_PAGE = 100
|
||||
|
||||
export async function createSearch({
|
||||
query,
|
||||
filter = undefined,
|
||||
index,
|
||||
page,
|
||||
hitsPerPage,
|
||||
sort,
|
||||
env
|
||||
}: {
|
||||
query?: string
|
||||
filter?: string
|
||||
index: string
|
||||
page?: number
|
||||
hitsPerPage: number
|
||||
sort: string[]
|
||||
env: Env
|
||||
}): Promise<SearchResponse> {
|
||||
const host = env.MEILI_HOST
|
||||
const apiKey = env.MEILI_API_KEY
|
||||
const client = new Meilisearch({ host, apiKey })
|
||||
const index_ = client.index(index)
|
||||
|
||||
return index_.search(query, {
|
||||
sort,
|
||||
filter,
|
||||
page,
|
||||
hitsPerPage:
|
||||
hitsPerPage > MAX_HITS_PER_PAGE ? MAX_HITS_PER_PAGE : hitsPerPage
|
||||
})
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
import type { User } from '@repo/auth/auth'
|
||||
import { requestIdContext, userContext } from '@repo/auth/context'
|
||||
|
||||
import type { LoaderFunctionArgs } from 'react-router'
|
||||
|
||||
export enum HttpMethod {
|
||||
GET = 'GET',
|
||||
POST = 'POST',
|
||||
PUT = 'PUT',
|
||||
PATCH = 'PATCH',
|
||||
DELETE = 'DELETE'
|
||||
}
|
||||
|
||||
type RequestArgs = {
|
||||
url: string
|
||||
method?: HttpMethod
|
||||
headers?: HeadersInit
|
||||
body?: BodyInit | null
|
||||
request: LoaderFunctionArgs['request']
|
||||
context: LoaderFunctionArgs['context']
|
||||
}
|
||||
|
||||
export function request({
|
||||
url,
|
||||
method = HttpMethod.GET,
|
||||
body = null,
|
||||
headers: _headers = {},
|
||||
request: { signal },
|
||||
context
|
||||
}: RequestArgs): Promise<Response> {
|
||||
const requestId = context.get(requestIdContext) as string
|
||||
const user = context.get(userContext) as User
|
||||
const url_ = new URL(url, context.cloudflare.env.API_URL)
|
||||
const headers = new Headers({
|
||||
Authorization: `Bearer ${user.accessToken}`
|
||||
})
|
||||
|
||||
if (_headers instanceof Headers) {
|
||||
_headers.forEach((value, key) => headers.set(key, value))
|
||||
} else {
|
||||
Object.entries(_headers).forEach(([key, value]) => headers.set(key, value))
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[${new Date().toISOString()}] [${requestId}] ${method} ${url_.toString()}`
|
||||
)
|
||||
|
||||
return fetch(url_.toString(), { method, headers, body, signal })
|
||||
}
|
||||
@@ -8,8 +8,7 @@ import { Await, useAsyncValue, useFetcher } from 'react-router'
|
||||
import { toast } from 'sonner'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { HttpMethod, request as req } from '@/lib/request'
|
||||
|
||||
import { request as req, HttpMethod } from '@repo/util/request'
|
||||
import { Skeleton } from '@repo/ui/components/skeleton'
|
||||
import {
|
||||
Breadcrumb,
|
||||
@@ -134,27 +133,27 @@ export async function action({ params, request, context }: Route.ActionArgs) {
|
||||
|
||||
export default function Component({ loaderData: { data } }) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Breadcrumb>
|
||||
<BreadcrumbList>
|
||||
<BreadcrumbItem>
|
||||
<BreadcrumbLink href="/">Cursos</BreadcrumbLink>
|
||||
</BreadcrumbItem>
|
||||
<BreadcrumbSeparator />
|
||||
<BreadcrumbItem>
|
||||
<BreadcrumbPage>Editar curso</BreadcrumbPage>
|
||||
</BreadcrumbItem>
|
||||
</BreadcrumbList>
|
||||
</Breadcrumb>
|
||||
<Suspense fallback={<Skeleton />}>
|
||||
<div className="space-y-4">
|
||||
<Breadcrumb>
|
||||
<BreadcrumbList>
|
||||
<BreadcrumbItem>
|
||||
<BreadcrumbLink href="/">Cursos</BreadcrumbLink>
|
||||
</BreadcrumbItem>
|
||||
<BreadcrumbSeparator />
|
||||
<BreadcrumbItem>
|
||||
<BreadcrumbPage>Editar curso</BreadcrumbPage>
|
||||
</BreadcrumbItem>
|
||||
</BreadcrumbList>
|
||||
</Breadcrumb>
|
||||
|
||||
<Suspense fallback={<Skeleton />}>
|
||||
<div className="lg:max-w-2xl mx-auto">
|
||||
<Await resolve={data}>
|
||||
<Editing />
|
||||
</Await>
|
||||
</div>
|
||||
</Suspense>
|
||||
</div>
|
||||
</div>
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,7 @@ import { AwardIcon, BanIcon, FileBadgeIcon, LaptopIcon } from 'lucide-react'
|
||||
import { Suspense, useMemo } from 'react'
|
||||
import { Await, NavLink, useSearchParams } from 'react-router'
|
||||
|
||||
import placeholder from '@/assets/placeholder.webp'
|
||||
|
||||
import { createSearch } from '@/lib/meili'
|
||||
|
||||
import { createSearch } from '@repo/util/meili'
|
||||
import { SearchForm } from '@repo/ui/components/search-form'
|
||||
import { Skeleton } from '@repo/ui/components/skeleton'
|
||||
import {
|
||||
@@ -31,19 +28,24 @@ import {
|
||||
TooltipContent,
|
||||
TooltipTrigger
|
||||
} from '@repo/ui/components/ui/tooltip'
|
||||
|
||||
import type { Course } from './edit'
|
||||
import placeholder from '@/assets/placeholder.webp'
|
||||
|
||||
export function meta({}: Route.MetaArgs) {
|
||||
return [{ title: 'Gerenciar seus cursos' }]
|
||||
}
|
||||
|
||||
export const loader = async ({ context }: Route.ActionArgs) => {
|
||||
const courses = createSearch({
|
||||
index: 'saladeaula_courses',
|
||||
sort: ['created_at:desc'],
|
||||
hitsPerPage: 100,
|
||||
env: context.cloudflare.env
|
||||
})
|
||||
|
||||
return {
|
||||
data: createSearch({
|
||||
index: 'saladeaula_courses',
|
||||
sort: ['created_at:desc'],
|
||||
env: context.cloudflare.env
|
||||
})
|
||||
data: courses
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,20 +54,20 @@ export default function Component({ loaderData: { data } }) {
|
||||
const term = searchParams.get('term') as string
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-0.5 mb-8">
|
||||
<h1 className="text-2xl font-bold tracking-tight">Cursos</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Gerencie seus cursos com facilidade e organize seu conteúdo.
|
||||
</p>
|
||||
</div>
|
||||
<Suspense fallback={<Skeleton />}>
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-0.5 mb-8">
|
||||
<h1 className="text-2xl font-bold tracking-tight">Cursos</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Gerencie seus cursos com facilidade e organize seu conteúdo.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Suspense fallback={<Skeleton />}>
|
||||
<div className="w-full xl:w-92">
|
||||
<div className="w-full xl:w-1/3">
|
||||
<SearchForm
|
||||
placeholder={
|
||||
<>
|
||||
Pressione <Kbd>/</Kbd> para filtrar...
|
||||
Digite <Kbd>/</Kbd> para pesquisar
|
||||
</>
|
||||
}
|
||||
defaultValue={term}
|
||||
@@ -75,15 +77,11 @@ export default function Component({ loaderData: { data } }) {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid lg:grid-cols-4 gap-5">
|
||||
<Await resolve={data}>
|
||||
{({ hits = [] }) => {
|
||||
return <List term={term} hits={hits} />
|
||||
}}
|
||||
</Await>
|
||||
</div>
|
||||
</Suspense>
|
||||
</div>
|
||||
<Await resolve={data}>
|
||||
{({ hits = [] }) => <List term={term} hits={hits} />}
|
||||
</Await>
|
||||
</div>
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -106,7 +104,7 @@ function List({ term, hits = [] }: { term: string; hits: Course[] }) {
|
||||
|
||||
if (hits_.length === 0) {
|
||||
return (
|
||||
<Empty>
|
||||
<Empty className="border border-dashed">
|
||||
<EmptyHeader>
|
||||
<EmptyMedia variant="icon">
|
||||
<BanIcon />
|
||||
@@ -120,9 +118,13 @@ function List({ term, hits = [] }: { term: string; hits: Course[] }) {
|
||||
)
|
||||
}
|
||||
|
||||
return hits_.map((props: Course, idx) => {
|
||||
return <Course key={idx} {...props} />
|
||||
})
|
||||
return (
|
||||
<div className="grid lg:grid-cols-4 gap-5">
|
||||
{hits_.map((props: Course, idx) => {
|
||||
return <Course key={idx} {...props} />
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Course({ id, name, access_period, cert, draft }: Course) {
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function Component({ 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">
|
||||
<Link to="/">
|
||||
<ThemedImage className="flex gap-1">
|
||||
<span className="text-muted-foreground text-xs">Estúdio</span>
|
||||
@@ -38,7 +38,7 @@ export default function Component({ loaderData }: Route.ComponentProps) {
|
||||
</header>
|
||||
|
||||
<main className="p-4">
|
||||
<div className="container mx-auto">
|
||||
<div className="container mx-auto max-w-7xl">
|
||||
<Outlet />
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable */
|
||||
// Generated by Wrangler by running `wrangler types` (hash: 94bfdc7e16675b26364c038a94ff21b3)
|
||||
// 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