type GroupeDataByDate = (arg: { filteredFiles: CustomerFile[] }) => { [key: string]: CustomerStatusCardsProps['data'][number]['data'][number][]; }; const groupeDataByDateDefaultValue: ReturnType<GroupeDataByDate> = {}; export const groupeDataByDate: GroupeDataByDate = ({ filteredFiles }) => { try { // ! Group files by date return filteredFiles.reduce((acc, item) => { const computedProjects = parseProjects({ file: item }); const filesByDate = { title: item.customer, data: computedProjects }; if (acc[item.updatedAt]) { return { ...acc, [item.updatedAt]: [...acc[item.updatedAt], filesByDate] }; } return { ...acc, [item.updatedAt]: [filesByDate] }; }, groupeDataByDateDefaultValue); } catch (error) { return groupeDataByDateDefaultValue; } };