<div class="main-content">
	<div class="container-fluid">
		<div *ngIf="user | async  as userProfile; else loading" class="row user-profile">
			<mat-card class="col-12 profile-card">
				<mat-card-content>
					<div class="row">
						<div class="col-12">
							<div class="row profile-card-center-row">
								<div class="col-auto"><img mat-card-avatar [src]="userProfile.avatarUrl" (error)="applyFallbackAvatar($event)">
								</div>
							</div>
							<div class="row profile-card-center-row">
								<mat-card-title class="col-auto">{{userProfile.name}}</mat-card-title>
							</div>
							<div class="row profile-card-center-row">
								<mat-card-subtitle class="col-auto">{{userProfile.email}}</mat-card-subtitle>
							</div>
							<div class="row profile-card-center-row">
								<a mat-raised-button (click)="logout()" class="col-3">
									{{'USER-DIALOG.LOG-OUT' | translate}} <mat-icon>exit_to_app</mat-icon>
								</a>
							</div>
						</div>
					</div>
				</mat-card-content>
			</mat-card>
			<mat-card class="col-12 profile-card">
				<mat-card-content>
					<div>
						<div>
							<h4>{{'USER-PROFILE.ASSOCIATED-DMPS' | translate}}</h4>
						</div>
						<div>
							<mat-list>
								<mat-list-item *ngFor="let dmp of userProfile.associatedDmps">
									<div class="clickable" (click)="navigateToDmp(dmp)">
										{{dmp.label}}
									</div>
									<div class="ml-2">
										<mat-chip-list>
											<mat-chip>{{getUserRole(dmp)}}</mat-chip>
										</mat-chip-list>
									</div>
								</mat-list-item>
							</mat-list>
							<button mat-button (click)="showAllDmps()">
								{{'USER-PROFILE.DMPS.SHOW-ALL' | translate}}</button>
						</div>
					</div>
				</mat-card-content>
			</mat-card>
			<mat-card class="col-12 profile-card">
				<mat-card-header>
					<mat-card-title>
						<div class="row">
							<h4 class="settings col-auto">{{ 'USER-PROFILE.SETTINGS.TITLE' | translate}}</h4>
							<button class="col-auto" *ngIf="!editMode" mat-icon-button (click)="unlock()">
								<mat-icon class="mat-24">edit</mat-icon>
							</button>
							<button class="col-auto" *ngIf="editMode" mat-icon-button (click)="lock()">
								<mat-icon class="mat-24">lock</mat-icon>
							</button>
						</div>
					</mat-card-title>
				</mat-card-header>
				<mat-card-content disabled="false">
					<div class="container">
						<div class="row" [formGroup]="formGroup">
							<mat-form-field class="col-md-4">
								<input type="text" placeholder="{{'USER-PROFILE.SETTINGS.TIMEZONE' | translate}}"
									[formControl]="this.formGroup.get('timezone')" matInput [matAutocomplete]="timezone"
									required>
								<mat-autocomplete #timezone="matAutocomplete">
									<mat-option *ngFor="let timezone of timezones | async" [value]="timezone">
										{{ timezone | timezoneInfoDisplay }}
									</mat-option>
								</mat-autocomplete>
							</mat-form-field>
							<mat-form-field class="col-md-4">
								<input type="text" placeholder="{{'USER-PROFILE.SETTINGS.CULTURE' | translate}}"
									[formControl]="this.formGroup.get('culture')" matInput [matAutocomplete]="culture"
									required>
								<mat-autocomplete #culture="matAutocomplete" [displayWith]="displayFn">
									<mat-option *ngFor="let culture of cultures | async" [value]="culture">
										{{ culture.displayName }} - {{ culture.nativeName }}
									</mat-option>
								</mat-autocomplete>
							</mat-form-field>
							<mat-form-field class="col-md-4">
								<mat-select placeholder="{{'USER-PROFILE.SETTINGS.LANGUAGE' | translate}}"
									[formControl]="this.formGroup.get('language')" required>
									<mat-option *ngFor="let language of languages" [value]="language">
										{{ language.label | translate }}
									</mat-option>
								</mat-select>
							</mat-form-field>
						</div>
					</div>
				</mat-card-content>
			</mat-card>
			<mat-card class="col-12 profile-card">
				<mat-card-header>
					<mat-card-title>
						<div class="row">
							<h4 class="settings col-auto">{{ 'USER-PROFILE.ZENODO.TITLE' | translate}}</h4>
						</div>
					</mat-card-title>
				</mat-card-header>
				<mat-card-content>
					<div class="container">
						<div class="row">
							<div class="col-md-4" *ngIf="!hasZenodo()">
								<button mat-raised-button type="button" (click)="loginToZenodo()" class="confirm" color="primary">{{'USER-PROFILE.ZENODO.LOGIN' | translate}}</button>
							</div>
							<div class="col-md-4" *ngIf="hasZenodo()">
								<div><label class="zenodo-email">{{ 'USER-PROFILE.ZENODO.DESCRIPTION' | translate}}</label></div>
								<label class="zenodo-email">{{zenodoEmail}}</label>
								<div><button mat-raised-button type="button" (click)="RemoveZenodo()" class="confirm unlinkBtn" >{{'USER-PROFILE.ZENODO.LOGOUT' | translate}}</button></div>
							</div>
						</div>
					</div>
				</mat-card-content>
			</mat-card>
		</div>
		<ng-template #loading>
		</ng-template>
	</div>
</div>
