]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts
fix a few typos (#2141)
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-settings / my-account-danger-zone / my-account-danger-zone.component.ts
CommitLineData
92b9d60c 1import { Component, Input } from '@angular/core'
f8b2c1b4 2import { Notifier } from '@app/core'
92b9d60c
C
3import { AuthService, ConfirmService, RedirectService } from '../../../core'
4import { UserService } from '../../../shared'
5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { User } from '@app/shared'
7
8@Component({
9 selector: 'my-account-danger-zone',
10 templateUrl: './my-account-danger-zone.component.html',
11 styleUrls: [ './my-account-danger-zone.component.scss' ]
12})
13export class MyAccountDangerZoneComponent {
14 @Input() user: User = null
15
16 constructor (
17 private authService: AuthService,
f8b2c1b4 18 private notifier: Notifier,
92b9d60c
C
19 private userService: UserService,
20 private confirmService: ConfirmService,
21 private redirectService: RedirectService,
22 private i18n: I18n
23 ) { }
24
25 async deleteMe () {
26 const res = await this.confirmService.confirmWithInput(
32d7f2b7 27 this.i18n('Are you sure you want to delete your account? This will delete all your data, including channels, videos etc.'),
92b9d60c
C
28 this.i18n('Type your username to confirm'),
29 this.user.username,
30 this.i18n('Delete your account'),
31 this.i18n('Delete my account')
32 )
33 if (res === false) return
34
35 this.userService.deleteMe().subscribe(
36 () => {
f8b2c1b4 37 this.notifier.success(this.i18n('Your account is deleted.'))
92b9d60c
C
38
39 this.authService.logout()
40 this.redirectService.redirectToHomepage()
41 },
42
f8b2c1b4 43 err => this.notifier.error(err.message)
92b9d60c
C
44 )
45 }
46}