Skip to content

Commit

Permalink
added courseduration for testing (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
satyadiksha authored Jul 12, 2024
1 parent 1a95dd8 commit 8dae965
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
<h4 *ngIf="recipient" class="sb-certificatePage-holder-name">
{{recipient}}
</h4>
<p *ngIf="courseName && issuedOn" class="sb-certificatePage-holder-desc">
<p *ngIf="courseName && issuedOn && courseDuration" class="sb-certificatePage-holder-desc">
{{resourceService?.frmelmnts?.lbl?.completingCourseSuccessfully}}
<strong class="d-block">“{{courseName}}”</strong>
<strong class="d-block">“{{courseDuration}}”</strong>
<span class="d-block">{{resourceService?.frmelmnts?.lbl?.onDiksha | interpolate:'{instance}':instance}}<strong> {{issuedOn}}</strong></span>
</p>

Expand Down Expand Up @@ -91,9 +92,10 @@ <h4 *ngIf="recipient" class="sb-certificatePage-holder-name">
<h4 *ngIf="recipient" class="sb-certificatePage-holder-name">
{{recipient}}
</h4>
<p *ngIf="courseName && issuedOn" class="sb-certificatePage-holder-desc">
<p *ngIf="courseName && issuedOn && courseDuration" class="sb-certificatePage-holder-desc">
{{resourceService?.frmelmnts?.lbl?.completingCourseSuccessfully}}
<strong class="d-block">“{{courseName}}”</strong>
<strong class="d-block">“{{courseDuration}}”</strong>
<span class="d-block">{{resourceService?.frmelmnts?.lbl?.onDiksha | interpolate:'{instance}':instance}}<strong>
{{issuedOn}}</strong></span>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class CertificateDetailsComponent implements OnInit , OnDestroy {
recipient: string;
courseName: string;
issuedOn: string;
courseDuration: string;
watchVideoLink: string;
validateRCCertificate: boolean = false;
@ViewChild('codeInputField') codeInputField: ElementRef;
Expand Down Expand Up @@ -85,17 +86,20 @@ export class CertificateDetailsComponent implements OnInit , OnDestroy {
};
this.certificateService.validateCertificate(request).subscribe(
(data: ServerResponse) => {
console.log('certificateVerify data-----', data)
if (_.get(data, 'result.response.related.certVideoUrl')) {
this.watchVideoLink = _.get(data, 'result.response.related.certVideoUrl');
this.processVideoUrl(this.watchVideoLink);
} else {
this.getCourseVideoUrl(_.get(data, 'result.response.related.courseId'));
}
const certData = _.get(data, 'result.response.json');
console.log('certificateVerify certData-----', certData)
this.loader = false;
this.viewCertificate = true;
this.recipient = _.get(certData, 'recipient.name');
this.courseName = _.get(certData, 'badge.name');
this.courseDuration =_.get(certData, 'courseDuration');
this.issuedOn = dayjs(new Date(_.get(certData, 'issuedOn'))).format('DD MMM YYYY');
},
(err) => {
Expand Down Expand Up @@ -200,29 +204,36 @@ export class CertificateDetailsComponent implements OnInit , OnDestroy {
* Function to validate certificate if URL has `data` params
*/
validateCertificate() {
console.log('validateCertificate ------- ')
this.loader = true;
let url = _.get(this.activatedRoute, 'snapshot.queryParams.data').toString();
url = url.replace(/ /g, "+");
this.CsCertificateService
.getEncodedData(url)
.then((resp) => {
console.log('resp ------- ', resp)
let requestBody = {
certificateData: resp,
schemaName: 'certificate',
certificateId: _.get(this.activatedRoute, 'snapshot.params.uuid'),
};
console.log('requestBody ------- ', requestBody)
this.CsCertificateService.verifyCertificate(requestBody, {
apiPath: '/learner/certreg/v2',
apiPathLegacy: '/certreg/v1',
rcApiPath: '/learner/rc/${schemaName}/v1',
}).subscribe(
(data) => {
console.log('validateCertificate data-----', data)
const certData = _.get(data, 'certificateData');
console.log('validateCertificate certData-----', certData)
this.loader = false;
if (_.get(data, 'verified')) {
console.log('validateCertificate if-----', data)
this.viewCertificate = true;
this.recipient = _.get(certData, 'issuedTo');
this.courseName = _.get(certData, 'trainingName');
this.courseDuration =_.get(certData, 'courseDuration');
this.issuedOn = dayjs(new Date(_.get(certData, 'issuanceDate'))).format('DD MMM YYYY');
} else {
this.viewCertificate = false;
Expand All @@ -246,22 +257,28 @@ export class CertificateDetailsComponent implements OnInit , OnDestroy {
* Function to validate certificate if URL has `t` params
*/
validateTCertificate() {
console.log('validateTCertificate----')
let requestBody = {
schemaName: 'certificate',
certificateId: _.get(this.activatedRoute, 'snapshot.params.uuid'),
};
console.log('validateTCertificate requestBody----', requestBody)
this.CsCertificateService.verifyCertificate(requestBody, {
apiPath: '/learner/certreg/v2',
apiPathLegacy: '/certreg/v1',
rcApiPath: '/learner/rc/${schemaName}/v1',
}).subscribe(
(data) => {
console.log('validataTCertificate-----', data)
const certData = _.get(data, 'certificateData');
console.log('validateTCertificate certData----', certData)
this.loader = false;
if (_.get(data, 'verified')) {
console.log('validataTCertificate if-----', data)
this.viewCertificate = true;
this.recipient = _.get(certData, 'issuedTo');
this.courseName = _.get(certData, 'trainingName');
this.courseDuration =_.get(certData, 'courseDuration')
this.issuedOn = dayjs(new Date(_.get(certData, 'issuanceDate'))).format('DD MMM YYYY');
} else {
this.viewCertificate = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export class CertificateService {
constructor(public learnerService: LearnerService, public configService: ConfigService) { }

validateCertificate(data): Observable<ServerResponse> {
console.log('validateCertificate data-----', data)
const option = {
url: this.configService.urlConFig.URLS.USER.VALIDATE_CERTIFICATE,
data: data
};
console.log('validateCertificate option-----', option)
return this.learnerService.post(option);

}
Expand Down

0 comments on commit 8dae965

Please sign in to comment.