Skip to content

Conversation

sunilsabatp
Copy link
Contributor

@sunilsabatp sunilsabatp commented Mar 27, 2025

Utilize the useApi() hook for api call.
pages covered :

  • /profile/recurrency
  • /profile/register-trees
  • /profile/bulk-codes

Copy link

vercel bot commented Mar 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
planet-webapp-multi-tenancy-setup ✅ Ready (Inspect) Visit Preview Apr 2, 2025 9:31am

Copy link
Contributor

coderabbitai bot commented Mar 27, 2025

Walkthrough

The changes refactor multiple components and pages by replacing legacy authenticated API call methods with new methods from the useApi hook. The modifications remove the previous getAuthenticatedRequest, postAuthenticatedRequest, and getRequest functions, as well as redundant variables like logoutUser and tenantConfig. The API call parameters have been simplified, and new type safety measures have been introduced where applicable.

Changes

Files Change Summary
pages/sites/[slug]/[locale]/profile/bulk-codes/[method]/[id].tsx
pages/sites/[slug]/[locale]/profile/recurrency.tsx
Replaced getAuthenticatedRequest with getApiAuthenticated from useApi; removed logoutUser parameter and streamlined API call parameters.
src/features/user/BulkCodes/components/ProjectSelector.tsx
src/features/user/BulkCodes/forms/IssueCodesForm.tsx
src/features/user/BulkCodes/index.tsx
Removed legacy API functions (getAuthenticatedRequest, postAuthenticatedRequest, getRequest) and the useTenant hook; replaced with getApiAuthenticated, postApiAuthenticated, and getApi from useApi; refined API parameters by eliminating unnecessary fields such as tenant, token, and logout functions.
src/features/user/RegisterTrees/RegisterTreesWidget.tsx
src/features/common/types/map.d.ts
Replaced both getAuthenticatedRequest and postAuthenticatedRequest with getApiAuthenticated and postApiAuthenticated from useApi; added a new type RegisteredTreesApiPayload for submission data and updated the submission payload for improved type safety and clarity; renamed RegisterTreeGeometry to RegisteredTreesGeometry.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI Component
    participant Api as useApi Hook
    participant Server as API Server

    UI->>Api: Invoke getApiAuthenticated/postApiAuthenticated with URL and params
    Api->>Server: Send authenticated API request
    Server-->>Api: Return response
    Api-->>UI: Deliver processed response
Loading

Possibly related PRs

Suggested labels

PR: reviewed-approved

Suggested reviewers

  • sunilsabatp

Poem

I'm a rabbit with hops so neat,
Code paths now light and sweet.
No tangled hooks in my burrow deep,
Just streamlined API calls to keep.
With each clean change I bound and leap,
Celebrating code dreams that never sleep!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5f091c and 6e1d70a.

📒 Files selected for processing (2)
  • src/features/common/types/map.d.ts (1 hunks)
  • src/features/user/RegisterTrees/RegisterTreesWidget.tsx (8 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/features/common/types/map.d.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/features/user/RegisterTrees/RegisterTreesWidget.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: ESLint on Ubuntu

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sunilsabatp sunilsabatp changed the base branch from develop to feature/api March 27, 2025 05:13
Base automatically changed from feature/api to develop April 1, 2025 04:57
Copy link
Collaborator

@mohitb35 mohitb35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunilsabatp Made some minor changes, but this is good to merge

@sunilsabatp sunilsabatp merged commit e07ff26 into develop Apr 2, 2025
5 of 6 checks passed
@sunilsabatp sunilsabatp deleted the feature/use-api-hook2 branch April 2, 2025 09:36
This was referenced Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants