-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat]: Add Delete Task Timesheet function (#3338)
* Add deleteTaskTimesheet function to handle timesheet deletion * fix: coderabbitai * fix: build * feat: make AlertDialogConfirmation fully controllable via external props * fix: coderabbitai * fix: coderabbitai
- Loading branch information
1 parent
aace163
commit 5c1cada
Showing
15 changed files
with
484 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { deleteTaskTimesheetRequest } from '@/app/services/server/requests'; | ||
import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function DELETE(req: Request) { | ||
const res = new NextResponse(); | ||
const body = await req.json(); | ||
const { logIds = [] } = body; | ||
|
||
if (!Array.isArray(logIds) || logIds.length === 0) { | ||
return NextResponse.json( | ||
{ error: 'logIds must be a non-empty array' }, | ||
{ status: 400 } | ||
); | ||
} | ||
|
||
const { $res, user, tenantId, organizationId, access_token, } = await authenticatedGuard(req, res); | ||
if (!user) return $res('Unauthorized'); | ||
try { | ||
const { data } = await deleteTaskTimesheetRequest({ | ||
tenantId, | ||
organizationId, | ||
logIds, | ||
}, access_token); | ||
|
||
if (!data) { | ||
return NextResponse.json( | ||
{ error: 'No data found' }, | ||
{ status: 404 } | ||
); | ||
} | ||
|
||
return NextResponse.json(data); | ||
} catch (error) { | ||
console.error('Error delete timesheet:', error); | ||
return NextResponse.json( | ||
{ error: 'Failed to delete timesheet data' }, | ||
{ status: 500 } | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.