import { Component, OnInit, ViewChild } from '@angular/core'
import { Notifier, ServerService } from '@app/core'
-import { FormReactive, FormValidatorService, InstanceValidatorsService } from '@app/shared/shared-forms'
+import {
+ BODY_VALIDATOR,
+ FROM_EMAIL_VALIDATOR,
+ FROM_NAME_VALIDATOR,
+ SUBJECT_VALIDATOR
+} from '@app/shared/form-validators/instance-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { InstanceService } from '@app/shared/shared-instance'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
-import { I18n } from '@ngx-translate/i18n-polyfill'
+import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
import { ServerConfig } from '@shared/models'
@Component({
constructor (
protected formValidatorService: FormValidatorService,
private modalService: NgbModal,
- private instanceValidatorsService: InstanceValidatorsService,
private instanceService: InstanceService,
private serverService: ServerService,
- private notifier: Notifier,
- private i18n: I18n
+ private notifier: Notifier
) {
super()
}
.subscribe(config => this.serverConfig = config)
this.buildForm({
- fromName: this.instanceValidatorsService.FROM_NAME,
- fromEmail: this.instanceValidatorsService.FROM_EMAIL,
- subject: this.instanceValidatorsService.SUBJECT,
- body: this.instanceValidatorsService.BODY
+ fromName: FROM_NAME_VALIDATOR,
+ fromEmail: FROM_EMAIL_VALIDATOR,
+ subject: SUBJECT_VALIDATOR,
+ body: BODY_VALIDATOR
})
}
this.instanceService.contactAdministrator(fromEmail, fromName, subject, body)
.subscribe(
() => {
- this.notifier.success(this.i18n('Your message has been sent.'))
+ this.notifier.success($localize`Your message has been sent.`)
this.hide()
},
err => {
- this.error = err.status === 403
- ? this.i18n('You already sent this form recently')
+ this.error = err.status === HttpStatusCode.FORBIDDEN_403
+ ? $localize`You already sent this form recently`
: err.message
}
)