Commit f0c6faa1 authored by Omar Chehab's avatar Omar Chehab

Fix cannot import report when some select input does not have data

When a user is importing a client or employee report and the other report type does not have data from either manager or clockify, then the select input does not have any options.

I made all four select input optional and only validated the two required inputs depending on the value of the type of report that is being generated.
parent 1eedfb30
......@@ -535,36 +535,24 @@
<div id="import-report-client">
<label><span class="timetracker-name"></span> Client</label>
<select
name="timeTrackerClientId"
required
>
<select name="timeTrackerClientId">
</select>
<label>Manager Customer</label>
<select
name="managerCustomerId"
required
>
<select name="managerCustomerId">
</select>
</div>
<div id="import-report-employee">
<label><span class="timetracker-name"></span> User</label>
<select
name="timeTrackerUserId"
required
>
<select name="timeTrackerUserId">
</select>
<label>Manager Employee</label>
<select
name="managerEmployeeId"
required
>
<select name="managerEmployeeId">
</select>
</div>
......
......@@ -433,12 +433,22 @@ importReportTab.addEventListener('submit', async function(event) {
switch (selections.reportType) {
case 'client':
if (!selections.timeTrackerClientId || !selections.managerCustomerId) {
fetchReportSubmit.innerText = 'Back';
fetchReportError.innerText = 'Both Clockify Client and Manager Customer are required.';
return;
}
timeTrackerReportResponse = await timeTracker.getClientReport(selections.timeTrackerWorkspaceId, selections.timeTrackerClientId, selections.reportStartDate, selections.reportEndDate, {
signal,
});
break;
case 'employee':
if (!selections.timeTrackerUserId || !selections.managerEmployeeId) {
fetchReportSubmit.innerText = 'Back';
fetchReportError.innerText = 'Both Clockify User and Manager Employee are required.';
return;
}
timeTrackerReportResponse = await timeTracker.getEmployeeReport(selections.timeTrackerWorkspaceId, selections.timeTrackerUserId, selections.reportStartDate, selections.reportEndDate, {
signal,
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment