]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+signup/+register/steps/register-step-terms.component.ts
Refactoring login component style
[github/Chocobozzz/PeerTube.git] / client / src / app / +signup / +register / steps / register-step-terms.component.ts
1 import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
2 import { FormGroup } from '@angular/forms'
3 import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
4 import { REGISTER_REASON_VALIDATOR, REGISTER_TERMS_VALIDATOR } from '../shared'
5
6 @Component({
7 selector: 'my-register-step-terms',
8 templateUrl: './register-step-terms.component.html',
9 styleUrls: [ './step.component.scss' ]
10 })
11 export class RegisterStepTermsComponent extends FormReactive implements OnInit {
12 @Input() hasCodeOfConduct = false
13 @Input() requiresApproval: boolean
14 @Input() minimumAge = 16
15 @Input() instanceName: string
16
17 @Output() formBuilt = new EventEmitter<FormGroup>()
18 @Output() termsClick = new EventEmitter<void>()
19 @Output() codeOfConductClick = new EventEmitter<void>()
20
21 constructor (
22 protected formReactiveService: FormReactiveService
23 ) {
24 super()
25 }
26
27 get instanceHost () {
28 return window.location.host
29 }
30
31 ngOnInit () {
32 this.buildForm({
33 terms: REGISTER_TERMS_VALIDATOR,
34
35 registrationReason: this.requiresApproval
36 ? REGISTER_REASON_VALIDATOR
37 : null
38 })
39
40 setTimeout(() => this.formBuilt.emit(this.form))
41 }
42
43 onTermsClick (event: Event) {
44 event.preventDefault()
45 this.termsClick.emit()
46 }
47
48 onCodeOfConductClick (event: Event) {
49 event.preventDefault()
50 this.codeOfConductClick.emit()
51 }
52 }