parent
652b1925d6
commit
6395a54999
@ -1,3 +1,3 @@
|
||||
<app-book-menu></app-book-menu>
|
||||
<!-- <app-book-menu></app-book-menu> -->
|
||||
|
||||
<router-outlet (activate)="onActivate($event)"></router-outlet>
|
@ -1,26 +1,56 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { UserMenuComponent } from '../user-menu/user-menu.component';
|
||||
import { UserService } from '../../services/user-service';
|
||||
import { NgFor } from '@angular/common';
|
||||
|
||||
interface Streak {
|
||||
day: string
|
||||
isPlayed: boolean
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-accueil',
|
||||
standalone: true,
|
||||
imports: [UserMenuComponent,RouterModule],
|
||||
imports: [UserMenuComponent,RouterModule,NgFor],
|
||||
templateUrl: './user-accueil.component.html',
|
||||
styleUrl: './user-accueil.component.css'
|
||||
})
|
||||
|
||||
export class UserAccueilComponent {
|
||||
protected formattedDate : String
|
||||
protected streaks: Object[]
|
||||
|
||||
public constructor() {
|
||||
public constructor(us : UserService) {
|
||||
const currentDate: Date = new Date
|
||||
const options: Intl.DateTimeFormatOptions = {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
};
|
||||
this.formattedDate = currentDate.toLocaleDateString(undefined, options);
|
||||
}
|
||||
}
|
||||
this.formattedDate = currentDate.toLocaleDateString(undefined, options)
|
||||
|
||||
this.streaks = ["❌","❌","❌","❌","❌","❌","❌"]
|
||||
|
||||
let userConnecte = localStorage.getItem('UserConnecte')
|
||||
if(userConnecte == undefined) {return}
|
||||
|
||||
let id = us.getIdByUser(userConnecte)
|
||||
if(id == undefined) {return}
|
||||
|
||||
let streaks = us.getStreaksFromId(id)
|
||||
if(streaks == undefined) {return}
|
||||
|
||||
this.streaks = []
|
||||
streaks.forEach(element => {
|
||||
let a : Streak = element as Streak
|
||||
if(a["isPlayed"]){
|
||||
this.streaks.push("✅")
|
||||
} else {
|
||||
this.streaks.push("❌")
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in new issue