Tax category page follow-up cleanups

Open
#5,305 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
react, typescript
Domain
frontend, testing

Research direction

The issue lists four independent cleanups under packages/client, with target files and a test file named for the BusinessScreen change. Start with one cleanup, read its listed call sites, and run the corresponding tests; for the screen change, update screens/businesses/__tests__/business-screen.test.tsx. Done means the selected cleanup is covered by passing tests, with behavior unchanged.

Written by the indexing model from the issue text.

Description

Cleanups noticed during the tax category page work (docs/tax-category-page/). None change behaviour.

  1. Remove BusinessScreen's unreachable fallback. packages/client/src/components/screens/businesses/business.tsx keeps a paused urql useQuery plus a no-loader <Navigate> branch. The /businesses/:businessId route always runs businessLoader (it either returns data or throws), so that path never runs in the app. Drop it, as was done for TaxCategoryScreen, and simplify the refresh to useRevalidator. Update screens/businesses/__tests__/business-screen.test.tsx.

  2. Shared membership-role lookup. Several call sites look up the user's role in a business with memberships.find(m => m.businessId === id)?.role, each with its own rules about who may edit:

    • components/business/admin/securities-settings-section.tsx
    • components/business/admin/depreciation-settings-section.tsx
    • components/manual-automations/manual-automations-access.ts
    • components/tax-category/details-section.tsx

    Extract a pure getMembershipRole(userContext, businessId) helper. Keep each site's role set and scope rules where they are; only the lookup is shared.

  3. Shared renderWithRouter test helper. About 30 client test files repeat the same createRoot + act + MemoryRouter harness, for example the cell tests under charges/cells/__tests__, ledger-table/__tests__, transactions-table/cells/__tests__, documents-table/cells/__tests__, business-ledger/cells/__tests__ and charge-matches/cells/__tests__. A shared helper would shorten them; migrate a few as part of adding it.

  4. NamedFinancialEntityRef type alias. FinancialEntityRef & { name: string } (from packages/client/src/router/routes.ts) is repeated in:

    • business-ledger/cells/business-name-cell.tsx
    • business-ledger/cells/counter-account-cell.tsx
    • charge-matches/cells/business.tsx
    • charge-matches/index.tsx
    • charges/cells/counterparty.tsx
    • ledger-table/counterparty-cell.tsx
    • common/financial-entity-link.tsx

    Add one alias next to FinancialEntityRef.

These can land as separate small PRs.

Dominant language
TypeScript
Stars
30
Forks
10
Avg merge
2d 12h
Merged PRs (30d)
276

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Urigo/accounter-fullstack

All issues in Urigo/accounter-fullstack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.