diff --git a/apps/admin.saladeaula.digital/app/routes/_.$orgid.scheduled/route.tsx b/apps/admin.saladeaula.digital/app/routes/_.$orgid.scheduled/route.tsx index c69a741..aad1b9d 100644 --- a/apps/admin.saladeaula.digital/app/routes/_.$orgid.scheduled/route.tsx +++ b/apps/admin.saladeaula.digital/app/routes/_.$orgid.scheduled/route.tsx @@ -3,9 +3,13 @@ import type { Route } from './+types/route' import type { MouseEvent, ReactNode } from 'react' import { useRequest, useToggle } from 'ahooks' import { + AlertTriangleIcon, BanIcon, + CalendarClockIcon, CalendarIcon, CircleXIcon, + ClockAlertIcon, + ClockCheckIcon, EllipsisIcon, PlusIcon, RocketIcon, @@ -151,19 +155,37 @@ export default function Route({ {({ items }) => ( - + + + + + )} - {({ items }) => <>...} + {({ items }) => ( + + + + + + )} - {({ items }) => <>...} + + {({ items }) => ( + + + + + + )} + @@ -198,55 +220,134 @@ function Timeline({ ) } -function Scheduled({ items, className }) { +function Scheduled({ items = [] }) { return ( - - - - {items.map( - ({ sk, user, course, created_by, scheduled_at }, index) => ( - - - - - - {initials(user.name)} - - - + + {items.map(({ sk, user, course, created_by, scheduled_at }, index) => ( + + + + + + {initials(user.name)} + + + - - {course.name} - - {user.name} - {user.email} - + + {course.name} + + {user.name} + {user.email} + -
-
    -
  • - {' '} - {datetime.format(new Date(scheduled_at))} -
  • -
  • - {created_by.name} -
  • -
-
-
+
+
    +
  • + + {datetime.format(new Date(scheduled_at))} +
  • +
  • + + {created_by.name} +
  • +
+
+
- - - -
+ + + +
- {index !== items.length - 1 && } -
- ) - )} -
-
-
+ {index !== items.length - 1 && } + + ))} + + ) +} + +function Executed({ items = [] }) { + return ( + + {items.map(({ course, user, created_at }, index) => ( + + + + + + {initials(user.name)} + + + + + + {course.name} + + {user.name} + {user.email} + + +
+
    +
  • + + {datetime.format(new Date(created_at))} +
  • +
+
+
+
+ + {index !== items.length - 1 && } +
+ ))} +
+ ) +} + +function Failed({ items = [] }) { + return ( + + {items.map(({ snapshot: { course, user }, cause, created_at }, index) => ( + + + + + + {initials(user.name)} + + + + + + {course.name} + + {user.name} + {user.email} + + +
+
    +
  • + + {datetime.format(new Date(created_at))} +
  • + {cause?.type === 'DeduplicationConflictError' ? ( +
  • + + Protegido contra duplicação +
  • + ) : null} +
+
+
+
+ + {index !== items.length - 1 && } +
+ ))} +
) } @@ -266,9 +367,7 @@ function ActionMenu({ sk }: { sk: string }) { - - Matricular agora - + @@ -276,6 +375,26 @@ function ActionMenu({ sk }: { sk: string }) { ) } +function Proceedtem({ sk, onSuccess }: { sk: string; onSuccess?: () => void }) { + const { runAsync, loading } = useRequest( + async () => { + await new Promise((r) => setTimeout(r, 1000)) + }, + { manual: true } + ) + + const proceed = async (e: MouseEvent) => { + e.preventDefault() + await runAsync() + } + + return ( + + {loading ? : } Matricular agora + + ) +} + function CancelItem({ sk, onSuccess }: { sk: string; onSuccess?: () => void }) { const { orgid } = useParams() const [open, { set: setOpen }] = useToggle(false) diff --git a/enrollments-events/app/events/enroll_scheduled.py b/enrollments-events/app/events/enroll_scheduled.py index 8963d6c..fd2bb97 100644 --- a/enrollments-events/app/events/enroll_scheduled.py +++ b/enrollments-events/app/events/enroll_scheduled.py @@ -8,7 +8,6 @@ from aws_lambda_powertools.utilities.data_classes import ( from aws_lambda_powertools.utilities.typing import LambdaContext from layercake.dateutils import now from layercake.dynamodb import DynamoDBPersistenceLayer -from layercake.funcs import pick from boto3clients import dynamodb_client from config import ENROLLMENT_TABLE @@ -58,14 +57,13 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool: persistence_layer=dyn, ) - keys = ('id', 'name') dyn.put_item( item={ 'id': old_image['id'], 'sk': f'{sk}#EXECUTED', 'enrollment_id': enrollment.id, - 'user': pick(keys, old_image['user']), - 'course': pick(keys, old_image['course']), + 'user': old_image['user'], + 'course': old_image['course'], 'created_by': created_by, 'created_at': now_, }