Added PlantTouchPoint and IPMSchedule models. Implemented touch-points and IPM controllers/routes. Updated frontend with Dashboard feed and IPM widgets.
22 lines
843 B
TypeScript
22 lines
843 B
TypeScript
import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
|
|
import { createOrUpdateSchedule, getSchedule, getDueTreatments } from '../controllers/ipm.controller';
|
|
|
|
export async function ipmRoutes(fastify: FastifyInstance) {
|
|
const authenticate = async (request: FastifyRequest, reply: FastifyReply) => {
|
|
try {
|
|
await request.jwtVerify();
|
|
} catch (err) {
|
|
reply.send(err);
|
|
}
|
|
};
|
|
|
|
fastify.post('/api/ipm/schedule', { preHandler: [authenticate] }, createOrUpdateSchedule);
|
|
|
|
interface GetScheduleRequest {
|
|
Params: {
|
|
batchId: string;
|
|
}
|
|
}
|
|
fastify.get<GetScheduleRequest>('/api/batches/:batchId/ipm/schedule', { preHandler: [authenticate] }, getSchedule);
|
|
fastify.get('/api/ipm/due', { preHandler: [authenticate] }, getDueTreatments);
|
|
}
|