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

View file

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

View file

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