Merge pull request #88 from AlineRinquin/cecile

Cecile
This commit is contained in:
AlineRinquin 2022-03-06 19:23:33 +01:00 committed by GitHub
commit b4518612ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 76 additions and 15 deletions

View file

@ -41,6 +41,7 @@ import { HumeurComponent } from './components/humeur/humeur.component';
import { DeconnexionComponent } from './components/deconnexion/deconnexion.component';
import { AlertComponent } from './components/alert/alert.component';
import { PageAjoutEvenementsComponent } from './pages/page-ajout-evenements/page-ajout-evenements.component';
import { PageSupportComponent } from './pages/page-support/page-support.component';
registerLocaleData(localeFr)
@NgModule({
@ -78,7 +79,8 @@ registerLocaleData(localeFr)
DeconnexionComponent,
HumeurComponent,
AlertComponent,
PageAjoutEvenementsComponent
PageAjoutEvenementsComponent,
PageSupportComponent
],
imports: [
BrowserModule,

View file

@ -8,5 +8,6 @@
<a routerLink="../to-do-list" routerLinkActive="active-custom" class="nav-link">To-Do-List</a>
<a routerLink="../agenda" routerLinkActive="active-custom" class="nav-link">Agenda</a>
<a routerLink="../menu" routerLinkActive="active-custom" class="nav-link">Menus</a>
<a routerLink="../page-support" routerLinkActive="active-custom" class="nav-link">Nous contacter</a>
</div>
</div>
</div>

View file

@ -7,4 +7,9 @@ font-size: smaller;
.footer {
margin-top: 20px;
}
h3{
color : blue;
font-size : 16px;
}

View file

@ -2,7 +2,12 @@
<div>
<h2>Mon humeur :</h2>
<app-alert
*ngIf="isShow"
[alert]="alert"
(eventClose)="onClickCloseAlert()"
></app-alert>
@ -19,4 +24,5 @@
<div >
</div> </div>
</div> </div>

View file

@ -6,6 +6,7 @@ p>img {
img {
width: 50px;
height: 50px;
margin: 8px;
}
.humeur {
@ -13,6 +14,7 @@ display: inline;
}
div {
background-color: #87AFC7;
width: 400px;
background-color: #87AFC7;
text-align: center;
}

View file

@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { MembreService } from 'src/app/services/membre.service';
import { TokenService } from 'src/app/services/token.service';
@Component({
selector: 'app-humeur',
@ -6,10 +8,10 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./humeur.component.scss']
})
export class HumeurComponent implements OnInit {
monHumeurLien! : string[];
monHumeurTitle! : string[] ;
monHumeurLien! : string[];
monHumeurTitle! : string[] ;
isShow: boolean;
alert: any;
tabHumeur= [
@ -19,18 +21,48 @@ export class HumeurComponent implements OnInit {
{ title : "Je suis en colère", lien : "assets/images/emoticon-insulter.png"},
{ title : "Je suis en joie", lien : "assets/images/emoticon-feter.png"} ]
constructor() { }
constructor(private membreService: MembreService, private tokenService: TokenService) {
this.isShow= false;
this.alert="";
}
ngOnInit(): void { }
ngOnInit(): void {
const userId = this.tokenService.getCurrentMembreId();
this.membreService.getMembreId(userId).subscribe({
next: result => {
this.monHumeurTitle= [this.tabHumeur[result.smiley].title];
this.monHumeurLien= [this.tabHumeur[result.smiley].lien];
// console.log("resultat smiley ", result.smiley);
}
})
}
onChoixHumeur(numero: number){
this.monHumeurTitle= [this.tabHumeur[numero].title];
this.monHumeurLien= [this.tabHumeur[numero].lien];
this.membreService.updateHumeur(numero)?.subscribe(
{
next: result => {
this.alert={"type":"success", "content":"L'humeur a bien été modifiée"};
this.isShow = true;
},
error: err => {
this.alert={"type":"danger", "content":"Problème lors de la modification de l'humeur"};
this.isShow = true;
},
complete: () => console.log('DONE!')
}
);
console.log("humeur titre est : ", this.monHumeurTitle);
console.log("humeur lien est : ", this.monHumeurLien);
console.log("index humeur est : ", numero );
console.log("index humeur est : ", numero);
}
onClickCloseAlert(){
this.isShow=!this.isShow;
}
}

View file

@ -28,4 +28,5 @@
<button type="button" class="btn btn-danger">Effacer</button>
</div>
</form>
</div>
</div>
<app-footer></app-footer>

View file

@ -57,4 +57,16 @@ export class MembreService {
this.router.navigate(['accueil']);
}
}
updateHumeur(numero : number) : Observable<any> | void {
const userId = this.tokenService.getCurrentMembreId();
if (userId){
return this.http.put(`${this.apiUrl}/membres/update/smiley/${userId}`, numero);
}else {
this.router.navigate(['accueil']);
}
}
}