From 5801e83e6f397e6d910c1558592b7eb782d0477c Mon Sep 17 00:00:00 2001 From: Adrien Boutigny Date: Fri, 31 May 2024 16:19:59 +0200 Subject: [PATCH] use generated types in report --- .../src/audits/dto/audit-report.dto.ts | 36 +++--- .../src/components/report/ReportErrors.vue | 6 +- confiture-web-app/src/types/report.ts | 113 +----------------- confiture-web-app/src/types/types.ts | 2 + confiture-web-app/src/utils.ts | 9 +- 5 files changed, 32 insertions(+), 134 deletions(-) diff --git a/confiture-rest-api/src/audits/dto/audit-report.dto.ts b/confiture-rest-api/src/audits/dto/audit-report.dto.ts index f7baacf2..6d3265a9 100644 --- a/confiture-rest-api/src/audits/dto/audit-report.dto.ts +++ b/confiture-rest-api/src/audits/dto/audit-report.dto.ts @@ -36,24 +36,7 @@ export class AuditReportDto { */ accessibilityRate: number; - /** - * @example { - * total: 106; - * compliant: 30; - * notCompliant: 46; - * blocking: 12; - * applicable: 76; - * notApplicable: 30; - * } - */ - criteriaCount: { - total: number; - compliant: number; - notCompliant: number; - blocking: number; - applicable: number; - notApplicable: number; - }; + criteriaCount: CriteriaCount; /** Global distribution of criteria by result */ resultDistribution: ResultDistribution; @@ -67,6 +50,21 @@ export class AuditReportDto { results: ReportCriterionResult[]; } +class CriteriaCount { + /** @example 106 */ + total: number; + /** @example 30 */ + compliant: number; + /** @example 46 */ + notCompliant: number; + /** @example 12 */ + blocking: number; + /** @example 76 */ + applicable: number; + /** @example 30 */ + notApplicable: number; +} + class RawAndPercentage { /** * @example 47 @@ -204,6 +202,8 @@ class ReportCriterionResult { recommandation: string | null; notApplicableComment: string | null; + + quickWin: boolean; } class ExampleImage { diff --git a/confiture-web-app/src/components/report/ReportErrors.vue b/confiture-web-app/src/components/report/ReportErrors.vue index fa0d7461..0057e192 100644 --- a/confiture-web-app/src/components/report/ReportErrors.vue +++ b/confiture-web-app/src/components/report/ReportErrors.vue @@ -124,9 +124,9 @@ const defaultUserImpactFillters = [ null ]; -const userImpactFilters = ref>( - defaultUserImpactFillters -); +const userImpactFilters = ref< + Array +>(defaultUserImpactFillters); const disabledResetFilters = computed( () => diff --git a/confiture-web-app/src/types/report.ts b/confiture-web-app/src/types/report.ts index 86e2494d..61aa2003 100644 --- a/confiture-web-app/src/types/report.ts +++ b/confiture-web-app/src/types/report.ts @@ -1,111 +1,4 @@ -import { AuditType, CriteriumResult } from "../types"; +import { paths } from "./confiture-api"; -export interface AuditReport { - consultUniqueId: string; - - contactEmail?: string; - contactFormUrl?: string; - - procedureInitiator?: string; - procedureName: string; - procedureUrl?: string; - - creationDate?: string; - publishDate?: string; - updateDate?: string; - - notCompliantContent?: string; - derogatedContent?: string; - notInScopeContent?: string; - notes?: string; - - auditType: AuditType; - - context: AuditReportContext; - - accessibilityRate: number; - - criteriaCount: { - total: number; - compliant: number; - notCompliant: number; - blocking: number; - applicable: number; - notApplicable: number; - }; - - /** Global distribution of criteria by result */ - resultDistribution: ResultDistribution; - - /** Distribution of criteria by page */ - pageDistributions: PageResultDistribution[]; - - /** Distribution of criteria by topic */ - topicDistributions: TopicResultDistribution[]; - - results: Array< - Omit & { - exampleImages: { - url: string; - filename: string; - }[]; - } - >; -} - -interface ResultDistribution { - compliant: { - raw: number; - percentage: number; - }; - notCompliant: { - raw: number; - percentage: number; - }; - notApplicable: { - raw: number; - percentage: number; - }; -} - -interface PageResultDistribution extends ResultDistribution { - name: string; -} - -interface TopicResultDistribution extends ResultDistribution { - name: string; -} - -interface AuditReportContext { - referencial: string; - - auditorName: string; - auditorEmail: string | null; - auditorOrganisation: string; - - technologies: string[]; - - samples: PageSample[]; - - tools: string[]; - - desktopEnvironments: Environment[]; - mobileEnvironments: Environment[]; -} - -interface PageSample { - // number: number; - id: number; - order: number; - name: string; - url: string; -} - -interface Environment { - operatingSystem: string; - operatingSystemVersion?: string; - assistiveTechnology: string; - assistiveTechnologyVersion?: string; - browser: string; - browserVersion?: string; -} +export type AuditReport = + paths["/reports/{consultUniqueId}"]["get"]["responses"]["200"]["content"]["application/json"]; diff --git a/confiture-web-app/src/types/types.ts b/confiture-web-app/src/types/types.ts index 41d84b97..b7ba49ce 100644 --- a/confiture-web-app/src/types/types.ts +++ b/confiture-web-app/src/types/types.ts @@ -28,6 +28,8 @@ export enum AuditType { FULL = "FULL" } +export type AuditTypeString = `${AuditType}`; + export enum AuditStatus { IN_PROGRESS = "IN_PROGRESS", COMPLETED = "COMPLETED", diff --git a/confiture-web-app/src/utils.ts b/confiture-web-app/src/utils.ts index 8ad9f066..18bd7aa3 100644 --- a/confiture-web-app/src/utils.ts +++ b/confiture-web-app/src/utils.ts @@ -8,6 +8,7 @@ import { AuditReport, AuditStatus, AuditType, + AuditTypeString, CriterionResultUserImpact, CriteriumResultStatus } from "./types"; @@ -44,7 +45,7 @@ const FORMATTED_USER_IMPACT = { * Format a criterion result user impact type string into French. */ export function formatUserImpact( - userImpact: CriterionResultUserImpact + userImpact: CriterionResultUserImpact | `${CriterionResultUserImpact}` ): string { return FORMATTED_USER_IMPACT[userImpact]; } @@ -59,7 +60,9 @@ const FORMATTED_STATUS = { /** * Format a criterion result status type string into French. */ -export function formatStatus(status: CriteriumResultStatus): string { +export function formatStatus( + status: CriteriumResultStatus | `${CriteriumResultStatus}` +): string { return FORMATTED_STATUS[status]; } @@ -72,7 +75,7 @@ const CRITERIA_COUNT = { /** * Return the number of criteria for a given audit type. */ -export function getCriteriaCount(auditType: AuditType): number { +export function getCriteriaCount(auditType: AuditTypeString): number { return CRITERIA_COUNT[auditType]; }