Skip to content

Conversation

@Payel-Manna
Copy link
Contributor

Feature Pull Request Template ✨

We welcome all contributions to this project! 🚀


Related Issue 📎


Proposed Changes 📝

  • Added StepValidateModal.jsx component to show a modal with missing fields.
  • Updated Steps.jsx to validate each step before proceeding.
  • Stored form data in session storage on successful validation.

What File You Changed

  • src/components/Templates/admission/StepValidateModal.jsx — Modal component for step validation.
  • src/components/Templates/admission/Steps.jsx — Added step validation logic and integrated modal.

Additional Info 📌

  • This feature prevents users from moving to the next step with missing required fields.
  • Enhances user experience by providing clear feedback on incomplete form data.

Feature Description 🌟

  • What is the new feature?
    A validation modal that shows missing required fields for each step of the admission form.

  • How does it work?
    Each step is checked for required inputs; if any field is missing, the modal opens listing the missing fields. Image upload on the last step is also validated.

  • Why is this feature needed?
    Prevents incomplete form submissions and improves clarity for users filling out multi-step forms.


Implementation Details 🔧

  • StepValidateModal.jsx — Functional component with isOpen, onClose, title, message, and missingFields props.
  • Steps.jsxvalidateStep() checks required fields per step, sets missing fields, and opens modal if validation fails.
  • Form data saved in session storage after successful validation.

Checklist ✅

  • Testing: All steps validated successfully before submission.
  • Documentation: Component behavior documented in code comments.
  • Read the Rules and Guidelines: Followed project style and commit guidelines.

@vercel
Copy link

vercel bot commented Oct 10, 2025

@Payel-Manna is attempting to deploy a commit to the code-with-abhishek-kumar's projects Team on Vercel.

A member of the Team first needs to authorize it.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Payel-Manna, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a critical feature for the multi-step admission form: step-by-step validation. It ensures that users complete all necessary fields before advancing to the next stage, thereby preventing incomplete submissions. A dedicated modal clearly communicates any missing information, and form progress is securely saved to session storage, enhancing both data integrity and user experience.

Highlights

  • New Component: A new StepValidateModal.jsx component has been added to display a modal listing missing required fields.
  • Step Validation Logic: The Steps.jsx component now includes robust validation logic for each step of the admission form, preventing users from proceeding with incomplete data.
  • Session Storage Integration: Form data is now stored in session storage upon successful validation of each step, ensuring data persistence across steps.
  • Enhanced User Experience: The system provides clear feedback to users by showing a modal with specific missing fields, improving the form-filling experience.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a validation modal for a multi-step admission form. The changes include a new StepValidateModal component and updated logic in the Steps component to validate form fields before proceeding to the next step. While the feature is a great addition for user experience, I've found a critical issue in the validation logic within Steps.jsx. The current implementation validates incorrect fields for some steps and completely omits validation for many required fields and entire steps. I've provided a detailed comment and a code suggestion to refactor the validation logic to be more correct, complete, and maintainable. The rest of the changes look good.

Comment on lines 145 to 177
const validateStep = () => {
const requiredFields = [];

const missing = [];
if (activeStep === 0) {
requiredFields.push('firstName', 'lastName', 'email');
} else if (activeStep === 1) {
requiredFields.push('fatherName', 'motherName');
} else if (activeStep === 4 && !image) {
setIsModalOpen(true);
setMissingFields(['Profile Picture']);
return false;
}
for (let field of requiredFields) {
if (!formData[field] || formData[field].trim() === '') {
const formatted = field
.replace(/([A-Z])/g, ' $1')
.replace(/^./, str => str.toUpperCase());
missing.push(formatted);
}
}

if (missing.length > 0) {
setMissingFields(missing);
setIsModalOpen(true);
return false;
}

sessionStorage.setItem(
'admissionFormData',
JSON.stringify(formData),
);
return true;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

There are several critical issues with the step validation logic:

  1. Incorrect Field Validation: The validation for activeStep === 1 checks for fatherName and motherName, but these fields belong to the YourInfo component, which is displayed at activeStep === 0. The fields for the ParentsInfo component (e.g., Gname), which are displayed at activeStep === 1, are not being validated.

  2. Incomplete Validation: Many fields marked as required in the form components are not being validated. For example, in YourInfo.jsx (activeStep === 0), fields like AadharCardNumber, contactNumber, dateOfBirth, and the entire address are required but are missing from the validation check.

  3. Missing Step Validation: There is no validation for steps 2 (AreyouHuman), 3 (Grades), and 4 (UniversityInfo), except for the profile picture on the last step.

  4. Potential Runtime Error: The check formData[field].trim() === '' can cause a runtime error if formData[field] is a number (e.g., from an input with type='number'), as numbers do not have a .trim() method.

This can lead to incomplete data being saved and passed to the next step. To make the validation more robust and maintainable, I recommend defining the required fields for each step in a configuration object. This will make the validation logic cleaner and easier to update.

   const validateStep = () => {
     const stepValidationConfig = {
       0: [
         'firstName',
         'lastName',
         'email',
         'fatherName',
         'motherName',
         'AadharCardNumber',
         'contactNumber',
         'dateOfBirth',
         'gender',
         'nationality',
         'street',
         'city',
         'state',
         'pinCode',
       ],
       1: ['Gname', 'Grelation', 'GcontactNumber'],
       // Step 2 (Are you Human?) needs custom validation if required.
       3: ['tenthBoard', 'tenthGrade', 'twelfthMarks', 'twelfthGrade'],
       4: ['university', 'courseName', 'mode'],
     };

     const formatFieldName = field =>
       field
         .replace(/([A-Z])/g, ' $1')
         .replace(/^./, str => str.toUpperCase());

     const missing = [];
     const requiredFields = stepValidationConfig[activeStep] || [];

     for (const field of requiredFields) {
       if (!formData[field] || String(formData[field]).trim() === '') {
         missing.push(formatFieldName(field));
       }
     }

     // Special case for image upload on the last step
     if (activeStep === 4 && !image) {
       missing.push('Profile Picture');
     }

     if (missing.length > 0) {
       setMissingFields(missing);
       setIsModalOpen(true);
       return false;
     }

     sessionStorage.setItem(
       'admissionFormData',
       JSON.stringify(formData),
     );
     return true;
   };

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Payel-Manna, This gemini suggest show all the filed to be validated in the model.

Your implementation:

image

With Gemini Suggestion:

image

However, we won't need to show validation error like this in the modal.

@Payel-Manna
Copy link
Contributor Author

Hi @sanjaysah101 and @abhishek-nexgen-dev 👋

This PR implements the step validation modal for the admission form as per #232.

  • Required fields are validated step by step.
  • Missing fields trigger a modal showing the fields that need attention.
  • Form data is temporarily saved in session storage.

Please review when you get a chance. 🚀

@vercel
Copy link

vercel bot commented Oct 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
ciitm-frontend Ready Ready Preview Comment Oct 10, 2025 6:20am

@Payel-Manna
Copy link
Contributor Author

Thank you for the automated review @gemini-code-assist 🙌
I’ll wait for feedback from the maintainers (@sanjaysah101 @abhishek-nexgen-dev) before making any further changes.

@gemini-code-assist
Copy link
Contributor

You're welcome, @Payel-Manna! I'll be here if you or the maintainers have any further questions or need additional review assistance. Looking forward to seeing this feature merged! 😊

@Payel-Manna
Copy link
Contributor Author

Thank you @gemini-code-assist for the detailed review and feedback! 🙌
I’ll wait for the maintainers’ review (@sanjaysah101 @abhishek-nexgen-dev) before making any further changes.
Looking forward to your feedback. 🚀

@gemini-code-assist
Copy link
Contributor

You're most welcome, @Payel-Manna! I'm glad the summary was helpful. I'm currently finalizing the detailed review comments and will post them shortly. Thank you for your patience! 😊

@abhishek-nexgen-dev
Copy link
Member

@sanjaysah101 can you review this pr

@Payel-Manna
Copy link
Contributor Author

Hi @sanjaysah101 and @abhishek-nexgen-dev 👋

Just following up on this PR for the step validation modal for the admission form.
Would appreciate it if you could take a look when you get a chance. 🚀

Thanks! 🙏

@sanjaysah101 sanjaysah101 self-assigned this Oct 11, 2025
@sanjaysah101
Copy link
Collaborator

Hi @Payel-Manna, I have reviewed this MR and found few major bugs:

  • After closing the modal, value in the input fields get cleared because of page refresh.
  • Lets show validation error just bellow the input fields (already did). Only show these errors when user click on next button.
Bug.in.admission.page.mp4

@sanjaysah101
Copy link
Collaborator

@abhishek-nexgen-dev

  • Add validation for the input fileds as same as same as define in backend.

@sanjaysah101
Copy link
Collaborator

Hi @Payel-Manna, I have update the task description. Kindly check it

@Payel-Manna
Copy link
Contributor Author

OK I will be checking this.
Thankyou @sanjaysah101 for the reviev.

@Payel-Manna
Copy link
Contributor Author

Hi @sanjaysah101
I’ve updated the PR as per your review:

Fixed the issue where input values were cleared after closing the modal (no more page refresh).

Validation errors are now shown below the input fields, visible only when clicking “Next”.

Regarding backend validation, I couldn’t find the exact schema file (e.g., AdmissionSchema.Joi.js) in the backend repo.
If you could confirm or share the validation structure, I’ll align the frontend validation rules accordingly. 🙏

Please review the current changes and let me know if any further adjustments are needed. 🚀

@sanjaysah101
Copy link
Collaborator

Hi @sanjaysah101 I’ve updated the PR as per your review:

Fixed the issue where input values were cleared after closing the modal (no more page refresh).

Validation errors are now shown below the input fields, visible only when clicking “Next”.

Regarding backend validation, I couldn’t find the exact schema file (e.g., AdmissionSchema.Joi.js) in the backend repo. If you could confirm or share the validation structure, I’ll align the frontend validation rules accordingly. 🙏

Please review the current changes and let me know if any further adjustments are needed. 🚀

Still the UI is broken:

image

Regarding backend validation, @abhishek-nexgen-dev can assist you on this

@Payel-Manna
Copy link
Contributor Author

Hi @sanjaysah101, thanks for the review!

Regarding backend validation, @abhishek-nexgen-dev could you confirm the schema file or share the validation rules? I want to make sure frontend validation aligns perfectl

@Payel-Manna
Copy link
Contributor Author

Ok!

@abhishek-nexgen-dev
Copy link
Member

Hi @Payel-Manna, I have update the task description. Kindly check it

@sanjaysah101 i already added validation in backend

@abhishek-nexgen-dev
Copy link
Member

Hi @Payel-Manna, I have reviewed this MR and found few major bugs:

  • After closing the modal, value in the input fields get cleared because of page refresh.
  • Lets show validation error just bellow the input fields (already did). Only show these errors when user click on next button.
Bug.in.admission.page.mp4

@sanjaysah101 i think there is some issue in frontend the backend work properly

@sanjaysah101
Copy link
Collaborator

Hi @Payel-Manna, I have update the task description. Kindly check it

@sanjaysah101 i already added validation in backend

However, we should add the validation in client side too for better user experience (UX)

@abhishek-nexgen-dev
Copy link
Member

@Payel-Manna What's the current status payel

@Payel-Manna
Copy link
Contributor Author

Sorry for the delay! I have my end-term exam today, so I’ll be updating the PR by EOD.

@abhishek-nexgen-dev
Copy link
Member

Sorry for the delay! I have my end-term exam today, so I’ll be updating the PR by EOD.

@Payel-Manna try to do this earlier

@abhishek-nexgen-dev
Copy link
Member

@Payel-Manna are you facing any issue

@Payel-Manna
Copy link
Contributor Author

I’m really sorry for the delay, @abhishek-nexgen-dev. I’ve been caught up with my end-term exams and facing some Wi-Fi issues, so I couldn’t find enough time to work on the fixes.
I’ll make sure to push the updated changes by EOD today. Thanks a lot for your patience and understanding 🙏

@Payel-Manna
Copy link
Contributor Author

Hi @abhishek-nexgen-dev @sanjaysah101,
Fixed the issue where input values cleared after closing the modal.
Validation errors now appear below inputs only after clicking Next.
Please check if this works as expected.

@abhishek-nexgen-dev
Copy link
Member

@Payel-Manna okay

@Payel-Manna
Copy link
Contributor Author

Hi @abhishek-nexgen-dev @sanjaysah101,
Just checking in — were you able to review the changes?

@abhishek-nexgen-dev
Copy link
Member

@Payel-Manna ok

@abhishek-nexgen-dev
Copy link
Member

@Payel-Manna can you please attech a video

@abhishek-nexgen-dev abhishek-nexgen-dev changed the base branch from master to dev October 19, 2025 15:07
@abhishek-nexgen-dev abhishek-nexgen-dev merged commit 258f2fb into NexGenStudioDev:dev Oct 19, 2025
0 of 2 checks passed
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.

3 participants