Add measures evidences tab

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Jonathan
2025-06-09 12:14:56 +02:00
committed by Sacha Al Himdani
parent b660c0ce7f
commit 140857bfb3
92 changed files with 8427 additions and 865 deletions

View File

@@ -17,3 +17,18 @@ export function fileSize(__: (s: string) => string, size: number): string {
return `${formattedSize} ${units[unitIndex]}`;
}
type FileInfo = {
type: string;
mimeType: string;
};
export function fileType(__: (s: string) => string, info: FileInfo): string {
if (
info.type !== "FILE" ||
(info.mimeType !== "text/uri-list" && info.mimeType !== "text/uri")
) {
return __("Document");
}
return __("Link");
}

View File

@@ -14,3 +14,5 @@ export { getRole, getRoles, peopleRoles } from "./people";
export { certificationCategoryLabel, certifications } from "./certifications";
export { availableFrameworks } from "./frameworks";
export { getDocumentTypeLabel, documentTypes } from "./documents";
export { promisifyMutation } from "./relay";
export { fileType, fileSize } from "./file";

View File

@@ -0,0 +1,37 @@
export function promisifyMutation<Response, Error, Args>(
mutationFn: (
args: {
onCompleted?: (response: Response, error: Error) => void;
onError?: (error: Error) => void;
} & Args,
) => void,
): (
args: {
onCompleted?: (response: Response, error: Error) => void;
onError?: (error: Error) => void;
} & Args,
) => Promise<Response> {
return (opts) => {
return new Promise((resolve, reject) => {
mutationFn({
...opts,
onCompleted: (response, error) => {
if (opts.onCompleted) {
opts.onCompleted(response, error);
}
if (error) {
reject(error);
} else {
resolve(response);
}
},
onError: (error) => {
if (opts.onError) {
opts.onError(error);
}
reject(error);
},
});
});
};
}