Skip to content

feature: Overdue inbound dashboard card - #6

Open
matthewguerra-cog wants to merge 1 commit into
spec-driven-developmentfrom
devin/1787242953-overdue-inbound-dashboard-card
Open

matthewguerra-cog wants to merge 1 commit into
spec-driven-developmentfrom
devin/1787242953-overdue-inbound-dashboard-card

Conversation

@matthewguerra-cog

@matthewguerra-cog matthewguerra-cog commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

✨ Description of Change

Link to GitHub issue or Jira ticket: n/a — spec source is docs/demo/ui-spec-prompt.md on spec-driven-development (the branch has no specs/ui/*.spec.md).

Description:

Adds an "Overdue inbound" table card to the warehouse dashboard, backed by the GET /api/shipments/exceptions/overdue endpoint that already exists on this branch. No backend query, domain, or migration changes.

The dashboard fetch path assumed every widget endpoint lives under /api/dashboard and already returns the card shape. Instead of adding a second fetch path, widgets can now declare a responseAdapter that maps an arbitrary API response onto the card shape:

// runtime.groovy
overdueInbound { graphType = "table"; endpoint = "/api/shipments/exceptions/overdue?max=5"; responseAdapter = "overdueInboundShipments" }

// fetchGraphIndicator
indicatorData = adapters[config.responseAdapter]?.(res.data, translate) ?? res.data

Consequences of that hook:

  • fetchGraphIndicator gets a translate argument (column headers come from the adapter, not from the backend), threaded from redux state via getTranslate(state.localize) in the thunks that reach it.
  • Configured endpoints may now carry a query string, so the locationId param is appended with & when the endpoint already has a ?.
  • fetchConfigAndData's unused trailing filterSelected arg is dropped; it was forwarded into a getData parameter that never existed, and that slot now carries translate.

Card behavior: columns shipment / origin / days late, rows in the API's default daysLate desc order, each shipment number linking to its stock movement, card title linking to the inbound list's Overdue view. TableCard renders a translated empty row when a card supplies emptyMessage, so the card reads as "no overdue inbound shipments" rather than an empty table. Loading and error states, drag-to-reorder, and the add-widget flow are the existing generic dashboard ones; the endpoint scopes results to the session warehouse and returns a validation error without one, which surfaces as the standard card error state.

To make the card's link land on the filtered list, StockMovementInboundList now seeds its overdue toggle from ?overdue=true.


📷 Screenshots & Recordings (optional)

UI verification is running; screenshots/recording to follow in a comment.

Devin-Org: engineering

Link to Devin session: https://app.devin.ai/sessions/eef130c0744642c99c7aa9382de2109f
Requested by: @matthewguerra-cog


Devin Review

Status Commit
🟢 Reviewed 4ba706c
Open in Devin Review (Staging)

…erdue shipments API

Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@staging-devin-ai-integration staging-devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review (Staging)
Debug

Playground

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 5 potential issues.

Open in Devin Review

Comment thread src/js/actions/index.js
Comment on lines +309 to +316
function getTranslateFromState(getState) {
return translateWithDefaultMessage(getTranslate(getState().localize));
}

function adaptIndicatorResponse(indicatorConfig, responseData, translate) {
const adapter = dashboardResponseAdapters[indicatorConfig.responseAdapter];
return adapter ? adapter(responseData, translate) : responseData;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: responseAdapter hook is a generic, backward-compatible extension

The new responseAdapter mechanism in src/js/actions/index.js:313-316 and src/js/utils/dashboard-response-adapters.js is threaded correctly through all four thunks that reach fetchGraphIndicator (reloadIndicator, fetchIndicators, addToIndicators, fetchConfigAndData), each now passing getTranslateFromState(getState). For widgets without a responseAdapter, adaptIndicatorResponse returns the raw res.data, preserving existing behavior. The backend passes the full config through (UserService.getDashboardConfig deep-copies the entire dashboardConfig), so responseAdapter/endpoint reach the frontend. I confirmed state.localize is the correct store slice (used identically in src/js/middlewares/index.js:12).

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/js/actions/index.js
Comment on lines +328 to +329
const separator = indicatorConfig.endpoint.includes('?') ? '&' : '?';
const url = `${indicatorConfig.endpoint}${separator}${listParams}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Endpoint query-string separator change only affects the new widget

The separator logic at src/js/actions/index.js:328-329 appends locationId with & when the endpoint already contains ?. Only the new overdueInbound endpoint (/api/shipments/exceptions/overdue?max=5) has a query string; all existing dashboard endpoints have none, so they keep the ? separator and are unaffected. The extra locationId/listFiltersSelected params sent to the overdue endpoint are harmless since Grails command binding ignores unknown params and the controller scopes results by session.warehouse.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +3 to +24
const overdueInboundShipments = (responseData, translate) => {
const rows = responseData?.data ?? [];

return {
link: `${STOCK_MOVEMENT_URL.listInbound()}&overdue=true`,
data: {
number: translate('react.dashboard.overdueInbound.column.shipment.label', 'Shipment'),
name: translate('react.dashboard.overdueInbound.column.origin.label', 'Origin'),
value: translate('react.dashboard.overdueInbound.column.daysLate.label', 'Days late'),
emptyMessage: {
id: 'react.dashboard.overdueInbound.empty.label',
defaultMessage: 'No overdue inbound shipments',
},
body: rows.map((row) => ({
number: row.shipmentNumber,
numberLink: row.id ? STOCK_MOVEMENT_URL.show(row.id) : undefined,
name: row.origin?.name,
value: `${row.daysLate}`,
})),
},
};
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Column headers captured at dispatch time, relying on default-message fallback

getTranslateFromState(getState) captures a translate function bound to the state at thunk-dispatch time. If react.dashboard.overdueInbound.column.* translations are not yet loaded when the adapter runs, translateWithDefaultMessage falls back to the English default strings ('Shipment', 'Origin', 'Days late') rather than showing translation keys, so the card degrades gracefully. Worth noting the captured translate won't reactively update if translations load afterward, but the fallback makes this a non-issue in practice.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +65 to +74
{!data.body.length && data.emptyMessage ? (
<tr className="empty-table-row">
<td colSpan={3}>
<Translate
id={data.emptyMessage.id}
defaultMessage={data.emptyMessage.defaultMessage}
/>
</td>
</tr>
) : null}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Empty-message row colSpan is consistent with rendered header columns

The empty-state row uses colSpan={3} (src/js/components/dashboard/TableCard.jsx:67). This is only reached when data.body.length is 0, in which case the optional icon <td/> header cell (rendered via data.body.find((item) => item.icon) at line 55) is absent, leaving exactly 3 header columns (number/name/value). So the span matches. Also, !data.body.length is safe because existing code already dereferences data.body.find/.map unconditionally, meaning body is always defined for TableCard usages.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +22 to +25
const { search } = useLocation();
const [overdue, setOverdue] = useState(
queryString.parse(search).overdue === 'true',
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Overdue toggle seeded once from URL query

StockMovementInboundList initializes overdue from ?overdue=true via useState, so it is read only at mount. Subsequent query-param changes without a remount won't re-seed the toggle. This matches the intent (landing on the filtered list from the dashboard card link) and is a typical pattern, but reviewers should be aware the toggle won't react to later URL changes.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@devin-ai-integration

Copy link
Copy Markdown

UI test: Overdue inbound dashboard card — passed (one caveat)

Tested end-to-end against a real local build of this branch (MySQL 8 + Grails bootRun + React bundle rebuilt with Node 14), logged in as admin @ Main Warehouse, with 3 seeded overdue inbound shipments (12 / 5 / 2 days late) plus 1 future-dated negative control.

Card renders correctly (translated headers, most-overdue-first, control excluded)

Overdue inbound card

  • Title Overdue inbound, headers Shipment | Origin | Days late — translated, no raw i18n keys, which exercises the translate fn threaded through fetchGraphIndicator.
  • Rows most-overdue-first: TESTOVD-12D / Central Warehouse (NYC) / 12, TESTOVD-5D / Chicago Warehouse / 5, TESTOVD-2D / Central Warehouse (NYC) / 2.
  • Future-dated TESTFUT-7D correctly absent; info tooltip shows the "expected delivery date has passed" copy.
Empty state, error state and recovery
  • Pushing all seeded dates into the future renders a single No overdue inbound shipments row with headers still visible; reverting brings the 3 rows back.
  • Blocking *exceptions/overdue* renders the existing generic error tile with the ↻ button — no crash, other cards unaffected. Unblocking + ↻ repopulates the rows with translated headers, so reloadIndicator applies the adapter and translations too.
Navigation, regression, drag/archive, narrow viewport
  • Clicking TESTOVD-12D opens /openboxes/stockMovement/show/test-overdue-0001.
  • Clicking the card title opens the inbound list with the Overdue filter already active and only the 3 overdue shipments.
  • All pre-existing cards still render (Inventory Summary, Expiration Summary, Incoming Stock Movements By Status, Outgoing in Progress, Delayed Incoming, Items received with a discrepancy).
  • Drag-to-reorder works and raises the "Save configuration" prompt; archiving the card (Archived Indicators 18→19) and re-adding it via Unarchive brings it back with correct rows/headers.
  • At 620x800 the card stacks full width with all three columns readable, no clipping.

Narrow viewport

⚠️ Caveat: after clicking the card title the Overdue filter is active and the list is correctly filtered, but the address bar shows only ?direction=INBOUND — overdue=true is consumed when the list seeds its state and then dropped by the existing filter-param cleaner, so the deep link is not round-trippable. Behaviour is correct; persisting the param in the URL would be a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant