Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove form from main component. add form to slideone #770

Conversation

John-Paul-Larkin
Copy link
Member

@John-Paul-Larkin John-Paul-Larkin commented Feb 25, 2024

Pull Request details

  • Trying my best (against my natural instincts) to keep the PR small and manageable.

  • This PR modifies the main component by removing the form. I also add a form to slideOne.

  • I have two options for submitting the form, you can see in the video. I think the commented out version is better.

  • Once I have this PR through i will do a few more PRs

    1. Update the other slides in the same manner
    1. create the server actions
    1. Add logic for routing based on the null field status

Associated Screenshots

https://youtu.be/2BrD5Ogfrms

Summary by CodeRabbit

  • Refactor
    • Renamed and restructured types and schemas for handling user details, improving form handling and rendering within the app.

@John-Paul-Larkin John-Paul-Larkin requested a review from a team as a code owner February 25, 2024 22:04
Copy link

vercel bot commented Feb 25, 2024

@John-Paul-Larkin is attempting to deploy a commit to the Codú Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Feb 25, 2024

Walkthrough

The recent update involves renaming and restructuring types and schemas related to user details handling. This change impacts form handling logic and form element rendering within a component named SlideOne, aiming to enhance the codebase's clarity and efficiency in managing user information.

Changes

File Path Change Summary
.../alpha/additional-details/_client.tsx Renamed and restructured types and schemas from AdditionalDetailsSchema and TypeAdditionalDetailsSchema to TypeSlideOneSchema and slideOneSchema. Adjusted form handling logic and updated form element rendering in SlideOne.

🐇✨
In a codebase vast and wide,
A rabbit hops with agile stride.
From AdditionalDetails it parts,
To SlideOne with fresh starts.
Schemas change, the forms align,
In this digital burrow of code and design.
🌟🐾

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fa2c72d and 7928b10.
Files selected for processing (1)
  • app/(app)/alpha/additional-details/_client.tsx (2 hunks)
Additional comments: 3
app/(app)/alpha/additional-details/_client.tsx (3)
  • 7-8: The import statements for TypeSlideOneSchema and slideOneSchema have been updated to reflect the new schema names. This change aligns with the PR objectives of restructuring form handling by introducing a new form to SlideOne.
  • 68-70: The useForm hook has been correctly configured to use the TypeSlideOneSchema type and the slideOneSchema for form validation using Zod through the zodResolver. This ensures that the form data adheres to the expected schema, enhancing data integrity and validation logic.
  • 99-201: The form rendering within SlideOne is well-structured, with clear labeling and input fields for user details. The use of the register function from react-hook-form for each input field ensures that form data is correctly managed and validated against the TypeSlideOneSchema. However, it's important to ensure that all user input is properly sanitized before submission to prevent security vulnerabilities such as XSS attacks.

Comment on lines 73 to 80
const onFormSubmit = async (data: TypeSlideOneSchema) => {
try {
// TODO add server action logic
// await handleFormSlideOneSubmit(data);
toast.success("Saved");
router.push(`?slide=${2}`, { scroll: false });
} catch (error) {
toast.error("An unexpected error occurred.");
Copy link
Contributor

Choose a reason for hiding this comment

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

The onFormSubmit function correctly handles form submission asynchronously, displaying a success message upon completion and redirecting to the next slide. However, there's a TODO comment indicating that server action logic needs to be added. It's important to ensure that this logic is implemented before deploying these changes to production to avoid incomplete form handling.

Would you like assistance in implementing the server action logic for form submission?

Comment on lines 84 to 96
// const onFormSubmit = async (data: TypeSlideOneSchema) => {
// try {
// const isSuccess = await handleFormSlideOneSubmit(data);
// if (isSuccess) {
// toast.success("Saved");
// router.push(`?slide=${2}`, { scroll: false });
// } else {
// toast.error("Error, saving was unsuccessful.");
// }
// } catch (error) {
// toast.error("An unexpected error occurred.");
// }
// };
Copy link
Contributor

Choose a reason for hiding this comment

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

The commented-out alternative form submission logic includes a conditional check for the success of the form submission before proceeding. This approach provides more granular control over the user experience based on the outcome of the form submission. Since the PR description mentions a preference for the currently commented-out option, it's recommended to finalize the decision on which submission logic to use and remove the unused code to maintain code cleanliness.

Consider finalizing the form submission logic based on the preferred user interaction model and removing the unused code to avoid confusion and maintain code cleanliness.

}
};

// const onFormSubmit = async (data: TypeSlideOneSchema) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this comment needed?

I have two options for the onFormSubmit function. Line 73 vs line 84.

const isSuccess = await handleFormSlideOneSubmit(data)
Returns a boolean from the action.

My preference is for the commented out version, but I wanted your opinion on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect! I'll look at it a little later. In meetings for the afternoon.

Copy link
Contributor

Choose a reason for hiding this comment

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

Go with your preference! I think that's good for the moment. 🦾

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7928b10 and 6b62d4a.
Files selected for processing (1)
  • app/(app)/alpha/additional-details/_client.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/(app)/alpha/additional-details/_client.tsx

Copy link
Contributor

@NiallJoeMaher NiallJoeMaher left a comment

Choose a reason for hiding this comment

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

LGTM 🌮

Copy link

vercel bot commented Feb 27, 2024

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

Name Status Preview Comments Updated (UTC)
codu ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2024 3:40pm

@NiallJoeMaher NiallJoeMaher merged commit 17a1079 into codu-code:develop Feb 27, 2024
4 checks passed
@John-Paul-Larkin John-Paul-Larkin deleted the refactor-additional-user-details-form-2 branch March 27, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants