Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/controllers/participantCard.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const fetchAllParticipantsData = async () => {
};

const getParticipantCards = asyncHandler(async (req, res, next) => {
const collegeId = req.user.id;
const collegeId = req.params?.id || req.user?.id;

const { users, error } = await fetchParticipansData(collegeId);
if (error) {
Expand All @@ -117,13 +117,13 @@ const getParticipantCards = asyncHandler(async (req, res, next) => {

res.set({
"Content-Type": "application/pdf",
"Content-Disposition": 'attachment; filename="participant-cards.pdf"',
"Content-Disposition": `attachment; filename="${users[0]?.college}-participant-cards-A6.pdf"`,
});
res.send(Buffer.from(pdfBytes));
});

const getParticipantCardsCompact = asyncHandler(async (req, res, next) => {
const collegeId = req.user.id;
const collegeId = req.params?.id || req.user?.id;

const { users, error } = await fetchParticipansData(collegeId);
if (error) {
Expand All @@ -134,7 +134,7 @@ const getParticipantCardsCompact = asyncHandler(async (req, res, next) => {

res.set({
"Content-Type": "application/pdf",
"Content-Disposition": 'attachment; filename="participant-cards-A4.pdf"',
"Content-Disposition": `attachment; filename="${users[0]?.college}-participant-cards.pdf"`,
});
res.send(Buffer.from(pdfBytes));
});
Expand Down
5 changes: 5 additions & 0 deletions src/routes/admin.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ router.route("/event-registration").get(eventRegistrationController.getAllEventR
// PDF export routes
router.route("/participants-list/:id").get(pdfExportController.getProgramParticipantsListById);
router.route("/all-participant-cards").get(participantCardController.getAllParticipantCardsCompact);
router.route("/participant-cards-compact/:id").get(participantCardController.getParticipantCardsCompact)
router.route("/participant-cards/:id").get(participantCardController.getParticipantCards);
// get participant card by user Id
router.route("/participant-card/:id").get(participantCardController.getParticipantCardById);


router.route("/result-categories").get(eventController.fetchResultCategories);

Expand Down
6 changes: 3 additions & 3 deletions src/routes/organization.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ router.route("/events").get(eventController.fetchAllEvents);
// PDF export routes
router.route("/participant-tickets").get(pdfExportController.getParticipantTickets);
router.route("/ticket/:id").get(pdfExportController.getParticipantTicketById);
router.route("/participant-cards").get(participantCardController.getParticipantCards);
router.route("/participant-card/:id").get(participantCardController.getParticipantCardById);
router.route("/participant-cards-compact").get(participantCardController.getParticipantCardsCompact);
// router.route("/participant-cards").get(participantCardController.getParticipantCards);
// router.route("/participant-card/:id").get(participantCardController.getParticipantCardById);
// router.route("/participant-cards-compact").get(participantCardController.getParticipantCardsCompact);


// configs
Expand Down