diff --git a/frontend/src/lib/utils/utils.js b/frontend/src/lib/utils/utils.js index 0c73b18..e71fd67 100644 --- a/frontend/src/lib/utils/utils.js +++ b/frontend/src/lib/utils/utils.js @@ -68,13 +68,20 @@ export function isEmpty(obj) { } return true; } + /** - * Test whether or not an object is empty. + * @typedef {Object} FormattedError + * @property {string} error - The error message + * @property {number} id - A unique identifier for the error + */ +/** + * Format Error object(s) * @param {any} obj - The object to test - * @returns `true` or `false` + * @returns @type {FormattedError[]} */ export function formatError(obj) { + /** @type {FormattedError[]} */ const errors = []; if (typeof obj === "object" && obj !== null) { if (Array.isArray(obj)) { @@ -103,3 +110,9 @@ export function formatError(obj) { return errors; } + +export function toRFC3339(dateString) { + if (!dateString) return ""; + const date = new Date(dateString); + return date.toISOString(); +}