Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Fix invalid date for volunteer specialisation #127; Fix missing error message for accredited_by field #120 #194

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class EditVolunteerComponent implements OnInit {
coursenameError = false;
acreditedby: any;
accreditedError = false;
obtained: Date;
obtained: { year: number; month: number; day: number };
dateError = false;

/**
Expand Down Expand Up @@ -306,8 +306,7 @@ export class EditVolunteerComponent implements OnInit {
this.acreditedby = obj.item.static_accreditor;
this.static_accreditor = true;
} else {
this.acreditedby = {
};
this.acreditedby = '';
this.static_accreditor = false;
}
this.coursenameError = false;
Expand All @@ -332,7 +331,9 @@ export class EditVolunteerComponent implements OnInit {
this.fb.group({
course_name: this.coursename.name,
course_name_id: this.coursename._id,
obtained: moment(this.obtained).format('DD.MM.YYYY'),
// moment.js indexes months from 0; one month has to be extracted from the value
// returned by ngbDatepicker
obtained: moment({...this.obtained, month: this.obtained.month - 1}).format('DD.MM.YYYY'),
accredited_by: this.acreditedby.hasOwnProperty('name') ? this.acreditedby.name : this.acreditedby
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { VolunteerService } from '../../../volunteers.service';
import { AuthenticationService } from '@app/core';
import { Location } from '@angular/common';
import * as moment from 'moment';

@Component({
selector: 'app-volunteer-details',
Expand Down Expand Up @@ -84,6 +85,14 @@ export class VolunteerDetailsComponent implements OnInit {
getData() {
this.volunteerService.getVolunteer(this.route.snapshot.paramMap.get('id')).subscribe((data) => {
this.data = data;
this.data = {
...data,
updated_at: moment(data.updated_at),
courses: data.courses.map((course: any) => ({
...course,
obtained: moment(course.obtained),
}))
};

if (data.courses && data.courses.length > 0) {
this.hasAccreditation = true;
Expand Down