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>
|
<router-outlet (activate)="onActivate($event)"></router-outlet>
|
@ -1,26 +1,56 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { UserMenuComponent } from '../user-menu/user-menu.component';
|
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({
|
@Component({
|
||||||
selector: 'app-user-accueil',
|
selector: 'app-user-accueil',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [UserMenuComponent,RouterModule],
|
imports: [UserMenuComponent,RouterModule,NgFor],
|
||||||
templateUrl: './user-accueil.component.html',
|
templateUrl: './user-accueil.component.html',
|
||||||
styleUrl: './user-accueil.component.css'
|
styleUrl: './user-accueil.component.css'
|
||||||
})
|
})
|
||||||
|
|
||||||
export class UserAccueilComponent {
|
export class UserAccueilComponent {
|
||||||
protected formattedDate : String
|
protected formattedDate : String
|
||||||
|
protected streaks: Object[]
|
||||||
|
|
||||||
public constructor() {
|
public constructor(us : UserService) {
|
||||||
const currentDate: Date = new Date
|
const currentDate: Date = new Date
|
||||||
const options: Intl.DateTimeFormatOptions = {
|
const options: Intl.DateTimeFormatOptions = {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
day: 'numeric'
|
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