Skip to content

Commit

Permalink
feat: data inclusion api call (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-gavanier authored Oct 10, 2024
1 parent 4d87a24 commit 190d29e
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 125 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"volta": {
"node": "20.18.0",
"yarn": "1.22.10"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MatomoTracker } from 'ngx-matomo';
import {
ChangeDetectionStrategy,
Component,
Expand All @@ -6,22 +7,25 @@ import {
Input,
Output,
ViewChild,
Optional
Optional,
OnInit
} from '@angular/core';
import { FormGroup } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { DispositifProgrammeNational } from '@gouvfr-anct/lieux-de-mediation-numerique';
import { LieuMediationNumeriqueDetailsPresentation } from '../../presenters';
import { OrientationSheetForm, SendLieuByEmail } from '../../models';
import { FilterPresentation } from '../../../core/presenters';
import { FormGroup } from '@angular/forms';
import { MatomoTracker } from 'ngx-matomo';
import { environment } from 'projects/client-application/src/environments/environment';

const authorizationToken = (token?: string) => (token ? { headers: { Authorization: `Bearer ${token}` } } : {});

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'app-lieux-mediation-numerique-details',
templateUrl: './lieux-mediation-numerique-details.component.html'
})
export class LieuxMediationNumeriqueDetailsComponent {
export class LieuxMediationNumeriqueDetailsComponent implements OnInit {
@ViewChild('source') sourceRef!: ElementRef;

@Input() public lieuMediationNumerique!: LieuMediationNumeriqueDetailsPresentation;
Expand Down Expand Up @@ -49,17 +53,23 @@ export class LieuxMediationNumeriqueDetailsComponent {

@Output() public showLabelInvokingContext: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();

public constructor(@Optional() private readonly _matomoTracker?: MatomoTracker) {}
public constructor(private readonly _http: HttpClient, @Optional() private readonly _matomoTracker?: MatomoTracker) {}

public ngOnInit(): void {
this.lieuMediationNumerique.source?.forEach((source) => {
if (source.origin == null) return;
this._http.get(source.origin.api, authorizationToken(source.origin.token)).subscribe();
});
}

onScrollToSource = (): void => {
this.sourceRef.nativeElement.scrollIntoView({ behavior: 'smooth', block: 'end', inline: 'start' });
};

public onPrintFromBandeau(): void {
if (environment.production) {
this._matomoTracker?.trackEvent('fiche détail', 'bandeau footer', `impression fiche`);
const sourceLabels = this.lieuMediationNumerique.source?.map((source) => source.label).join(', ');
this._matomoTracker?.trackEvent('fiche détail', sourceLabels ?? 'Source inconnue', 'bandeau footer - impression fiche');
}
if (!environment.production) return;
this._matomoTracker?.trackEvent('fiche détail', 'bandeau footer', `impression fiche`);
const sourceLabels = this.lieuMediationNumerique.source?.map((source) => source.label).join(', ');
this._matomoTracker?.trackEvent('fiche détail', sourceLabels ?? 'Source inconnue', 'bandeau footer - impression fiche');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('score completion presenter', (): void => {

const scoreCompletionTotal: number = scoreCompletionRate(structure);

expect(scoreCompletionTotal).toStrictEqual(95);
expect(scoreCompletionTotal).toStrictEqual(98);
});

it('should return low score completion', async (): Promise<void> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type SourcePresentation = {
detail?: string;
update_link?: string;
logo?: string;
origin?: { api: string; token?: string };
};

export type LieuMediationNumeriqueDetailsPresentation = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ describe('lieux médiation numérique details presenter', (): void => {
Samedi: '08h30 - 12h00',
Dimanche: 'Fermé'
},
source: [],
status: {
label: 'Ouvert',
limite: 'Ferme à 18h30'
Expand Down Expand Up @@ -241,6 +242,7 @@ describe('lieux médiation numérique details presenter', (): void => {
adresse: `12 BIS RUE DE LECLERCQ Le patio du bois de l'Aulne 51100 Reims`,
code_postal: '51100',
commune: 'reims',
source: [],
services: [Service.MaitriseDesOutilsNumeriquesDuQuotidien, Service.AccesInternetEtMaterielInformatique]
});
});
Expand Down Expand Up @@ -284,6 +286,7 @@ describe('lieux médiation numérique details presenter', (): void => {
adresse: `12 BIS RUE DE LECLERCQ Le patio du bois de l'Aulne 51100 Reims`,
code_postal: '51100',
commune: 'reims',
source: [],
services: [Service.MaitriseDesOutilsNumeriquesDuQuotidien, Service.AccesInternetEtMaterielInformatique],
horaires: {
Lundi: '09h00 - 12h00\n14h00 - 18h30',
Expand Down Expand Up @@ -340,6 +343,7 @@ describe('lieux médiation numérique details presenter', (): void => {
adresse: `12 BIS RUE DE LECLERCQ Le patio du bois de l'Aulne 51100 Reims`,
code_postal: '51100',
commune: 'reims',
source: [],
services: [Service.MaitriseDesOutilsNumeriquesDuQuotidien, Service.AccesInternetEtMaterielInformatique],
localisation: Localisation({ latitude: 45.7689958, longitude: 4.8343466 }),
distance: 0
Expand Down
Loading

0 comments on commit 190d29e

Please sign in to comment.