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

LF-4309 Complete form breaks when not completed fast enough allowing page to time out or something #3324

Conversation

kathyavini
Copy link
Collaborator

@kathyavini kathyavini commented Jul 22, 2024

Description

This PR removes the passing of the purpose and method keys from the saga to the task utility functions in favour of using { shouldUnregister: true } on the inputs that need to be nulled when their method_id / purpose_id is not selected

Notes:

  • Removing the calls to api.endpoints.getSoilAmendmentPurposes.select()(state), fixes the timeout that makes the form unsubmittable after the api cache expires
  • <Unit /> component needed a little bit of adjustment to accept shouldUnregister: true
  • A cleanup before insert on the model was still needed on PATCH, but I feel this is an appropriate place for it because
    • Nothing is wrong with the PATCH request, it is correctly only giving the updated data, which means it doesn't overwrite any old data in the other fields (e.g. other_application_method), potentially triggering the check constraint
    • There is no longer any ambiguity about what data is correct
    • It is logical + readable on the model where it is defined specifically on PATCH (update)
  • the code changes (not sure if it's merely shouldUnregister or the task flow revert as well) resolves the other persistence bugs we saw; I will re-test this momentarily then indicate their tickets below as well
    • Update: needed to fix some logic and now those are resolved as well

Jira link: https://lite-farm.atlassian.net/browse/LF-4309

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)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Checked on the soil_amendment_task product table and the soil_amendment_task_products_purpose_relationship table of db.

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • 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
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have added "MISSING" for all new language tags to languages I don't speak
  • I have added the GNU General Public License to all new files

@kathyavini kathyavini added the bug Something isn't working label Jul 22, 2024
@kathyavini kathyavini self-assigned this Jul 22, 2024
@kathyavini kathyavini requested review from a team as code owners July 22, 2024 20:20
@kathyavini kathyavini requested review from Duncan-Brain and SayakaOno and removed request for a team July 22, 2024 20:20
@kathyavini kathyavini marked this pull request as draft July 22, 2024 20:35
@kathyavini kathyavini marked this pull request as ready for review July 22, 2024 21:02
Copy link
Collaborator

@SayakaOno SayakaOno left a comment

Choose a reason for hiding this comment

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

soil_amendment_task_products: DBSoilAmendmentTaskProduct[];
[key: string]: any;
};

type FormTask = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know if I would have undid the updated naming since soil_amendment_task has meaning and does not have property of soil_amendment_task_products.

Copy link
Collaborator

@Duncan-Brain Duncan-Brain left a comment

Choose a reason for hiding this comment

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

Always love a net removal of code! ❤️

I like what you are saying for PATCH being able to make the decision that a POST could not 👍 . I think we will need to add to this for weight and volume too. I thought I saw a similar bug there.

@Duncan-Brain Duncan-Brain merged commit db2bf63 into patch/3.6.5 Jul 23, 2024
@kathyavini kathyavini mentioned this pull request Sep 5, 2024
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants