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:
committed by
Sacha Al Himdani
parent
b660c0ce7f
commit
140857bfb3
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
37
packages/helpers/src/relay.ts
Normal file
37
packages/helpers/src/relay.ts
Normal 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);
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user