diff --git a/src/pages/Main/ClockifyTaskForm/ClockifyTaskForm.jsx b/src/pages/Main/ClockifyTaskForm/ClockifyTaskForm.jsx index b8a93f8..29c7d63 100644 --- a/src/pages/Main/ClockifyTaskForm/ClockifyTaskForm.jsx +++ b/src/pages/Main/ClockifyTaskForm/ClockifyTaskForm.jsx @@ -116,6 +116,19 @@ const ClockifyTaskForm = ({timerOn, setTimerOn, signedIn, apiKey, setApiKey, tas const response = await fetch(`https://api.clockify.me/api/v1/workspaces/${e}/projects`, request) const data = await response.json() + data.forEach((project, index) => { + if (project.clientName !== "" && !project.archived) { + + if (!data.clients) { + data.clients = {[project.clientName]: [project]} + } else { + data.clients[project.clientName].push(project) + } + + project.archived = true + } + }) + changeClockifyData({projects: data}) } catch (error) { @@ -219,6 +232,21 @@ const ClockifyTaskForm = ({timerOn, setTimerOn, signedIn, apiKey, setApiKey, tas : null )) } + { + (clockifyData.projects && clockifyData.projects.clients) && + Object.keys(clockifyData.projects.clients).map((client, index) => ( + <> + {index === 0 && } + + { + clockifyData.projects.clients[client].map(project => ( + + )) + } + + + )) + }