Tax Rate Management Workspace
Tax Rate Management Workspace
Welcome back. In the previous lesson, you laid the foundation for tax management by creating a compact tax API module in src/lib/api/tax.ts and a reusable controlled form in src/components/admin/TaxRateForm.tsx. That gave the project two important building blocks: a small set of semantic tax request helpers and a form that can collect, normalize, and submit tax-rate values cleanly without hardcoding page-specific logic.
This lesson turns those building blocks into a real admin workspace. You will add the tax admin route, create a dedicated TaxAdminPageClient page, load the current tax-rate collection with a read-only workflow, and then connect the reusable TaxRateForm so the page can save and delete rates while refreshing the visible list from canonical server data after every write. The main idea is to make the tax screen feel like a trustworthy internal operations surface: clear heading, honest page states, meaningful data cards, and simple refresh-after-write behavior.
Previously
Last time, the focus was on boundaries. src/lib/api/tax.ts stayed purely about named request helpers like listTaxRates(), getTaxRate(countryCode), upsertTaxRate(...), and deleteTaxRate(...), while src/components/admin/TaxRateForm.tsx stayed purely about controlled input state and normalized submission. The form collected countryCode and rateBps, normalized the country code on submit, awaited the parent onSubmit(...), and reset itself for repeated admin use.
That separation matters directly in this lesson. Because the API helpers and form are already cleanly separated, TaxAdminPageClient can focus on page-level workflow: loading the collection, deciding which UI state to show, handling saves and deletes, and refreshing the list afterward.
Starting the Tax Admin Route with a Thin Page File
As in the rest of this project, the route file itself stays intentionally simple. The page route in src/app/admin/tax/page.tsx is a thin handoff that activates the route and delegates all UI behavior to a dedicated client component.
Here is the full route file:
-
This follows the same architectural pattern used throughout the path. Route files stay lightweight, which makes them easy to scan and keeps routing concerns separate from client-side state, async workflows, and UI branching.
-
Returning
TaxAdminPageClientdirectly is also a good consistency move. Once a learner has seen this structure across products, orders, and admin screens, they can quickly recognize where route setup ends and page behavior begins. -
In the earliest stage of this lesson, the point is mostly structural progress: the route should exist, it should resolve correctly, and it should have a dedicated place for the tax-management workspace to grow.
