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