Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
ee542a0
:sparkles: get themes from back and display buttons for each
Irwin-SOLIMAN Apr 7, 2025
d660bfc
section messages completed !
Mar 23, 2025
fd399b5
:sparkles: add Theme Filter bar
Irwin-SOLIMAN Apr 9, 2025
f3301b7
review Pilou for staging
Apr 9, 2025
8dbb3de
:sparkles: get themes from back and display buttons for each
Irwin-SOLIMAN Apr 7, 2025
8f50982
:sparkles: add Theme Filter bar
Irwin-SOLIMAN Apr 9, 2025
8fb571c
:hammer: make button reusable
Irwin-SOLIMAN Apr 9, 2025
fcd7d44
:hammer: small adjustment after merge
Irwin-SOLIMAN Apr 9, 2025
fd948b4
Merge branch 'feature/issue-15/filters-activity' of github.com:WildCo…
Irwin-SOLIMAN Apr 9, 2025
e18956c
Merge pull request #28 from WildCodeSchool/feature/issue-15/filters-a…
EmmanuelleBonoli Apr 9, 2025
e8f068b
add map from open map Libre
Irwin-SOLIMAN Apr 10, 2025
ba6842e
:sparkles: add interactive legends to filters markers on map
Irwin-SOLIMAN Apr 10, 2025
1f9168f
Merge pull request #29 from WildCodeSchool/feature/issue-16/interacti…
EmmanuelleBonoli Apr 10, 2025
fd32a47
feat(auth): enhance login/register UX, fix state issues
SebastienDechand Apr 7, 2025
1363c22
Merge pull request #31 from WildCodeSchool/feature/issue-25/create-lo…
EmmanuelleBonoli Apr 10, 2025
07dfdb3
style(login): fix errors and style
SebastienDechand Apr 10, 2025
20cf3b5
Merge pull request #32 from WildCodeSchool/feature/issue-9998/fix-style
EmmanuelleBonoli Apr 10, 2025
69450a8
style: adjust style on home page to display many cards
SebastienDechand Apr 11, 2025
a90b9b2
Merge pull request #33 from WildCodeSchool/feature/issue-9998/fix-style
EmmanuelleBonoli Apr 11, 2025
d4c266f
not send api request messages when not connected
Apr 10, 2025
468ed85
fix update userStore for new activity registration and save (#34)
EmmanuelleBonoli Apr 16, 2025
3bfde96
:hammer: refacto + add resolver (#36)
Irwin-SOLIMAN Apr 17, 2025
fb1aa07
fix: comment deletion and changes in registration form fr to eng (#38)
SebastienDechand Apr 17, 2025
c3c6488
Merge pull request #26 from WildCodeSchool/development
peacepilou Apr 17, 2025
f5a2587
feat(issue-18): create reusable multiple input and use it in home pag…
SebastienDechand Apr 17, 2025
4e053ba
fix interaction with user and delete all old ways to handle it (#41)
EmmanuelleBonoli May 9, 2025
b86f1fd
Feature/issue 68/customize map (#39)
EmmanuelleBonoli May 9, 2025
aae1f95
handle unread messages activities (#40)
EmmanuelleBonoli May 9, 2025
001bf96
fix popup map with new way to handle user interaction
May 9, 2025
a7d793c
Feature/issue 34/create activity page (#43)
Irwin-SOLIMAN May 12, 2025
0e64110
Feature/issue 45/admin report (#45)
EmmanuelleBonoli May 13, 2025
b4acdeb
refactor: use only reactives forms on inputs (#46)
SebastienDechand May 15, 2025
a5f379f
Feature/issue 84/resize image (#49)
Irwin-SOLIMAN Jun 11, 2025
23af1c2
feat(issue-38): implement association profile page, settings, and use…
SebastienDechand Jun 12, 2025
8544eb1
fix(issue-38): change delete activity route (#51)
SebastienDechand Jun 12, 2025
37bdc78
create report modal (#52)
EmmanuelleBonoli Jun 12, 2025
b2791bc
refactor: clean code and standardise utils after review (#54)
SebastienDechand Jul 8, 2025
d8dc1c9
Merge pull request #53 from WildCodeSchool/development
peacepilou Jul 8, 2025
348c036
Feature/issue 85/add draft to activity creation (#55)
Irwin-SOLIMAN Jul 15, 2025
d499b7f
Feature/issue 2/docker (#56)
EmmanuelleBonoli Jul 15, 2025
6aed0fd
Feature/issue 7/add tests (#58)
SebastienDechand Jul 23, 2025
dbe3fba
Feature/issue 2/docker (#59)
SebastienDechand Jul 23, 2025
6f5e489
Feature/issue 2/docker (#61)
SebastienDechand Jul 23, 2025
569da64
Feature/issue 2/docker (#62)
SebastienDechand Jul 23, 2025
c3ce63c
Feature/issue 2/docker (#63)
SebastienDechand Jul 24, 2025
fca9637
Feature/issue 2/docker (#64)
SebastienDechand Jul 24, 2025
b8ac390
Feature/issue 2/docker (#65)
SebastienDechand Jul 24, 2025
f124012
Feature/issue 2/docker (#66)
SebastienDechand Jul 24, 2025
971e5df
feat: implement CD
SebastienDechand Jul 27, 2025
e1d654a
Development (#60)
SebastienDechand Jul 27, 2025
8d48a06
feat: implement CD
SebastienDechand Jul 27, 2025
ef7fcfa
Merge branch 'staging' into development
SebastienDechand Jul 27, 2025
6e5940e
Development (#69)
SebastienDechand Jul 27, 2025
69971ab
feat: implement CD
SebastienDechand Jul 27, 2025
f435650
Merge branch 'development' into feature/issue-666/cd-front
SebastienDechand Jul 27, 2025
d12d9ff
feat: implement CD
SebastienDechand Jul 27, 2025
79c9bcf
Development
SebastienDechand Jul 27, 2025
925ec77
feat: implement CD
SebastienDechand Jul 27, 2025
a42cb85
feat: implement CD
SebastienDechand Jul 27, 2025
80bdb41
Development
SebastienDechand Jul 27, 2025
29444cb
feat: implement CD
SebastienDechand Jul 27, 2025
cb66cca
feat: implement CD
SebastienDechand Jul 27, 2025
f57ca18
Development
SebastienDechand Jul 27, 2025
6006b09
Development (#80)
EmmanuelleBonoli Aug 26, 2025
1d7295a
Update Dockerfile.staging
EmmanuelleBonoli Aug 26, 2025
9044353
Update docker-compose.staging.yml
EmmanuelleBonoli Aug 26, 2025
0c809d7
Development (#97)
EmmanuelleBonoli Aug 26, 2025
0bf1897
Development (#100)
EmmanuelleBonoli Aug 26, 2025
245afdc
Development (#103)
EmmanuelleBonoli Aug 26, 2025
1e8188d
Development (#105)
EmmanuelleBonoli Aug 26, 2025
adae666
Development (#109)
EmmanuelleBonoli Aug 26, 2025
46526c2
Development (#111)
EmmanuelleBonoli Aug 26, 2025
a34bfb2
Delete src/app/features/authentication/components/register-modal/logi…
EmmanuelleBonoli Aug 26, 2025
348ddcc
Development (#115)
EmmanuelleBonoli Aug 26, 2025
d0452c6
merge to production
Aug 26, 2025
a0a9f26
Update branch-policy.yml
EmmanuelleBonoli Aug 26, 2025
c5009f3
Development (#121)
EmmanuelleBonoli Aug 26, 2025
e0ba860
Merge branch 'production' into staging
EmmanuelleBonoli Aug 26, 2025
3396d0a
Development (#124)
SebastienDechand Aug 27, 2025
8ab0b7a
Development (#130)
SebastienDechand Aug 27, 2025
50866e0
Merge branch 'production' into staging
SebastienDechand Aug 27, 2025
517461f
Development (#134)
EmmanuelleBonoli Aug 28, 2025
877600d
Merge branch 'production' into staging
SebastienDechand Aug 28, 2025
b6f4954
Development (#140)
SebastienDechand Sep 1, 2025
cae4ed3
Merge branch 'production' into staging
SebastienDechand Sep 1, 2025
a8a25da
Development (#143)
SebastienDechand Sep 1, 2025
79b461c
Development (#148)
SebastienDechand Sep 22, 2025
0564a29
Merge branch 'production' into staging
SebastienDechand Sep 22, 2025
0f5a544
Development (#153)
EmmanuelleBonoli Sep 24, 2025
10ca1c9
Development (#157)
Irwin-SOLIMAN Sep 25, 2025
5ca2e5c
Merge branch 'production' into staging
SebastienDechand Sep 25, 2025
326ebd7
Development (#163)
Irwin-SOLIMAN Oct 23, 2025
49454bc
Development (#167)
EmmanuelleBonoli Oct 23, 2025
3b7f89b
Merge branch 'production' into staging
Irwin-SOLIMAN Oct 23, 2025
e202e05
Development (#169)
EmmanuelleBonoli Oct 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions cypress/e2e/report.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ describe('Feature Report', () => {
it('can\'t report with an empty reason', () => {
loginAsVoluntary();
accessToReportModal();
cy.get('p-button').contains('Envoyer')
.click();
cy.get('app-textarea-field p')
.contains('Ce champ est requis')
.should('be.visible');
cy.get('p-button[label="Envoyer"] button')
.should('be.disabled');
cy.get('body').find('.p-dialog-mask')
.click({ force: true });
logout();
Expand Down
5 changes: 5 additions & 0 deletions cypress/fixtures/common/userByToken.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"user": {

}
}
1 change: 1 addition & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
beforeEach(() => {
// the home page's necessary mocks
cy.intercept('GET', '/auth/token', {fixture: null}).as('getUserByToken');
cy.intercept('GET', '/activities/future', { fixture: '/common/activities.json' }).as('getActivities');
cy.intercept('GET', '/themes', { fixture: '/common/themes.json' }).as('getThemes');
cy.intercept('GET', 'https://api.maptiler.com/maps/**', { statusCode: 200, body: {} }).as('mapTiler');
Expand Down
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ module.exports = tseslint.config(
"@angular-eslint/template/no-call-expression": "warn",
"@angular-eslint/template/no-distracting-elements": "warn",
"@angular-eslint/template/mouse-events-have-key-events": "warn",
"@angular-eslint/template/no-inline-styles": "warn",
"@angular-eslint/template/no-interpolation-in-attributes": "warn",
"@angular-eslint/template/prefer-control-flow": "warn",
},
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class AppComponent implements OnInit {
loading = false;

ngOnInit(): void {
this._authFacade.initUserFromStorage();
this._authFacade.getUserByToken();
this._handleRouterEvents();
this._applySavedTheme();
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/common/components/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="right-side-container">
@if (userInfos$ | async; as userInfo) {
@if (userInfo.isConnected) {
@if (userInfo.canPublishActivity && !isOnActivityCreationPage()) {

Check warning on line 10 in src/app/common/components/header/header.component.html

View workflow job for this annotation

GitHub Actions / 🧪 Lint + Unit Tests

Avoid calling expressions in templates
<app-single-button
class="underline-animate"
[type]="'button'"
Expand All @@ -34,5 +34,5 @@
</div>
</header>
<app-register-modal [(visible)]="showRegisterModal"></app-register-modal>
<app-login-modal [(visible)]="showLoginModal" (openPasswordForgottenModal)="openPasswordForgottenModal()"></app-login-modal>
<app-login-modal [email]="email" [(visible)]="showLoginModal" (openPasswordForgottenModal)="openPasswordForgottenModal()"></app-login-modal>
<app-forgot-password-modal [(visible)]="showPasswordForgottenModal" (closeLoginModal)="closeLoginModal()"></app-forgot-password-modal>
4 changes: 4 additions & 0 deletions src/app/common/components/header/header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ header {
border: none;
transition: background-color 0.3s ease;
font-family: var(--font-family-p);

@media screen and (max-width: 400px) {
padding: 0.75rem 1rem;
}
}

.inscription-btn {
Expand Down
12 changes: 11 additions & 1 deletion src/app/common/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,21 @@ export class HeaderComponent extends DestroyableComponent implements OnInit {

showRegisterModal = false;
showLoginModal = false;
email: string = '';

showPasswordForgottenModal = false;
ButtonStyleClass = ButtonStyleClass;

userInfos$: Observable<UserHeaderInfo> = this._authFacade.getUserHeaderInfo();

ngOnInit(): void {
this._authService.openLoginModal$.pipe(this.untilDestroyed()).subscribe(() => {
this._authService.openLoginModal$.pipe(this.untilDestroyed()).subscribe((email: string | null) => {
this.email = email ?? '';
this.handleLoginModal(true);
});
this._authService.openSubscribeModal$.pipe(this.untilDestroyed()).subscribe(() => {
this.handleSubscribeModal(true);
});
}

openRegisterModal(): void {
Expand All @@ -62,6 +68,10 @@ export class HeaderComponent extends DestroyableComponent implements OnInit {
handleLoginModal(status: boolean): void {
this.showLoginModal = status;
}
handleSubscribeModal(status: boolean): void {
this.showLoginModal = false;
this.showRegisterModal = status;
}

closeLoginModal(): void {
this.showLoginModal = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
@if (control.errors?.['invalidAddress']) {
<p>L'adresse sélectionnée est invalide. Veuillez en choisir une depuis la liste</p>
}
@if (control.errors?.['dateRequired']) {
<p>La date saisie doit être dans le futur</p>
@if (control.errors?.['pastDate']) {
<p>La date doit être dans le passé.</p>
}
@if (control.errors?.['futureDate']) {
<p>La date doit être dans le futur.</p>
}
@if (control.errors?.['email']) {
<p>Adresse e-mail invalide</p>
}
@if (control.errors?.['maxSize']) {
<p>Le fichier est trop volumineux (max 5MB).</p>
<p>Le fichier est trop volumineux (max 10MB).</p>
}
@if (control.errors?.['invalidFormat']) {
<p>Format non autorisé.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
appendTo="body"
dateFormat="dd.mm.yy"
[ariaLabel]="fieldConfig.label"
[placeholder]="fieldConfig.placeholder ?? ''">
[placeholder]="fieldConfig.placeholder ?? ''"
[minDate]="dateMode === 'future' ? minDate : null"
[maxDate]="dateMode === 'past' ? maxDate : null">
</p-calendar>
} @else if (fieldConfig.type === 'password') {
<p-password
Expand Down Expand Up @@ -38,10 +40,10 @@
[id]="inputId"
[formControlName]="fieldConfig.name"
[type]="inputType"
[min]="fieldConfig.min"
[disabled]="disabled"
[placeholder]="fieldConfig.placeholder ?? ''"
autocomplete="on"
[ariaLabel]="fieldConfig.label" />
autocomplete="on" />
}
</ng-template>

Expand Down
16 changes: 14 additions & 2 deletions src/app/common/components/input-field/input-field.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommonModule } from '@angular/common';
import { Component, Input } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CalendarModule } from 'primeng/calendar';
import { DividerModule } from 'primeng/divider';
Expand All @@ -8,6 +8,7 @@ import { IftaLabelModule } from 'primeng/iftalabel';
import { InputTextModule } from 'primeng/inputtext';
import { PasswordModule } from 'primeng/password';
import { FormField } from 'src/app/features/authentication/models/form.model';
import { updateDateLimits } from '../../utils/date.utils';

@Component({
selector: 'app-input-field',
Expand All @@ -26,14 +27,25 @@ import { FormField } from 'src/app/features/authentication/models/form.model';
templateUrl: './input-field.component.html',
styleUrls: ['./input-field.component.scss'],
})
export class InputFieldComponent {
export class InputFieldComponent implements OnInit {
@Input() submitted: boolean = true;
@Input() disabled: boolean = false;
@Input() variant: 'in' | 'on' = 'in';
@Input() useIftaLabel: boolean = false;
@Input() showPasswordRules: boolean = false;

@Input({ required: true }) fieldConfig!: FormField;
@Input({ required: true }) formGroup: FormGroup;
@Input() dateMode: 'future' | 'past' | 'all' = 'all';

minDate: Date | undefined;
maxDate: Date | undefined;

ngOnInit(): void {
const { maxDate, minDate } = updateDateLimits(this.dateMode);
this.maxDate = maxDate;
this.minDate = minDate;
}

get inputId(): string {
return 'input_' + this.fieldConfig.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
(onClear)="emitValues()"
[inputId]="'input-' + i"
[placeholder]="field.placeholder"
[minDate]="dateMode === 'future' ? minDate : null"
[maxDate]="dateMode === 'past' ? maxDate : null"
[showIcon]="true"
inputStyleClass="custom-calendar-input"
dateFormat="dd/mm/yy" />
Expand Down Expand Up @@ -49,7 +51,7 @@
</div>

@if (showErrors) {
<app-input-field-error [control]="formGroup.get(field.name)" [fieldName]="field.name" class="input-error-message"> </app-input-field-error>

Check warning on line 54 in src/app/common/components/multiple-input-field/multiple-input-field.component.html

View workflow job for this annotation

GitHub Actions / 🧪 Lint + Unit Tests

Avoid calling expressions in templates
}
@if (!isLast) {
<div class="separator"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FormField } from 'src/app/features/authentication/models/form.model';
import { AutosaveFieldComponent } from '../../directives/autosave-field.component';
import { SaveStatus } from '../../models/status';
import { InputFieldErrorComponent } from '../input-field-error/input-field-error.component';
import { updateDateLimits } from '../../utils/date.utils';

@Component({
selector: 'app-multiple-input-field',
Expand All @@ -32,13 +33,16 @@ export class MultipleInputFieldComponent extends AutosaveFieldComponent<Record<s
@Output() inputValuesChanged = new EventEmitter<Record<string, string>>();
@Output() save = new EventEmitter<Record<string, string>>();

@Input() dateMode: 'future' | 'past' | 'all' = 'all';
@Input() fieldConfigs: FormField[] = [];
@Input() showSearchButton = false;
@Input() showSaveButton = false;
@Input() showErrors = false;
@Input() formGroup!: FormGroup;
@Input() override autosave = false;

minDate: Date | undefined;
maxDate: Date | undefined;
focusedIndex: number | null = null;
inputConfigs: { name: string; label: string; placeholder: string; type: string; value: string }[] = [];

Expand All @@ -65,6 +69,10 @@ export class MultipleInputFieldComponent extends AutosaveFieldComponent<Record<s
value: '',
}));
}

const { maxDate, minDate } = updateDateLimits(this.dateMode);
this.maxDate = maxDate;
this.minDate = minDate;
}

emitValues(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ p-tablist::ng-deep {
}

@media screen and (max-width: 400px) {
padding: 4px 8px;
padding: 8px 8px;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/common/interceptors/error-server.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const errorInterceptor: HttpInterceptorFn = (req, next) => {
detail = "Vous n'avez pas la permission d'accéder à cette ressource.";
} else if (error.status === HttpStatusCode.Unauthorized) {
const message = error?.error?.message;
console.error('Unauthorized error message from server:', message);
const isTokenExpired = message === 'Token expired';

if (isTokenExpired) {
Expand All @@ -42,7 +43,7 @@ export const errorInterceptor: HttpInterceptorFn = (req, next) => {
authService.triggerLoginModal();
} else {
summary = 'Authentification';
detail = message || 'Accès non autorisé.';
detail = 'Accès non autorisé.';
severity = 'error';
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/app/common/pipes/date-iso-pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({ name: 'isoDate' })
export class IsoDatePipe implements PipeTransform {
transform(value: string | Date | null): string {
if (!value) return '';
const date = value instanceof Date ? value : new Date(value);
return date.toISOString().split('T')[0]; // format yyyy-MM-dd
}
}
22 changes: 22 additions & 0 deletions src/app/common/utils/date.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
type DateLimits = {
minDate: Date | undefined;
maxDate: Date | undefined;
};

export function updateDateLimits(dateMode: string): DateLimits {
const today = new Date();
let minDate: Date | undefined;
let maxDate: Date | undefined;

if (dateMode === 'future') {
minDate = today;
maxDate = undefined;
} else if (dateMode === 'past') {
maxDate = today;
minDate = undefined;
} else {
minDate = undefined;
maxDate = undefined;
}
return { minDate, maxDate };
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
[appendTo]="'body'"
styleClass="custom-dialog"
contentStyleClass="custom-dialog-content">
<p class="subtitle" style="color: grey">Sélectionner une photo parmi vos précédentes activités ou télécharger une nouvelle image</p>

<div class="existing-photos">
@if (existingImages$ | async; as existingImages) {
@for (pic of existingImages; track pic.id) {
Expand All @@ -56,7 +58,7 @@
[type]="'button'"
(buttonClicked)="loadMorePictures()"
[styleClass]="ButtonStyleClass.defaultWhite"
label="Plus d'images"
label="Charger plus d'images précédentes"
ariaLabel="button pour charger plus de photos"
size="small">
</app-single-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@
}
}

.modal-container {
::ng-deep .p-dialog-header .p-dialog-title {
font-family: var(--font-family-big-medium-title);
font-size: var(--font-size-medium-title);
font-weight: 400 !important;
}
.modal-container ::ng-deep .p-dialog-header .p-dialog-title {
font-family: var(--font-family-big-medium-title);
font-size: var(--font-size-medium-title);
font-weight: 400 !important;

.existing-photos {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ export class ActivityAddPhotoComponent implements OnInit, OnChanges {
return;
}

const maxFileSize = 2 * 1024 * 1024;
const maxFileSize = 10 * 1024 * 1024;
if (file.size > maxFileSize) {
showErrorToast(this._toast, 'Le fichier est trop volumineux (max 2MB).');
showErrorToast(this._toast, 'Le fichier est trop volumineux (max 10MB).');
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { Activity, Participant } from '../../models/activity.model';
import { ActivityFacadeService } from '../../services/activity-facade.service';
import { FavoriteHeartComponent } from '../favorite-heart/favorite-heart.component';
import { InscriptionBadgeComponent } from '../inscription-badge/inscription-badge.component';
import { UUIDTypes } from 'uuid';
import { AuthFacade } from '../../../authentication/services/auth-facade.service';

@Component({
selector: 'app-activity-card',
Expand All @@ -23,19 +25,21 @@ export class ActivityCardComponent implements OnInit {
@Output() editActivity = new EventEmitter<string>();

@Input() activity!: Activity;
@Input() showDeleteButton: boolean = false;
@Input() showEditButton: boolean = false;

private _activityFacadeService: ActivityFacadeService = inject(ActivityFacadeService);
private _authService = inject(AuthService);
private _authFacadeService = inject(AuthFacade);

public isSavedActivity$: Observable<boolean>;
public voluntariesRegistered$: Observable<Participant>;
public apiUrl: string = environment.apiUrl;
public associationLogoUrl!: string;
public showDeleteButton: boolean = false;
isVoluntary$: Observable<boolean> = this._authService.isVoluntaryUser();
isAssociation$: Observable<boolean> = this._authService.isAssociationUser();
isAdmin$: Observable<boolean> = this._authService.isAdminUser();
connectedUserId$: Observable<UUIDTypes> = this._authFacadeService.getConnectedUserId();
showFavorite$: Observable<boolean> = combineLatest([this.isVoluntary$, this.isAdmin$]).pipe(
map(([isVoluntary, isAdmin]) => isVoluntary && !isAdmin)
);
Expand All @@ -44,6 +48,12 @@ export class ActivityCardComponent implements OnInit {
this.isSavedActivity$ = this._activityFacadeService.getIsSavedActivity(this.activity.id);
this.voluntariesRegistered$ = this._activityFacadeService.getVoluntariesRegisteredToAnActivity(this.activity.id);
this._setAssociationLogoUrl();

combineLatest([this.isAssociation$, this.isAdmin$, this.connectedUserId$]).subscribe(([isAssociation, isAdmin, connectedUserId]) => {
if ((isAssociation && this.activity.association.id === connectedUserId) || isAdmin) {
this.showDeleteButton = true;
}
});
}

onDeleteClick(event: MouseEvent): void {
Expand Down
Loading
Loading