<form [formGroup]="form" (ngSubmit)="passwordReset()" *ngIf="!success">
    <mat-card>
        <mat-card-content>
            <h2>{{'password.reset' | i18n}}</h2>
            <mat-error *ngIf="tokenInvalid">
                {{'password.reset.tokenInvalid' | i18n}}
            </mat-error>
            <mat-form-field>
                <input matInput type="password" placeholder="{{'password' | i18n}}" formControlName="password"
                    [(ngModel)]="model.password">
                <mat-error *ngFor="let error of form.get('password').errors | keyvalue">
                    {{error.key}}
                </mat-error>
            </mat-form-field>
            <mat-form-field>
                <input matInput type="password" length="6" placeholder="{{'password.confirm' | i18n}}"
                    formControlName="password2" [(ngModel)]="model.password2">
                <mat-error>
                    {{'password.not-match' | i18n}}
                </mat-error>
            </mat-form-field>
        </mat-card-content>
        <mat-card-actions>
            <button *ngIf="!working" mat-raised-button color="primary" [disabled]="form.invalid">
                {{'password.reset' | i18n}}
            </button>

            <mat-progress-bar *ngIf="working" mode="indeterminate"></mat-progress-bar>
        </mat-card-actions>
    </mat-card>
</form>

<mat-card *ngIf="success">
    <mat-card-content>
        <h2>{{'password.reset.success.title' | i18n}}</h2>
        <p>{{'password.reset.success.text' | i18n}}</p>
    </mat-card-content>
    <mat-card-actions>
        <a routerLink="/login" mat-raised-button color="primary">
            {{'password.reset.login' | i18n}}
        </a>
    </mat-card-actions>
</mat-card>