Skip to content

Commit 0a72fd8

Browse files
feat: create inscription badge
1 parent 0a3824c commit 0a72fd8

File tree

11 files changed

+58
-9
lines changed

11 files changed

+58
-9
lines changed

public/activities/tempActivitiesData.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"location": "Marseille",
7070
"date": "2024-12-15",
7171
"participants": {
72-
"current": 3,
72+
"current": 10,
7373
"max": 10
7474
},
7575
"theme": ["Nature"],

src/app/features/activity/components/activity-card/activity-card.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
<div class="description-card">
44
<div class="header-description">
55
<h3>{{ activity.title }}</h3>
6-
<div>Badge volonteers</div>
6+
@if (activity) {
7+
<app-inscription-badge [activity]="activity"></app-inscription-badge>
8+
}
79
<!-- TODO: changer pour le composant réutilisable -->
810
</div>
911
<div>

src/app/features/activity/components/activity-card/activity-card.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
.header-description {
1313
display: flex;
1414
justify-content: space-between;
15+
align-items: center;
1516
}
1617

1718
.info-asso {

src/app/features/activity/components/activity-card/activity-card.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Component, Input } from '@angular/core';
22
import { Activity } from '../../models/activity.model';
3+
import { InscriptionBadgeComponent } from '../inscription-badge/inscription-badge.component';
34

45
@Component({
56
selector: 'app-activity-card',
6-
imports: [],
7+
imports: [InscriptionBadgeComponent],
78
templateUrl: './activity-card.component.html',
89
styleUrl: './activity-card.component.scss',
10+
standalone: true,
911
})
1012
export class ActivityCardComponent {
1113
@Input() activity!: Activity;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@if (activity && activity.participants) {
2+
<div class="badge-container">
3+
@if (activity.participants.current === activity.participants.max) {
4+
<p class="badge full">Complet</p>
5+
} @else {
6+
<p class="badge">{{ activity.participants.current }} / {{ activity.participants.max }} pers.</p>
7+
}
8+
</div>
9+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.badge-container {
2+
width: 75px;
3+
height: 30px;
4+
.badge {
5+
border-radius: 8px;
6+
display: flex;
7+
align-items: center;
8+
justify-content: center;
9+
margin: auto;
10+
text-align: center;
11+
width: 75px;
12+
height: 30px;
13+
background-color: var(--secondaryValidateColor);
14+
color: white;
15+
font-size: var(--fontSizePMini);
16+
font-family: var(--fontFamilyP);
17+
&.full {
18+
background-color: var(--secondaryCompleteColor);
19+
}
20+
}
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component, Input } from '@angular/core';
2+
import { Activity } from '../../models/activity.model';
3+
4+
@Component({
5+
selector: 'app-inscription-badge',
6+
standalone: true,
7+
imports: [],
8+
templateUrl: './inscription-badge.component.html',
9+
styleUrl: './inscription-badge.component.scss',
10+
})
11+
export class InscriptionBadgeComponent {
12+
@Input() activity!: Activity;
13+
}

src/app/features/activity/models/activity.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class Activity {
1919
organization: Organization = { name: '', logo: '', isFollow: false };
2020
location: string = '';
2121
date: Date = new Date();
22-
participant: Participant = { current: 0, max: 10 };
22+
participants: Participant = { current: 0, max: 10 };
2323
theme: Theme[];
2424
isFavorite: boolean = false;
2525

@@ -31,7 +31,7 @@ export class Activity {
3131
this.organization = data.organization || { name: '', logo: '', isFollow: false };
3232
this.location = data.location || '';
3333
this.date = data.date || new Date();
34-
this.participant = data.participant || { current: 0, max: 10 };
34+
this.participants = data.participants || { current: 0, max: 10 };
3535
this.theme = data.theme || [];
3636
this.isFavorite = data.isFavorite || false;
3737
}

src/app/features/activity/pages/activities-home/activities-home.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AsyncPipe } from '@angular/common';
1010
imports: [ActivityCardComponent, AsyncPipe],
1111
templateUrl: './activities-home.component.html',
1212
styleUrl: './activities-home.component.scss',
13+
standalone: true,
1314
})
1415
export class ActivitiesHomeComponent implements OnInit {
1516
activityFacadeService: ActivityFacadeService = inject(ActivityFacadeService);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Injectable, inject } from '@angular/core';
21
import { HttpClient } from '@angular/common/http';
3-
import { Observable, tap } from 'rxjs';
2+
import { Injectable, inject } from '@angular/core';
3+
import { Observable } from 'rxjs';
44
import { Activity } from '../models/activity.model';
55

66
@Injectable({
@@ -11,6 +11,6 @@ export class ActivitiesApiService {
1111

1212
getAllActivities(): Observable<Activity[]> {
1313
// return this._http.get<Activity[]>("/activities");
14-
return this._http.get<Activity[]>('/activities/tempActivitiesData.json').pipe(tap((activities: Activity[]) => console.log(activities)));
14+
return this._http.get<Activity[]>('/activities/tempActivitiesData.json');
1515
}
1616
}

0 commit comments

Comments
 (0)