Skip to content

Commit

Permalink
use generated types in report
Browse files Browse the repository at this point in the history
  • Loading branch information
hissalht committed May 31, 2024
1 parent 90b0494 commit 5801e83
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 134 deletions.
36 changes: 18 additions & 18 deletions confiture-rest-api/src/audits/dto/audit-report.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -204,6 +202,8 @@ class ReportCriterionResult {
recommandation: string | null;

notApplicableComment: string | null;

quickWin: boolean;
}

class ExampleImage {
Expand Down
6 changes: 3 additions & 3 deletions confiture-web-app/src/components/report/ReportErrors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ const defaultUserImpactFillters = [
null
];
const userImpactFilters = ref<Array<CriterionResultUserImpact | null>>(
defaultUserImpactFillters
);
const userImpactFilters = ref<
Array<CriterionResultUserImpact | `${CriterionResultUserImpact}` | null>
>(defaultUserImpactFillters);
const disabledResetFilters = computed(
() =>
Expand Down
113 changes: 3 additions & 110 deletions confiture-web-app/src/types/report.ts
Original file line number Diff line number Diff line change
@@ -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<CriteriumResult, "exampleImages"> & {
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"];
2 changes: 2 additions & 0 deletions confiture-web-app/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export enum AuditType {
FULL = "FULL"
}

export type AuditTypeString = `${AuditType}`;

export enum AuditStatus {
IN_PROGRESS = "IN_PROGRESS",
COMPLETED = "COMPLETED",
Expand Down
9 changes: 6 additions & 3 deletions confiture-web-app/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
AuditReport,
AuditStatus,
AuditType,
AuditTypeString,
CriterionResultUserImpact,
CriteriumResultStatus
} from "./types";
Expand Down Expand Up @@ -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];
}
Expand All @@ -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];
}

Expand All @@ -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];
}

Expand Down

0 comments on commit 5801e83

Please sign in to comment.