Skip to content

Read TKF onboarding document links from the backend API#1557

Closed
stenehrlich-tuleva wants to merge 1 commit into
masterfrom
tkf-onboarding-document-links
Closed

Read TKF onboarding document links from the backend API#1557
stenehrlich-tuleva wants to merge 1 commit into
masterfrom
tkf-onboarding-document-links

Conversation

@stenehrlich-tuleva

Copy link
Copy Markdown
Contributor

What & why

The Täiendav Kogumisfond (TKF100) onboarding signing step links three legal documents — terms, prospectus, key information. Those URLs were hardcoded and duplicated in the two onboarding flow parents and silently went stale when the documents were re-issued (they pointed at the superseded 12.01.2026 versions).

This switches the frontend to read the URLs from the backend: a useSavingsFundDocuments() hook calls GET /v1/savings/documents and the returned URLs are mapped onto the existing linkText label ids. WordPress stays the editable source (the backend mirrors it) — the frontend no longer needs a deploy when the documents change.

Issue: TulevaEE/TKF-VPII2026#63
Backend (serves the endpoint): TulevaEE/onboarding-service#1647
WordPress prereq (exposes the ACF fields over REST): TulevaEE/wordpress-theme#67

Changes

  • useSavingsFundDocuments() react-query hook + getSavingsFundDocuments() API fn + SavingsFundDocuments type.
  • SavingsFundOnboarding.tsx and SavingsFundCompanyOnboarding.tsx read documents from the hook and pass them to TermsStepthe hardcoded arrays are removed.
  • TermsStep shows a loading state (shared Loader) instead of an empty link list while documents are loading, so the step never renders linkless mid-load.
  • No translation changes — the linkText.{terms,prospectus,keyInfo} labels already exist.

Tests

Strict TDD, semantic RTL queries. TermsStep gets a graceful-loading test; both flow tests supply documents via a mocked GET /v1/savings/documents backend, and the happy-flow test asserts the Terms link carries the API-provided href (not a constant). Run with:

TZ=UTC npx react-scripts test --watchAll=false --no-coverage --reporters=default --reporters=tdd-guard-jest --testPathPattern=savingsAccount/SavingsFundOnboarding

Savings onboarding + TermsStep suites green (23/23); tsc --noEmit, eslint --max-warnings=0, and Prettier clean on the changed files.

Note

Live end-to-end (URLs sourced from real WordPress REST) waits on TulevaEE/wordpress-theme#67 deploying; until then the backend serves a baked-in fallback, so the links are correct regardless.

🤖 Generated with Claude Code

The savings fund (TKF100) signing step linked three legal documents — terms,
prospectus, key information — from URLs hardcoded (and duplicated) in the two
onboarding flow parents, which silently went stale when the documents were
re-issued.

Replace the hardcoded arrays with a useSavingsFundDocuments() react-query hook
that reads GET /v1/savings/documents, and map the returned URLs onto the existing
linkText label ids. WordPress stays the editable source (the backend mirrors it);
the frontend no longer needs a deploy when the documents change.

TermsStep renders a loading state (shared Loader) instead of an empty link list
while the documents are loading, so the step never renders linkless mid-load.

Tests via the mocked GET /v1/savings/documents backend; the flow test asserts the
links carry the API-provided href, not a constant. No translation changes (labels
already exist).

Refs TulevaEE/TKF-VPII2026#63

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.00%. Comparing base (419771f) to head (848a7c8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1557      +/-   ##
==========================================
+ Coverage   81.97%   82.00%   +0.02%     
==========================================
  Files         317      317              
  Lines        6576     6586      +10     
  Branches     1441     1444       +3     
==========================================
+ Hits         5391     5401      +10     
  Misses        797      797              
  Partials      388      388              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stenehrlich-tuleva

Copy link
Copy Markdown
Contributor Author

Parking the WordPress-backed approach for now — it's more than we want to take on before our CTO is back to review the design. The branch stays put for pickup; tracking in TulevaEE/TKF-VPII2026#63. In the meantime we'll ship a minimal interim fix that just bumps the hardcoded document URLs to the current in-force (Feb 2026) versions.

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