-
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 time Entry Modal and Update Timesheet Status based on API…
… response (#3365) * feat: feat: add AddTimeEntyModal component for managing task entries with time and project association * feat: update timesheet status based on API response * feat: display total for pending tasks * fix:coderabbitai * fix:coderabbitai * fix:coderabbitai * fix:coderabbitai
- Loading branch information
1 parent
8f6352d
commit 528362c
Showing
16 changed files
with
476 additions
and
59 deletions.
There are no files selected for viewing
281 changes: 250 additions & 31 deletions
281
apps/web/app/[locale]/timesheet/[memberId]/components/AddTaskModal.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { ID } from "@/app/interfaces"; | ||
import { authenticatedGuard } from "@/app/services/server/guards/authenticated-guard-app"; | ||
import { updateStatusTimesheetRequest } from "@/app/services/server/requests"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function PUT(req: Request) { | ||
const res = new NextResponse(); | ||
const { | ||
$res, | ||
user, | ||
tenantId, | ||
organizationId, | ||
access_token | ||
} = await authenticatedGuard(req, res); | ||
if (!user) return $res('Unauthorized'); | ||
|
||
try { | ||
const { searchParams } = new URL(req.url); | ||
|
||
const rawIds = searchParams.get('ids'); | ||
const status = searchParams.get('status'); | ||
|
||
if (!rawIds || !status) { | ||
return $res({ | ||
success: false, | ||
message: 'Missing required parameters' | ||
}); | ||
} | ||
let ids: ID[]; | ||
try { | ||
ids = JSON.parse(rawIds); | ||
if (!Array.isArray(ids) || !ids.length) { | ||
throw new Error('Invalid ids format'); | ||
} | ||
} catch (error) { | ||
return $res({ | ||
success: false, | ||
message: 'Invalid ids format' | ||
}); | ||
} | ||
const validStatuses = ['pending', 'approved', 'rejected']; | ||
if (!validStatuses.includes(status)) { | ||
return $res({ | ||
success: false, | ||
message: 'Invalid status value' | ||
}); | ||
} | ||
const { data } = await updateStatusTimesheetRequest( | ||
{ | ||
ids, | ||
organizationId, | ||
status, | ||
tenantId | ||
}, | ||
access_token | ||
); | ||
|
||
return $res({ | ||
success: true, | ||
data | ||
}); | ||
} catch (error) { | ||
console.error('Error updating timesheet status:', error); | ||
return $res({ | ||
success: false, | ||
message: 'Failed to update timesheet status' | ||
}); | ||
} | ||
} |
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
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.