Skip to content

Commit

Permalink
fix: fixing task deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasz97 committed Sep 18, 2024
1 parent d3374d8 commit 9387f40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/components/timesheet/TimeSheetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ export const TimeSheetTable = component$<TimeSheetTableProps>(
updateTimeEntries(timeEntryObject);
});

const deleteHandler = $((entry: TimeEntry) => {
if (!entry.isUnsaved) {
const deleteHandler = $((entries: TimeEntry[]) => {
if (entries.findIndex((entry) => !entry.isUnsaved) !== -1) {
deleteTimeEntriesRowModalState.isVisible = true;
deleteTimeEntriesRowModalState.confirmLabel = t('ACTION_CONFIRM');
deleteTimeEntriesRowModalState.cancelLabel = t('ACTION_CANCEL');
deleteTimeEntriesRowModalState.onConfirm$ = $(() => {
deleteProjectEntries(entry);
entries.forEach((entry) => deleteProjectEntries(entry));
});

return;
}

deleteProjectEntries(entry);
entries.forEach((entry) => deleteProjectEntries(entry));
});

useTask$(async ({ track }) => {
Expand Down Expand Up @@ -288,7 +288,7 @@ export const TimeSheetTable = component$<TimeSheetTableProps>(
</span>
</td>
<td class='border border-surface-50 px-4 py-3 text-center'>
<button onClick$={() => deleteHandler(entries[0])}>
<button onClick$={() => deleteHandler(entries)}>
{getIcon('Bin')}
</button>
</td>
Expand Down
2 changes: 1 addition & 1 deletion src/services/timeSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getTimeEntries = async (from: string, to: string): Promise<TimeEntr
export const deleteTimeEntry = async (entry: TimeEntry): Promise<Boolean> =>
checkHttpResponseStatus(`time-entry/mine`, 200, 'DELETE', {
...entry,
task: entry.task.name,
project: entry.project.name,
});

export const postTimeEntries = async (timeEntry: TimeEntryObject): Promise<boolean> => {
Expand Down

0 comments on commit 9387f40

Please sign in to comment.