Fixed registration age submission

This commit is contained in:
piratefinn 2017-06-15 16:17:33 +01:00
parent 7620b1429a
commit 014722c694
3 changed files with 14 additions and 20 deletions

View file

@ -65,9 +65,9 @@
</div>
<div class="input-group mb-3">
<span class="input-group-addon">Age Range</span>
<select class="form-control" type="text" formControlName="age_range">
<option *ngFor="let range of ageRanges" [value]="range.id">{{ range.string }}</option>
<span class="input-group-addon">Year of Birth</span>
<select class="form-control" type="text" formControlName="year_of_birth">
<option *ngFor="let range of years" [value]="range">{{ range }}</option>
</select>
</div>

View file

@ -15,7 +15,7 @@ export class RegisterComponent {
signupForm: ValidationManager;
customerForm: ValidationManager;
organisationForm: ValidationManager;
ageRanges: Object[];
years: Object[];
constructor(
private http: Http,
@ -23,13 +23,13 @@ export class RegisterComponent {
private router: Router,
private api: ApiService,
) {
this.api.getAgeRanges()
.subscribe(
result => {
console.log(result);
this.ageRanges = result.ages;
}
);
this.years = [];
let max = new Date().getFullYear() - 10,
min = max - 140;
for (let i = max; i>=min; i--){
this.years.push(i);
}
this.signupForm = new ValidationManager({
token: 'required',
usertype: 'required',
@ -41,7 +41,7 @@ export class RegisterComponent {
display_name: 'required',
full_name: 'required',
postcode: 'required',
age_range: 'required',
year_of_birth: 'required',
});
this.organisationForm = new ValidationManager({
name: 'required',
@ -69,7 +69,7 @@ export class RegisterComponent {
display_name: customerForm.display_name,
full_name: customerForm.full_name,
postcode: customerForm.postcode,
age_range: customerForm.age_range,
year_of_birth:customerForm.year_of_birth,
};
console.log(data);
this.api

View file

@ -34,12 +34,6 @@ export class ApiService {
localStorage.removeItem('sessionKey');
}
public getAgeRanges() {
return this.http.get(
this.apiUrl + '/info/ages'
).map( res => res.json() );
}
public register(data) {
return this.http.post(
this.apiUrl + '/register',