1 import { Component, OnInit, Input } from '@angular/core'
2 import { FormBuilder, FormGroup } from '@angular/forms'
3 import { Router } from '@angular/router'
5 import { NotificationsService } from 'angular2-notifications'
7 import { AuthService } from '../../core'
14 import { UserUpdateMe } from '../../../../../shared'
17 selector: 'my-account-details',
18 templateUrl: './account-details.component.html'
21 export class AccountDetailsComponent extends FormReactive implements OnInit {
22 @Input() user: User = null
28 validationMessages = {}
31 private authService: AuthService,
32 private formBuilder: FormBuilder,
33 private notificationsService: NotificationsService,
34 private userService: UserService
40 this.form = this.formBuilder.group({
41 displayNSFW: [ this.user.displayNSFW ]
44 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
52 const displayNSFW = this.form.value['displayNSFW']
53 const details: UserUpdateMe = {
58 this.userService.updateMyDetails(details).subscribe(
60 this.notificationsService.success('Success', 'Information updated.')
62 this.authService.refreshUserInformation()
65 err => this.error = err.message