Skip to content

Commit

Permalink
feat: make form OK
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey committed Nov 27, 2024
1 parent 8e860d0 commit 625bc75
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
6 changes: 5 additions & 1 deletion firestore.devfest.rules
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ service cloud.firestore {
allow get: if true;
allow update: if isAdministrator();
}
match /editions/{configurationId} {
allow get: if true;
allow update: if isAdministrator();
}
}
}

Expand All @@ -28,5 +32,5 @@ function isOwner(companyId) {
return request.auth.token.email in resource.data.email;
}
function isAdministrator() {
return request.auth.token.email.matches(".*@devlille.fr")
return request.auth.token.email.matches(".*@devlille.fr") || request.auth.token.email.matches(".*@gdglille.org")
}
3 changes: 3 additions & 0 deletions functions/src/model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Timestamp } from 'firebase-admin/firestore';

export type Convention = {
edition: string;
startdate: string;
Expand Down Expand Up @@ -46,6 +48,7 @@ export type SponsorshipConfiguration = {
export type Configuration = SponsoringType & {
next_value: string;
enabled: boolean;
openingDate: Timestamp;
sponsorships: SponsorshipConfiguration[];
webhooks?: string[];
convention: Convention;
Expand Down
1 change: 1 addition & 0 deletions public/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class AppComponent {
constructor() {
this.titleService.setTitle(environment.title);
this.auth.onAuthStateChanged((state) => {
console.log(state);
this.isLoggedIn = !!state?.email?.endsWith('@' + environment.emailDomain);
});
}
Expand Down
22 changes: 14 additions & 8 deletions public/src/app/private-dashboard/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommonModule } from '@angular/common';
import { Component, inject, AfterViewInit, signal, computed, viewChild } from '@angular/core';
import { Component, inject, AfterViewInit, signal, computed, viewChild, linkedSignal } from '@angular/core';
import { Timestamp } from '@angular/fire/firestore';
import { Functions, httpsCallable } from '@angular/fire/functions';
import { FormsModule } from '@angular/forms';
Expand Down Expand Up @@ -34,21 +34,25 @@ export class DashboardComponent implements AfterViewInit {
originalPartners = signal<Partial<Company>[]>([]);
filterByStatusValue = signal<FilterValueType[]>(['validated', 'generated', 'sign', 'paid', 'received', 'communicated', 'code']);

shouldDisplayRelanceButton = computed(() => {
shouldDisplayRelanceButton = linkedSignal(() => {
const status = this.filterByStatusValue();
return status.length === 1 && ['generated', 'sign', 'paid'].indexOf(status[0]) >= 0;
});
filterByTypeValue = signal<FilterByType[]>(['esn', 'other', 'undefined']);

filteredPartnersByStatus = computed(() => {
filteredPartnersByStatus = linkedSignal(() => {
const status = this.filterByStatusValue();
console.log(this.originalPartners(), status);

return this.originalPartners().filter((partner) => status.find((v) => !!partner.status && partner.status[v] === 'pending'));
});

filteredPartnersByStatusAndPacks = computed(() => {
filteredPartnersByStatusAndPacks = linkedSignal(() => {
const packs = this.filterByPackValue();

console.log(packs, this.filteredPartnersByStatus());
return this.filteredPartnersByStatus().filter((partner) => {
console.log(partner.sponsoring);
if (!partner.sponsoring) {
return false;
}
Expand All @@ -58,16 +62,17 @@ export class DashboardComponent implements AfterViewInit {

filteredPartners = computed(() => {
const types = this.filterByTypeValue();

console.log(types, this.filteredPartnersByStatusAndPacks());
return this.filteredPartnersByStatusAndPacks().filter((partner) => {
console.log({ partner });
return types.indexOf(partner.type!) >= 0 || (!partner.type && types.indexOf('undefined') >= 0);
});
});

dataSource = computed(() => {
dataSource = linkedSignal(() => {
const dataSource = new MatTableDataSource(this.filteredPartners());
dataSource.sort = this.sort();

console.log({ dataSource });
return dataSource;
});

Expand Down Expand Up @@ -110,7 +115,7 @@ export class DashboardComponent implements AfterViewInit {
this.filterByPackSelected.set(pack);
}

filterByType = computed(() => {
filterByType = linkedSignal(() => {
const partners = this.filteredPartnersByStatusAndPacks();

let numberESN = 0;
Expand Down Expand Up @@ -161,6 +166,7 @@ export class DashboardComponent implements AfterViewInit {
this.partnerService.getCurrentConfiguration().then((config) => this.configuration.set(config));

this.partnerService.getAll().subscribe((partners) => {
console.log(partners);
this.originalPartners.set(
partners.map((partners) => ({
...partners,
Expand Down
1 change: 1 addition & 0 deletions public/src/app/services/partner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class PartnerService {
}

public getAll(): Observable<Company[]> {
console.log('getall');
return collectionSnapshots(this.companiesCollection).pipe(
map((snapshots: QueryDocumentSnapshot[]) => {
return snapshots.map((snapshot) => ({ ...snapshot.data(), id: snapshot.id }) as Company).filter((company) => !company.archived && company.status?.validated !== 'refused');
Expand Down

0 comments on commit 625bc75

Please sign in to comment.