Skip to content

[OSDEV-2353] Connect fetchFacility action wrapper to the ProductionLocationDetailsContent component#888

Merged
VadimKovalenkoSNF merged 7 commits intomainfrom
OSDEV-2353-fetch-production-location-data
Feb 25, 2026
Merged

[OSDEV-2353] Connect fetchFacility action wrapper to the ProductionLocationDetailsContent component#888
VadimKovalenkoSNF merged 7 commits intomainfrom
OSDEV-2353-fetch-production-location-data

Conversation

@VadimKovalenkoSNF
Copy link
Contributor

@VadimKovalenkoSNF VadimKovalenkoSNF commented Feb 24, 2026

Follow-up PR for OSDEV-2353

Fetch single facility data in the production location page (ProductionLocationDetailsContent.jsx)

@VadimKovalenkoSNF VadimKovalenkoSNF self-assigned this Feb 24, 2026
@barecheck
Copy link

barecheck bot commented Feb 24, 2026

React App | Jest test suite - Code coverage report

Total: 40.01%

Your code coverage diff: -0.02% ▾

✅ All code changes are covered

@barecheck
Copy link

barecheck bot commented Feb 24, 2026

Dedupe Hub App | Unittest test suite - Code coverage report

Total: 55.73%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@barecheck
Copy link

barecheck bot commented Feb 24, 2026

Contricleaner App | Unittest test suite - Code coverage report

Total: 98.75%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds URL ID normalization, triggers facility fetch on mount/update and clears on unmount, shows a loading spinner while fetching, introduces PropTypes/defaultProps, and simplifies mapDispatchToProps to expose fetchFacility(id, contributorId) and clearFacility().

Changes

Cohort / File(s) Summary
ProductionLocationDetailsContent component
src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx
Added imports (PropTypes, CircularProgress, getLastPathParameter, facilityPropType); compute normalizedOsID from location.pathname / match.params.osID; call fetchFacility(normalizedOsID, contributors) on ID change; render CircularProgress while fetching; call clearFacility on unmount; add propTypes and defaultProps; mapDispatchToProps simplified to fetchFacility(id, contributorId) and clearFacility(); removed embed/facilities dispatch usage and embed/config fields from mapStateToProps.

Sequence Diagram(s)

sequenceDiagram
    participant Component as ProductionLocationDetailsContent
    participant Router as Router (location/match)
    participant Dispatcher as mapDispatchToProps
    participant Action as fetchSingleFacility (thunk)
    participant Store as Redux Store / API

    Router->>Component: provide pathname / params
    Component->>Component: compute normalizedOsID
    Component->>Dispatcher: fetchFacility(normalizedOsID, contributors)
    Dispatcher->>Action: dispatch fetchSingleFacility(id, contributorId)
    Action->>Store: request facility data (API)
    Store-->>Action: facility data response
    Action-->>Dispatcher: dispatch success/failure
    Dispatcher-->>Component: props updated (data/fetching/error)

    Component->>Dispatcher: on unmount -> clearFacility()
    Dispatcher->>Store: dispatch clear facility action
    Store-->>Component: facility cleared
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • vladsha-dev
  • mazursasha1990
  • Innavin369
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: connecting the fetchFacility action wrapper to ProductionLocationDetailsContent component.
Description check ✅ Passed The description is directly related to the changeset, explaining that it's a follow-up PR that connects fetchFacility to the production location page component.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch OSDEV-2353-fetch-production-location-data

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx (1)

132-149: Rename fetchFacility parameter for clarity.
contributorId actually holds the contributors array; renaming reduces future call-site confusion.

♻️ Suggested rename
-        fetchFacility: (id, contributorId) => {
-            const contributorValue = get(contributorId, ['0', 'value']);
-            const contributors = contributorValue ? contributorId : null;
+        fetchFacility: (id, contributors) => {
+            const contributorValue = get(contributors, ['0', 'value']);
+            const normalizedContributors = contributorValue ? contributors : null;
 
-            return dispatch(fetchSingleFacility(id, 0, contributors, true));
+            return dispatch(fetchSingleFacility(id, 0, normalizedContributors, true));
         },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`
around lines 132 - 149, Rename the fetchFacility parameter from contributorId to
contributors (or contributorsArray) inside mapDispatchToProps to reflect that it
holds the contributors array; update the internal references (change
get(contributorId, ['0','value']) and the contributors assignment) to use the
new parameter name and ensure the dispatch call still passes contributors (not
contributorId). Also update any local usages within this file that reference
fetchFacility's parameter name so call-sites remain correct.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`:
- Around line 52-57: The useEffect is calling fetchFacility(normalizedOsID, 0,
contributors) but the fetchFacility wrapper expects (id, contributors) so the
contributors argument gets dropped; update the call in
ProductionLocationDetailsContent (the useEffect that currently calls
fetchFacility) to pass only the id and contributors—i.e., call
fetchFacility(normalizedOsID, contributors)—or alternatively adjust the wrapper
signature to accept (id, page, contributors) consistently, ensuring the
contributors value reaches the fetchFacility implementation.

---

Nitpick comments:
In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`:
- Around line 132-149: Rename the fetchFacility parameter from contributorId to
contributors (or contributorsArray) inside mapDispatchToProps to reflect that it
holds the contributors array; update the internal references (change
get(contributorId, ['0','value']) and the contributors assignment) to use the
new parameter name and ensure the dispatch call still passes contributors (not
contributorId). Also update any local usages within this file that reference
fetchFacility's parameter name so call-sites remain correct.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c3b88b and fa30009.

📒 Files selected for processing (1)
  • src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx

@barecheck
Copy link

barecheck bot commented Feb 24, 2026

Countries App | Unittest test suite - Code coverage report

Total: 100%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@barecheck
Copy link

barecheck bot commented Feb 24, 2026

Django App | Unittest test suite - Code coverage report

Total: 81.9%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`:
- Around line 52-55: The useEffect calling fetchFacility(normalizedOsID,
contributors) is missing contributors (and fetchFacility) in its dependency
array, causing stale facility data when contributors change; update the effect
on ProductionLocationDetailsContent by including contributors and fetchFacility
in the dependency array (e.g., [normalizedOsID, contributors, fetchFacility])
and remove the eslint-disable comment so React re-runs fetchFacility when those
values change.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11972c6 and 7820bbf.

📒 Files selected for processing (1)
  • src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx (1)

52-54: ⚠️ Potential issue | 🟡 Minor

Guard against calling fetchFacility with a falsy ID.

If location.pathname is empty and osID is undefined, normalizedOsID resolves to an empty or falsy value, triggering a fetch with an invalid ID.

🛠️ Proposed fix
     useEffect(() => {
+        if (!normalizedOsID) return;
         fetchFacility(normalizedOsID, contributors);
     }, [normalizedOsID, contributors, fetchFacility]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`
around lines 52 - 54, The useEffect currently calls
fetchFacility(normalizedOsID, contributors) even when normalizedOsID is falsy;
update the effect in ProductionLocationDetailsContent (the useEffect that
references normalizedOsID, contributors, fetchFacility) to first check that
normalizedOsID is a truthy/non-empty value before invoking fetchFacility, so the
fetch is skipped when location.pathname/osID is undefined or empty; keep the
same dependency array ([normalizedOsID, contributors, fetchFacility]) and only
call fetchFacility when the guard passes.
🧹 Nitpick comments (2)
src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx (2)

156-166: Misleading parameter name contributorId and unnecessary intermediate variable.

contributorId actually receives the contributors array from Redux state (an array of objects with .value). Naming it as a singular ID is confusing. The intermediate contributorValue variable can also be inlined.

♻️ Proposed cleanup
-        fetchFacility: (id, contributorId) => {
-            const contributorValue = get(contributorId, ['0', 'value']);
-            const contributors = contributorValue ? contributorId : null;
-
-            return dispatch(fetchSingleFacility(id, 0, contributors, true));
+        fetchFacility: (id, contributors) => {
+            const resolvedContributors = get(contributors, ['0', 'value'])
+                ? contributors
+                : null;
+
+            return dispatch(fetchSingleFacility(id, 0, resolvedContributors, true));
         },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`
around lines 156 - 166, Rename the misleading parameter contributorId to
contributors in mapDispatchToProps and inline the intermediate variable: inside
fetchFacility use get(contributors, ['0','value']) directly to decide whether to
pass the original contributors array or null into
dispatch(fetchSingleFacility(...)); keep function names as-is
(mapDispatchToProps, fetchFacility, fetchSingleFacility,
clearFacility/resetSingleFacility) so callers remain unchanged.

47-50: Remove redundant fallback in normalizedOsID chain.

osID comes from match.params.osID and is already a bare path segment without slashes. Calling getLastPathParameter on a slash-free string returns it unchanged (confirmed by test case), making the second and third conditions in the || chain equivalent. Simplify to:

Suggested change
-    const normalizedOsID =
-        getLastPathParameter(location?.pathname || '') ||
-        getLastPathParameter(osID) ||
-        osID;
+    const normalizedOsID =
+        getLastPathParameter(location?.pathname || '') || osID;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`
around lines 47 - 50, The fallback chain for normalizedOsID is redundant: remove
the middle getLastPathParameter(osID) call and compute normalizedOsID by taking
getLastPathParameter(location?.pathname || '') first and falling back to osID
(which is already a raw segment from match.params.osID); update the expression
that sets normalizedOsID in ProductionLocationDetailsContent.jsx to use
getLastPathParameter(location?.pathname || '') || osID so the logic remains
correct but avoids the duplicate transformation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`:
- Line 56: The useEffect in ProductionLocationDetailsContent currently uses a
cleanup arrow without listing clearFacility in the dependency array; update the
effect to include clearFacility (e.g., useEffect(() => () => clearFacility(),
[clearFacility])) or, if you intentionally only want unmount behavior and
clearFacility is a stable Redux dispatch wrapper, add an inline eslint disable
comment (// eslint-disable-next-line react-hooks/exhaustive-deps) immediately
above that useEffect to suppress the lint warning; target the useEffect in the
ProductionLocationDetailsContent component and reference the clearFacility
symbol when making the change.

---

Duplicate comments:
In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`:
- Around line 52-54: The useEffect currently calls fetchFacility(normalizedOsID,
contributors) even when normalizedOsID is falsy; update the effect in
ProductionLocationDetailsContent (the useEffect that references normalizedOsID,
contributors, fetchFacility) to first check that normalizedOsID is a
truthy/non-empty value before invoking fetchFacility, so the fetch is skipped
when location.pathname/osID is undefined or empty; keep the same dependency
array ([normalizedOsID, contributors, fetchFacility]) and only call
fetchFacility when the guard passes.

---

Nitpick comments:
In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`:
- Around line 156-166: Rename the misleading parameter contributorId to
contributors in mapDispatchToProps and inline the intermediate variable: inside
fetchFacility use get(contributors, ['0','value']) directly to decide whether to
pass the original contributors array or null into
dispatch(fetchSingleFacility(...)); keep function names as-is
(mapDispatchToProps, fetchFacility, fetchSingleFacility,
clearFacility/resetSingleFacility) so callers remain unchanged.
- Around line 47-50: The fallback chain for normalizedOsID is redundant: remove
the middle getLastPathParameter(osID) call and compute normalizedOsID by taking
getLastPathParameter(location?.pathname || '') first and falling back to osID
(which is already a raw segment from match.params.osID); update the expression
that sets normalizedOsID in ProductionLocationDetailsContent.jsx to use
getLastPathParameter(location?.pathname || '') || osID so the logic remains
correct but avoids the duplicate transformation.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7820bbf and 7a1c80a.

📒 Files selected for processing (1)
  • src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx (2)

56-56: ⚠️ Potential issue | 🟡 Minor

Include clearFacility in cleanup effect deps (or explicitly suppress lint).

Line 56 still captures clearFacility with an empty deps array. This is the same dependency-array concern previously raised.

#!/bin/bash
# Verify hook lint configuration and the exact cleanup effect usage.
rg -n "react-hooks/exhaustive-deps|react-hooks/rules-of-hooks" src/react/.eslintrc
rg -n "useEffect\\(\\(\\) => \\(\\) => clearFacility\\(\\), \\[\\]\\)" src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`
at line 56, The useEffect cleanup currently references clearFacility but has an
empty dependency array; update the effect in ProductionLocationDetailsContent to
either include clearFacility in the deps (e.g., useEffect(() => () =>
clearFacility(), [clearFacility])) or, if clearFacility is stable and you
intentionally want an empty deps array, add an explicit lint suppression comment
for the react-hooks/exhaustive-deps rule above the effect; locate the useEffect
inside the ProductionLocationDetailsContent component and modify it accordingly.

52-54: ⚠️ Potential issue | 🟡 Minor

Guard the fetch call when ID normalization returns empty.

If normalizedOsID is empty/undefined, this still dispatches fetchSingleFacility with an invalid ID.

🔧 Proposed fix
 useEffect(() => {
+    if (!normalizedOsID) return;
     fetchFacility(normalizedOsID, contributors);
 }, [normalizedOsID, contributors]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`
around lines 52 - 54, The effect currently calls fetchFacility(normalizedOsID,
contributors) even when normalizedOsID is empty; update the useEffect in
ProductionLocationDetailsContent to first check that normalizedOsID is truthy
(non-empty) before dispatching fetchFacility (i.e., only call
fetchFacility(normalizedOsID, contributors) when normalizedOsID exists), leaving
the dependency array as [normalizedOsID, contributors] and ensuring no
fetchSingleFacility is dispatched with an invalid ID.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`:
- Around line 158-160: In fetchFacility, the logic uses contributorValue =
get(contributorId, ['0','value']) and then contributorValue ? contributorId :
null which incorrectly treats valid falsy values (e.g., 0) as missing; change
the presence check to test the contributorId list itself (e.g.,
Array.isArray(contributorId) && contributorId.length > 0 or an equivalent check)
and use that result to set contributors, leaving contributorValue extraction via
get untouched.

---

Duplicate comments:
In
`@src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx`:
- Line 56: The useEffect cleanup currently references clearFacility but has an
empty dependency array; update the effect in ProductionLocationDetailsContent to
either include clearFacility in the deps (e.g., useEffect(() => () =>
clearFacility(), [clearFacility])) or, if clearFacility is stable and you
intentionally want an empty deps array, add an explicit lint suppression comment
for the react-hooks/exhaustive-deps rule above the effect; locate the useEffect
inside the ProductionLocationDetailsContent component and modify it accordingly.
- Around line 52-54: The effect currently calls fetchFacility(normalizedOsID,
contributors) even when normalizedOsID is empty; update the useEffect in
ProductionLocationDetailsContent to first check that normalizedOsID is truthy
(non-empty) before dispatching fetchFacility (i.e., only call
fetchFacility(normalizedOsID, contributors) when normalizedOsID exists), leaving
the dependency array as [normalizedOsID, contributors] and ensuring no
fetchSingleFacility is dispatched with an invalid ID.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a1c80a and e4a5e5e.

📒 Files selected for processing (1)
  • src/react/src/components/ProductionLocation/ProductionLocationDetailsContent/ProductionLocationDetailsContent.jsx

@sonarqubecloud
Copy link

Copy link
Contributor

@vlad-shapik vlad-shapik left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@protsack-stephan protsack-stephan left a comment

Choose a reason for hiding this comment

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

Great work!

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.

3 participants