Skip to content

Commit

Permalink
fix: eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey committed Dec 16, 2024
1 parent ab45726 commit 211dbcf
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 54 deletions.
10 changes: 8 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ export default [
{ files: ['**/*.{js,mjs,cjs,ts}'] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-require-imports': 'off'
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/no-confusing-non-null-assertion': 'off',
'@typescript-eslint/no-empty-function': 'off'
}
}
];
6 changes: 3 additions & 3 deletions functions/src/cms4devfest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ export const relancePartnaireConventionASigner = functions.https.onCall(async ()
const configuration = await getConfiguration(firestore);
const data = await firestore.collection('companies-2025').get();
const partners = data.docs.map((d) => d.data()).filter((p) => p.status.sign === StatusEnum.PENDING);
relance(relanceConventionSignee, partners, configuration);
relance(relanceConventionSignee, partners as Company[], configuration);
});

export const relancePartnaireFacture = functions.https.onCall(async () => {
const configuration = await getConfiguration(firestore);
const data = await firestore.collection('companies-2025').get();
const partners = data.docs.map((d) => d.data()).filter((p) => p.status.paid === StatusEnum.PENDING);
relance(relancePaiement, partners, configuration);
relance(relancePaiement, partners as Company[], configuration);
});

export const relanceInformationPourGeneration = functions.https.onCall(async () => {
const configuration = await getConfiguration(firestore);
const data = await firestore.collection('companies-2025').get();
const partners = data.docs.map((d) => d.data()).filter((p) => p.status.generated === StatusEnum.PENDING);
relance(relanceInformationsComplementaires, partners, configuration);
relance(relanceInformationsComplementaires, partners as Company[], configuration);
});

export const newPartner = functions.firestore.document('companies-2025/{companyId}').onCreate(async (snap) => {
Expand Down
4 changes: 2 additions & 2 deletions functions/src/emails/template/relancePaiement.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Configuration } from '../../model';
import { Company, Configuration } from '../../model';

export default (partner: Record<string, unknown>, configuration: Configuration) => {
export default (partner: Company, configuration: Configuration) => {
return {
subject: `Partenariat ${configuration.gdg.event} ${configuration.convention.edition}: Relance Paiement`,
body: `
Expand Down
2 changes: 1 addition & 1 deletion functions/src/emails/template/step-5-billet-web-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ${configuration.mail.signature} ${configuration.convention.edition}
});

export default (company: Company, configuration: Configuration) => {
const billetWebUrl = company.billetWebUrl!;
const billetWebUrl = company.billetWebUrl ?? '';
if (company.sponsoring === 'Platinium' || company.sponsoring === 'Gold' || company.sponsoring === 'Silver') {
return generateEmailForSponsorWithStand(billetWebUrl, configuration);
}
Expand Down
1 change: 1 addition & 0 deletions functions/src/generator/lib/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function generateFile(company: Company, fileName: string, fileModule: { default:
PO: company.PO,
SPONSORING_TEXT,
SPONSORING_NUMBER: total,
INSTALLATION_DATE: configuration.convention.installationdate,
START_DATE: configuration.convention.startdate,
END_DATE: configuration.convention.enddate,
DATE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ As indicated in the invoice, here are the Banking Information of the association
- BIC QNTOFRP1XXX
<% if (HAS_BOOTH === 'true') { %>
The Partner is committed to install its stand on June, the 5th. A security team will be present the night in the exhibition room.
The Partner is committed to install its stand on <%= INSTALLATION_DATE %>. A security team will be present the night in the exhibition room.
<% } %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Comme indiqué sur le devis, vous trouverez ci-dessous les informations bancaire
- BIC QNTOFRP1XXX
<% if (HAS_BOOTH === 'true') { %>
Le partenaire s'engage à installer son stand le mercredi 5 juin après-midi entre 14h et 18h. Une équipe de sécurité sera présente la nuit pour surveiller la zone d'expositions.
Le partenaire s'engage à installer son stand le <%= INSTALLATION_DATE %> après-midi entre 14h et 18h. Une équipe de sécurité sera présente la nuit pour surveiller la zone d'expositions.
Le stand doit respecter les contraintes suivante :
- ne pas dépasser 2.4m de hauteur sur la panneau du fond
Expand Down
35 changes: 21 additions & 14 deletions functions/src/model.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
import { Timestamp } from 'firebase-admin/firestore';

export type EmailContent = { subject: string; body: string };
export interface EmailContent {
subject: string;
body: string;
}

export type Convention = {
export interface Convention {
edition: string;
startdate: string;
enddate: string;
};
installationdate: string;
}

export type Hosting = {
export interface Hosting {
baseurl: string;
};
}

export type Association = {
export interface Association {
address: string;
zipcode: string;
city: string;
event: string;
tel: string;
accountantemail: string;
website: string;
};
}

export type Email = {
export interface Email {
mailgun: string;
mailgun_email: '[email protected]';
enabled: string;
Expand All @@ -31,23 +35,23 @@ export type Email = {
from: string;
fromname: string;
cc: string;
};
}

export type Mailjet = {
export interface Mailjet {
api: string;
private: string;
};
}

export type SponsoringType = Record<string, number>;
export type SponsorshipConfiguration = {
export interface SponsorshipConfiguration {
freeTickets: number;
name: string;
price: number;
priceString: string;
considerations: string[];
considerationsEn: string[];
hasBooth: boolean;
};
}

export type Configuration = SponsoringType & {
next_value: string;
Expand All @@ -63,7 +67,10 @@ export type Configuration = SponsoringType & {
template_folder: string;
};

export type SponsoringOption = { label: string; price: number };
export interface SponsoringOption {
label: string;
price: number;
}
export type SponsoringOptions = SponsoringOption[];

export interface WorkflowStatus {
Expand Down
4 changes: 2 additions & 2 deletions functions/src/utils/document-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export enum StatusEnum {
export async function onDocumentChange(firestore: FirebaseFirestore.Firestore, before: Company, after: Company, id: string, configuration: Configuration) {
const document = firestore.doc('companies-2025/' + id);
console.log(`onDocumentChange ${id}: ${JSON.stringify(before.status)} -> ${JSON.stringify(after.status)}`);
const status = after.status!;
const beforeStatus = before.status!;
const status = after.status ?? {};
const beforeStatus = before.status ?? {};
if (status.generated === StatusEnum.PENDING) {
if (!!after.address && !!after.zipCode && !!after.city && !!after.siret && !!after.representant && !!after.role) {
return document.update({
Expand Down
2 changes: 1 addition & 1 deletion functions/src/v3/domain/sendToWebhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Configuration } from '../../model';
export const sendToWebhooks = async (configuration: Configuration, changes: Change<QueryDocumentSnapshot>) => {
const length = configuration.webhooks?.length ?? 0;
if (length > 0) {
for (const webhook of configuration.webhooks!) {
for (const webhook of configuration.webhooks ?? []) {
console.log(`Sending to webhook ${webhook} information about ${changes.after.data().name}`);
await axios.post(webhook, {
id: changes.after.id,
Expand Down
6 changes: 5 additions & 1 deletion public/src/app/model/company.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export type Configuration = SponsoringType & {
sponsoringOptions?: SponsoringOption[];
} & z.infer<typeof ZodConfiguration>;

export type SponsoringOption = { key: string; label: string; price: number };
export interface SponsoringOption {
key: string;
label: string;
price: number;
}
export interface Workflow {
id: number;
steps: WorkflowStep[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import { MatExpansionModule } from '@angular/material/expansion';

type FilterValueType = 'sign' | 'generated' | 'validated' | 'paid' | 'received' | 'communicated' | 'code';

type Option = { value: FilterValueType | string; label: string };
interface Option {
value: FilterValueType | string;
label: string;
}
type Options = Option[];
type OptionWithChecked = Option & { checked: boolean };

export type Search = {
export interface Search {
status: string[];
packs: string[];
types: string[];
};
}

const PackOptions: Options = [
{ value: 'bronze', label: `Bronze` },
Expand Down
44 changes: 36 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,6 @@
import { CommonModule } from '@angular/common';
import { AfterViewInit, Component, computed, inject, linkedSignal, signal, viewChild } from '@angular/core';
import { AfterViewInit, Component, computed, effect, inject, linkedSignal, signal, viewChild } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { Timestamp } from '@angular/fire/firestore';
import { Functions, httpsCallable } from '@angular/fire/functions';
import { FormsModule } from '@angular/forms';
Expand All @@ -11,11 +12,18 @@ import { MatExpansionModule } from '@angular/material/expansion';
import { MatRadioModule } from '@angular/material/radio';
import { MatSort, MatSortModule } from '@angular/material/sort';
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router';

import { Company, Configuration, WorkflowStatus } from '../../model/company';
import { PartnerService } from '../../services/partner.service';
import { DashboardFilterComponent, Search } from './dashboard-filter.component';

const DefaultSearchValue = {
status: ['sign', 'generated', 'validated', 'paid', 'received', 'communicated', 'code'],
packs: ['bronze', 'silver', 'gold', 'party'],
types: ['esn', 'other', 'undefined']
};

@Component({
selector: 'cms-dashboard',
imports: [
Expand All @@ -35,12 +43,35 @@ import { DashboardFilterComponent, Search } from './dashboard-filter.component';
styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements AfterViewInit {
value = signal<Search>({
status: ['sign', 'generated', 'validated', 'paid', 'received', 'communicated', 'code'],
packs: ['bronze', 'silver', 'gold', 'party'],
types: ['esn', 'other', 'undefined']
private readonly partnerService: PartnerService = inject(PartnerService);
private readonly functions: Functions = inject(Functions);
private readonly route = inject(ActivatedRoute);
private readonly router = inject(Router);

private readonly queryParameters = toSignal(this.route.queryParams);

value = linkedSignal<Search>(() => {
const queryParameterValues = this.queryParameters();
if (queryParameterValues && Object.keys(queryParameterValues).length > 0) {
return {
status: queryParameterValues['status']?.split(',') ?? [],
packs: queryParameterValues['packs']?.split(',') ?? [],
types: queryParameterValues['types']?.split(',') ?? []
};
}
return DefaultSearchValue;
});

syncParams = effect(() => {
this.router.navigate([], {
queryParams: {
status: this.value().status?.join(','),
packs: this.value().packs?.join(','),
types: this.value().types?.join(',')
},
queryParamsHandling: 'merge'
});
});
readonly sort = viewChild.required(MatSort);

onFilterChange = (search: Search) => {
Expand Down Expand Up @@ -75,9 +106,6 @@ export class DashboardComponent implements AfterViewInit {
return dataSource;
});

private readonly partnerService: PartnerService = inject(PartnerService);
private readonly functions: Functions = inject(Functions);

async relance() {
const status = this.value().status;
if (status[0] === 'generated') {
Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions public/src/app/private-dashboard/private-dashboard.component.ts

This file was deleted.

6 changes: 4 additions & 2 deletions public/src/app/ui/filled/filled.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Component } from '@angular/core';
@Component({
selector: 'cms-filled',
imports: [],
template: ` <p>Nous avons bien pris en compte votre souhait de devenir partenaire et nous vous en remercions.</p> `
template: ` <p>{{ message }}</p> `
})
export class FilledComponent {}
export class FilledComponent {
message = 'Nous avons bien pris en compte votre souhait de devenir partenaire et nous vous en remercions.';
}
4 changes: 2 additions & 2 deletions public/src/environments/environment.type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type Environement = {
export interface Environement {
firebase?: Record<string, string>;
emailDomain: string;
files: Record<string, string>;
title: string;
};
}

0 comments on commit 211dbcf

Please sign in to comment.