chore: sync test → main (Privy auth for task delete)#1733
Conversation
* feat: integrate Privy authentication for task deletion
- Updated `useDeleteScheduledAction` to include Privy authentication, requiring an access token for task deletion.
- Modified `deleteTask` function to accept an access token and handle API requests accordingly, improving security and error handling.
- Enhanced error messages for better user feedback during deletion failures.
* feat: enhance task deletion error handling and local fallback
- Introduced a constant for the sign-in error message in `useDeleteScheduledAction` for improved consistency.
- Updated error handling in `deleteTask` to check for a "Schedule not found" error and fallback to a local delete endpoint.
- Added a test case to verify the fallback behavior when the scheduler indicates that a task is not found.
* fix: improve error handling in task deletion process
- Enhanced the `deleteTaskFromDatabase` function to throw an error with detailed HTTP status and message when the delete request fails.
- Updated the `deleteTask` function to handle "Schedule not found" errors by attempting a local delete fallback.
- Added test cases to verify the new error handling and fallback behavior for task deletion.
* feat: integrate Privy authentication for task deletion in TaskDetailsDialog and TaskCard
- Added Privy authentication to conditionally render delete buttons in TaskDetailsDialogActionButtons and TaskCard components.
- Updated useDeleteScheduledAction to check for user authentication before allowing task deletion.
- Refactored deleteTask function to improve error handling and ensure proper authentication flow during deletion.
* refactor: simplify TaskDetailsDialogActionButtons by using custom hook
- Replaced inline logic with a custom hook `useTaskDetailsDialogActionButtons` to manage state and actions for task details.
- Removed unnecessary props and improved button disable logic based on editing permissions.
- Streamlined the component structure for better readability and maintainability.
* refactor: enhance TaskDetailsDialogActionButtons and useTaskDetailsDialogActionButtons
- Converted TaskDetailsDialogActionButtons to a functional component with improved prop handling.
- Streamlined the useTaskDetailsDialogActionButtons hook by consolidating error handling and removing unnecessary variables.
- Added a constant for the sign-in error message in useDeleteScheduledAction to improve consistency in error feedback.
- Improved readability and maintainability of both components through structural changes.
* refactor: remove legacy scheduled actions delete route and related fallback logic
- Deleted the scheduled actions delete API route as it is no longer needed.
- Removed associated fallback logic in the deleteTask function that handled "Schedule not found" errors.
- Updated tests to reflect the removal of the fallback behavior for task deletion.
* refactor: update error handling in useDeleteScheduledAction for unauthenticated attempts
- Replaced the sign-in error message constant with a new sentinel for unauthenticated delete attempts.
- Improved error handling to throw the new error message when deletion is attempted without authentication.
- Enhanced logging and user feedback for deletion failures while maintaining existing functionality.
* refactor: consolidate TaskDetailsDialogActionButtons and remove custom hook
- Refactored TaskDetailsDialogActionButtons to directly handle task actions, eliminating the use of the custom hook `useTaskDetailsDialogActionButtons`.
- Improved prop handling and error management for task updates and deletions.
- Streamlined button rendering logic by removing conditional rendering based on authentication, simplifying the component structure.
- Updated the delete action to ensure proper error handling and user feedback during task deletion.
* refactor: update TaskDetailsDialogActionButtons to use Privy authentication and streamline task actions
- Refactored TaskDetailsDialogActionButtons to utilize Privy for authentication, conditionally rendering the delete button based on user authentication status.
- Consolidated task action handlers into a custom hook, improving code organization and readability.
- Enhanced prop handling by importing types directly from the mutation handlers, simplifying the component's interface.
- Updated error handling in useDeleteScheduledAction to throw a specific error for unauthenticated delete attempts, improving clarity in error management.
* refactor: streamline TaskDetailsDialogActionButtons and remove custom hook
- Refactored TaskDetailsDialogActionButtons to directly manage task actions, eliminating the custom hook for improved clarity and maintainability.
- Enhanced prop handling by defining the interface directly within the component, simplifying the structure.
- Updated task action handlers to provide better error handling and user feedback during task updates and deletions.
- Removed legacy code related to Privy authentication, ensuring a more straightforward implementation of task actions.
* revert: drop unrelated cosmetic changes from TaskDetailsDialogActionButtons
The Privy auth integration lives in useDeleteScheduledAction.ts and deleteTask.ts
— this file doesn't need touching. Reverting to test removes formatting noise
(inlined objects/JSX, removed intermediate vars, exported interface) and the
redundant `disabled={isLoading || !canEdit}` (the parent already gates rendering
on canEdit at TaskDetailsDialog.tsx:72).
---------
Co-authored-by: Sweets Sweetman <sweetmantech@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
No issues found across 5 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Modifies task deletion logic, removes a local fallback, and introduces Privy auth dependency. This changes error handling and could affect data integrity if the new API path fails.
Summary
Test plan
DELETE https://test-recoup-api.vercel.app/api/tasksreturns 200 with Privy Bearer auth (results)Summary by cubic
Enforces Privy-authenticated task deletion and removes the legacy local delete route. Deletions now call
/api/taskswith a Bearer token and provide clearer errors.useDeleteScheduledAction: gets an access token from@privy-io/react-authand passes it todeleteTask.deleteTask: sends Authorization Bearer to${getClientApiBaseUrl()}/api/tasks; throws on non-ok responses or when API returnsstatus: "error".app/api/scheduled-actions/delete/route.tsand the local fallback logic.Written for commit 8d57493. Summary will update on new commits.