import type { Route } from './+types/route' import { BanIcon, CalendarIcon, EllipsisIcon, PlusIcon, UserIcon } from 'lucide-react' import { DateTime } from 'luxon' import { Fragment, Suspense } from 'react' import { Await } from 'react-router' import { request as req } from '@repo/util/request' import { Button } from '@repo/ui/components/ui/button' import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from '@repo/ui/components/ui/empty' import { Skeleton } from '@repo/ui/components/skeleton' import { Card, CardContent } from '@repo/ui/components/ui/card' import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemSeparator, ItemTitle } from '@repo/ui/components/ui/item' import { Link } from 'react-router' export function meta({}: Route.MetaArgs) { return [{ title: 'Matrículas agendadas' }] } export async function loader({ context, request, params }: Route.LoaderArgs) { const scheduled = req({ url: `/orgs/${params.orgid}/enrollments/scheduled`, context, request }).then((r) => r.json()) return { scheduled } } export default function Route({ loaderData: { scheduled } }: Route.ComponentProps) { return ( }>

Matrículas agendadas

Acompanhe todas as matrículas agendadas, cancele quando quiser ou matricule imediatamente.

{({ items }) => { const scheduled = grouping(items) if (scheduled.length === 0) { return ( Nenhum agendamento ainda Agende a matrícula dos seus colaboradores de forma rápida e organizada. ) } return (
{scheduled.map(([run_at, items], index) => (
{DateTime.fromISO(run_at) .setLocale('pt-BR') .toFormat('cccc, dd LLL yyyy')}
{items.map( ( { user, course, created_by, scheduled_at }, index ) => ( {course.name} {user.name} {/**/}
  • {' '} {datetime.format( new Date(scheduled_at) )}
  • {' '} {created_by.name}
{/* */}
{index !== items.length - 1 && }
) )}
))}
) }}
) } function grouping(items) { const newItems = Object.entries( items.reduce((acc, item) => { const [run_at] = item.sk.split('#') if (!acc[run_at]) { acc[run_at] = [] } acc[run_at].push(item) return acc }, []) ) return newItems.sort((x, y) => x[0].localeCompare(y[0])) } const datetime = new Intl.DateTimeFormat('pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit' })