Skip to content

Commit

Permalink
feat: generate registration number for child
Browse files Browse the repository at this point in the history
  • Loading branch information
naftis committed Nov 4, 2024
1 parent 3d0025c commit 17c3b10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/server/src/registration-number.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const generateRegistrationNumber = (trackingId: string) => {
const currentYear = new Date().getFullYear().toString();
return `${currentYear}${trackingId}`;
};
8 changes: 5 additions & 3 deletions packages/server/src/webhooks/mosip.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FastifyRequest, FastifyReply } from "fastify";
import { z } from "zod";
import { confirmRegistration } from "../opencrvs-api";
import * as opencrvs from "../opencrvs-api";
import { generateRegistrationNumber } from "../registration-number";

export const mosipNidSchema = z.object({
eventId: z
Expand All @@ -27,12 +28,13 @@ export const mosipHandler = async (
reply: FastifyReply
) => {
const { eventId, trackingId, nid, token } = request.body;
const registrationNumber = generateRegistrationNumber(trackingId);

await confirmRegistration(
await opencrvs.confirmRegistration(
eventId,
{
trackingId,
registrationNumber: "BRN12341234", // @TODO
registrationNumber,
childIdentifiers: [{ type: "NID", value: nid }],
},
{ headers: { Authorization: `Bearer ${token}` } }
Expand Down

0 comments on commit 17c3b10

Please sign in to comment.