add created_at
This commit is contained in:
@@ -80,6 +80,7 @@ def enroll(
|
||||
enrollments: Annotated[tuple[Enrollment, ...], Body(embed=True)],
|
||||
):
|
||||
now_ = now()
|
||||
created_by: Authenticated = router.context['user']
|
||||
org = dyn.collection.get_items(
|
||||
KeyPair(
|
||||
pk=str(org_id),
|
||||
@@ -105,7 +106,7 @@ def enroll(
|
||||
|
||||
ctx = {
|
||||
'org': Org.model_validate(org),
|
||||
'created_by': router.context['user'],
|
||||
'created_by': created_by,
|
||||
'terms': SubscriptionTerms.model_validate(org['terms']),
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ def enroll(
|
||||
'status': r.status.value,
|
||||
'input_record': extract_event_from_common_models(r.input_record),
|
||||
'output': extract_event_from_common_models(r.output),
|
||||
'cause': extract_event_from_common_models(r.cause),
|
||||
'cause': r.cause,
|
||||
}
|
||||
|
||||
item = {
|
||||
@@ -132,6 +133,10 @@ def enroll(
|
||||
'enrolled': list(map(fmt, now_out)) if now_out else None,
|
||||
'scheduled': list(map(fmt, later_out)) if later_out else None,
|
||||
'ttl': ttl(start_dt=now_, days=30 * 6),
|
||||
'created_by': {
|
||||
'id': created_by.id,
|
||||
'name': created_by.name,
|
||||
},
|
||||
}
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import type { Route } from './+types/route'
|
||||
|
||||
import { AlertCircleIcon, CheckCircle2Icon, ClockIcon } from 'lucide-react'
|
||||
import {
|
||||
AlertCircleIcon,
|
||||
CheckCircle2Icon,
|
||||
ClockIcon,
|
||||
CalendarIcon,
|
||||
UserIcon
|
||||
} from 'lucide-react'
|
||||
import { Link } from 'react-router'
|
||||
import { Suspense } from 'react'
|
||||
|
||||
@@ -8,6 +14,7 @@ import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle
|
||||
} from '@repo/ui/components/ui/card'
|
||||
@@ -70,29 +77,26 @@ export default function Route({ loaderData: { data } }: Route.ComponentProps) {
|
||||
</BreadcrumbList>
|
||||
</Breadcrumb>
|
||||
|
||||
<div className="lg:max-w-4xl mx-auto space-y-2.5">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-2xl">
|
||||
Relatório de matrículas
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
Resumo detalhado do processamento das matrículas enviadas.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<Await resolve={data}>
|
||||
{({ enrolled, scheduled, sk, created_by }) => {
|
||||
const succeed = enrolled.filter(
|
||||
({ status }) => status === 'success'
|
||||
)
|
||||
const failed = enrolled.filter(({ status }) => status === 'fail')
|
||||
|
||||
<CardContent className="space-y-4">
|
||||
<Await resolve={data}>
|
||||
{({ enrolled, scheduled }) => {
|
||||
const succeed = enrolled.filter(
|
||||
({ status }) => status === 'success'
|
||||
)
|
||||
const failed = enrolled.filter(
|
||||
({ status }) => status === 'fail'
|
||||
)
|
||||
return (
|
||||
<div className="lg:max-w-4xl mx-auto space-y-2.5">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-2xl">
|
||||
Relatório de matrículas
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
Resumo detalhado do processamento das matrículas enviadas.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
|
||||
// console.log(succeed)
|
||||
return (
|
||||
<CardContent className="space-y-4 text-base">
|
||||
<>
|
||||
{succeed?.length > 0 && (
|
||||
<Alert className="text-green-500 *:data-[slot=alert-description]:text-green-500/90">
|
||||
@@ -101,7 +105,7 @@ export default function Route({ loaderData: { data } }: Route.ComponentProps) {
|
||||
Matrículas adicionadas com sucesso.
|
||||
</AlertTitle>
|
||||
<AlertDescription>
|
||||
<ul className="list-decimal list-inside">
|
||||
<ul className="list-disc list-inside">
|
||||
{succeed.map(({ output }) => (
|
||||
<li className="space-x-1">
|
||||
<Abbr>{output.user.name}</Abbr>
|
||||
@@ -119,7 +123,7 @@ export default function Route({ loaderData: { data } }: Route.ComponentProps) {
|
||||
<AlertCircleIcon />
|
||||
<AlertTitle>Matrículas não processadas.</AlertTitle>
|
||||
<AlertDescription>
|
||||
<ul className="list-decimal list-inside">
|
||||
<ul className="list-disc list-inside">
|
||||
{failed.map(({ input_record }) => (
|
||||
<li className="space-x-1">
|
||||
<Abbr>{input_record.user.name}</Abbr>
|
||||
@@ -148,13 +152,38 @@ export default function Route({ loaderData: { data } }: Route.ComponentProps) {
|
||||
</Alert>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}}
|
||||
</Await>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
<CardFooter>
|
||||
<ul
|
||||
className="grid lg:grid-cols-2 gap-x-4 text-muted-foreground text-sm
|
||||
*:flex *:gap-1 *:items-center"
|
||||
>
|
||||
<li>
|
||||
<CalendarIcon className="size-3.5" />
|
||||
{formatted.format(new Date(sk))}
|
||||
</li>
|
||||
{created_by && (
|
||||
<li>
|
||||
<UserIcon className="size-3.5" /> {created_by.name}
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
</Await>
|
||||
</div>
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
const formatted = new Intl.DateTimeFormat('pt-BR', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user