/** * Merges the first element of a translation array into the main object. * * @param translationKey - The key in the object that holds the translation array. * @param item - The object containing the translation array. * @returns A new object combining the original object properties with the properties * of the first translation, excluding the translation array. */ export const itemTranslations = ( translationKey: string, item: T ) => { let locale = {}; if (item[translationKey] && item[translationKey]?.length > 0) { locale = { ...item[translationKey][0] }; } delete item[translationKey]; return { ...locale, ...(item as any), }; };