Skip to content

ON-5981: Consolidate import flow into 3-step inventory mapping screen#2777

Merged
tatimoreira merged 6 commits into
developfrom
fix/ON-5981-Update-inventory-mapping-screen-design
Jul 6, 2026
Merged

ON-5981: Consolidate import flow into 3-step inventory mapping screen#2777
tatimoreira merged 6 commits into
developfrom
fix/ON-5981-Update-inventory-mapping-screen-design

Conversation

@tatimoreira

@tatimoreira tatimoreira commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Consolidates the previous 4-step import flow (Upload → Validation Results → Mapping Columns → Review & Confirm) into a 3-step flow (Upload → Inventory Mapping → Review & Confirm). The new Inventory Mapping step combines validation feedback and column mapping into a single inline-editable table, gated by a Continue button that requires required fields to be mapped.

Changes

  • Add InventoryMappingStep component: single table with FIELD NAME / VALUE / MAP TO columns, mandatory fields marked with red asterisks, inline NativeSelect dropdowns for all columns, red error banner when required fields are unmapped, orange warning banner when optional fields are unmapped, "Needs remapping" indicators per row, mandatory columns sorted to the top
  • Refactor import page.tsx from 4 steps to 3 steps; derive canContinue via useMemo in the parent (instead of useEffect in child) to ensure the Continue button updates synchronously when mappings change
  • Add i18n keys for the new step across all 5 locales (en, pt, es, fr, de)
  • Fix Continue button gate: required fields (GPC ref. no., Sector, Sub-sector, Activity Amount) must all have a non-empty mapping selected; clearing and re-selecting any value correctly enables/disables the button
  • Display city name above the heading on all three import steps for context

Preview

image image image

How to test

  1. Navigate to GHGI → Import inventory for any city with an inventory year
  2. Step 1 – Upload: city name appears above heading; upload a CSV/XLSX file
  3. Step 2 – Inventory Mapping: all columns appear in the table; required fields have red asterisks; red error banner is shown until GPC ref. no. (or Sector + Sub-sector) and Activity Amount are all mapped; orange warning appears when optional fields are unmapped; Continue button only enables when all required fields have a selection
  4. Clear a required field → Continue disables; re-select any value → Continue re-enables
  5. Step 3 – Review & Confirm: city name appears above heading; summary and field mappings are correct; Import button triggers the import

Ticket

ON-5981

Notes

The canContinue check mirrors the backend validation rule: identity is satisfied by gpcRefNo alone or both sector + subsector together; activityAmount is always required. The gate enforces that every auto-detected mandatory column has a non-empty value selected (not necessarily the originally detected key), which matches the backend's flexibility.

@tatimoreira
tatimoreira requested a review from lemilonkh July 3, 2026 03:14

@cephaschapa cephaschapa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Amazing work 👍✨

@lemilonkh lemilonkh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome, thanks 👍 ✨

Comment thread app/src/app/[lng]/cities/[cityId]/GHGI/onboarding/import/page.tsx
…n mapping

Single confirmation screen that replaces the separate validation-results and
mapping-columns steps. Shows real-time validation banners (error when required
GPC fields are unmapped, warning when optional columns lack mapping), red
asterisks on mandatory fields, and inline "Needs remapping" indicators per row.
Exposes onCanContinueChange so the parent can gate the Continue button.
Replaces the separate ValidationResultsStep (step 1) and MappingColumnsStep
(step 2) with the new InventoryMappingStep. Updates step titles array, step
rendering, and the bottom action bar so the Continue button on the mapping
step is gated by canContinueMapping. The Import button now appears at step 2
(previously step 3).
New keys: inventory-mapping-step (step title), inventory-mapping-heading,
inventory-mapping-description, required-fields-not-mapped (+ description),
some-columns-need-mapping (+ description), needs-remapping,
select-option-to-map. Non-English locales translated; legacy step-title
keys kept for backward compatibility.
Lifted canContinue computation out of the child's useEffect into a useMemo
in the parent, so it updates synchronously when mappingOverrides changes
with no render-cycle delay.

The gate logic was also corrected: instead of checking that auto-detected
keys remain in mappedKeys (too strict), it now checks that every column
marked as mandatory (by auto-detection or current override) has any
non-empty effective key. This allows clearing and re-selecting to any
value — including one that satisfies identity via the sector+subsector
path — to correctly re-enable Continue.
Added cityName prop (sourced from inventory.city.name) to UploadFileStep,
InventoryMappingStep, and ReviewConfirmStep so the city context is
visible consistently across all three steps of the import flow.
@tatimoreira
tatimoreira force-pushed the fix/ON-5981-Update-inventory-mapping-screen-design branch from 8174a0f to 86f140d Compare July 6, 2026 16:59
@tatimoreira
tatimoreira merged commit 7c159f8 into develop Jul 6, 2026
9 checks passed
@tatimoreira
tatimoreira deleted the fix/ON-5981-Update-inventory-mapping-screen-design branch July 6, 2026 17:17
lemilonkh pushed a commit that referenced this pull request Jul 8, 2026
…2804)

PR #2772 improved mapping-columns-step.tsx but that component was deleted
by PR #2777 when the import flow was consolidated into InventoryMappingStep.
Port the same fixes to the new component:

- Convert emission factor example values (CO2/CH4/N2O/TotalCO2e) from raw
  units to metric tonnes (t CO2e)
- Show "Not specified" in tertiary color instead of "-" for empty/undefined
  example values
- Sort: required fields first, then auto-detected fields, then undetected,
  so Activity data amount and other mandatory fields group at the top
lemilonkh pushed a commit that referenced this pull request Jul 8, 2026
…2804)

PR #2772 improved mapping-columns-step.tsx but that component was deleted
by PR #2777 when the import flow was consolidated into InventoryMappingStep.
Port the same fixes to the new component:

- Convert emission factor example values (CO2/CH4/N2O/TotalCO2e) from raw
  units to metric tonnes (t CO2e)
- Show "Not specified" in tertiary color instead of "-" for empty/undefined
  example values
- Sort: required fields first, then auto-detected fields, then undetected,
  so Activity data amount and other mandatory fields group at the top
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