type ParseProjects = (arg: { file: File; }) => Props['data'][number]['data'][number]['data'][number][]; const parseProjectsDefaultValue: ReturnType<ParseProjects> = []; export const parseProjects: ParseProjects = ({ file }) => { try { // ! Projects make project array return Object.entries(file.project).reduce((acc, item) => { const currentKey = item[0] as PROJECT; if (item[1]) { const result: ReturnType<ParseProjects>[number] = { project: currentKey, status: CUSTOMER_STATUS.CONTACTED, label: '', }; return [...acc, result]; } return acc; }, parseProjectsDefaultValue); } catch { return parseProjectsDefaultValue; } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter