- Implemented AbsenceNotifyView for notifying absence with session details. - Created AnalyticsView for displaying group analytics and managing students at risk. - Added ClassAttendanceView for marking attendance in classes. - Defined new schemas for analytics and attendance in shared package.
25 lines
829 B
TypeScript
25 lines
829 B
TypeScript
import type { NotifyAbsence } from '@gruperly/shared';
|
|
import { NotifyAbsenceSchema } from '@gruperly/shared';
|
|
import { Hono } from 'hono';
|
|
import { problemJson, resultJson, unauthorizedProblem } from '@/http/problem-details';
|
|
import { validate } from '@/http/validate';
|
|
import { NotifySessionAbsence } from './use-case';
|
|
|
|
const route = new Hono();
|
|
|
|
route.post('/:sessionId/notify-absence', validate.json(NotifyAbsenceSchema), async (c) => {
|
|
const user = c.get('user');
|
|
if (!user) {
|
|
return problemJson(c, unauthorizedProblem(c.req.path));
|
|
}
|
|
|
|
const sessionId = c.req.param('sessionId');
|
|
const payload = c.req.valid('json') as NotifyAbsence;
|
|
const useCase = new NotifySessionAbsence();
|
|
const result = await useCase.execute(sessionId, payload, user.id);
|
|
|
|
return resultJson(c, result);
|
|
});
|
|
|
|
export default route;
|