Skip to content

LF-4672 (3) - rtk locations upgrade remove duplication#4099

Open
Duncan-Brain wants to merge 45 commits intortk-upgrade/locations-rebasefrom
rtk-upgrade/locations-2-location-details
Open

LF-4672 (3) - rtk locations upgrade remove duplication#4099
Duncan-Brain wants to merge 45 commits intortk-upgrade/locations-rebasefrom
rtk-upgrade/locations-2-location-details

Conversation

@Duncan-Brain
Copy link
Copy Markdown
Collaborator

@Duncan-Brain Duncan-Brain commented Mar 24, 2026

Description

Removes ~7000 LOC ! Think of how easy it will be to make a new location now.

Removes location type specific elements for:

  • slices
  • edit container
  • post container
  • saga
  • "pure" components
  • routes
  • stories

Adds

  • snackbar usage for success and fail for location types
  • a non-zero amount config objects, which would be nice to improve upon eventually but this is good enough for now

Review notes:

  • added inline comments of interest for small changes
  • everything else is abstracted form of what was there
  • some configs objects I think could be removed with smarter data handling but I kept it as it was for now

Future looking

  • update to typescript
  • unify and reduces special types and enums and functions locationEnum, barnEnum ... , type Location = {[key]: any}
  • reduce config objects

Jira link: LF-4672

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?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

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

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 ordered translation keys alphabetically (optional: run pnpm i18n to help with this)
  • I have added the GNU General Public License to all new files

@Duncan-Brain Duncan-Brain self-assigned this Mar 24, 2026
@Duncan-Brain Duncan-Brain changed the title Rtk upgrade/locations 2 location details LF-4672 - rtk locations upgrade (3) remove duplication Mar 24, 2026
@Duncan-Brain Duncan-Brain changed the title LF-4672 - rtk locations upgrade (3) remove duplication LF-4672 (3) - rtk locations upgrade remove duplication Mar 25, 2026
loading: false,
loaded: false,
},
irrigationTaskReducer: {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Missing some reducers...

"MAP": {
"FAIL_PATCH": "Failed to update",
"FAIL_POST": "Failed to add new",
"FAIL_DELETE": "Failed to retire",
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Using snackbars instead of WarningBox

@@ -0,0 +1,678 @@
/*
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This could probably be reduced as well.. specifically RadioGroup

@@ -0,0 +1,45 @@
import { useTranslation } from 'react-i18next';
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not a new file the git mv did not work on this one for some reason...

<PageTitle
title={title}
onCancel={isCreateLocationPage && onCancel}
onCancel={isCreateLocationPage ? onCancel : undefined}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Typings didn't like the boolean here for a function.

...pick(data, locationProperties),
};
};
const getBarnFromLocationObject = (location) => {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

no handled by clean() and flatten() in the location api hook.

return result;
};

const propertiesToPick = {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These utilities are moved from the aggregation of the slices.

const AddNewCrop = React.lazy(() => import('../containers/AddNewCrop'));
const PlantingLocation = React.lazy(
() => import('../containers/Crop/AddManagementPlan/PlantingLocation'),
const PlantingLocation = React.lazy(() =>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

lol prettier love this.. some real edits in this file.

@@ -0,0 +1,344 @@
/*
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This story isn't the best because it is intermittently laggy and slow sometimes freezes. I think it is because the service worker is weird when working with the readiness for offline reducer.

It is quite broken on integration already because it needs adding the store to that. This seems to be one of the few that isn't very pure.

So.. there room for improvement here but its a story so at least it is fixed and working.

@@ -0,0 +1,177 @@
/*
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not explicitly all necessary to make the story work but I didn't care to test the limits of what is all needed after running into some undefined errors

@Duncan-Brain Duncan-Brain marked this pull request as ready for review March 25, 2026 23:03
@Duncan-Brain Duncan-Brain requested review from a team as code owners March 25, 2026 23:03
@Duncan-Brain Duncan-Brain requested review from SayakaOno and removed request for a team March 25, 2026 23:03
@Duncan-Brain
Copy link
Copy Markdown
Collaborator Author

Waiting for others to be reviewed edited before merging and fixing conflict. It doesn't affect this pr

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.

1 participant