Skip to content

Commit

Permalink
fix:enrollment and sports certificates issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ManojNathIC committed Nov 28, 2024
2 parents 9319156 + 3949c3c commit e4da20a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
41 changes: 40 additions & 1 deletion src/inspector/inspector.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,50 @@ export class InspectorService {
async renderHtml(data: any, type: any): Promise<string> {
const htmlTemplate = await this.loadTemplate(type); // Load the HTML template from file
const template = Handlebars.compile(htmlTemplate); // Compile the template using Handlebars
console.log('-----------------------', htmlTemplate, data);
// console.log('-----------------------', htmlTemplate, data);

data = this.mapCertificateData(data);

return template(data); // Inject the dynamic data
}

mapCertificateData(data: any) {
const mappedData: { [key: string]: any } = {};
const addressFields = [
'addressLine1',
'addressLine2',
'house',
'landmark',
'locality',
'vtc',
'district',
'pin',
'state',
'country',
'orgAddressLine1',
'orgAddressLine2',
'orgLandmark',
'orgLocality',
'orgVtc',
'orgDistrict',
'orgPin',
'orgState',
'orgCountry',
'schoolAddressLine1',
'schoolAddressLine2',
];

for (const key in data) {
if (data.hasOwnProperty(key)) {
if (addressFields.includes(key)) {
mappedData[key] = data[key] !== null ? data[key] + ', ' : '';
} else mappedData[key] = data[key] || '--';
}
}

return mappedData;
}

async generateQrCode(id: string): Promise<string> {
const text = `${this.baseUrl}/credentials/credentials/${id}/verify`;
try {
Expand Down
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ async function bootstrap() {
const globalPrefix = process.env.API_PREFIX || 'api';
app.setGlobalPrefix(globalPrefix);

const PORT = process.env.PORT || 3000;
console.log(
`Application is running on: http://localhost:${process.env.PORT}/${globalPrefix}`,
`Application is running on: http://localhost:${PORT}/${globalPrefix}`,
);
await app.listen(process.env.PORT);
await app.listen(PORT);
}
bootstrap();
16 changes: 2 additions & 14 deletions template/casteCertificate.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,8 @@ <h2>Issuing Authority</h2>
<td>{{orgOfficerRank}}</td>
</tr>
<tr>
<th>District</th>
<td>{{orgDistrict}}</td>
</tr>
<tr>
<th>PIN</th>
<td>{{orgPin}}</td>
</tr>
<tr>
<th>State</th>
<td>{{orgState}}</td>
</tr>
<tr>
<th>Country</th>
<td>{{orgCountry}}</td>
<th>Address</th>
<td>{{orgDistrict}} {{orgPin}} {{orgState}} {{orgCountry}}</td>
</tr>
</table>
</div>
Expand Down
16 changes: 2 additions & 14 deletions template/sportsParticipationCertificate.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,8 @@ <h2>Issuing Authority</h2>
<td>{{orgOfficerRank}}</td>
</tr>
<tr>
<th>District</th>
<td>{{orgDistrict}}</td>
</tr>
<tr>
<th>PIN</th>
<td>{{orgPin}}</td>
</tr>
<tr>
<th>State</th>
<td>{{orgState}}</td>
</tr>
<tr>
<th>Country</th>
<td>{{orgCountry}}</td>
<th>Address</th>
<td>{{orgDistrict}} {{orgPin}} {{orgState}} {{orgCountry}}</td>
</tr>
</table>
</div>
Expand Down

0 comments on commit e4da20a

Please sign in to comment.