Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
This is better
Browse files Browse the repository at this point in the history
  • Loading branch information
GDamaso committed Aug 15, 2024
1 parent 00a0355 commit 1274b8f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 4 additions & 6 deletions frontend/src/Utils/convertToNMP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@ const convertToNMP = (
sampleDate: field.SoilTest.sampleDate ?? '2024-07-01T00:00:00',
}
: null,
LeafTest: field.HasLeafTest
? {
leafTissueP: field.LeafTest.leafTissueP,
leafTissueK: field.LeafTest.leafTissueK,
}
: null,
LeafTest: {
leafTissueP: field.LeafTest?.leafTissueP ?? 0,
leafTissueK: field.LeafTest?.leafTissueK ?? 0,
},
Crops: newCrops,

HasNutrients: field.Nutrients && field.Nutrients?.nutrientFertilizers?.length >= 0,
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/Utils/getLocalDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ const loadFarmDetails = (): FarmDetailsInterface => {
updatedFarmDetails.FarmRegion = nmpFarmDetails.FarmRegion ?? 0;

fieldsJSON.forEach((field) => {
const updateField: FieldDetailInterface = field;
const updateField: FieldDetailInterface = {
...field,
HasLeafTest:
(field.LeafTest?.leafTissueK >= 0 && field.LeafTest?.leafTissueP >= 0) ?? false,
};
updatedFarmDetails.Fields.push(updateField);
});
updatedFarmDetails.Fields = localDetails.years[0].Fields;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Utils/getLocalFertilizers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const loadFertDetails = (farmDetails: FarmDetailsInterface): FertilizerInterface
const localFerts = getLocalFertilizers();
const updatedFertDetails = [...localFerts];

farmDetails.Fields.forEach((field) => {
field.Nutrients.nutrientFertilizers.forEach((fertilizer) => {
farmDetails.Fields?.forEach((field) => {
field.Nutrients.nutrientFertilizers?.forEach((fertilizer) => {
const normalizedFertilizerId = fertilizer.fertilizerId.toString();

if (!updatedFertDetails.find((f) => f.fertilizerId === normalizedFertilizerId)) {
Expand Down

0 comments on commit 1274b8f

Please sign in to comment.