Skip to content

Commit

Permalink
Handle deleting single timesheet entries before submit. #35
Browse files Browse the repository at this point in the history
  • Loading branch information
syedfarhankabir committed Oct 23, 2022
1 parent 5c7fd3c commit 0e92e48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/entry/controller/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,14 @@ class Entry extends Controller {
throw new BadRequest('The project link must be in the format /projects/123');
}

const project = await projectService.findById(+projectId);

await entryService.deleteEntry(entry, project);
await entryService.deleteEntry(entry);

ctx.response.status = 204;
// ctx.response.links.add({
// rel: 'invalidates',
// href: `/org/${org.id}/category`
// });
ctx.response.links.add({
rel: 'invalidates',
href: `/person/${entry.project.id}/entry`
});


}

Expand Down
4 changes: 2 additions & 2 deletions src/entry/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ export async function update(entry: Entry): Promise<void> {

}

export async function deleteEntry(entry: Entry, project: Project): Promise<void>{
export async function deleteEntry(entry: Entry): Promise<void>{
await knex('entries')
.where({project_id: project.id})
.where({project_id: entry.project.id})
.where({id: entry.id})
.del();
}
Expand Down

0 comments on commit 0e92e48

Please sign in to comment.