diff --git a/api.saladeaula.digital/app/routes/enrollments/enroll.py b/api.saladeaula.digital/app/routes/enrollments/enroll.py index 8bcf545..71ed0f1 100644 --- a/api.saladeaula.digital/app/routes/enrollments/enroll.py +++ b/api.saladeaula.digital/app/routes/enrollments/enroll.py @@ -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: diff --git a/apps/admin.saladeaula.digital/app/routes/_.$orgid.enrollments.$id.submitted/route.tsx b/apps/admin.saladeaula.digital/app/routes/_.$orgid.enrollments.$id.submitted/route.tsx index 5bae784..ace69f2 100644 --- a/apps/admin.saladeaula.digital/app/routes/_.$orgid.enrollments.$id.submitted/route.tsx +++ b/apps/admin.saladeaula.digital/app/routes/_.$orgid.enrollments.$id.submitted/route.tsx @@ -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) { -
- - - - Relatório de matrículas - - - Resumo detalhado do processamento das matrículas enviadas. - - + + {({ enrolled, scheduled, sk, created_by }) => { + const succeed = enrolled.filter( + ({ status }) => status === 'success' + ) + const failed = enrolled.filter(({ status }) => status === 'fail') - - - {({ enrolled, scheduled }) => { - const succeed = enrolled.filter( - ({ status }) => status === 'success' - ) - const failed = enrolled.filter( - ({ status }) => status === 'fail' - ) + return ( +
+ + + + Relatório de matrículas + + + Resumo detalhado do processamento das matrículas enviadas. + + - // console.log(succeed) - return ( + <> {succeed?.length > 0 && ( @@ -101,7 +105,7 @@ export default function Route({ loaderData: { data } }: Route.ComponentProps) { Matrículas adicionadas com sucesso. -
    +
      {succeed.map(({ output }) => (
    • {output.user.name} @@ -119,7 +123,7 @@ export default function Route({ loaderData: { data } }: Route.ComponentProps) { Matrículas não processadas. -
        +
          {failed.map(({ input_record }) => (
        • {input_record.user.name} @@ -148,13 +152,38 @@ export default function Route({ loaderData: { data } }: Route.ComponentProps) { )} - ) - }} - - - -
+
+ + +
    +
  • + + {formatted.format(new Date(sk))} +
  • + {created_by && ( +
  • + {created_by.name} +
  • + )} +
+
+
+
+ ) + }} + ) } + +const formatted = new Intl.DateTimeFormat('pt-BR', { + day: '2-digit', + month: '2-digit', + year: 'numeric', + hour: '2-digit', + minute: '2-digit' +})