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

#190/show required fields lables on add item page by default #213

Conversation

AlexVOiceover
Copy link

@AlexVOiceover AlexVOiceover commented May 20, 2024

Description

Closes #190
The add item form now shows correctly the fields that need to be filled even when an image wasn't attached yet. The previous behaviour was forcing the user to have an image uploaded.

Files changed

app/(dashboard)/add-item/page.tsx
Makes the comprobation of the image being uploaded

components/form/UploadImageInput.tsx
Will pass as a prop a flag to specify if the image was uploaded (onImageUpload)

app/(dashboard)/add-item/pageTypes.ts
This file was created to extend the type PartialItem to include the boolean 'imageUploaded'

UI changes

image

Tests

Manual tested. Try to create item without image and without some required fields

Copy link

netlify bot commented May 20, 2024

👷 Deploy request for cool-creponne-3e1272 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 7e40e6b

.eslintrc.json Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jun 8, 2024

🤖 meep morp! This PR is now marked as stale because there has been no activity for a while. Please guarantee this is still a relevant PR.

@github-actions github-actions bot added the Stale This issue has been inactive and will be moved to the Backlog if not resolved soon label Jun 8, 2024
@github-actions github-actions bot removed the Stale This issue has been inactive and will be moved to the Backlog if not resolved soon label Jun 11, 2024
Copy link

🤖 meep morp! This PR is now marked as stale because there has been no activity for a while. Please guarantee this is still a relevant PR.

@github-actions github-actions bot added the Stale This issue has been inactive and will be moved to the Backlog if not resolved soon label Jun 25, 2024
.eslintrc.json Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
nichgalzin
nichgalzin previously approved these changes Jul 5, 2024
@nichgalzin
Copy link
Contributor

Hey @AlexVOiceover,
Can you please resolve the issues on on PR with the example .env file. Please and thanks. Then we can merge this PR.

@AlexVOiceover
Copy link
Author

Hi @nichgalzin and team,

I have resolved the conflicts by merging the latest changes from the dev branch into my feature branch and deleting the .env.example file as per the upstream changes. The PR should now be ready for merging.

Thank you!

Copy link
Contributor

@camelPhonso camelPhonso left a comment

Choose a reason for hiding this comment

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

Thanks for the update Alex.

Asked to remove an unnecessary file here.

Copy link
Contributor

Choose a reason for hiding this comment

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

We no longer use Playwright on the code base so I presume this is an old report that got staged. Can you remove this from the PR please?

@AlexVOiceover
Copy link
Author

The comprobation of the mandatory fields on the form and the presence of the image cannot be done in separate react components, that way it will only perform the "outer" component once that the nested one was resolved.
All comprobations were moved to the parent (AddNewItemForm.tsx).
For a similar reason it was needed to add the function handleFormSubmit as some kind of middleware. It will update isSubmitAttempted before trying to submit, so all the form mandatory fields comprobations and the error messages for the checkboxes and the image will be done at once.
Without this function, submitHandler will check the mandatory fields, and only after everything is right will carry on with checking the image.

setError and isRequired were left on the props for compatibility with other potential components that use this functionality, these should be udpated.

@camelPhonso
Copy link
Contributor

Closing this PR as the issue has been handed over to another contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale This issue has been inactive and will be moved to the Backlog if not resolved soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show required fields lables on add item page by default
4 participants