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

feat: listings management draft and publish validation backend & frontend #1850

Merged
merged 38 commits into from
Oct 4, 2021

Conversation

emilyjablonski
Copy link
Collaborator

@emilyjablonski emilyjablonski commented Sep 17, 2021

Pull Request Template

Issue

Addresses #1543 #1541 #1811 #1542

  • This change addresses the issue in full
  • This change addresses only certain aspects of the issue
  • This change is a dependency for another issue
  • This change has a dependency from another issue

Description

Adds the backend and frontend pieces for validations on listings management on both draft and publish. I also refactored a little how we are submitting data so we don't need to keep track of status or submitData in state.

For draft, required fields are:

  • Listing name
  • Jurisdiction (only shows if user has more than one, otherwise defaults)

For publish, required fields are:

  • Listing name
  • Jurisdiction
  • Developer
  • Image
  • Is there a digital application?
  • Is there a paper application?
  • Is this a referral opportunity?
  • Building Address (specifically street, city, state, zipCode)
  • Units - At least one unit
  • Deposit Min (has a default)
  • Deposit Max (has a default)
  • Rental Assistance (has a default)
  • How is the application review order determined? (has a default)
  • Is the waitlist open?
  • Leasing agent email
  • Leasing agent name
  • Leasing agent phone

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Prototype/POC (not to merge)
  • This change is a refactor/address technical debt
  • This change requires a documentation update
  • This change requires a SQL Script

How Can This Be Tested/Reviewed?

Create a new listing from scratch and without filling anything out and try to save as draft and publish and the frontend validations should kick in. Also try to edit an existing listing.

The one kinda wonky frontend validation is buildingAddress, because if you send nothing we get a generic "buildingAddress" error but if at least one field is filled out we get errors specific to the four required fields. Should show as individual errors tho.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have reviewed the changes in a desktop view
  • I have reviewed the changes in a mobile view
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have assigned reviewers
  • I have updated the changelog to include a description of my changes
  • I have run yarn generate:client if I made backend changes

@emilyjablonski emilyjablonski added the wip This PR is not ready for review, do not review it's a “Work In Progress” label Sep 17, 2021
@emilyjablonski emilyjablonski changed the title feat: listings management publish validation frontend feat: listings management draft and publish validation frontend Sep 18, 2021
@emilyjablonski emilyjablonski changed the base branch from feature/listing_publish_validation to dev September 20, 2021 21:39
@netlify
Copy link

netlify bot commented Sep 21, 2021

✔️ Deploy Preview for dev-bloom ready!

🔨 Explore the source changes: 45c3aa3

🔍 Inspect the deploy log: https://app.netlify.com/sites/dev-bloom/deploys/6158d072d540b70008e5cf3f

😎 Browse the preview: https://deploy-preview-1850--dev-bloom.netlify.app

@netlify
Copy link

netlify bot commented Sep 21, 2021

✔️ Deploy Preview for dev-storybook-bloom ready!

🔨 Explore the source changes: 45c3aa3

🔍 Inspect the deploy log: https://app.netlify.com/sites/dev-storybook-bloom/deploys/6158d072ead1500008dedc6d

😎 Browse the preview: https://deploy-preview-1850--dev-storybook-bloom.netlify.app

@netlify
Copy link

netlify bot commented Sep 21, 2021

✔️ Deploy Preview for dev-partners-bloom ready!

🔨 Explore the source changes: 45c3aa3

🔍 Inspect the deploy log: https://app.netlify.com/sites/dev-partners-bloom/deploys/6158d072da94050007060a2f

😎 Browse the preview: https://deploy-preview-1850--dev-partners-bloom.netlify.app

@emilyjablonski emilyjablonski changed the title feat: listings management draft and publish validation frontend feat: listings management draft and publish validation backend & frontend Sep 21, 2021
@emilyjablonski emilyjablonski added ready for review and removed wip This PR is not ready for review, do not review it's a “Work In Progress” labels Sep 21, 2021
@emilyjablonski emilyjablonski force-pushed the feat/publish_validation_frontend branch 2 times, most recently from dcb229a to 4a241f8 Compare September 22, 2021 15:31
@dominikx96 dominikx96 self-requested a review September 23, 2021 13:05
Copy link
Collaborator

@dominikx96 dominikx96 left a comment

Choose a reason for hiding this comment

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

@emilyjablonski

1. I think the error message should be different than generic:
#1542
"Please resolve any errors before publishing your listing."

2. Noticed a problem when I trigger errors and then fill the form with correct values:
See video: https://share.getcloudapp.com/NQuYXn1R
So the correct jurisdiction value has been removed and I still see an error.

3. When I put a user agent phone, then the phone should be validated using phone regex
Currently, I am able to put a phone with the incorrect format: https://share.getcloudapp.com/o0uP01R0

4. "Is the waitlist open?" field is not validated
https://share.getcloudapp.com/d5uR5QgB

5. Lottery fields
When I choose the lottery option, I suppose date fields also should be required (?)
https://share.getcloudapp.com/nOuvO476

6. Add unit
When I tried to add a new unit type (I've just selected unit type "studio" from the select field, other fields were empty), I've noticed the error: https://share.getcloudapp.com/wbubgOgw

7. Edit and delete unit don't work
Nothing happened after click
https://share.getcloudapp.com/E0ujvN1B

8. Building address validation
https://share.getcloudapp.com/NQuYXn84

When I filled only street address, other errors have gone:
https://share.getcloudapp.com/9ZuQp65e

9. Application types validation doesn't work:
https://share.getcloudapp.com/bLuqL21x

@emilyjablonski emilyjablonski added wip This PR is not ready for review, do not review it's a “Work In Progress” and removed ready for review labels Sep 23, 2021
@emilyjablonski
Copy link
Collaborator Author

emilyjablonski commented Sep 23, 2021

@dominikx96

Everything is fixed except for 6 which is waiting on a product update / followup ticket :)

  1. Good catch, updated
  2. This was an existing problem with the Jurisdiction select before this PR. It would occasionally just….not select? But I fixed it by removing the Controller.
  3. We actually don’t have any existing backend validations for phone number, elsewhere in our apps where we validate phone number fields we must be validating on the frontend. I added a backend phone number validator for this field though so it works now!
  4. Oops! Missed this because we assign it “false” on submit once all other fields are validated. I removed this default value so we can tell if they actually clicked the field yes/no.
  5. They shouldn’t be, we actually made a fix a few weeks ago so that they wouldn’t be required because apparently often leasing agents won’t know the lottery date yet on listing publish, but thanks for asking!
  6. My bad, didn’t expect anything in units to be validating yet, and I always submitted units with an AMI chart! You can now submit a unit without an AMI chart. Unclear if AMI on every unit should be required on publish of a listing. I’m still waiting to hear back from Kathy/Jesse on any info concerning what should be required in the unit form, and I think ideally that’s handled in a separate ticket since we’ll be doing a sort of pre-publish backend call to validate.
  7. Similar to 6. Edit and delete now work.
  8. The screenshot was expected behavior and I mentioned this a little in the PR description, but I agree w your feedback that it’s weird and I refactored it a little so now I think it probably meets what you would expect.
  9. Same as 4. Fixed!

Ty again for this ✨ amazing ✨ review! :D

@emilyjablonski emilyjablonski added ready for review and removed wip This PR is not ready for review, do not review it's a “Work In Progress” labels Sep 24, 2021
@dominikx96 dominikx96 self-requested a review September 27, 2021 14:35
Copy link
Collaborator

@dominikx96 dominikx96 left a comment

Choose a reason for hiding this comment

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

@emilyjablonski

  1. I still have a problem with the phone number, it's validated, but then I trigger an error (e.g. phone field is empty) - then fill it correctly, I'm still facing the error:
    https://share.getcloudapp.com/v1u07GWO

  2. When I'm trying to save as a draft, I see building address errors (I think they shouldn't be required in the draft state):
    https://share.getcloudapp.com/L1urAldZ

  3. When I'm editing a listing and triggering publish action (with some issues, empty fields), then listing unit actions (edit, delete) don't work.

Otherwise looks good to me, it's a large amount of great work, @emilyjablonski ! 💪

@emilyjablonski
Copy link
Collaborator Author

@dominikx96 Thank you again 🙏

  1. I can't repro this :( Will slack you
  2. Fixed! Introduced by latest rebase, hadn't seen that
  3. Discovered there's even more issues beyond that with units while testing this. The units will straight up just disappear sometimes while editing. Testing / fixing this now.

@emilyjablonski
Copy link
Collaborator Author

emilyjablonski commented Sep 27, 2021

Okay the unit issue is fixed! And as far as the phone number issue, the number 444-444-4444 fails (and it does too in the validator's official demo so it is supposed to http://libphonenumber.appspot.com/phonenumberparser?number=4444444444&country=US) and I believe this is because it is validating that the phone number is a valid US phone number down the area code, and 444 isn't a valid US area code. If I put in for example my phone number, it works. I assume we want to restrict to US phone numbers?

@dominikx96
Copy link
Collaborator

@emilyjablonski you're right, I tried with the US number and it works better than I expected! :D

I noticed one thing, building address probably should be optional for draft, but I still see errors:
https://share.getcloudapp.com/6quYgoZ7

@emilyjablonski
Copy link
Collaborator Author

@dominikx96 I can't repro that, will slack you

@seanmalbert seanmalbert self-assigned this Sep 28, 2021
@dominikx96
Copy link
Collaborator

@dominikx96 I can't repro that will slack you

As we discussed at the meeting, it was my fault, I forgot to fetch changes, LGTM! 👍

Copy link
Collaborator

@seanmalbert seanmalbert left a comment

Choose a reason for hiding this comment

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

@emilyjablonski ,
Took an initial pass and added some comments. Going to finish review in the morning.

backend/core/src/shared/url-helper.ts Outdated Show resolved Hide resolved
sites/partners/lib/helpers.ts Show resolved Hide resolved
Comment on lines 23 to 25
? /https?:\/\//.exec(listingFormPhoto.fileId)
? listingFormPhoto.fileId
: cloudinaryUrlFromId(listingFormPhoto.fileId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this was already here, but regex.test might be better used here instead of exec.

Copy link
Collaborator

@jaredcwhite jaredcwhite left a comment

Choose a reason for hiding this comment

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

Nice work @emilyjablonski! I think my main comment would be that if src/listings/PaperListingForm/index.tsx is getting changed to this degree, it'd be a great opportunity to refactor. The file's getting pretty large (~800 lines) and feels like it needs more of an architecture. What do you think?

@emilyjablonski
Copy link
Collaborator Author

@jaredcwhite I think that's an excellent idea that given the already large size and complexity of this PR should be handled in a separate issue

Copy link
Collaborator

@seanmalbert seanmalbert left a comment

Choose a reason for hiding this comment

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

Looks good @emilyjablonski . I created a new issue off of @jaredcwhite's comment on refactoring the main listing form.

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.

None yet

6 participants