Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

Pages no longer show the previous record's data (#1855)

Sidf18c5dad02dd
diff --git a/.ai/lessons.md b/.ai/lessons.md
index da0439ff68..df9ff50372 100644
--- a/.ai/lessons.md
+++ b/.ai/lessons.md
@@ -2719,10 +2719,9 @@ GET navigation, so every reused ancestor loader re-runs unless its route exports
only opted out for same-pathname navigations, and the part layouts not at all. The burst is
what makes each call slow: the first concurrent wave ran ~200 ms per call, later ones 30–60 ms.
-**Rule:** A layout loader with children exports `shouldRevalidate` and re-runs only when what
-it reads changes — `isUnaffectedByNavigation(args, { params, search })` from `@carbon/utils`,
-naming the route and search params the loader reads. Mutations and
-`useRevalidator().revalidate()` still reach it. Data in a shell loader that does not gate
+**Rule (superseded 2026-10-06, see "A layout that skips its loader is only as correct as its
+skip rule"):** layouts no longer export `shouldRevalidate`; the skip was removed and slow layout
+loaders are made faster instead. Data in a shell loader that does not gate
rendering is returned as a promise and read with `useResolved` (`~/hooks/useResolved`), never
awaited.
@@ -3071,3 +3070,35 @@ And a delete whose failure the caller ignores is not a delete: return the error.
**Rule:** Filter on the fact that decides whether a row belongs, never on a column that only usually agrees with it. When a type makes a field meaningless, clear the field in the one function every writer goes through (`normalizeOperationSourceIds`), because hiding the input does not clear it. Hiding a row from a list is not a gate: refuse it in the routes that open and start it too.
**Applies to:** `get_active_job_operations_by_location`; `get_batchable_operations` and the `batch-operations` `assertEligible`; the MES operation, start and event routes; any form that hides a field by type; any list whose visibility rests on a NULL.
+
+
+## State seeded from loaded data is a copy that nothing updates
+
+**Context:** A route's components stay mounted when only its params change, and loaded data changes under a mounted component constantly: a save's revalidation, a realtime reload, a layout that reloads after its page has mounted.
+
+**Problem:** `useState(valueFromLoaderData)` reads the value once. Two bugs came from it (2026-10-06). The quote summary summed its totals from lines copied into state at mount, so a deleted line stayed in the subtotal until a reload. And a notes editor seeded from record A stayed mounted on record B: B showed A's notes, and the first keystroke saved A's text into B. An audit of 467 seeded `useState` calls found 17 confirmed cases. Reloading every layout on every navigation had hidden most of the first kind, not fixed it.
+
+**Rule:** Do not copy loaded data into state. A value computed from the data is computed during render (`useMemo`). The user's choices over the data are the only state, combined with the current data during render (`selectQuoteLines`). A draft the user edits is fine as state because the page it lives in remounts for another record: every route under `/x` renders `RecordOutlet` (`@carbon/react`), never a plain `<Outlet>`. Do not write an effect that copies the data into state again. Checks: `no-bare-outlet` and `no-state-copy-of-loader-data` (`@carbon/checks`; the second sees only a hook result used by name in the same file, not a copy seeded from a prop).
+
+**Applies to:** every component that reads `useLoaderData`, `useRouteData` or props that come from them; every route with a param in its path.
+
+
+## A layout that skips its loader is only as correct as its skip rule
+
+**Context:** 186 layouts exported `shouldRevalidate` and skipped a GET navigation that left their params unchanged (`isUnaffectedByNavigation`, 2026-10-01), to save a layout loader run on each click.
+
+**Problem:** The rule inferred "nothing changed" from `formMethod`. React Router passes a fetcher's submission to the first navigation after it only, so a delete that redirected to a record's bare URL, whose index route redirects again, arrived as a plain navigation and every layout kept its data (2026-10-06). An earlier patch had fixed the same blind spot for a revalidation restarting a navigation. 154 of the 186 layouts also declared no realtime tables, so another user's change did not show until the record changed. A module-level "a save happened" flag closed the redirect case and was rejected: one package set it, another cleared it, a third read it.
+
+**Rule:** Layouts do not skip their loaders. Do not export `shouldRevalidate` from a layout to save a loader run; make the loader cheaper instead (one query, the direct connection, shared work through middleware context). The root and the app shell are the only exceptions. To see which loaders a navigation asked for, read the `_routes` query of its `.data` request. Estimated cost of removing the skip, from production traces: 100 to 300 ms on a click that used to skip, until the dozen slow record loaders are optimised.
+
+**Applies to:** every layout route; `packages/utils/src/revalidate.ts`; the record loaders (`purchase-order+/$orderId`, `supplier+/$supplierId`, `sales-invoice+/$invoiceId`, `part+/$itemId`, `sales-order+/$orderId`, `quote+/$quoteId`).
+
+## A restore told the change log but not the open tabs
+
+**Context:** Backup restore and template revert reload a company through `wipeAndLoad` with triggers off (`session_replication_role = replica`). The live lists (items, customers, suppliers, people) are kept in the browser and updated from broadcasts; the change log (`tableChange`) is what a tab reads when it loads or reconnects.
+
+**Problem:** With triggers off nothing was broadcast. `wipeAndLoad` wrote a reset row to the change log, but an open tab only reads the log when a broadcast tells it to, or once an hour. After a demo template was reverted and applied again, a tab's part picker held the reverted parts next to the new ones, and creating a job with a reverted part returned 404 (2026-10-06, production). The first reproductions missed it because they applied a template (triggers on), which broadcasts correctly.
+
+**Rule:** A writer that turns triggers off does both halves itself: a null-`rowId` row per `CHANGE_LOGGED_TABLES` entry, and a null-`ids` broadcast on every `REALTIME_TABLES` topic of the company, inside the same transaction. When a stale client list is suspected, compare the ids in `window.clientCache.getQueryData(["live", companyId, name])` with the database before reading code.
+
+**Applies to:** `packages/jobs/src/inngest/functions/tasks/company-restore.ts` (`wipeAndLoad`); any new job that sets `session_replication_role`.
diff --git a/.ai/playbooks/record-switch-sweep.md b/.ai/playbooks/record-switch-sweep.md
new file mode 100644
index 0000000000..db63ef806f
--- /dev/null
+++ b/.ai/playbooks/record-switch-sweep.md
@@ -0,0 +1,43 @@
+# Record switch sweep
+
+Last tested: 2026-10-06 (38 of 38 pages the same as a fresh load; on main before the fix, 6 differed)
+Script: `.ai/scripts/record-switch-sweep.py`
+
+## What it proves
+A page shown for record B after a client navigation from record A must be identical to a
+fresh load of B. React Router keeps a route mounted when only its params change, so anything
+seeded once from the record (a form's default values, an editor's content, a `useState` copy)
+stays A's unless the page remounts. `RecordOutlet` (`@carbon/react`) remounts it; this sweep is
+the proof, page by page.
+
+## Prerequisites
+- The local stack is up and a demo dataset is applied (two records of each kind are needed;
+ a kind with fewer is reported as SKIP).
+- `agent-browser` is signed in as `[email protected]` (the auth skill).
+- Do not edit source files while it runs. A rebuild under it makes pages time out and the
+ run takes minutes per page instead of ~18 s.
+
+## Steps
+```bash
+python3 .ai/scripts/record-switch-sweep.py # all pages, ~15 min
+python3 .ai/scripts/record-switch-sweep.py receipt part # only these
+```
+
+## Reading the result
+- `same`: the page after the switch equals a fresh load.
+- `DIFF`: the two lines under it are what only the switched page had and what only the fresh
+ load had. `supplierId=<A>` against `supplierId=<B>` is a form still holding the previous
+ record. A difference only in `heading=` with the same field count is usually content that
+ had not finished loading; rerun that page alone (raise `SWEEP_WAIT`).
+- To see the bug this guards, make `RecordOutlet` pass `key={undefined}` and rerun: part,
+ maintenance, supplier-tax, customer-payments, receipt and shipment differ.
+
+## Add a page
+Append a row to `PAGES` in the script: name, path with `ID`, table, optional SQL filter. Add
+every new record page and every tab that has a form.
+
+## Known findings
+- Receipt and shipment differed even with `RecordOutlet`: their forms have a fixed `id`, and a
+ new `ValidatedForm` read the previous instance's stored values on its first render. Fixed in
+ `@carbon/form` (`ownsState`).
+- The shipment page logs a hydration warning on a full load (present on main).
diff --git a/.ai/scripts/record-switch-sweep.py b/.ai/scripts/record-switch-sweep.py
new file mode 100644
index 0000000000..035dbe3a5f
--- /dev/null
+++ b/.ai/scripts/record-switch-sweep.py
@@ -0,0 +1,204 @@
+#!/usr/bin/env python3
+"""Record-switch sweep: does a page show record B after switching from record A?
+
+For each record page it opens record A, switches to record B inside the app (a
+client navigation, as a link or the search does), reads every field, editor and
+heading on screen, and compares that with a fresh load of record B. A
+difference is state carried over from A: a form with A's id, an editor with A's
+text. On 2026-10-06 six of 38 pages failed this on main (supplier tax and
+customer payments kept the previous party's id, so a save went to the wrong
+record).
+
+Needs the local stack running and a signed-in agent-browser session (see the
+auth skill). Do not edit source files while it runs: a rebuild under it makes
+pages time out. A page that loads content late can differ once; rerun it alone.
+
+ python3 .ai/scripts/record-switch-sweep.py # every page below
+ python3 .ai/scripts/record-switch-sweep.py part job # only these names
+
+Exit code 1 when any page differs or could not be read.
+"""
+
+import collections
+import json
+import os
+import re
+import subprocess
+import sys
+import time
+
+WAIT = float(os.environ.get("SWEEP_WAIT", "4"))
+
+# name, path (ID = the record), table, extra SQL filter
+PAGES = [
+ ("part", "/x/part/ID/details", "item", "and type='Part'"),
+ ("part-purchasing", "/x/part/ID/purchasing", "item", "and type='Part'"),
+ ("part-planning", "/x/part/ID/planning", "item", "and type='Part'"),
+ ("part-inventory", "/x/part/ID/inventory", "item", "and type='Part'"),
+ ("part-sales", "/x/part/ID/sales", "item", "and type='Part'"),
+ ("part-costing", "/x/part/ID/costing", "item", "and type='Part'"),
+ ("part-quality", "/x/part/ID/quality", "item", "and type='Part'"),
+ ("material", "/x/material/ID/details", "item", "and type='Material'"),
+ ("tool", "/x/tool/ID/details", "item", "and type='Tool'"),
+ ("consumable", "/x/consumable/ID/details", "item", "and type='Consumable'"),
+ ("service", "/x/service/ID/details", "item", "and type='Service'"),
+ ("job", "/x/job/ID/details", "job", ""),
+ ("job-materials", "/x/job/ID/materials", "job", ""),
+ ("job-operations", "/x/job/ID/operations", "job", ""),
+ ("purchase-order", "/x/purchase-order/ID/details", "purchaseOrder", ""),
+ ("sales-order", "/x/sales-order/ID/details", "salesOrder", ""),
+ ("quote", "/x/quote/ID/details", "quote", ""),
+ ("sales-invoice", "/x/sales-invoice/ID/details", "salesInvoice", ""),
+ ("purchase-invoice", "/x/purchase-invoice/ID/details", "purchaseInvoice", ""),
+ ("supplier", "/x/supplier/ID/details", "supplier", ""),
+ ("supplier-contacts", "/x/supplier/ID/contacts", "supplier", ""),
+ ("supplier-locations", "/x/supplier/ID/locations", "supplier", ""),
+ ("supplier-payments", "/x/supplier/ID/payments", "supplier", ""),
+ ("supplier-shipping", "/x/supplier/ID/shipping", "supplier", ""),
+ ("supplier-tax", "/x/supplier/ID/tax", "supplier", ""),
+ ("customer", "/x/customer/ID/details", "customer", ""),
+ ("customer-contacts", "/x/customer/ID/contacts", "customer", ""),
+ ("customer-locations", "/x/customer/ID/locations", "customer", ""),
+ ("customer-payments", "/x/customer/ID/payments", "customer", ""),
+ ("customer-shipping", "/x/customer/ID/shipping", "customer", ""),
+ ("customer-tax", "/x/customer/ID/tax", "customer", ""),
+ ("issue", "/x/issue/ID/details", "nonConformance", ""),
+ ("receipt", "/x/receipt/ID/details", "receipt", ""),
+ ("shipment", "/x/shipment/ID/details", "shipment", ""),
+ ("picking-list", "/x/picking-list/ID/details", "pickingList", ""),
+ ("stock-transfer", "/x/stock-transfer/ID", "stockTransfer", ""),
+ ("warehouse-transfer", "/x/warehouse-transfer/ID/details", "warehouseTransfer", ""),
+ ("inventory-count", "/x/inventory-count/ID", "inventoryCount", ""),
+ ("maintenance", "/x/maintenance/ID", "maintenanceDispatch", ""),
+ ("supplier-quote", "/x/supplier-quote/ID/details", "supplierQuote", ""),
+ ("sales-rfq", "/x/sales-rfq/ID/details", "salesRfq", ""),
+ ("purchasing-rfq", "/x/purchasing-rfq/ID/details", "purchasingRfq", ""),
+ ("sales-return", "/x/sales-return-order/ID/details", "salesReturnOrder", ""),
+ ("purchase-return", "/x/purchase-return-order/ID/details", "purchaseReturnOrder", ""),
+ ("procedure", "/x/procedure/ID", "procedure", ""),
+ ("payment", "/x/payments/ID", "payment", ""),
+ ("fixed-asset", "/x/fixed-asset/ID/details", "fixedAsset", ""),
+ ("journal-entry", "/x/journal-entry/ID/details", "journal", ""),
+ ("person", "/x/person/ID/details", "employee", ""),
+ ("change-notice", "/x/items/change-notice/ID/details", "changeOrder", ""),
+ ("gauge-drawer", "/x/quality/gauges/ID", "gauge", ""),
+ ("work-center-drawer", "/x/resources/work-centers/ID", "workCenter", ""),
+ ("process-drawer", "/x/resources/processes/ID", "process", ""),
+ ("payment-term-drawer", "/x/accounting/payment-terms/ID", "paymentTerm", ""),
+]
+
+# Everything a user could read off the page that belongs to the record.
+FINGERPRINT = r"""(() => { const f=[];
+// The page and any drawer or modal over it (those render outside <main>).
+const main={ querySelectorAll: (q) => [...document.querySelectorAll("main, [role=dialog]")].flatMap(r=>[...r.querySelectorAll(q)]) };
+main.querySelectorAll("input,textarea,select").forEach(e=>{ const n=e.name||e.getAttribute("aria-label")||e.placeholder||e.type; if(/^__|csrf|search/i.test(n)) return; f.push(n+"="+(e.type==="checkbox"||e.type==="radio"?e.checked:e.value)) });
+main.querySelectorAll("[contenteditable=true],.ProseMirror").forEach(e=>f.push("editor="+e.textContent.trim().slice(0,160)));
+main.querySelectorAll("h1,h2,h3,[role=tab][aria-selected=true]").forEach(e=>f.push("heading="+e.textContent.trim().slice(0,80)));
+return JSON.stringify({p:location.pathname,n:f.length,f}) })()"""
+VOLATILE = re.compile(r"\b(ago|just now|seconds?|minutes?)\b", re.I)
+
+
+def env(name):
+ for line in open(".env.local"):
+ if line.startswith(name + "="):
+ return line.split("=", 1)[1].strip().strip('"')
+ sys.exit(f"{name} is not in .env.local: is the stack set up (crbn up)?")
+
+
+def browser(*args, timeout=60):
+ try:
+ result = subprocess.run(
+ ["agent-browser", *args], capture_output=True, text=True, timeout=timeout
+ )
+ return (result.stdout or result.stderr).strip().split("\n")[-1]
+ except subprocess.TimeoutExpired:
+ return "TIMEOUT"
+
+
+def fingerprint():
+ raw = browser("eval", FINGERPRINT)
+ try:
+ value = json.loads(raw)
+ return json.loads(value) if isinstance(value, str) else value
+ except Exception:
+ return {"p": "?", "n": -1, "f": ["UNREADABLE " + raw[:120]]}
+
+
+def sign_in(erp):
+ """A new browser session, signed in through the dev bypass."""
+ browser("close")
+ browser("open", erp + "/login")
+ time.sleep(8)
+ browser("fill", "input[name=email]", "[email protected]")
+ browser("click", "button[type=submit]")
+ time.sleep(8)
+ return "/x" in browser("get", "url")
+
+
+def stable(fields):
+ return collections.Counter(x for x in fields if not VOLATILE.search(x))
+
+
+def two_records(db, table, where):
+ company = (
+ '(select u."companyId" from "userToCompany" u join "user" us on us.id=u."userId" '
+ "where us.email='[email protected]' limit 1)"
+ )
+ sql = f'select id from "{table}" where "companyId"={company} {where} order by id limit 2'
+ out = subprocess.run(["psql", db, "-Atc", sql], capture_output=True, text=True)
+ return [line for line in out.stdout.split("\n") if line.strip()]
+
+
+def main():
+ erp, db = env("ERP_URL"), env("SUPABASE_DB_URL")
+ only = set(sys.argv[1:])
+ counts = collections.Counter()
+ for name, path, table, where in PAGES:
+ if only and name not in only:
+ continue
+ ids = two_records(db, table, where)
+ if len(ids) < 2:
+ counts["skipped"] += 1
+ print(f"SKIP {name}: fewer than two records in {table}")
+ continue
+ a, b = (path.replace("ID", record) for record in ids)
+ for attempt in (1, 2):
+ browser("open", erp + a)
+ time.sleep(WAIT)
+ browser("eval", f"(() => {{ window.__reactRouterDataRouter.navigate('{b}'); return 1 }})()")
+ time.sleep(WAIT)
+ switched = fingerprint()
+ browser("open", erp + b)
+ time.sleep(WAIT)
+ fresh = fingerprint()
+ if switched["n"] > 0 and fresh["n"] > 0:
+ break
+ # The tab crashed or the session was lost: nothing was read.
+ if attempt == 1:
+ sign_in(erp)
+ if switched["n"] <= 0 or fresh["n"] <= 0:
+ # Never "same": two unreadable pages are equal to each other.
+ counts["unreadable"] += 1
+ print(f"ERROR {name}: the page could not be read ({fresh['f'][:1]})")
+ continue
+ if switched["p"] != fresh["p"]:
+ counts["differ"] += 1
+ print(f"DIFF {name}: the switch did not arrive ({switched['p']})")
+ continue
+ only_switched = stable(switched["f"]) - stable(fresh["f"])
+ only_fresh = stable(fresh["f"]) - stable(switched["f"])
+ if only_switched or only_fresh:
+ counts["differ"] += 1
+ print(f"DIFF {name}: {fresh['n']} fields")
+ print(" after the switch:", "; ".join(list(only_switched)[:5]))
+ print(" on a fresh load: ", "; ".join(list(only_fresh)[:5]))
+ else:
+ counts["same"] += 1
+ print(f"same {name}: {fresh['n']} fields")
+ sys.stdout.flush()
+ print(dict(counts))
+ sys.exit(1 if counts["differ"] or counts["unreadable"] else 0)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/.claude/rules/coding-conventions.md b/.claude/rules/coding-conventions.md
index 1604114a2f..2049314fff 100644
--- a/.claude/rules/coding-conventions.md
+++ b/.claude/rules/coding-conventions.md
@@ -106,11 +106,16 @@ MES is lighter: services live under `apps/mes/app/services/`, components under
destructuring `{ client, companyId, userId }` (also `email`, `companyGroupId`).
- Loaders/actions return **plain objects** or `data(value, responseInit)`.
Do NOT use `json(...)` — that is the old Remix helper and is not the convention here.
-- A route with children that has a loader exports `shouldRevalidate`. Single fetch
- re-runs every matched loader on every navigation otherwise. Use
- `isUnaffectedByNavigation(args, { params, search })` from `@carbon/utils`, naming the
- route params the loader reads and either the search params it reads or `search: "all"`
- for a list loader. Shell data that does not gate rendering is returned as a promise
+- A layout does NOT export `shouldRevalidate` to skip its loader. Single fetch
+ re-runs every matched loader on every navigation, and that is what keeps a page
+ correct after a save, a redirect or another user's change. The skip was tried
+ (2026-10-01 to 2026-10-06, 186 layouts) and removed: it depended on what React
+ Router passes along, which is lost on a second redirect, and on realtime covering
+ every table a layout reads. A slow layout loader is made faster (one query, the
+ direct connection, work shared through middleware context), not skipped. The two
+ exceptions are the root (same-pathname navigations) and the app shell (re-runs
+ after five minutes), whose data does not change with the record on screen.
+ Shell data that does not gate rendering is returned as a promise
and read with `useResolved` (`~/hooks/useResolved`) when a late value is harmless.
Data that adds or removes something on first paint (a nav item, a card) is awaited
instead: streamed in, it arrives after the page is drawn and pushes it around — the
@@ -121,6 +126,11 @@ MES is lighter: services live under `apps/mes/app/services/`, components under
component that stays mounted across records passes the record id as its third
argument (`useResolved(promise, null, itemId)`), or it shows the previous record's
value until the new one arrives.
+- A route under `/x` renders `<RecordOutlet />` from `@carbon/react`, never a plain
+ `<Outlet />`. React Router keeps a page mounted when only its params change, so
+ a form's default values, an editor's content or a `useState` copy would stay the
+ previous record's. `RecordOutlet` remounts the page for another record and
+ leaves it mounted when a drawer opens over it. Enforced by `no-bare-outlet`.
- An index route that only redirects (`/x/issue/:id` → `…/details`, a module root →
its first page) also exports `middleware = [redirectBeforeLoaders(loader)]` from
`@carbon/utils`. The loaders of a matched branch run in parallel, so without it every
@@ -140,6 +150,10 @@ MES is lighter: services live under `apps/mes/app/services/`, components under
React Router skips `handleError` for it, so an unlogged throw leaves no server trace.
- Also log failures you deliberately swallow (best-effort cleanup, ignored
`{ error }` results, `.catch(() => {})`).
+- The body of a thrown 4xx `Response` is shown to the user on the route error
+ screen (`routeErrorCopy`, `@carbon/react`), with its status. Write it for a
+ person and say what was wrong ("The item could not be found…"); never pass a
+ database or provider error as the body. A 5xx body is not shown.
- Redirects (`throw redirect(...)`) are control flow, not errors; no log needed.
## Components & UI Library
@@ -155,6 +169,11 @@ MES is lighter: services live under `apps/mes/app/services/`, components under
same name may only re-export it. Enforced by the `no-duplicated-app-file` check
(`@carbon/checks`); the copies that predate it are baselined.
- Functional components, props typed inline or via `type`/`z.infer<typeof validator>`.
+- Do not seed `useState` from loader or route data: it is a copy that no reload
+ updates. Compute a derived value during render; keep only the user's own input
+ in state and combine it with the current data. Do not add an effect that copies
+ the data in again. Enforced, for a hook result used in the same file, by
+ `no-state-copy-of-loader-data` (`@carbon/checks`).
- Styling is Tailwind. Theme colors are CSS variables — use `hsl(var(--primary))`
for theme-aware fills (e.g. Recharts), not hard-coded colors.
diff --git a/.claude/rules/realtime-system.md b/.claude/rules/realtime-system.md
index 0fe756cbbe..3a3f00574d 100644
--- a/.claude/rules/realtime-system.md
+++ b/.claude/rules/realtime-system.md
@@ -98,10 +98,8 @@ loader entries and revalidates the page. A burst is one reload; a route and a
component following the same table reload once; a reload waits while a fetcher
is submitting or a navigation is in flight, and runs when both are done
(`useRevalidator` from `@carbon/query`, the only one app code may import). During
-an action React Router drops the fetcher's redirect; during the navigation that
-follows a save, a revalidation restarts it WITHOUT the submission, and every
-layout whose `shouldRevalidate` skips a plain navigation then keeps its data
-from before the save. The save's own broadcast arrives in exactly that window.
+an action React Router drops the fetcher's redirect, and a revalidation during
+the navigation that follows a save restarts that navigation.
- Update the list when the loader starts reading a new table. Nothing checks
that a list is COMPLETE, only that each name can broadcast.
@@ -177,6 +175,12 @@ company) is the only reader, and the backup engine skips the table.
token every call resets, until the hourly `util.purge_table_changes()` writes
a new one. A writer that runs with triggers off (company restore) inserts a
null-`rowId` row per `CHANGE_LOGGED_TABLES` entry itself.
+- **A writer with triggers off must also broadcast.** The log only answers a
+ client that asks, and an open tab asks when a broadcast tells it to (or once an
+ hour). `wipeAndLoad` (backup restore, template revert) therefore sends a
+ null-`ids` message on every `REALTIME_TABLES` topic of the company, in its
+ transaction. Without it a tab kept a reverted template's parts in its pickers,
+ and creating a job with one of them returned 404.
- **`table_changes_since` must stay `STABLE`**: the read of the log and
`pg_current_snapshot()` then share one snapshot. As `VOLATILE`, a change
committed between the two is skipped for good.
diff --git a/apps/erp/app/components/Grid/components/Cell.tsx b/apps/erp/app/components/Grid/components/Cell.tsx
index c71adac07b..52e0c51e0f 100644
--- a/apps/erp/app/components/Grid/components/Cell.tsx
+++ b/apps/erp/app/components/Grid/components/Cell.tsx
@@ -9,6 +9,7 @@ import { flexRender } from "@tanstack/react-table";
import { memo, useState } from "react";
import { LuPencil } from "react-icons/lu";
import type { EditableTableCellComponent } from "~/components/Editable";
+import { CellContent } from "~/components/Table/components/CellContent";
import { useMovingCellRef } from "~/hooks";
import { getAccessorKey } from "../utils";
@@ -94,7 +95,7 @@ const Cell = <T extends object>({
</div>
) : (
<div ref={ref}>
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
+ <CellContent cell={cell} />
{showEditAffordance && (
<LuPencil
aria-hidden
diff --git a/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx b/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx
index b3b43fc3b0..e6de905b72 100644
--- a/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx
+++ b/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx
@@ -222,15 +222,17 @@ const ViewsReorderGroup = ({
return [];
});
- const viewNames = views
- .map((view) => view.name)
+ // Everything a row shows or links to. Names alone missed a view whose
+ // filters or position changed: its link stayed the old one until a reload.
+ const viewsSignature = views
+ .map((view) => `${view.id}|${view.name}|${view.to}|${view.sortOrder}`)
.sort()
.join(",");
- // biome-ignore lint/correctness/useExhaustiveDependencies: suppressed due to migration
+ // biome-ignore lint/correctness/useExhaustiveDependencies: views is followed by value
useEffect(() => {
setSortedViews([...views].sort((a, b) => a.sortOrder - b.sortOrder));
- }, [views.length, viewNames]);
+ }, [viewsSignature]);
const debouncedOnReorder = useDebounce(onReorder, 500, true);
diff --git a/apps/erp/app/components/SearchFilter.tsx b/apps/erp/app/components/SearchFilter.tsx
index 552f392f0a..c974e05db5 100644
--- a/apps/erp/app/components/SearchFilter.tsx
+++ b/apps/erp/app/components/SearchFilter.tsx
@@ -9,7 +9,7 @@ import {
InputLeftElement,
useDebounce
} from "@carbon/react";
-import { useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { LuSearch } from "react-icons/lu";
import { useUrlParams } from "~/hooks";
@@ -19,11 +19,24 @@ type SearchFilterProps = InputProps & {
const SearchFilter = ({ param, size, ...props }: SearchFilterProps) => {
const [params, setParams] = useUrlParams();
- const [query, setQuery] = useState(params.get(param) || "");
+ const urlQuery = params.get(param) || "";
+ const [query, setQuery] = useState(urlQuery);
+ // What this input last wrote to the URL. A different value there came from
+ // elsewhere (a saved view, back/forward, a link) and replaces the text; our
+ // own write arriving late must not undo what was typed since.
+ const written = useRef(urlQuery);
const debounceQuery = useDebounce((q: string) => {
+ written.current = q.trim();
setParams({ [param]: q.trim(), offset: null, limit: null });
}, 500);
+ useEffect(() => {
+ if (urlQuery !== written.current) {
+ written.current = urlQuery;
+ setQuery(urlQuery);
+ }
+ }, [urlQuery]);
+
return (
<InputGroup size={size}>
<InputLeftElement>
diff --git a/apps/erp/app/components/SortableList.tsx b/apps/erp/app/components/SortableList.tsx
index f786e94c79..8d0c32a954 100644
--- a/apps/erp/app/components/SortableList.tsx
+++ b/apps/erp/app/components/SortableList.tsx
@@ -64,7 +64,7 @@ function SortableListItem<T>({
}: SortableListItemProps<T>) {
const { t } = useLingui();
const [isDragging, setIsDragging] = useState(false);
- const [isDraggable] = useState(!isExpanded && !isReadOnly);
+ const isDraggable = !isExpanded && !isReadOnly;
const dragControls = useDragControls();
const itemRef = useRef<HTMLDivElement>(null);
diff --git a/apps/erp/app/components/Table/components/Cell.tsx b/apps/erp/app/components/Table/components/Cell.tsx
index 9e8e511665..3b51609776 100644
--- a/apps/erp/app/components/Table/components/Cell.tsx
+++ b/apps/erp/app/components/Table/components/Cell.tsx
@@ -12,6 +12,7 @@ import { LuPencil } from "react-icons/lu";
import type { EditableTableCellComponent } from "~/components/Editable";
import { useMovingCellRef } from "~/hooks";
import { getAccessorKey } from "../utils";
+import { CellContent } from "./CellContent";
const logger = getLogger("erp", "cell");
@@ -127,7 +128,7 @@ const Cell = <T extends object>({
</div>
) : (
<div ref={ref}>
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
+ <CellContent cell={cell} />
{showEditAffordance && (
<LuPencil
aria-hidden
diff --git a/apps/erp/app/components/Table/components/CellContent.tsx b/apps/erp/app/components/Table/components/CellContent.tsx
new file mode 100644
index 0000000000..eaac3d81ef
--- /dev/null
+++ b/apps/erp/app/components/Table/components/CellContent.tsx
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import type { Cell as CellType } from "@tanstack/react-table";
+import { flexRender } from "@tanstack/react-table";
+
+/**
+ * Renders the column's cell under ONE component type.
+ *
+ * `flexRender` renders a cell function as `<cell />`, so the function IS the
+ * component type. Column definitions are rebuilt whenever something they close
+ * over changes (the loaded rows, a translation, a row-action callback), which
+ * gives every cell a new type: React then destroys and recreates the content of
+ * every cell in the table. A reload of the list behind a drawer made each row's
+ * buttons, links and thumbnails flicker. Calling the function from a stable
+ * wrapper lets React update the cell in place.
+ */
+export function CellContent<T>({ cell }: { cell: CellType<T, unknown> }) {
+ const render = cell.column.columnDef.cell;
+ if (
+ typeof render !== "function" ||
+ // A class component cannot be called.
+ (render as { prototype?: { isReactComponent?: unknown } }).prototype
+ ?.isReactComponent
+ ) {
+ return <>{flexRender(render, cell.getContext())}</>;
+ }
+ return <>{render(cell.getContext())}</>;
+}
diff --git a/apps/erp/app/hooks/useSavedToggle.test.ts b/apps/erp/app/hooks/useSavedToggle.test.ts
new file mode 100644
index 0000000000..fde4e7002e
--- /dev/null
+++ b/apps/erp/app/hooks/useSavedToggle.test.ts
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import type { Fetcher } from "react-router";
+import { describe, expect, it } from "vitest";
+import { useSavedToggle } from "./useSavedToggle";
+
+const fetcher = (
+ state: Fetcher["state"],
+ fields?: Record<string, string>
+): Fetcher => {
+ const formData = fields ? new FormData() : undefined;
+ for (const [key, value] of Object.entries(fields ?? {})) {
+ formData?.set(key, value);
+ }
+ return { state, formData } as Fetcher;
+};
+
+describe("useSavedToggle", () => {
+ it("shows the saved value when nothing is being saved", () => {
+ expect(useSavedToggle(fetcher("idle"), "fourEyes", true)).toBe(true);
+ expect(useSavedToggle(fetcher("idle"), "fourEyes", false)).toBe(false);
+ });
+
+ it("shows the value being saved while its request is in flight", () => {
+ const saving = fetcher("submitting", {
+ intent: "fourEyes",
+ enabled: "true"
+ });
+ expect(useSavedToggle(saving, "fourEyes", false)).toBe(true);
+ // Still in flight while the page reloads after the action.
+ const reloading = fetcher("loading", {
+ intent: "fourEyes",
+ enabled: "false"
+ });
+ expect(useSavedToggle(reloading, "fourEyes", true)).toBe(false);
+ });
+
+ it("is not moved by another switch saving through the same fetcher", () => {
+ const other = fetcher("submitting", { intent: "other", enabled: "true" });
+ expect(useSavedToggle(other, "fourEyes", false)).toBe(false);
+ });
+
+ it("returns to the saved value when the save has failed", () => {
+ // The request is over and the setting was not changed.
+ expect(useSavedToggle(fetcher("idle"), "fourEyes", false)).toBe(false);
+ });
+});
diff --git a/apps/erp/app/hooks/useSavedToggle.ts b/apps/erp/app/hooks/useSavedToggle.ts
new file mode 100644
index 0000000000..c24ebb47de
--- /dev/null
+++ b/apps/erp/app/hooks/useSavedToggle.ts
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import type { Fetcher } from "react-router";
+
+/**
+ * What a switch shows for a setting it saves on change: the value being saved
+ * while that request is in flight, otherwise the saved value.
+ *
+ * Nothing is copied into state. A switch that kept its own copy flipped on
+ * click and never read the setting again, so a save that failed left it in the
+ * position that was clicked.
+ *
+ * `intent` is the `intent` the switch submits with `enabled: "true" | "false"`.
+ */
+export function useSavedToggle(
+ fetcher: Fetcher,
+ intent: string,
+ saved: boolean
+): boolean {
+ const pending =
+ fetcher.state !== "idle" && fetcher.formData?.get("intent") === intent
+ ? fetcher.formData.get("enabled") === "true"
+ : undefined;
+ return pending ?? saved;
+}
diff --git a/apps/erp/app/modules/inventory/ui/Shipments/ShipmentForm/ShipmentForm.tsx b/apps/erp/app/modules/inventory/ui/Shipments/ShipmentForm/ShipmentForm.tsx
index a44fba25c9..a0179c78ea 100644
--- a/apps/erp/app/modules/inventory/ui/Shipments/ShipmentForm/ShipmentForm.tsx
+++ b/apps/erp/app/modules/inventory/ui/Shipments/ShipmentForm/ShipmentForm.tsx
@@ -63,10 +63,12 @@ import type {
ShipmentSourceDocument,
shipmentStatusType
} from "~/modules/inventory";
+// From the models file, not the module barrel: the barrel re-exports this
+// form, and the cycle left `ShipmentForm` read before it was defined in dev.
import {
shipmentSourceDocumentType,
shipmentValidator
-} from "~/modules/inventory";
+} from "~/modules/inventory/inventory.models";
import type { SalesInvoice } from "~/modules/invoicing/types";
import SalesInvoiceStatus from "~/modules/invoicing/ui/SalesInvoice/SalesInvoiceStatus";
import { path } from "~/utils/path";
diff --git a/apps/erp/app/modules/inventory/ui/StorageUnits/StorageUnitsTable.tsx b/apps/erp/app/modules/inventory/ui/StorageUnits/StorageUnitsTable.tsx
index 21b1f5c86e..56d223944a 100644
--- a/apps/erp/app/modules/inventory/ui/StorageUnits/StorageUnitsTable.tsx
+++ b/apps/erp/app/modules/inventory/ui/StorageUnits/StorageUnitsTable.tsx
@@ -21,6 +21,7 @@ import {
toast,
useDisclosure
} from "@carbon/react";
+import { async } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -142,20 +143,66 @@ const StorageUnitsTable = memo(
`${locationId}::${data.map((r) => r.id).join(",")}::${initialExpanded.join(",")}`,
[locationId, data, initialExpanded]
);
- const prevSignature = useRef(dataSignature);
- useEffect(() => {
- if (prevSignature.current === dataSignature) return;
- prevSignature.current = dataSignature;
- setChildrenCache(initialChildrenCache);
- setExpandedIds(new Set(initialExpanded));
- setLoadingIds(new Set());
- setSelectedIds(new Set());
- }, [dataSignature, initialChildrenCache, initialExpanded]);
-
// Keep a ref to the cache so the recursive descendant walk always sees
// the latest children without stale-closure issues.
const childrenCacheRef = useRef(childrenCache);
childrenCacheRef.current = childrenCache;
+ const expandedIdsRef = useRef(expandedIds);
+ expandedIdsRef.current = expandedIds;
+
+ const prevSignature = useRef(dataSignature);
+ const prevData = useRef(data);
+ useEffect(() => {
+ if (prevSignature.current !== dataSignature) {
+ prevSignature.current = dataSignature;
+ prevData.current = data;
+ setChildrenCache(initialChildrenCache);
+ setExpandedIds(new Set(initialExpanded));
+ setLoadingIds(new Set());
+ setSelectedIds(new Set());
+ return;
+ }
+ if (prevData.current === data) return;
+ prevData.current = data;
+
+ // The same rows, loaded again (a child was renamed, added or deleted):
+ // the tree stays as it is, and the children it shows are read again.
+ // Without this an expanded unit kept its old children until a reload.
+ setChildrenCache((prev) => ({ ...prev, ...initialChildrenCache }));
+ const fetched = [...expandedIdsRef.current].filter(
+ (id) => childrenCacheRef.current[id] && !initialChildrenCache[id]
+ );
+ let stale = false;
+ void async
+ .map(fetched, async (id) => {
+ const res = await fetch(path.to.api.storageUnitChildren(id));
+ const body = (await res.json()) as { data: StorageUnit[] };
+ return [id, body.data ?? []] as const;
+ })
+ .then((entries) => {
+ if (stale) return;
+ const fresh = Object.fromEntries(entries);
+ const cache = { ...childrenCacheRef.current, ...fresh };
+ setChildrenCache((prev) => ({ ...prev, ...fresh }));
+ // A selected child that is gone must not reach a bulk action.
+ const present = new Set([
+ ...data.map((row) => row.id),
+ ...Object.values(cache).flatMap((kids) => kids.map((k) => k.id))
+ ]);
+ setSelectedIds((prev) =>
+ [...prev].every((id) => present.has(id))
+ ? prev
+ : new Set([...prev].filter((id) => present.has(id)))
+ );
+ })
+ .catch(() => {
+ // A failed read leaves the children as shown; the next reload
+ // reads them again.
+ });
+ return () => {
+ stale = true;
+ };
+ }, [dataSignature, data, initialChildrenCache, initialExpanded]);
const collectDescendantIds = useCallback((id: string): string[] => {
const cache = childrenCacheRef.current;
diff --git a/apps/erp/app/modules/items/items.service.ts b/apps/erp/app/modules/items/items.service.ts
index aeb7a7a8c9..6950194f8f 100644
--- a/apps/erp/app/modules/items/items.service.ts
+++ b/apps/erp/app/modules/items/items.service.ts
@@ -13,9 +13,8 @@ import type {
import { storage } from "@carbon/files";
import { getLogger } from "@carbon/logger";
import { serverFns } from "@carbon/server-functions";
-import { datetime } from "@carbon/utils";
+import { datetime, withPathIds } from "@carbon/utils";
import type { PostgrestError, SupabaseClient } from "@supabase/supabase-js";
-import { nanoid } from "nanoid";
import type { z } from "zod";
import { createDocumentUploadUrl } from "~/modules/documents/documents.service";
import type { GenericQueryFilters } from "~/utils/query";
@@ -2022,13 +2021,6 @@ export async function getMethodTreeArray(
}
function getMethodTreeArrayToTree(items: Method[]): MethodTreeItem[] {
- function traverseAndRenameIds(node: MethodTreeItem) {
- const clone = structuredClone(node);
- clone.id = nanoid();
- clone.children = clone.children.map((n) => traverseAndRenameIds(n));
- return clone;
- }
-
const rootItems: MethodTreeItem[] = [];
const lookup: { [id: string]: MethodTreeItem } = {};
@@ -2059,7 +2051,9 @@ function getMethodTreeArrayToTree(items: Method[]): MethodTreeItem[] {
}
}
- return rootItems.map((item) => traverseAndRenameIds(item));
+ // A sub-assembly used in two places is one node above: give each place an
+ // id of its own, the same on every load (see `withPathIds`).
+ return withPathIds(rootItems);
}
export type BomItemAttributes = {
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
index 3969053a77..db5eb906d1 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -214,12 +214,10 @@ const BillOfMaterial = ({
const [selectedItemId, setSelectedItemId] = useState<string | null>(null);
const [temporaryItems, setTemporaryItems] = useState<TemporaryItems>({});
const [checkedState, setCheckedState] = useState<CheckedState>({});
- const [orderState, setOrderState] = useState<OrderState>(() => {
- return initialMaterials.reduce((acc, material) => {
- acc[material.id!] = material.order;
- return acc;
- }, {} as OrderState);
- });
+ // Only the rows this session has reordered. Every other row takes its order
+ // from the loaded data: a copy of all of them taken at mount hid a reorder
+ // made anywhere else until the page was reloaded.
+ const [orderState, setOrderState] = useState<OrderState>({});
const materialsById = new Map<string, Material>();
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
index 4e600f5960..bf8fdb0454 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -311,12 +311,10 @@ const BillOfProcess = ({
}, {} as PendingWorkInstructions);
});
const [checkedState, setCheckedState] = useState<CheckedState>({});
- const [orderState, setOrderState] = useState<OrderState>(() => {
- return initialOperations.reduce((acc, op) => {
- acc[op.id!] = op.order;
- return acc;
- }, {} as OrderState);
- });
+ // Only the rows this session has reordered. Every other row takes its order
+ // from the loaded data: a copy of all of them taken at mount hid a reorder
+ // made anywhere else until the page was reloaded.
+ const [orderState, setOrderState] = useState<OrderState>({});
const operationsById = new Map<
string,
@@ -1887,7 +1885,8 @@ function AttributesForm({
// Update sort order when steps change
useEffect(() => {
- if (steps && steps.length > 0) {
+ // Also when the last step is deleted: its id must leave the order.
+ if (steps) {
const sorted = [...steps]
.sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0))
.map((step) => step.id || "");
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
index 13c394649e..ebd07fd397 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
@@ -310,12 +310,10 @@ const JobBillOfMaterial = ({
const [selectedItemId, setSelectedItemId] = useState<string | null>(null);
const [temporaryItems, setTemporaryItems] = useState<TemporaryItems>({});
const [checkedState, setCheckedState] = useState<CheckedState>({});
- const [orderState, setOrderState] = useState<OrderState>(() => {
- return initialMaterials.reduce((acc, material) => {
- acc[material.id!] = material.order;
- return acc;
- }, {} as OrderState);
- });
+ // Only the rows this session has reordered. Every other row takes its order
+ // from the loaded data: a copy of all of them taken at mount hid a reorder
+ // made anywhere else until the page was reloaded.
+ const [orderState, setOrderState] = useState<OrderState>({});
const materialsById = new Map<string, Material>();
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
index 5c26726e2b..3200fa8c18 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
@@ -543,12 +543,10 @@ const JobBillOfProcess = ({
});
const [checkedState, setCheckedState] = useState<CheckedState>({});
- const [orderState, setOrderState] = useState<OrderState>(() => {
- return initialOperations.reduce((acc, op) => {
- acc[op.id!] = op.order;
- return acc;
- }, {} as OrderState);
- });
+ // Only the rows this session has reordered. Every other row takes its order
+ // from the loaded data: a copy of all of them taken at mount hid a reorder
+ // made anywhere else until the page was reloaded.
+ const [orderState, setOrderState] = useState<OrderState>({});
const operationsById = new Map<
string,
@@ -1116,7 +1114,8 @@ function StepsForm({
// Update sort order when steps change
useEffect(() => {
- if (steps && steps.length > 0) {
+ // Also when the last step is deleted: its id must leave the order.
+ if (steps) {
const sorted = [...steps]
.sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0))
.map((step) => step.id || "");
diff --git a/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx b/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx
index 8c34b780f1..63f6f767c9 100644
--- a/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx
+++ b/apps/erp/app/modules/production/ui/Planning/ProductionPlanningTable.tsx
@@ -26,10 +26,10 @@ import { useDateFormatter, useNumberFormatter } from "@react-aria/i18n";
import type { ColumnDef } from "@tanstack/react-table";
import {
useCallback,
+ useDeferredValue,
useEffect,
useMemo,
- useState,
- useTransition
+ useState
} from "react";
import {
LuBlocks,
@@ -204,9 +204,17 @@ const ProductionPlanningTable = ({
{}
);
- const [ordersByItemId, setOrdersByItemId] = useState<
- Map<string, ProductionOrder[]>
- >(new Map());
+ // Computed from the rows, a render behind them so a large plan does not
+ // block typing; `isPending` covers the gap.
+ const deferredData = useDeferredValue(data);
+ const isPending = deferredData !== data;
+ const ordersByItemId = useMemo(() => {
+ const orders = new Map<string, ProductionOrder[]>();
+ for (const item of deferredData) {
+ orders.set(item.id, getProductionOrdersFromPlanning(item, periods));
+ }
+ return orders;
+ }, [deferredData, periods]);
// biome-ignore lint/correctness/useExhaustiveDependencies: suppressed due to migration
const onBulkUpdate = useCallback(
@@ -281,22 +289,6 @@ const ProductionPlanningTable = ({
[]
);
- const [isPending, startTransition] = useTransition();
-
- // biome-ignore lint/correctness/useExhaustiveDependencies: suppressed due to migration
- useEffect(() => {
- startTransition(() => {
- const ordersByItemId = new Map<string, ProductionOrder[]>();
- data.forEach((item) => {
- ordersByItemId.set(
- item.id,
- getProductionOrdersFromPlanning(item, periods)
- );
- });
- setOrdersByItemId(ordersByItemId);
- });
- }, [data]);
-
// biome-ignore lint/correctness/useExhaustiveDependencies: suppressed due to migration
const columns = useMemo<ColumnDef<ProductionPlanningItem>[]>(() => {
const periodColumns: ColumnDef<ProductionPlanningItem>[] = periods.map(
diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/DateKanban.tsx b/apps/erp/app/modules/production/ui/Schedule/Kanban/DateKanban.tsx
index e494fe286a..697200eb2a 100644
--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/DateKanban.tsx
+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/DateKanban.tsx
@@ -26,6 +26,7 @@ import {
useCallback,
useContext,
useEffect,
+ useMemo,
useRef,
useState
} from "react";
@@ -280,14 +281,7 @@ const DateKanban = ({
);
// For date-based kanban, always use the column order from props (don't persist)
- const [columnOrder, setColumnOrder] = useState<string[]>(
- columns.map((col) => col.id)
- );
-
- // Update column order when columns change (e.g., navigating to a different week/month)
- useEffect(() => {
- setColumnOrder(columns.map((col) => col.id));
- }, [columns]);
+ const columnOrder = useMemo(() => columns.map((col) => col.id), [columns]);
const itemsById = new Map<string, JobItem>(
initialItems.map((item) => [item.id, item])
diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/Kanban.tsx b/apps/erp/app/modules/production/ui/Schedule/Kanban/Kanban.tsx
index e52554de8e..503fd1a4ee 100644
--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/Kanban.tsx
+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/Kanban.tsx
@@ -3,6 +3,7 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { ClientOnly, cn, toast } from "@carbon/react";
+import { withUnorderedLast } from "@carbon/utils";
import type {
Active,
Announcements,
@@ -401,27 +402,25 @@ const Kanban = ({
}, [batchUpdateFetchers]);
const [selectedGroup, setSelectedGroup] = useState<string | null>(null);
- const [columnOrder, setColumnOrder] = useState<string[]>(() => {
- // Get stored column order from localStorage
- const storedOrder = localStorage.getItem(COLUMN_ORDER_KEY);
- if (storedOrder) {
- const parsedOrder = JSON.parse(storedOrder) as string[];
- // Add any new columns that aren't in stored order
- const newOrder = [...parsedOrder];
- columns.forEach((col) => {
- if (!newOrder.includes(col.id)) {
- newOrder.push(col.id);
- }
- });
- return newOrder;
- }
- return columns.map((col) => col.id);
+ // Only the order the user chose is state. The columns come from the loader
+ // and change while the board is open (a filter, a work center's first
+ // operation): one copied in at mount never showed a column that arrived later.
+ const [storedOrder, setStoredOrder] = useState<string[]>(() => {
+ const stored = localStorage.getItem(COLUMN_ORDER_KEY);
+ return stored ? (JSON.parse(stored) as string[]) : [];
});
+ const columnOrder = useMemo(
+ () =>
+ withUnorderedLast(
+ storedOrder,
+ columns.map((col) => col.id)
+ ),
+ [storedOrder, columns]
+ );
- // Update localStorage when column order changes
useEffect(() => {
- localStorage.setItem(COLUMN_ORDER_KEY, JSON.stringify(columnOrder));
- }, [columnOrder]);
+ localStorage.setItem(COLUMN_ORDER_KEY, JSON.stringify(storedOrder));
+ }, [storedOrder]);
const pendingItems = usePendingItems();
// The board re-renders on every drag state change. Deriving these once per
@@ -725,7 +724,7 @@ const Kanban = ({
const overColumnIndex = columnOrder.findIndex((id) => id === overId);
if (activeColumnIndex >= 0 && overColumnIndex >= 0) {
- setColumnOrder(
+ setStoredOrder(
arrayMove(columnOrder, activeColumnIndex, overColumnIndex)
);
}
diff --git a/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx b/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx
index febee22b0a..eea56d345e 100644
--- a/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx
+++ b/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx
@@ -28,10 +28,10 @@ import type { ColumnDef } from "@tanstack/react-table";
import {
memo,
useCallback,
+ useDeferredValue,
useEffect,
useMemo,
- useState,
- useTransition
+ useState
} from "react";
import {
LuBlocks,
@@ -211,9 +211,26 @@ const PlanningTable = memo(
// Auto-computed planned orders for every row, used as the fallback when
// bulk-submitting items the user never opened in the drawer.
- const [ordersByItemId, setOrdersByItemId] = useState<
- Map<string, PlannedOrder[]>
- >(new Map());
+ // Computed from the rows and the supplier chosen for each, a render
+ // behind them so a large plan does not block typing; `isPending` covers
+ // the gap.
+ const deferredData = useDeferredValue(data);
+ const isPending = deferredData !== data;
+ const ordersByItemId = useMemo(() => {
+ const orders = new Map<string, PlannedOrder[]>();
+ for (const item of deferredData) {
+ orders.set(
+ item.id,
+ getPurchaseOrdersFromPlanning(
+ item,
+ periods,
+ items,
+ suppliersMap[item.id]
+ )
+ );
+ }
+ return orders;
+ }, [deferredData, periods, items, suppliersMap]);
// Clear local state when data changes (e.g., filters, search)
// biome-ignore lint/correctness/useExhaustiveDependencies: suppressed due to migration
@@ -313,27 +330,6 @@ const PlanningTable = memo(
[]
);
- const [isPending, startTransition] = useTransition();
-
- // biome-ignore lint/correctness/useExhaustiveDependencies: suppressed due to migration
- useEffect(() => {
- startTransition(() => {
- const ordersByItemId = new Map<string, PlannedOrder[]>();
- data.forEach((item) => {
- ordersByItemId.set(
- item.id,
- getPurchaseOrdersFromPlanning(
- item,
- periods,
- items,
- suppliersMap[item.id]
- )
- );
- });
- setOrdersByItemId(ordersByItemId);
- });
- }, [data]);
-
// biome-ignore lint/correctness/useExhaustiveDependencies: suppressed due to migration
const columns = useMemo<ColumnDef<PurchasingPlanningItem>[]>(() => {
const periodColumns: ColumnDef<PurchasingPlanningItem>[] = periods.map(
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
index bd82b526dc..0daa5046ac 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
@@ -300,12 +300,10 @@ const QuoteBillOfMaterial = ({
const [selectedItemId, setSelectedItemId] = useState<string | null>(null);
const [temporaryItems, setTemporaryItems] = useState<TemporaryItems>({});
const [checkedState, setCheckedState] = useState<CheckedState>({});
- const [orderState, setOrderState] = useState<OrderState>(() => {
- return initialMaterials.reduce((acc, material) => {
- acc[material.id!] = material.order;
- return acc;
- }, {} as OrderState);
- });
+ // Only the rows this session has reordered. Every other row takes its order
+ // from the loaded data: a copy of all of them taken at mount hid a reorder
+ // made anywhere else until the page was reloaded.
+ const [orderState, setOrderState] = useState<OrderState>({});
const materialsById = new Map<string, Material>();
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
index 7c51f597f6..9ecfea6358 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
@@ -346,12 +346,10 @@ const QuoteBillOfProcess = ({
}, {} as PendingWorkInstructions);
});
const [checkedState, setCheckedState] = useState<CheckedState>({});
- const [orderState, setOrderState] = useState<OrderState>(() => {
- return initialOperations.reduce((acc, op) => {
- acc[op.id!] = op.order;
- return acc;
- }, {} as OrderState);
- });
+ // Only the rows this session has reordered. Every other row takes its order
+ // from the loaded data: a copy of all of them taken at mount hid a reorder
+ // made anywhere else until the page was reloaded.
+ const [orderState, setOrderState] = useState<OrderState>({});
const { t } = useLingui();
@@ -861,7 +859,8 @@ function AttributesForm({
// Update sort order when steps change
useEffect(() => {
- if (steps && steps.length > 0) {
+ // Also when the last step is deleted: its id must leave the order.
+ if (steps) {
const sorted = [...steps]
.sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0))
.map((step) => step.id || "");
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx
index ddc3f61cdb..2e4092cce3 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx
@@ -25,8 +25,7 @@ import {
import { Trans } from "@lingui/react/macro";
import { useLocale } from "@react-aria/i18n";
import { motion } from "motion/react";
-import type { Dispatch, SetStateAction } from "react";
-import { useEffect, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useState } from "react";
import { LuChevronRight, LuImage } from "react-icons/lu";
import { Link, useParams } from "react-router";
import {
@@ -51,53 +50,24 @@ import type {
QuotationShipment,
SalesOrderLine
} from "../../types";
-
-type SelectedLine = {
- quantity: number;
- netUnitPrice: number;
- convertedNetUnitPrice: number;
- addOn: number;
- convertedAddOn: number;
- taxableAddOn: number;
- convertedTaxableAddOn: number;
- leadTime: number;
- shippingCost: number;
- convertedShippingCost: number;
- taxPercent: number;
- discountPercent: number;
- unitPrice: number;
- convertedUnitPrice: number;
-};
-
-const deselectedLine: SelectedLine = {
- addOn: 0,
- convertedAddOn: 0,
- taxableAddOn: 0,
- convertedTaxableAddOn: 0,
- netUnitPrice: 0,
- convertedNetUnitPrice: 0,
- quantity: 0,
- leadTime: 0,
- shippingCost: 0,
- convertedShippingCost: 0,
- taxPercent: 0,
- discountPercent: 0,
- unitPrice: 0,
- convertedUnitPrice: 0
-};
+import {
+ deselectedLine,
+ type SelectedLine,
+ selectQuoteLines
+} from "./quote-summary-selection";
const LineItems = ({
currencyCode,
formatter,
locale,
selectedLines,
- setSelectedLines
+ onSelectQuantity
}: {
currencyCode: string;
formatter: Intl.NumberFormat;
locale: string;
selectedLines: Record<string, SelectedLine>;
- setSelectedLines: Dispatch<SetStateAction<Record<string, SelectedLine>>>;
+ onSelectQuantity: (lineId: string, quantity: number) => void;
}) => {
// Settlement money at the document currency's configured decimals.
const currencyDecimals = useCurrencyDecimals(currencyCode);
@@ -263,7 +233,7 @@ const LineItems = ({
shouldConvertCurrency={shouldConvertCurrency}
locale={locale}
selectedLine={selectedLine}
- setSelectedLines={setSelectedLines}
+ onSelectQuantity={onSelectQuantity}
/>
</motion.div>
</motion.div>
@@ -282,7 +252,7 @@ type LinePricingOptionsProps = {
locale: string;
formatter: Intl.NumberFormat;
selectedLine: SelectedLine;
- setSelectedLines: Dispatch<SetStateAction<Record<string, SelectedLine>>>;
+ onSelectQuantity: (lineId: string, quantity: number) => void;
};
const LinePricingOptions = ({
@@ -294,7 +264,7 @@ const LinePricingOptions = ({
locale,
formatter,
selectedLine,
- setSelectedLines
+ onSelectQuantity
}: LinePricingOptionsProps) => {
// Settlement money at the document currency's configured decimals.
const currencyDecimals = useCurrencyDecimals(quoteCurrency);
@@ -306,9 +276,7 @@ const LinePricingOptions = ({
salesOrderLines: SalesOrderLine[];
}>(path.to.quote(quoteId));
- const [selectedValue, setSelectedValue] = useState<string | null>(
- selectedLine?.quantity?.toString() ?? null
- );
+ const selectedValue = selectedLine.quantity.toString();
const additionalChargesByQuantity =
line.quantity?.reduce(
@@ -336,33 +304,6 @@ const LinePricingOptions = ({
{ 0: 0 }
);
- const taxableAdditionalChargesByQuantity =
- line.quantity?.reduce(
- (acc, quantity) => {
- const charges = Object.values(line.additionalCharges ?? {}).reduce(
- (chargeAcc, charge) => {
- if (charge.taxable === false) return chargeAcc;
- const amount = charge.amounts?.[quantity];
- return chargeAcc + amount;
- },
- 0
- );
- acc[quantity] = charges;
- return acc;
- },
- { 0: 0 } as Record<number, number>
- ) ?? {};
-
- const convertedTaxableAdditionalChargesByQuantity = Object.entries(
- taxableAdditionalChargesByQuantity
- ).reduce<Record<number, number>>(
- (acc, [quantity, amount]) => {
- acc[Number(quantity)] = amount * quoteExchangeRate;
- return acc;
- },
- { 0: 0 }
- );
-
const additionalCharges: { name: string; amount: number }[] = [];
if (selectedLine.convertedShippingCost) {
additionalCharges.push({
@@ -388,48 +329,16 @@ const LinePricingOptions = ({
<VStack spacing={4}>
<RadioGroup
className="w-full"
- value={selectedValue ?? undefined}
+ value={selectedValue}
disabled={["Ordered", "Partial", "Expired", "Cancelled"].includes(
routeData?.quote.status ?? ""
)}
onValueChange={(value) => {
- const selectedOption =
- value === "0"
- ? deselectedLine
- : options.find((opt) => opt.quantity.toString() === value);
-
- if (selectedOption) {
- setSelectedLines((prev) => ({
- ...prev,
- [line.id!]: {
- quantity: selectedOption.quantity,
- netUnitPrice: selectedOption.netUnitPrice ?? 0,
- convertedNetUnitPrice:
- selectedOption.convertedNetUnitPrice ?? 0,
- addOn:
- additionalChargesByQuantity[selectedOption.quantity] || 0,
- convertedAddOn:
- convertedAdditionalChargesByQuantity[
- selectedOption.quantity
- ] || 0,
- taxableAddOn:
- taxableAdditionalChargesByQuantity[selectedOption.quantity] ||
- 0,
- convertedTaxableAddOn:
- convertedTaxableAdditionalChargesByQuantity[
- selectedOption.quantity
- ] || 0,
- leadTime: selectedOption.leadTime,
- shippingCost: selectedOption.shippingCost ?? 0,
- convertedShippingCost:
- selectedOption.convertedShippingCost ?? 0,
- taxPercent: line.taxPercent ?? 0,
- discountPercent: selectedOption.discountPercent ?? 0,
- unitPrice: selectedOption.unitPrice ?? 0,
- convertedUnitPrice: selectedOption.convertedUnitPrice ?? 0
- }
- }));
- setSelectedValue(value);
+ if (
+ value === "0" ||
+ options.some((opt) => opt.quantity.toString() === value)
+ ) {
+ onSelectQuantity(line.id!, Number(value));
}
}}
>
@@ -702,121 +611,30 @@ const QuoteSummary = ({
routeData?.quote?.currencyCode ?? "USD"
);
- const [selectedLines, setSelectedLines] = useState<
- Record<string, SelectedLine>
- >(() => {
- return (
- routeData?.lines?.reduce<Record<string, SelectedLine>>((acc, line) => {
- const salesOrderLine = routeData?.salesOrderLines?.find(
- (salesOrderLine) => salesOrderLine.id === line.id
- );
-
- if (
- Array.isArray(routeData?.salesOrderLines) &&
- routeData?.salesOrderLines.length > 0 &&
- !salesOrderLine
- ) {
- acc[line.id!] = deselectedLine;
- return acc;
- }
-
- const price = salesOrderLine
- ? routeData?.prices?.find(
- (price) =>
- price.quoteLineId === salesOrderLine.id &&
- price.quantity === salesOrderLine.saleQuantity
- )
- : routeData?.prices?.find(
- (price) =>
- price.quoteLineId === line.id &&
- line.quantity?.includes(price.quantity)
- );
- if (!line.id) {
- return acc;
- }
-
- if (!price) {
- acc[line.id] = deselectedLine;
- return acc;
- }
-
- const additionalChargesByQuantity =
- line.quantity?.reduce(
- (acc, quantity) => {
- const charges = Object.values(
- line.additionalCharges ?? {}
- ).reduce((chargeAcc, charge) => {
- const amount = charge.amounts?.[quantity];
- return chargeAcc + amount;
- }, 0);
- acc[quantity] = charges;
- return acc;
- },
- {} as Record<number, number>
- ) ?? {};
-
- const convertedAdditionalChargesByQuantity =
- Object.entries(additionalChargesByQuantity).reduce<
- Record<number, number>
- >(
- (acc, [quantity, amount]) => {
- acc[Number(quantity)] =
- amount * (routeData?.quote.exchangeRate ?? 1);
- return acc;
- },
- {} as Record<number, number>
- ) ?? {};
-
- const taxableAdditionalChargesByQuantity =
- line.quantity?.reduce(
- (acc, quantity) => {
- const charges = Object.values(
- line.additionalCharges ?? {}
- ).reduce((chargeAcc, charge) => {
- if (charge.taxable === false) return chargeAcc;
- const amount = charge.amounts?.[quantity];
- return chargeAcc + amount;
- }, 0);
- acc[quantity] = charges;
- return acc;
- },
- {} as Record<number, number>
- ) ?? {};
-
- const convertedTaxableAdditionalChargesByQuantity =
- Object.entries(taxableAdditionalChargesByQuantity).reduce<
- Record<number, number>
- >(
- (acc, [quantity, amount]) => {
- acc[Number(quantity)] =
- amount * (routeData?.quote.exchangeRate ?? 1);
- return acc;
- },
- {} as Record<number, number>
- ) ?? {};
-
- acc[line.id] = {
- quantity: price.quantity ?? 0,
- netUnitPrice: price.netUnitPrice ?? 0,
- convertedNetUnitPrice: price.convertedNetUnitPrice ?? 0,
- addOn: additionalChargesByQuantity[price.quantity] || 0,
- convertedAddOn:
- convertedAdditionalChargesByQuantity[price.quantity] || 0,
- taxableAddOn: taxableAdditionalChargesByQuantity[price.quantity] || 0,
- convertedTaxableAddOn:
- convertedTaxableAdditionalChargesByQuantity[price.quantity] || 0,
- leadTime: price.leadTime,
- shippingCost: price.shippingCost ?? 0,
- convertedShippingCost: price.convertedShippingCost ?? 0,
- taxPercent: line.taxPercent ?? 0,
- discountPercent: price.discountPercent ?? 0,
- unitPrice: price.unitPrice ?? 0,
- convertedUnitPrice: price.convertedUnitPrice ?? 0
- };
- return acc;
- }, {}) ?? {}
- );
- });
+ // Only what the user picked; everything else follows the quote's data.
+ const [picks, setPicks] = useState<Record<string, number>>({});
+ const selectedLines = useMemo(
+ () =>
+ selectQuoteLines({
+ lines: routeData?.lines,
+ prices: routeData?.prices,
+ salesOrderLines: routeData?.salesOrderLines,
+ exchangeRate: routeData?.quote.exchangeRate ?? 1,
+ picks
+ }),
+ [
+ routeData?.lines,
+ routeData?.prices,
+ routeData?.salesOrderLines,
+ routeData?.quote.exchangeRate,
+ picks
+ ]
+ );
+ const onSelectQuantity = useCallback(
+ (lineId: string, quantity: number) =>
+ setPicks((prev) => ({ ...prev, [lineId]: quantity })),
+ []
+ );
const subtotal = Object.values(selectedLines).reduce((acc, line) => {
return (
@@ -882,7 +700,7 @@ const QuoteSummary = ({
locale={locale}
formatter={formatter}
selectedLines={selectedLines}
- setSelectedLines={setSelectedLines}
+ onSelectQuantity={onSelectQuantity}
/>
<VStack spacing={2} className="mt-8">
diff --git a/apps/erp/app/modules/sales/ui/Quotes/quote-summary-selection.test.ts b/apps/erp/app/modules/sales/ui/Quotes/quote-summary-selection.test.ts
new file mode 100644
index 0000000000..ec15d60dd4
--- /dev/null
+++ b/apps/erp/app/modules/sales/ui/Quotes/quote-summary-selection.test.ts
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { describe, expect, it } from "vitest";
+import { selectQuoteLines } from "./quote-summary-selection";
+
+const price = (quoteLineId: string, quantity: number, net: number) => ({
+ quoteLineId,
+ quantity,
+ netUnitPrice: net,
+ convertedNetUnitPrice: net,
+ leadTime: 0,
+ shippingCost: 0,
+ convertedShippingCost: 0,
+ discountPercent: 0,
+ unitPrice: net,
+ convertedUnitPrice: net
+});
+const line = (id: string, quantity: number[]) => ({
+ id,
+ quantity,
+ additionalCharges: {},
+ taxPercent: 0
+});
+const select = (
+ lines: ReturnType<typeof line>[],
+ prices: ReturnType<typeof price>[],
+ picks: Record<string, number> = {}
+) =>
+ selectQuoteLines({
+ lines: lines as never,
+ prices: prices as never,
+ salesOrderLines: [],
+ exchangeRate: 1,
+ picks
+ });
+
+describe("selectQuoteLines", () => {
+ const prices = [price("a", 1, 73), price("a", 10, 60), price("b", 1, 20)];
+
+ it("takes each line's first priced break by default", () => {
+ const selected = select([line("a", [1, 10]), line("b", [1])], prices);
+ expect(selected.a?.convertedNetUnitPrice).toBe(73);
+ expect(selected.b?.convertedNetUnitPrice).toBe(20);
+ });
+
+ it("drops a deleted line, even one the user had picked a break for", () => {
+ const selected = select([line("b", [1])], prices, { a: 10 });
+ expect(Object.keys(selected)).toEqual(["b"]);
+ });
+
+ it("keeps a pick, and deselects on 0 or a break that no longer exists", () => {
+ const lines = [line("a", [1, 10])];
+ expect(select(lines, prices, { a: 10 }).a?.quantity).toBe(10);
+ expect(select(lines, prices, { a: 0 }).a?.quantity).toBe(0);
+ expect(select(lines, prices, { a: 25 }).a?.quantity).toBe(0);
+ });
+});
diff --git a/apps/erp/app/modules/sales/ui/Quotes/quote-summary-selection.ts b/apps/erp/app/modules/sales/ui/Quotes/quote-summary-selection.ts
new file mode 100644
index 0000000000..3d3c1d32b5
--- /dev/null
+++ b/apps/erp/app/modules/sales/ui/Quotes/quote-summary-selection.ts
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import type {
+ QuotationLine,
+ QuotationPrice,
+ SalesOrderLine
+} from "../../types";
+
+export type SelectedLine = {
+ quantity: number;
+ netUnitPrice: number;
+ convertedNetUnitPrice: number;
+ addOn: number;
+ convertedAddOn: number;
+ taxableAddOn: number;
+ convertedTaxableAddOn: number;
+ leadTime: number;
+ shippingCost: number;
+ convertedShippingCost: number;
+ taxPercent: number;
+ discountPercent: number;
+ unitPrice: number;
+ convertedUnitPrice: number;
+};
+
+export const deselectedLine: SelectedLine = {
+ addOn: 0,
+ convertedAddOn: 0,
+ taxableAddOn: 0,
+ convertedTaxableAddOn: 0,
+ netUnitPrice: 0,
+ convertedNetUnitPrice: 0,
+ quantity: 0,
+ leadTime: 0,
+ shippingCost: 0,
+ convertedShippingCost: 0,
+ taxPercent: 0,
+ discountPercent: 0,
+ unitPrice: 0,
+ convertedUnitPrice: 0
+};
+
+type Line = Pick<
+ QuotationLine,
+ "id" | "quantity" | "additionalCharges" | "taxPercent"
+>;
+type Price = Pick<
+ QuotationPrice,
+ | "quoteLineId"
+ | "quantity"
+ | "netUnitPrice"
+ | "convertedNetUnitPrice"
+ | "leadTime"
+ | "shippingCost"
+ | "convertedShippingCost"
+ | "discountPercent"
+ | "unitPrice"
+ | "convertedUnitPrice"
+>;
+
+function charges(line: Line, quantity: number, taxableOnly: boolean) {
+ return Object.values(line.additionalCharges ?? {}).reduce(
+ (total, charge) =>
+ taxableOnly && charge.taxable === false
+ ? total
+ : total + charge.amounts?.[quantity],
+ 0
+ );
+}
+
+function priced(line: Line, price: Price, exchangeRate: number): SelectedLine {
+ const addOn = charges(line, price.quantity, false) || 0;
+ const taxableAddOn = charges(line, price.quantity, true) || 0;
+ return {
+ quantity: price.quantity ?? 0,
+ netUnitPrice: price.netUnitPrice ?? 0,
+ convertedNetUnitPrice: price.convertedNetUnitPrice ?? 0,
+ addOn,
+ convertedAddOn: addOn * exchangeRate || 0,
+ taxableAddOn,
+ convertedTaxableAddOn: taxableAddOn * exchangeRate || 0,
+ leadTime: price.leadTime,
+ shippingCost: price.shippingCost ?? 0,
+ convertedShippingCost: price.convertedShippingCost ?? 0,
+ taxPercent: line.taxPercent ?? 0,
+ discountPercent: price.discountPercent ?? 0,
+ unitPrice: price.unitPrice ?? 0,
+ convertedUnitPrice: price.convertedUnitPrice ?? 0
+ };
+}
+
+/**
+ * The quantity break each quote line is totalled at, from the quote's CURRENT
+ * lines and prices. `picks` holds only what the user chose (line id → quantity,
+ * 0 for none); every other line takes its default: the ordered quantity when
+ * the quote became an order, else the first break that has a price.
+ *
+ * Derived on every render, never copied into state: a copy kept a deleted
+ * line in the totals until the page was reloaded.
+ */
+export function selectQuoteLines({
+ lines,
+ prices,
+ salesOrderLines,
+ exchangeRate,
+ picks
+}: {
+ lines: Line[] | undefined;
+ prices: Price[] | undefined;
+ salesOrderLines: Pick<SalesOrderLine, "id" | "saleQuantity">[] | undefined;
+ exchangeRate: number;
+ picks: Record<string, number>;
+}): Record<string, SelectedLine> {
+ const selected: Record<string, SelectedLine> = {};
+ const ordered = Array.isArray(salesOrderLines) && salesOrderLines.length > 0;
+
+ for (const line of lines ?? []) {
+ if (!line.id) continue;
+ const linePrices = (prices ?? []).filter((p) => p.quoteLineId === line.id);
+ const pick = picks[line.id];
+ const salesOrderLine = salesOrderLines?.find((s) => s.id === line.id);
+
+ let price: Price | undefined;
+ if (pick !== undefined) {
+ price =
+ pick === 0 ? undefined : linePrices.find((p) => p.quantity === pick);
+ } else if (salesOrderLine) {
+ price = linePrices.find(
+ (p) => p.quantity === salesOrderLine.saleQuantity
+ );
+ } else if (!ordered) {
+ price = linePrices.find((p) => line.quantity?.includes(p.quantity));
+ }
+
+ selected[line.id] = price
+ ? priced(line, price, exchangeRate)
+ : deselectedLine;
+ }
+ return selected;
+}
diff --git a/apps/erp/app/modules/shared/shared.server.ts b/apps/erp/app/modules/shared/shared.server.ts
index fa4c433c4a..b4e474f641 100644
--- a/apps/erp/app/modules/shared/shared.server.ts
+++ b/apps/erp/app/modules/shared/shared.server.ts
@@ -620,7 +620,7 @@ type CompanyScopedTable = {
}[keyof Tables];
/**
- * Throws a 404 `Response` unless a row of `table` in `companyId` matches every
+ * Throws a 404 `Response` naming the record unless a row of `table` in `companyId` matches every
* column in `match` — e.g. `{ id: lineId, quoteId }` proves the line exists,
* belongs to the company AND hangs off that quote. One query.
*
@@ -652,14 +652,27 @@ export async function requireCompanyRecord(
match,
error
});
- throw new Response("Not found", { status: 404 });
+ // The check itself failed: nothing is known about the record.
+ throw new Response(`Failed to verify the ${recordName(table)}`, {
+ status: 500
+ });
}
if (!data) {
logger.error("{table} not found for company", { table, companyId, match });
- throw new Response("Not found", { status: 404 });
+ // One message for a missing row and another company's row: the caller
+ // must not learn which.
+ throw new Response(
+ `The ${recordName(table)} could not be found. It may have been deleted, or it belongs to another company.`,
+ { status: 404 }
+ );
}
}
+/** `quoteLine` → `quote line`, for a message a person reads. */
+function recordName(table: string): string {
+ return table.replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase();
+}
+
// What `get_app_shell` returns: the rows the shell used to read with nine
// requests. Each key holds what `select("*")` on that table returned.
type AppShellRows = {
diff --git a/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunSteps.tsx b/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunSteps.tsx
index 368505936e..97b2cc5004 100644
--- a/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunSteps.tsx
+++ b/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunSteps.tsx
@@ -145,7 +145,10 @@ function StepRow({
}) {
const { t } = useLingui();
const label = useWorkflowLabel();
- const [expanded, setExpanded] = useState(defaultExpanded);
+ // Null until the user toggles the row: a step that fails while the run is
+ // being watched then opens on its own, as it does when the drawer is reopened.
+ const [toggled, setToggled] = useState<boolean | null>(null);
+ const expanded = toggled ?? defaultExpanded;
const [raw, setRaw] = useState(false);
const isNotReached = step === null;
@@ -177,7 +180,7 @@ function StepRow({
<button
type="button"
className="w-full flex items-center gap-3 py-3 px-3 hover:bg-muted/50 transition-colors text-left"
- onClick={() => hasDetail && setExpanded((p) => !p)}
+ onClick={() => hasDetail && setToggled(!expanded)}
disabled={!hasDetail}
>
{hasDetail ? (
diff --git a/apps/erp/app/routes/x+/account+/_layout.tsx b/apps/erp/app/routes/x+/account+/_layout.tsx
index 229f9c98b2..1f6138d846 100644
--- a/apps/erp/app/routes/x+/account+/_layout.tsx
+++ b/apps/erp/app/routes/x+/account+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import useAccountSubmodules from "~/modules/account/ui/useAccountSubmodules";
import type { Handle } from "~/utils/handle";
@@ -36,7 +36,7 @@ export default function AccountRoute() {
className="overflow-y-auto scrollbar-hide h-[calc(100dvh-var(--topbar-height)-var(--content-inset))]"
>
<VStack spacing={4} className="py-12 px-4 max-w-[60rem] h-full mx-auto">
- <Outlet />
+ <RecordOutlet />
</VStack>
</VStack>
);
diff --git a/apps/erp/app/routes/x+/accounting+/_layout.tsx b/apps/erp/app/routes/x+/accounting+/_layout.tsx
index 926ef09818..70d09e1e25 100644
--- a/apps/erp/app/routes/x+/accounting+/_layout.tsx
+++ b/apps/erp/app/routes/x+/accounting+/_layout.tsx
@@ -6,15 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getIntegrationIdsByRole } from "@carbon/ee";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import {
getAccountsList,
@@ -44,9 +40,6 @@ export const handle: Handle = {
sidebar: AccountingSidebar
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, companyGroupId } = await requirePermissions(
request,
@@ -92,7 +85,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function AccountingRoute() {
return (
<VStack spacing={0} className="relative h-full">
- <Outlet />
+ <RecordOutlet />
<AccountingBetaGate />
</VStack>
);
diff --git a/apps/erp/app/routes/x+/accounting+/asset-class.$assetClassId.tsx b/apps/erp/app/routes/x+/accounting+/asset-class.$assetClassId.tsx
index 8bf2d62601..8d123d5b2b 100644
--- a/apps/erp/app/routes/x+/accounting+/asset-class.$assetClassId.tsx
+++ b/apps/erp/app/routes/x+/accounting+/asset-class.$assetClassId.tsx
@@ -7,12 +7,8 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { useCloseRoute } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import {
fixedAssetClassValidator,
@@ -23,11 +19,6 @@ import { AssetClassForm } from "~/modules/accounting/ui/FixedAssets";
import { getCompanySettings } from "~/modules/settings";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["assetClassId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting"
diff --git a/apps/erp/app/routes/x+/accounting+/asset-classes.tsx b/apps/erp/app/routes/x+/accounting+/asset-classes.tsx
index 8f9ec41b7f..b0688fae05 100644
--- a/apps/erp/app/routes/x+/accounting+/asset-classes.tsx
+++ b/apps/erp/app/routes/x+/accounting+/asset-classes.tsx
@@ -3,15 +3,11 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { Button, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { Button, RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import { LuCirclePlus } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useNavigate } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useNavigate } from "react-router";
import { usePermissions } from "~/hooks";
import { getFixedAssetClasses } from "~/modules/accounting";
import { AssetClassesTable } from "~/modules/accounting/ui/FixedAssets";
@@ -25,11 +21,6 @@ export const handle: Handle = {
to: path.to.assetClasses
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting",
@@ -85,7 +76,7 @@ export default function AssetClassesRoute() {
)
}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/charts.tsx b/apps/erp/app/routes/x+/accounting+/charts.tsx
index bdba9dd23f..0dbbe1e32f 100644
--- a/apps/erp/app/routes/x+/accounting+/charts.tsx
+++ b/apps/erp/app/routes/x+/accounting+/charts.tsx
@@ -6,12 +6,12 @@ import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { useMemo, useState } from "react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { data, Outlet, useLoaderData } from "react-router";
+import { data, useLoaderData } from "react-router";
import { usePermissions, useSettings } from "~/hooks";
import type { Chart } from "~/modules/accounting";
import {
@@ -185,7 +185,7 @@ export default function ChartOfAccountsRoute() {
setAmounts((prev) => ({ ...prev, [accountId]: value }))
}
/>
- <Outlet />
+ <RecordOutlet />
<OpeningBalancePostModal
open={postModalOpen}
onClose={() => setPostModalOpen(false)}
diff --git a/apps/erp/app/routes/x+/accounting+/cost-centers.tsx b/apps/erp/app/routes/x+/accounting+/cost-centers.tsx
index f89abecf7b..d6ee92abb4 100644
--- a/apps/erp/app/routes/x+/accounting+/cost-centers.tsx
+++ b/apps/erp/app/routes/x+/accounting+/cost-centers.tsx
@@ -9,20 +9,18 @@ import { getApprovalRulesForApprover } from "@carbon/ee/approvals.server";
import {
Heading,
HStack,
+ RecordOutlet,
Tabs,
TabsContent,
TabsList,
TabsTrigger
} from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { useLingui } from "@lingui/react/macro";
import { useCallback } from "react";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useNavigate } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useNavigate } from "react-router";
import { New } from "~/components";
import { getCostCentersTree } from "~/modules/accounting";
import {
@@ -37,9 +35,6 @@ export const handle: Handle = {
to: path.to.costCenters
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting",
@@ -128,7 +123,7 @@ export default function Route() {
/>
</TabsContent>
- <Outlet />
+ <RecordOutlet />
</Tabs>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/depreciation-runs.tsx b/apps/erp/app/routes/x+/accounting+/depreciation-runs.tsx
index 7a0258895c..aa93023616 100644
--- a/apps/erp/app/routes/x+/accounting+/depreciation-runs.tsx
+++ b/apps/erp/app/routes/x+/accounting+/depreciation-runs.tsx
@@ -12,13 +12,10 @@ import {
useDisclosure,
VStack
} from "@carbon/react";
-import { formatDate, isUnaffectedByNavigation } from "@carbon/utils";
+import { formatDate } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { LuCirclePlus } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData, useNavigate } from "react-router";
import { Confirm } from "~/components/Modals";
import { usePermissions } from "~/hooks";
@@ -34,11 +31,6 @@ export const handle: Handle = {
to: path.to.depreciationRuns
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting",
diff --git a/apps/erp/app/routes/x+/accounting+/dimensions.tsx b/apps/erp/app/routes/x+/accounting+/dimensions.tsx
index 817a10344d..85768e7def 100644
--- a/apps/erp/app/routes/x+/accounting+/dimensions.tsx
+++ b/apps/erp/app/routes/x+/accounting+/dimensions.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getDimensions } from "~/modules/accounting";
import { DimensionsTable } from "~/modules/accounting/ui/Dimensions";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.dimensions
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyGroupId } = await requirePermissions(request, {
view: "accounting",
@@ -54,7 +45,7 @@ export default function DimensionsRoute() {
return (
<VStack spacing={0} className="h-full">
<DimensionsTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/exchange-rates.tsx b/apps/erp/app/routes/x+/accounting+/exchange-rates.tsx
index 923738993c..282fee55ff 100644
--- a/apps/erp/app/routes/x+/accounting+/exchange-rates.tsx
+++ b/apps/erp/app/routes/x+/accounting+/exchange-rates.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getCurrencies, getExchangeRates } from "~/modules/accounting";
import { ExchangeRatesTable } from "~/modules/accounting/ui/ExchangeRates";
import type { Handle } from "~/utils/handle";
@@ -24,11 +21,6 @@ export const handle: Handle = {
to: path.to.exchangeRates
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, companyGroupId } = await requirePermissions(
request,
@@ -96,7 +88,7 @@ export default function ExchangeRatesRoute() {
return (
<VStack spacing={0} className="h-full">
<ExchangeRatesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/fixed-assets.tsx b/apps/erp/app/routes/x+/accounting+/fixed-assets.tsx
index 444c918e31..f640e2c997 100644
--- a/apps/erp/app/routes/x+/accounting+/fixed-assets.tsx
+++ b/apps/erp/app/routes/x+/accounting+/fixed-assets.tsx
@@ -3,15 +3,11 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { Button, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { Button, RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import { LuCirclePlus } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useNavigate } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useNavigate } from "react-router";
import { usePermissions } from "~/hooks";
import { getFixedAssetClassesList, getFixedAssets } from "~/modules/accounting";
import { FixedAssetsTable } from "~/modules/accounting/ui/FixedAssets";
@@ -24,11 +20,6 @@ export const handle: Handle = {
to: path.to.fixedAssets
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting",
@@ -89,7 +80,7 @@ export default function FixedAssetsRoute() {
)
}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/intercompany.tsx b/apps/erp/app/routes/x+/accounting+/intercompany.tsx
index d9346f7b25..b0fa009cf2 100644
--- a/apps/erp/app/routes/x+/accounting+/intercompany.tsx
+++ b/apps/erp/app/routes/x+/accounting+/intercompany.tsx
@@ -3,15 +3,11 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { Button, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { Button, RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import { useLingui } from "@lingui/react/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useFetcher, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useFetcher, useLoaderData } from "react-router";
import { New } from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import { getIntercompanyTransactions } from "~/modules/accounting";
@@ -25,11 +21,6 @@ export const handle: Handle = {
to: path.to.intercompany
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyGroupId } = await requirePermissions(request, {
view: "accounting",
@@ -110,7 +101,7 @@ export default function IntercompanyRoute() {
)
}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/journals.tsx b/apps/erp/app/routes/x+/accounting+/journals.tsx
index 8b812dc908..339f0eff38 100644
--- a/apps/erp/app/routes/x+/accounting+/journals.tsx
+++ b/apps/erp/app/routes/x+/accounting+/journals.tsx
@@ -3,15 +3,11 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { Button, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { Button, RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import { LuCirclePlus } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useFetcher, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useFetcher, useLoaderData } from "react-router";
import { usePermissions } from "~/hooks";
import { getJournalEntries } from "~/modules/accounting";
import { JournalEntriesTable } from "~/modules/accounting/ui/JournalEntries";
@@ -24,11 +20,6 @@ export const handle: Handle = {
to: path.to.accountingJournals
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting",
@@ -86,7 +77,7 @@ export default function JournalEntriesRoute() {
permissions.can("create", "accounting") && <NewJournalEntry />
}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/payment-terms.tsx b/apps/erp/app/routes/x+/accounting+/payment-terms.tsx
index f998b3fb1e..3c10f91259 100644
--- a/apps/erp/app/routes/x+/accounting+/payment-terms.tsx
+++ b/apps/erp/app/routes/x+/accounting+/payment-terms.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getPaymentTerms } from "~/modules/accounting";
import { PaymentTermsTable } from "~/modules/accounting/ui/PaymentTerms";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.paymentTerms
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting",
@@ -54,7 +45,7 @@ export default function PaymentTermsRoute() {
return (
<VStack spacing={0} className="h-full">
<PaymentTermsTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/periods.tsx b/apps/erp/app/routes/x+/accounting+/periods.tsx
index f16d9deff1..18d8dd5037 100644
--- a/apps/erp/app/routes/x+/accounting+/periods.tsx
+++ b/apps/erp/app/routes/x+/accounting+/periods.tsx
@@ -5,16 +5,13 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { Button, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { Button, RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { LuCalendarPlus } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useNavigate } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useNavigate } from "react-router";
import { usePermissions } from "~/hooks";
import { getAccountingPeriods } from "~/modules/accounting";
import { PeriodsTable } from "~/modules/accounting/ui/Periods";
@@ -26,9 +23,6 @@ export const handle: Handle = {
to: path.to.accountingPeriods
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting",
@@ -71,7 +65,7 @@ export default function AccountingPeriodsRoute() {
) : undefined
}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/projects.tsx b/apps/erp/app/routes/x+/accounting+/projects.tsx
index 961e6b2fa7..a63fd9e95f 100644
--- a/apps/erp/app/routes/x+/accounting+/projects.tsx
+++ b/apps/erp/app/routes/x+/accounting+/projects.tsx
@@ -5,14 +5,10 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { data, Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { data, useLoaderData } from "react-router";
import { getProjects } from "~/modules/accounting";
import { ProjectsTable } from "~/modules/accounting/ui/Projects";
import type { Handle } from "~/utils/handle";
@@ -24,11 +20,6 @@ export const handle: Handle = {
to: path.to.projects
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting",
@@ -65,7 +56,7 @@ export default function ProjectsRoute() {
return (
<VStack spacing={0} className="h-full">
<ProjectsTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/sync-tieout.tsx b/apps/erp/app/routes/x+/accounting+/sync-tieout.tsx
index 03f3ba472f..9561a5be9c 100644
--- a/apps/erp/app/routes/x+/accounting+/sync-tieout.tsx
+++ b/apps/erp/app/routes/x+/accounting+/sync-tieout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { useRouteData } from "~/hooks";
import { getAccountingSyncTieOut } from "~/modules/accounting";
import { SyncTieOutTable } from "~/modules/accounting/ui/SyncTieOut";
@@ -34,11 +30,6 @@ function filterValues(
return match.operator === "in" ? match.value.split(",") : [match.value];
}
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting",
@@ -94,7 +85,7 @@ export default function SyncTieOutRoute() {
integrations={integrations}
accounts={accounts}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/assembly+/$id.tsx b/apps/erp/app/routes/x+/assembly+/$id.tsx
index 76415eb7ee..4399a9ce51 100644
--- a/apps/erp/app/routes/x+/assembly+/$id.tsx
+++ b/apps/erp/app/routes/x+/assembly+/$id.tsx
@@ -15,7 +15,7 @@ import {
useInterval,
useMode
} from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import type {
AssemblyGraph,
AssemblyPlayerHandle,
@@ -31,11 +31,7 @@ import {
import { msg } from "@lingui/core/macro";
import { useLingui } from "@lingui/react/macro";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import {
data,
useFetcher,
@@ -80,11 +76,6 @@ export const handle: Handle = {
module: "production"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "production",
diff --git a/apps/erp/app/routes/x+/assembly+/_layout.tsx b/apps/erp/app/routes/x+/assembly+/_layout.tsx
index 0764b229c6..2342cd34f9 100644
--- a/apps/erp/app/routes/x+/assembly+/_layout.tsx
+++ b/apps/erp/app/routes/x+/assembly+/_layout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -20,9 +16,6 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Assembly" }];
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
await requirePermissions(request, {
view: "production"
@@ -38,5 +31,5 @@ export const handle: Handle = {
};
export default function AssemblyRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/change-notice+/_layout.tsx b/apps/erp/app/routes/x+/change-notice+/_layout.tsx
index ea411443ee..9cc03753ca 100644
--- a/apps/erp/app/routes/x+/change-notice+/_layout.tsx
+++ b/apps/erp/app/routes/x+/change-notice+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function ChangeNoticeRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx
index 5d8d4e355d..66d8d5d678 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx
@@ -7,12 +7,8 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { useRouteData } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { useLoaderData, useNavigate, useParams } from "react-router";
import type { ConsumableSummary } from "~/modules/items";
import { supplierPartValidator, upsertSupplierPart } from "~/modules/items";
@@ -21,11 +17,6 @@ import { getDatabaseClient } from "~/services/database.server";
import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId", "supplierPartId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.tsx
index 2861966e7c..8639784361 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.tsx
@@ -7,13 +7,9 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { Suspense } from "react";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { Await, useLoaderData, useParams } from "react-router";
import { useRouteData } from "~/hooks";
import { getBatchProperties } from "~/modules/inventory";
@@ -27,11 +23,6 @@ import {
import { ItemPurchasingForm, SupplierParts } from "~/modules/items/ui/Item";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.tsx
index 824d5ccf9b..ae1a0b0660 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.tsx
@@ -5,15 +5,12 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { useRouteData } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, useRouteData } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Suspense } from "react";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { Await, useLoaderData, useParams } from "react-router";
import { ResizablePanels } from "~/components/Layout";
import type { ConsumableSummary, ItemFile } from "~/modules/items";
import {
@@ -42,11 +39,6 @@ export const handle: Handle = {
module: "items"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -240,7 +232,7 @@ export default function ConsumableRoute() {
}
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
- <Outlet />
+ <RecordOutlet />
</div>
}
properties={<ConsumableProperties key={itemId} />}
diff --git a/apps/erp/app/routes/x+/consumable+/_layout.tsx b/apps/erp/app/routes/x+/consumable+/_layout.tsx
index efe593a931..971a37c9e3 100644
--- a/apps/erp/app/routes/x+/consumable+/_layout.tsx
+++ b/apps/erp/app/routes/x+/consumable+/_layout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import { getUnitOfMeasuresList } from "~/modules/items";
import { getLocationsList } from "~/modules/resources";
import type { Handle } from "~/utils/handle";
@@ -28,9 +24,6 @@ export const handle: Handle = {
module: "items"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
@@ -48,5 +41,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function ConsumableRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/credits+/$memoId.tsx b/apps/erp/app/routes/x+/credits+/$memoId.tsx
index db956738d8..6a9690c5cb 100644
--- a/apps/erp/app/routes/x+/credits+/$memoId.tsx
+++ b/apps/erp/app/routes/x+/credits+/$memoId.tsx
@@ -7,13 +7,9 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { data, useLoaderData } from "react-router";
import {
getMemo,
@@ -47,15 +43,6 @@ export const handle: Handle = {
module: "invoicing"
};
-// A memo is just the credit/debit document — create it, then post it. Applying
-// it to invoices happens on the payment/receipt screen (alongside cash), so the
-// settlement UI lives in one place. The invoice's "Applied" panel shows where a
-// posted credit ended up.
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["memoId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "invoicing"
diff --git a/apps/erp/app/routes/x+/credits+/_layout.tsx b/apps/erp/app/routes/x+/credits+/_layout.tsx
index 04ea5106be..116bc1bcd2 100644
--- a/apps/erp/app/routes/x+/credits+/_layout.tsx
+++ b/apps/erp/app/routes/x+/credits+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function MemosRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/customer+/$customerId.bank-accounts.tsx b/apps/erp/app/routes/x+/customer+/$customerId.bank-accounts.tsx
index b620b86750..beb6c4b5c9 100644
--- a/apps/erp/app/routes/x+/customer+/$customerId.bank-accounts.tsx
+++ b/apps/erp/app/routes/x+/customer+/$customerId.bank-accounts.tsx
@@ -5,21 +5,13 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import { getCustomerBankAccounts } from "~/modules/sales";
import CustomerBankAccounts from "~/modules/sales/ui/Customer/CustomerBankAccounts";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["customerId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "accounting"
diff --git a/apps/erp/app/routes/x+/customer+/$customerId.contacts.tsx b/apps/erp/app/routes/x+/customer+/$customerId.contacts.tsx
index ec2477c757..1d56bd0775 100644
--- a/apps/erp/app/routes/x+/customer+/$customerId.contacts.tsx
+++ b/apps/erp/app/routes/x+/customer+/$customerId.contacts.tsx
@@ -5,21 +5,13 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import { getCustomerContacts } from "~/modules/sales";
import { CustomerContacts } from "~/modules/sales/ui/Customer";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["customerId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "sales"
diff --git a/apps/erp/app/routes/x+/customer+/$customerId.locations.tsx b/apps/erp/app/routes/x+/customer+/$customerId.locations.tsx
index d59ebec1b1..fd22db842d 100644
--- a/apps/erp/app/routes/x+/customer+/$customerId.locations.tsx
+++ b/apps/erp/app/routes/x+/customer+/$customerId.locations.tsx
@@ -5,21 +5,13 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import { getCustomerLocations } from "~/modules/sales";
import { CustomerLocations } from "~/modules/sales/ui/Customer";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["customerId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "sales"
diff --git a/apps/erp/app/routes/x+/customer+/$customerId.tsx b/apps/erp/app/routes/x+/customer+/$customerId.tsx
index 1b5b7fe28d..cd9569000b 100644
--- a/apps/erp/app/routes/x+/customer+/$customerId.tsx
+++ b/apps/erp/app/routes/x+/customer+/$customerId.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { cn } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { cn, RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+
import { usePermissions } from "~/hooks";
import {
getCustomer,
@@ -33,11 +30,6 @@ export const handle: Handle = {
module: "sales"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["customerId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales"
@@ -85,7 +77,7 @@ export default function CustomerRoute() {
})}
>
{isEmployee && <CustomerSidebar />}
- <Outlet />
+ <RecordOutlet />
</div>
</>
);
diff --git a/apps/erp/app/routes/x+/customer+/_layout.tsx b/apps/erp/app/routes/x+/customer+/_layout.tsx
index 8e44061d0a..4c1657b915 100644
--- a/apps/erp/app/routes/x+/customer+/_layout.tsx
+++ b/apps/erp/app/routes/x+/customer+/_layout.tsx
@@ -3,15 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import { getCustomerStatuses, getCustomerTypes } from "~/modules/sales";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -28,9 +23,6 @@ export const handle: Handle = {
module: "sales"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales"
@@ -58,7 +50,7 @@ export default function CustomerRoute() {
return (
<div className="flex h-full w-full justify-center bg-card">
<VStack spacing={4} className="h-full p-4 w-full max-w-[80rem]">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
);
diff --git a/apps/erp/app/routes/x+/depreciation-run+/$depreciationRunId.tsx b/apps/erp/app/routes/x+/depreciation-run+/$depreciationRunId.tsx
index d1da9b0cae..aa4d54f473 100644
--- a/apps/erp/app/routes/x+/depreciation-run+/$depreciationRunId.tsx
+++ b/apps/erp/app/routes/x+/depreciation-run+/$depreciationRunId.tsx
@@ -20,18 +20,15 @@ import {
HStack,
IconButton,
MENU_ITEM_SHORTCUTS,
+ RecordOutlet,
useDisclosure
} from "@carbon/react";
-import { formatDate, isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { formatDate, redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { LuEllipsisVertical, LuRepeat, LuTrash } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import {
Link,
- Outlet,
useFetcher,
useLoaderData,
useNavigate,
@@ -58,11 +55,6 @@ export const handle: Handle = {
module: "accounting"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["depreciationRunId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "accounting"
@@ -312,7 +304,7 @@ export default function DepreciationRunDetailRoute() {
</CardContent>
</Card>
- <Outlet />
+ <RecordOutlet />
<ConfirmDelete
action={path.to.deleteDepreciationRun(depreciationRunId)}
diff --git a/apps/erp/app/routes/x+/depreciation-run+/_layout.tsx b/apps/erp/app/routes/x+/depreciation-run+/_layout.tsx
index c0f57afe73..6839d917d1 100644
--- a/apps/erp/app/routes/x+/depreciation-run+/_layout.tsx
+++ b/apps/erp/app/routes/x+/depreciation-run+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function DepreciationRunLayout() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/documents+/_layout.tsx b/apps/erp/app/routes/x+/documents+/_layout.tsx
index f405c82d3b..f920b85607 100644
--- a/apps/erp/app/routes/x+/documents+/_layout.tsx
+++ b/apps/erp/app/routes/x+/documents+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { ContentSidebar } from "~/components/Layout/Navigation";
import { useDocumentsSubmodules } from "~/modules/documents";
import type { Handle } from "~/utils/handle";
@@ -32,7 +32,7 @@ export const handle: Handle = {
export default function DocumentsRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/documents+/search.tsx b/apps/erp/app/routes/x+/documents+/search.tsx
index 6339f58ff8..41676fec88 100644
--- a/apps/erp/app/routes/x+/documents+/search.tsx
+++ b/apps/erp/app/routes/x+/documents+/search.tsx
@@ -6,13 +6,15 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { generateDownloadToken } from "@carbon/auth/download-token.server";
import { flash } from "@carbon/auth/session.server";
-import { ResizablePanel, ResizablePanelGroup, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import {
+ RecordOutlet,
+ ResizablePanel,
+ ResizablePanelGroup,
+ VStack
+} from "@carbon/react";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { useResolved } from "~/hooks/useResolved";
import type { Document } from "~/modules/documents";
import {
@@ -24,11 +26,6 @@ import {
import { path } from "~/utils/path";
import { getGenericQueryFilters } from "~/utils/query";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "documents"
@@ -114,7 +111,7 @@ export default function DocumentsAllRoute() {
extensions={extensions}
/>
</ResizablePanel>
- <Outlet />
+ <RecordOutlet />
</ResizablePanelGroup>
</VStack>
);
diff --git a/apps/erp/app/routes/x+/fixed-asset+/$fixedAssetId.tsx b/apps/erp/app/routes/x+/fixed-asset+/$fixedAssetId.tsx
index 89489efa98..e87d5b90bf 100644
--- a/apps/erp/app/routes/x+/fixed-asset+/$fixedAssetId.tsx
+++ b/apps/erp/app/routes/x+/fixed-asset+/$fixedAssetId.tsx
@@ -21,9 +21,10 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
MENU_ITEM_SHORTCUTS,
+ RecordOutlet,
useDisclosure
} from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import {
LuChevronDown,
@@ -35,17 +36,8 @@ import {
LuStore,
LuTrash
} from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import {
- Link,
- Outlet,
- useLoaderData,
- useNavigate,
- useParams
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { Link, useLoaderData, useNavigate, useParams } from "react-router";
import { DateTime, DocumentHeader } from "~/components";
import { AuditLogDrawer } from "~/components/AuditLog";
import { Enumerable } from "~/components/Enumerable";
@@ -73,11 +65,6 @@ export const handle: Handle = {
module: "accounting"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["fixedAssetId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "accounting"
@@ -503,7 +490,7 @@ export default function FixedAssetDetailRoute() {
</Card>
)}
- <Outlet />
+ <RecordOutlet />
<ConfirmDelete
action={path.to.deleteFixedAsset(fixedAssetId)}
diff --git a/apps/erp/app/routes/x+/fixed-asset+/_layout.tsx b/apps/erp/app/routes/x+/fixed-asset+/_layout.tsx
index d4587ba0c4..e65f809926 100644
--- a/apps/erp/app/routes/x+/fixed-asset+/_layout.tsx
+++ b/apps/erp/app/routes/x+/fixed-asset+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function FixedAssetLayout() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/get-started+/_layout.tsx b/apps/erp/app/routes/x+/get-started+/_layout.tsx
index 2a6bfd0cfa..210cbd9c04 100644
--- a/apps/erp/app/routes/x+/get-started+/_layout.tsx
+++ b/apps/erp/app/routes/x+/get-started+/_layout.tsx
@@ -26,16 +26,12 @@ import {
HubProvider,
toFormFields
} from "@carbon/onboarding/ui";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { useCallback, useEffect, useMemo, useRef } from "react";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
import {
- Outlet,
useFetcher,
useLoaderData,
useLocation,
@@ -145,9 +141,6 @@ export const handle: Handle = {
sidebar: GetStartedSidebar
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {});
@@ -276,7 +269,7 @@ export default function GetStartedLayout() {
resolveScreenUrl={resolveScreenUrl}
resolveVideoUrl={resolveVideoUrl}
>
- <Outlet />
+ <RecordOutlet />
</HubProvider>
</div>
</div>
diff --git a/apps/erp/app/routes/x+/inspection+/$id.tsx b/apps/erp/app/routes/x+/inspection+/$id.tsx
index 5fd16ff662..5ea3cb368d 100644
--- a/apps/erp/app/routes/x+/inspection+/$id.tsx
+++ b/apps/erp/app/routes/x+/inspection+/$id.tsx
@@ -6,12 +6,9 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { data, useLoaderData } from "react-router";
import invariant from "tiny-invariant";
import {
@@ -54,11 +51,6 @@ export const handle: Handle = {
module: "quality"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "quality",
diff --git a/apps/erp/app/routes/x+/inspection+/_layout.tsx b/apps/erp/app/routes/x+/inspection+/_layout.tsx
index 5f65f60723..04f9a6280a 100644
--- a/apps/erp/app/routes/x+/inspection+/_layout.tsx
+++ b/apps/erp/app/routes/x+/inspection+/_layout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -20,9 +16,6 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Inspection" }];
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
await requirePermissions(request, {
view: "quality"
@@ -38,5 +31,5 @@ export const handle: Handle = {
};
export default function InspectionRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/inventory+/_layout.tsx b/apps/erp/app/routes/x+/inventory+/_layout.tsx
index fc8ae0ac88..0b750c2ef1 100644
--- a/apps/erp/app/routes/x+/inventory+/_layout.tsx
+++ b/apps/erp/app/routes/x+/inventory+/_layout.tsx
@@ -3,15 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import { useInventorySubmodules } from "~/modules/inventory";
import { getUnitOfMeasuresList } from "~/modules/items";
@@ -37,9 +32,6 @@ export const handle: Handle = {
sidebar: InventorySidebar
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "inventory"
@@ -59,7 +51,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function InventoryRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/inventory-count.tsx b/apps/erp/app/routes/x+/inventory+/inventory-count.tsx
index 8d4d170aa0..e4c047b379 100644
--- a/apps/erp/app/routes/x+/inventory+/inventory-count.tsx
+++ b/apps/erp/app/routes/x+/inventory+/inventory-count.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getInventoryCounts, InventoryCountsTable } from "~/modules/inventory";
import { getLocationsList } from "~/modules/resources";
import type { Handle } from "~/utils/handle";
@@ -25,11 +22,6 @@ export const handle: Handle = {
to: path.to.inventoryCounts
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "inventory"
@@ -79,7 +71,7 @@ export default function InventoryCountRoute() {
count={count ?? 0}
locations={locations}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/kanbans.tsx b/apps/erp/app/routes/x+/inventory+/kanbans.tsx
index 058172dbf9..4d94a97ae4 100644
--- a/apps/erp/app/routes/x+/inventory+/kanbans.tsx
+++ b/apps/erp/app/routes/x+/inventory+/kanbans.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getKanbans } from "~/modules/inventory";
import KanbansTable from "~/modules/inventory/ui/Kanbans/KanbansTable";
import { getLocationsList } from "~/modules/resources";
@@ -28,11 +25,6 @@ export const handle: Handle = {
module: "inventory"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "inventory",
@@ -115,7 +107,7 @@ export default function KanbansRoute() {
locationId={locationId}
kanbanOutput={kanbanOutput}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/picking-lists.tsx b/apps/erp/app/routes/x+/inventory+/picking-lists.tsx
index bdedb0c684..70336facfb 100644
--- a/apps/erp/app/routes/x+/inventory+/picking-lists.tsx
+++ b/apps/erp/app/routes/x+/inventory+/picking-lists.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getPickingLists } from "~/modules/inventory";
import type { PickingList } from "~/modules/inventory/ui/PickingLists";
import { PickingListsTable } from "~/modules/inventory/ui/PickingLists";
@@ -72,7 +72,7 @@ export default function PickingListsRoute() {
data={pickingLists as PickingList[]}
count={pickingListCount}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx
index 28e13a108e..479c9270cb 100644
--- a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx
+++ b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx
@@ -167,7 +167,19 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
};
}
+// The feed keeps the pages it has loaded in state, seeded from the loader. A
+// reload for another location or highlight is a new feed: without the key it
+// kept showing the first one, with the new one's paging cursors. An entry
+// posted while the feed is open is deliberately not a new feed: remounting
+// would drop the older pages already loaded and the scroll position.
export default function ItemInventoryActivityRoute() {
+ const { itemId, locationId, highlightId } = useLoaderData<typeof loader>();
+ return (
+ <ItemInventoryActivity key={`${itemId}:${locationId}:${highlightId}`} />
+ );
+}
+
+function ItemInventoryActivity() {
const {
initialItemLedgers,
itemId,
diff --git a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx
index 13950d3dda..a2caf2d6b9 100644
--- a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.tsx
@@ -6,27 +6,20 @@ import { error, notFound } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import {
+ RecordOutlet,
ResizableHandle,
ResizablePanel,
ScrollArea,
VStack
} from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import InventoryItemHeader from "~/modules/inventory/ui/Inventory/InventoryItemHeader";
import { getItem, getPickMethod, upsertPickMethod } from "~/modules/items";
import { resolveLocationId } from "~/modules/shared/location.server";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"], search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "inventory"
@@ -109,7 +102,7 @@ export default function ItemInventoryRoute() {
itemType={item.type}
/>
<VStack className="p-2">
- <Outlet />
+ <RecordOutlet />
</VStack>
</ScrollArea>
</ResizablePanel>
diff --git a/apps/erp/app/routes/x+/inventory+/quantities.tsx b/apps/erp/app/routes/x+/inventory+/quantities.tsx
index 2cb50d35e3..b308b44edb 100644
--- a/apps/erp/app/routes/x+/inventory+/quantities.tsx
+++ b/apps/erp/app/routes/x+/inventory+/quantities.tsx
@@ -5,13 +5,15 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { ResizablePanel, ResizablePanelGroup, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, pluckUnique, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import {
+ RecordOutlet,
+ ResizablePanel,
+ ResizablePanelGroup,
+ VStack
+} from "@carbon/react";
+import { pluckUnique, redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import type { InventoryItem } from "~/modules/inventory";
import {
expandStorageUnitIdsWithDescendants,
@@ -35,11 +37,6 @@ export const handle: Handle = {
realtime: ["itemStockQuantities"]
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "inventory",
@@ -173,7 +170,7 @@ export default function QuantitiesRoute() {
storageUnits={storageUnits}
/>
</ResizablePanel>
- <Outlet />
+ <RecordOutlet />
</ResizablePanelGroup>
</VStack>
);
diff --git a/apps/erp/app/routes/x+/inventory+/receipts.tsx b/apps/erp/app/routes/x+/inventory+/receipts.tsx
index a90698643c..267d63e462 100644
--- a/apps/erp/app/routes/x+/inventory+/receipts.tsx
+++ b/apps/erp/app/routes/x+/inventory+/receipts.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getReceipts, ReceiptsTable } from "~/modules/inventory";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -59,7 +59,7 @@ export default function ReceiptsRoute() {
return (
<VStack spacing={0} className="h-full">
<ReceiptsTable data={receipts} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/shipments.tsx b/apps/erp/app/routes/x+/inventory+/shipments.tsx
index 9331fae029..b4b323e0a1 100644
--- a/apps/erp/app/routes/x+/inventory+/shipments.tsx
+++ b/apps/erp/app/routes/x+/inventory+/shipments.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getShipments } from "~/modules/inventory";
import ShipmentsTable from "~/modules/inventory/ui/Shipments/ShipmentsTable";
import type { Handle } from "~/utils/handle";
@@ -60,7 +60,7 @@ export default function ShipmentsRoute() {
return (
<VStack spacing={0} className="h-full">
<ShipmentsTable data={shipments} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/shipping-methods.tsx b/apps/erp/app/routes/x+/inventory+/shipping-methods.tsx
index e469501382..dbf2e2340b 100644
--- a/apps/erp/app/routes/x+/inventory+/shipping-methods.tsx
+++ b/apps/erp/app/routes/x+/inventory+/shipping-methods.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getAccountsList } from "~/modules/accounting";
import { getShippingMethods, ShippingMethodsTable } from "~/modules/inventory";
import type { Handle } from "~/utils/handle";
@@ -24,11 +21,6 @@ export const handle: Handle = {
to: path.to.shippingMethods
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, companyGroupId } = await requirePermissions(
request,
@@ -74,7 +66,7 @@ export default function ShippingMethodsRoute() {
return (
<VStack spacing={0} className="h-full">
<ShippingMethodsTable data={shippingMethods ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/stock-movements.tsx b/apps/erp/app/routes/x+/inventory+/stock-movements.tsx
index 043e6cffdf..a8ab0b140f 100644
--- a/apps/erp/app/routes/x+/inventory+/stock-movements.tsx
+++ b/apps/erp/app/routes/x+/inventory+/stock-movements.tsx
@@ -6,12 +6,9 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import { getStockMovements } from "~/modules/inventory";
import StockMovementsTable from "~/modules/inventory/ui/StockMovements/StockMovementsTable";
@@ -25,11 +22,6 @@ export const handle: Handle = {
to: path.to.stockMovements
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "inventory"
diff --git a/apps/erp/app/routes/x+/inventory+/stock-transfers.tsx b/apps/erp/app/routes/x+/inventory+/stock-transfers.tsx
index c28cbfdab1..7185f2b6f7 100644
--- a/apps/erp/app/routes/x+/inventory+/stock-transfers.tsx
+++ b/apps/erp/app/routes/x+/inventory+/stock-transfers.tsx
@@ -6,11 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getStockTransfers } from "~/modules/inventory";
import StockTransfersTable from "~/modules/inventory/ui/StockTransfers/StockTransfersTable";
import { getLocationsList } from "~/modules/resources";
@@ -103,7 +103,7 @@ export default function StockTransfersRoute() {
count={count ?? 0}
locationId={locationId}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/storage-rules.$id.tsx b/apps/erp/app/routes/x+/inventory+/storage-rules.$id.tsx
index 197405d4fa..0a40ef8f9a 100644
--- a/apps/erp/app/routes/x+/inventory+/storage-rules.$id.tsx
+++ b/apps/erp/app/routes/x+/inventory+/storage-rules.$id.tsx
@@ -9,23 +9,14 @@ import { requireFeature } from "@carbon/ee/plan.server";
import { upsertEnforcementRule } from "@carbon/ee/rules.server";
import { validationError, validator } from "@carbon/form";
import type { ConditionAst } from "@carbon/utils";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { data, useLoaderData, useNavigate } from "react-router";
import { storageRuleValidator } from "~/modules/inventory";
import StorageRuleForm from "~/modules/inventory/ui/StorageRules/StorageRuleForm";
import { getEnforcementRule } from "~/modules/shared";
import { getParams, path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "inventory"
diff --git a/apps/erp/app/routes/x+/inventory+/storage-rules.tsx b/apps/erp/app/routes/x+/inventory+/storage-rules.tsx
index eb18be1e5f..58d0ec21c8 100644
--- a/apps/erp/app/routes/x+/inventory+/storage-rules.tsx
+++ b/apps/erp/app/routes/x+/inventory+/storage-rules.tsx
@@ -5,13 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { usePlanGate } from "~/hooks/usePlanGate";
import StorageRulesGroups from "~/modules/inventory/ui/StorageRules/StorageRulesGroups";
import StorageRulesUpgradeOverlay from "~/modules/inventory/ui/StorageRules/StorageRulesUpgradeOverlay";
@@ -27,9 +25,6 @@ export const handle: Handle = {
to: path.to.storageRules
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "inventory",
@@ -73,7 +68,7 @@ export default function StorageRulesRoute() {
return (
<>
<StorageRulesGroups rules={rows as never} />
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/storage-types.tsx b/apps/erp/app/routes/x+/inventory+/storage-types.tsx
index 63bc5626a8..681a8f2895 100644
--- a/apps/erp/app/routes/x+/inventory+/storage-types.tsx
+++ b/apps/erp/app/routes/x+/inventory+/storage-types.tsx
@@ -6,14 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getStorageTypes } from "~/modules/inventory";
import StorageTypesTable from "~/modules/inventory/ui/StorageTypes/StorageTypesTable";
import type { Handle } from "~/utils/handle";
@@ -27,11 +24,6 @@ export const handle: Handle = {
to: path.to.storageTypes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -72,7 +64,7 @@ export default function StorageTypesRoute() {
return (
<VStack spacing={0} className="h-full">
<StorageTypesTable data={storageTypes} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/storage-units.$storageUnitId.tsx b/apps/erp/app/routes/x+/inventory+/storage-units.$storageUnitId.tsx
index ac12353e86..d4c8dd02b7 100644
--- a/apps/erp/app/routes/x+/inventory+/storage-units.$storageUnitId.tsx
+++ b/apps/erp/app/routes/x+/inventory+/storage-units.$storageUnitId.tsx
@@ -6,10 +6,10 @@ import { assertIsPost, error, notFound, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
-import { useCloseRoute } from "@carbon/react";
+import { RecordOutlet, useCloseRoute } from "@carbon/react";
import { redirect } from "@carbon/utils";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { data, Outlet, useLoaderData } from "react-router";
+import { data, useLoaderData } from "react-router";
import {
getEffectiveWorkCenterId,
getStorageUnit,
@@ -121,7 +121,7 @@ export default function EditStorageUnitRoute() {
inheritedWorkCenter={inheritedWorkCenter}
onClose={() => closeRoute()}
/>
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/storage-units.tsx b/apps/erp/app/routes/x+/inventory+/storage-units.tsx
index b1525bc1b8..4ff21d07fe 100644
--- a/apps/erp/app/routes/x+/inventory+/storage-units.tsx
+++ b/apps/erp/app/routes/x+/inventory+/storage-units.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
getStorageTypesList,
getStorageUnitParentIdsWithChildren,
@@ -37,11 +34,6 @@ export const handle: Handle = {
// Nodes below this still render with an expand chevron and lazy-load on click.
const EAGER_EXPAND_MAX_DEPTH = 5;
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "inventory",
@@ -222,7 +214,7 @@ export default function StorageUnitsRoute() {
parentIdsWithChildren={parentIdsWithChildren}
initialExpanded={initialExpanded}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/warehouse-transfers.tsx b/apps/erp/app/routes/x+/inventory+/warehouse-transfers.tsx
index 6a6a3d78de..b8b29cc20e 100644
--- a/apps/erp/app/routes/x+/inventory+/warehouse-transfers.tsx
+++ b/apps/erp/app/routes/x+/inventory+/warehouse-transfers.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getWarehouseTransfers } from "~/modules/inventory";
import WarehouseTransfersTable from "~/modules/inventory/ui/WarehouseTransfers/WarehouseTransfersTable";
import type { Handle } from "~/utils/handle";
@@ -60,7 +60,7 @@ export default function WarehouseTransfersRoute() {
return (
<VStack spacing={0} className="h-full">
<WarehouseTransfersTable data={warehouseTransfers} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/inventory-count+/$id.tsx b/apps/erp/app/routes/x+/inventory-count+/$id.tsx
index a6e434ce69..5bf8062616 100644
--- a/apps/erp/app/routes/x+/inventory-count+/$id.tsx
+++ b/apps/erp/app/routes/x+/inventory-count+/$id.tsx
@@ -5,13 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, pluckUnique, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { pluckUnique, redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
getInventoryCount,
getInventoryCountLineSummary,
@@ -42,11 +40,6 @@ export const handle: Handle = {
module: "inventory"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"], search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "inventory"
@@ -171,7 +164,7 @@ export default function InventoryCountDetailRoute() {
storageUnits={storageUnits}
/>
</div>
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/inventory-count+/_layout.tsx b/apps/erp/app/routes/x+/inventory-count+/_layout.tsx
index 4b16df427b..8a2cf14ec5 100644
--- a/apps/erp/app/routes/x+/inventory-count+/_layout.tsx
+++ b/apps/erp/app/routes/x+/inventory-count+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function InventoryCountLayoutRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/invoicing+/_layout.tsx b/apps/erp/app/routes/x+/invoicing+/_layout.tsx
index 4db1631ece..c425ea2ed4 100644
--- a/apps/erp/app/routes/x+/invoicing+/_layout.tsx
+++ b/apps/erp/app/routes/x+/invoicing+/_layout.tsx
@@ -3,15 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import useInvoicingSubmodules from "~/modules/invoicing/ui/useInvoicingSubmodules";
import type { Handle } from "~/utils/handle";
@@ -35,9 +30,6 @@ export const handle: Handle = {
sidebar: InvoicingSidebar
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
await requirePermissions(request, {
view: "invoicing"
@@ -49,7 +41,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function InvoicingRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/invoicing+/charges.$id.tsx b/apps/erp/app/routes/x+/invoicing+/charges.$id.tsx
index 38d316b31c..3c59160385 100644
--- a/apps/erp/app/routes/x+/invoicing+/charges.$id.tsx
+++ b/apps/erp/app/routes/x+/invoicing+/charges.$id.tsx
@@ -23,13 +23,10 @@ import {
useDisclosure,
VStack
} from "@carbon/react";
-import { formatDate, isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { formatDate, redirect } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
import { useLocale } from "@react-aria/i18n";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData, useNavigate } from "react-router";
import { Hyperlink } from "~/components";
import { Enumerable } from "~/components/Enumerable";
@@ -38,11 +35,6 @@ import { useCurrencyFormatter, usePermissions } from "~/hooks";
import { ChargeStatus, getCharge } from "~/modules/invoicing";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId, companyGroupId } = await requirePermissions(
request,
diff --git a/apps/erp/app/routes/x+/invoicing+/charges.tsx b/apps/erp/app/routes/x+/invoicing+/charges.tsx
index 8d7e9248f0..a0a7e52c5d 100644
--- a/apps/erp/app/routes/x+/invoicing+/charges.tsx
+++ b/apps/erp/app/routes/x+/invoicing+/charges.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { ChargesTable, getCharges } from "~/modules/invoicing";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -24,11 +21,6 @@ export const handle: Handle = {
module: "invoicing"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "invoicing"
@@ -81,7 +73,7 @@ export default function ChargesRoute() {
return (
<VStack spacing={0} className="h-full">
<ChargesTable data={data} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/invoicing+/payables.tsx b/apps/erp/app/routes/x+/invoicing+/payables.tsx
index a432ef3c4b..d9d637a477 100644
--- a/apps/erp/app/routes/x+/invoicing+/payables.tsx
+++ b/apps/erp/app/routes/x+/invoicing+/payables.tsx
@@ -3,12 +3,9 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { datetime, isUnaffectedByNavigation } from "@carbon/utils";
+import { datetime } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import {
ARAPWorkbench,
@@ -36,11 +33,6 @@ function parseBuckets(raw: string | null): [number, number, number] {
return [30, 60, 90];
}
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "invoicing"
diff --git a/apps/erp/app/routes/x+/invoicing+/purchasing.tsx b/apps/erp/app/routes/x+/invoicing+/purchasing.tsx
index fcff17a47a..6bef4a1b16 100644
--- a/apps/erp/app/routes/x+/invoicing+/purchasing.tsx
+++ b/apps/erp/app/routes/x+/invoicing+/purchasing.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import {
getPurchaseInvoices,
PurchaseInvoicesTable
@@ -69,7 +69,7 @@ export default function InvoicingPurchaseInvoicesRoute() {
return (
<VStack spacing={0} className="h-full">
<PurchaseInvoicesTable data={purchaseInvoices} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/invoicing+/receivables.tsx b/apps/erp/app/routes/x+/invoicing+/receivables.tsx
index ac596802f9..1edad6cf82 100644
--- a/apps/erp/app/routes/x+/invoicing+/receivables.tsx
+++ b/apps/erp/app/routes/x+/invoicing+/receivables.tsx
@@ -3,12 +3,9 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { datetime, isUnaffectedByNavigation } from "@carbon/utils";
+import { datetime } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import {
ARAPWorkbench,
@@ -36,11 +33,6 @@ function parseBuckets(raw: string | null): [number, number, number] {
return [30, 60, 90];
}
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "invoicing"
diff --git a/apps/erp/app/routes/x+/invoicing+/sales.tsx b/apps/erp/app/routes/x+/invoicing+/sales.tsx
index a968a8a52d..0672d62467 100644
--- a/apps/erp/app/routes/x+/invoicing+/sales.tsx
+++ b/apps/erp/app/routes/x+/invoicing+/sales.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getSalesInvoices } from "~/modules/invoicing";
import SalesInvoicesTable from "~/modules/invoicing/ui/SalesInvoice/SalesInvoicesTable";
import type { Handle } from "~/utils/handle";
@@ -67,7 +67,7 @@ export default function InvoicingSalesInvoicesRoute() {
return (
<VStack spacing={0} className="h-full">
<SalesInvoicesTable data={salesInvoices} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/issue+/$id.tsx b/apps/erp/app/routes/x+/issue+/$id.tsx
index 6250d89b83..e6d58d38b1 100644
--- a/apps/erp/app/routes/x+/issue+/$id.tsx
+++ b/apps/erp/app/routes/x+/issue+/$id.tsx
@@ -6,16 +6,13 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { useLingui } from "@lingui/react/macro";
import { Suspense } from "react";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { Await, useLoaderData, useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import {
getChangeNoticesForNonConformance,
@@ -58,11 +55,6 @@ export const handle: Handle = {
module: "quality"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "quality",
@@ -257,7 +249,7 @@ export default function IssueRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/issue+/_layout.tsx b/apps/erp/app/routes/x+/issue+/_layout.tsx
index d73eb6d933..b1eb2026b6 100644
--- a/apps/erp/app/routes/x+/issue+/_layout.tsx
+++ b/apps/erp/app/routes/x+/issue+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function IssueRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/issue-workflow+/_layout.tsx b/apps/erp/app/routes/x+/issue-workflow+/_layout.tsx
index 13abb3fb45..a25dbda536 100644
--- a/apps/erp/app/routes/x+/issue-workflow+/_layout.tsx
+++ b/apps/erp/app/routes/x+/issue-workflow+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function IssueWorkflowRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/items+/_layout.tsx b/apps/erp/app/routes/x+/items+/_layout.tsx
index 28bcb58d78..ee814d025d 100644
--- a/apps/erp/app/routes/x+/items+/_layout.tsx
+++ b/apps/erp/app/routes/x+/items+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import useItemsSubmodules from "~/modules/items/ui/useItemsSubmodules";
import type { Handle } from "~/utils/handle";
@@ -32,7 +32,7 @@ export const handle: Handle = {
export default function PartsRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/change-notice+/$id.$affectedId.details.$supplierPartId.tsx b/apps/erp/app/routes/x+/items+/change-notice+/$id.$affectedId.details.$supplierPartId.tsx
index b6a0a3fd8b..f33af5510c 100644
--- a/apps/erp/app/routes/x+/items+/change-notice+/$id.$affectedId.details.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/items+/change-notice+/$id.$affectedId.details.$supplierPartId.tsx
@@ -3,31 +3,13 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData, useNavigate, useParams } from "react-router";
import { useRouteData } from "~/hooks";
import type { AffectedItemDraft } from "~/modules/items/ui/ChangeNotice";
import { SupplierPartForm } from "~/modules/items/ui/Item";
import { path } from "~/utils/path";
-// Edit drawer for a supplier part on a CO line's draft item — reached
-// relatively from the embedded Supplier Parts grid. The loader mirrors the part
-// purchasing edit route ($itemId.purchasing.$supplierPartId): the supplier part
-// row + its price breaks (the form re-posts the full price-break set, so they
-// MUST be seeded or saving would wipe them) + purchase history. No action here:
-// the form posts to the part edit action (path.to.partSupplier), which returns
-// { success } so the CO stays put.
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, {
- params: ["affectedId", "id", "supplierPartId"]
- })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
diff --git a/apps/erp/app/routes/x+/items+/change-notice+/$id.tsx b/apps/erp/app/routes/x+/items+/change-notice+/$id.tsx
index 2a487ce424..84a7df655f 100644
--- a/apps/erp/app/routes/x+/items+/change-notice+/$id.tsx
+++ b/apps/erp/app/routes/x+/items+/change-notice+/$id.tsx
@@ -7,13 +7,11 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
import type { JSONContent } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import {
getChangeNotice,
@@ -64,11 +62,6 @@ export const handle: Handle = {
hideModuleSidebar: true
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
@@ -340,7 +333,7 @@ export default function ChangeNoticeIdRoute() {
explorer={<ChangeNoticeExplorer />}
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
- <Outlet />
+ <RecordOutlet />
</div>
}
properties={<ChangeNoticeProperties key={id} />}
diff --git a/apps/erp/app/routes/x+/items+/change-notice+/_layout.tsx b/apps/erp/app/routes/x+/items+/change-notice+/_layout.tsx
index 40468f40ab..d15ea1e439 100644
--- a/apps/erp/app/routes/x+/items+/change-notice+/_layout.tsx
+++ b/apps/erp/app/routes/x+/items+/change-notice+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -19,5 +20,5 @@ export const handle: Handle = {
};
export default function ChangeNoticeRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/items+/change-notice-actions.tsx b/apps/erp/app/routes/x+/items+/change-notice-actions.tsx
index d5566b1bf7..394dc4830e 100644
--- a/apps/erp/app/routes/x+/items+/change-notice-actions.tsx
+++ b/apps/erp/app/routes/x+/items+/change-notice-actions.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getChangeNoticeRequiredActions } from "~/modules/items";
import { ChangeNoticeRequiredActionsTable } from "~/modules/items/ui/ChangeNoticeActions";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.changeNoticeRequiredActions
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -54,7 +45,7 @@ export default function ChangeNoticeActionsRoute() {
return (
<VStack spacing={0} className="h-full">
<ChangeNoticeRequiredActionsTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/change-notice-types.tsx b/apps/erp/app/routes/x+/items+/change-notice-types.tsx
index 3af1f19943..fb0b8324cf 100644
--- a/apps/erp/app/routes/x+/items+/change-notice-types.tsx
+++ b/apps/erp/app/routes/x+/items+/change-notice-types.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getChangeNoticeTypes } from "~/modules/items";
import { ChangeNoticeTypesTable } from "~/modules/items/ui/ChangeNoticeTypes";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.changeNoticeTypes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -54,7 +45,7 @@ export default function ChangeNoticeTypesRoute() {
return (
<VStack spacing={0} className="h-full">
<ChangeNoticeTypesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/change-notices+/_index.tsx b/apps/erp/app/routes/x+/items+/change-notices+/_index.tsx
index e257343dcc..17f3dfa3fb 100644
--- a/apps/erp/app/routes/x+/items+/change-notices+/_index.tsx
+++ b/apps/erp/app/routes/x+/items+/change-notices+/_index.tsx
@@ -5,10 +5,10 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getChangeNotices, getChangeNoticeTypesList } from "~/modules/items";
import { ChangeNoticesTable } from "~/modules/items/ui/ChangeNotice";
import { path } from "~/utils/path";
@@ -60,7 +60,7 @@ export default function ChangeNoticesIndexRoute() {
return (
<VStack spacing={0} className="h-full">
<ChangeNoticesTable data={changeNotices} count={count} types={types} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/change-notices+/_layout.tsx b/apps/erp/app/routes/x+/items+/change-notices+/_layout.tsx
index 7fb1587f29..40e26d39e9 100644
--- a/apps/erp/app/routes/x+/items+/change-notices+/_layout.tsx
+++ b/apps/erp/app/routes/x+/items+/change-notices+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -19,5 +20,5 @@ export const handle: Handle = {
};
export default function ChangeNoticesRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/items+/consumables.tsx b/apps/erp/app/routes/x+/items+/consumables.tsx
index 14d06911b7..84c09fbc25 100644
--- a/apps/erp/app/routes/x+/items+/consumables.tsx
+++ b/apps/erp/app/routes/x+/items+/consumables.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getConsumables } from "~/modules/items";
import { ConsumablesTable } from "~/modules/items/ui/Consumables";
import { getTagsList } from "~/modules/shared";
@@ -73,7 +73,7 @@ export default function ConsumablesSearchRoute() {
return (
<VStack spacing={0} className="h-full">
<ConsumablesTable data={consumables} count={count} tags={tags} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/dimensions.tsx b/apps/erp/app/routes/x+/items+/dimensions.tsx
index eb556fd67b..2469279b32 100644
--- a/apps/erp/app/routes/x+/items+/dimensions.tsx
+++ b/apps/erp/app/routes/x+/items+/dimensions.tsx
@@ -6,14 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getMaterialDimensions } from "~/modules/items";
import MaterialDimensionsTable from "~/modules/items/ui/MaterialDimensions/MaterialDimensionsTable";
import { getCompanySettings } from "~/modules/settings/settings.service";
@@ -28,11 +25,6 @@ export const handle: Handle = {
to: path.to.materialDimensions
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -76,7 +68,7 @@ export default function MaterialDimensionsRoute() {
return (
<VStack spacing={0} className="h-full">
<MaterialDimensionsTable data={materialDimensions} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/finishes.tsx b/apps/erp/app/routes/x+/items+/finishes.tsx
index 9a470e3f42..ae137b1f22 100644
--- a/apps/erp/app/routes/x+/items+/finishes.tsx
+++ b/apps/erp/app/routes/x+/items+/finishes.tsx
@@ -6,14 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getMaterialFinishes } from "~/modules/items";
import MaterialFinishesTable from "~/modules/items/ui/MaterialFinishes/MaterialFinishesTable";
import type { Handle } from "~/utils/handle";
@@ -27,11 +24,6 @@ export const handle: Handle = {
to: path.to.materialFinishes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -72,7 +64,7 @@ export default function MaterialFinishesRoute() {
return (
<VStack spacing={0} className="h-full">
<MaterialFinishesTable data={materialFinishes} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/forms.tsx b/apps/erp/app/routes/x+/items+/forms.tsx
index 10d5aca7bf..d3486c4b34 100644
--- a/apps/erp/app/routes/x+/items+/forms.tsx
+++ b/apps/erp/app/routes/x+/items+/forms.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getMaterialForms } from "~/modules/items";
import { MaterialFormsTable } from "~/modules/items/ui/MaterialShapes";
import type { Handle } from "~/utils/handle";
@@ -24,11 +21,6 @@ export const handle: Handle = {
to: path.to.materialForms
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -68,7 +60,7 @@ export default function MaterialFormsRoute() {
return (
<VStack spacing={0} className="h-full">
<MaterialFormsTable data={materialForms} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/grades.tsx b/apps/erp/app/routes/x+/items+/grades.tsx
index 753c085f58..956c1add22 100644
--- a/apps/erp/app/routes/x+/items+/grades.tsx
+++ b/apps/erp/app/routes/x+/items+/grades.tsx
@@ -6,14 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getMaterialGrades } from "~/modules/items";
import MaterialGradesTable from "~/modules/items/ui/MaterialGrades/MaterialGradesTable";
import type { Handle } from "~/utils/handle";
@@ -27,11 +24,6 @@ export const handle: Handle = {
to: path.to.materialGrades
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -72,7 +64,7 @@ export default function MaterialGradesRoute() {
return (
<VStack spacing={0} className="h-full">
<MaterialGradesTable data={materialGrades} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/groups.tsx b/apps/erp/app/routes/x+/items+/groups.tsx
index c7801dac5c..84977a3bc4 100644
--- a/apps/erp/app/routes/x+/items+/groups.tsx
+++ b/apps/erp/app/routes/x+/items+/groups.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getAccountsList } from "~/modules/accounting";
import { getItemPostingGroups } from "~/modules/items";
import { ItemPostingGroupsTable } from "~/modules/items/ui/ItemPostingGroups";
@@ -25,11 +22,6 @@ export const handle: Handle = {
to: path.to.itemPostingGroups
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, companyGroupId } = await requirePermissions(
request,
@@ -83,7 +75,7 @@ export default function ItemPostingGroupsRoute() {
return (
<VStack spacing={0} className="h-full">
<ItemPostingGroupsTable data={itemPostingGroups} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/materials.tsx b/apps/erp/app/routes/x+/items+/materials.tsx
index 56a5bda4f5..028d158a46 100644
--- a/apps/erp/app/routes/x+/items+/materials.tsx
+++ b/apps/erp/app/routes/x+/items+/materials.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getMaterials } from "~/modules/items";
import { MaterialsTable } from "~/modules/items/ui/Materials";
import { getTagsList } from "~/modules/shared";
@@ -69,7 +69,7 @@ export default function MaterialsSearchRoute() {
return (
<VStack spacing={0} className="h-full">
<MaterialsTable data={materials} count={count} tags={tags} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/parts.tsx b/apps/erp/app/routes/x+/items+/parts.tsx
index 5c7355ef9a..c1d4cd83e5 100644
--- a/apps/erp/app/routes/x+/items+/parts.tsx
+++ b/apps/erp/app/routes/x+/items+/parts.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getParts } from "~/modules/items";
import { PartsTable } from "~/modules/items/ui/Parts";
import { getTagsList } from "~/modules/shared";
@@ -72,7 +72,7 @@ export default function PartsSearchRoute() {
return (
<VStack spacing={0} className="h-full">
<PartsTable data={parts} count={count} tags={tags} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/services.tsx b/apps/erp/app/routes/x+/items+/services.tsx
index 76688823de..4dee2cb2bb 100644
--- a/apps/erp/app/routes/x+/items+/services.tsx
+++ b/apps/erp/app/routes/x+/items+/services.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getServices } from "~/modules/items";
import { ServicesTable } from "~/modules/items/ui/Services";
import { getTagsList } from "~/modules/shared";
@@ -71,7 +71,7 @@ export default function ServicesSearchRoute() {
return (
<VStack spacing={0} className="h-full">
<ServicesTable data={services} count={count} tags={tags} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/substances.tsx b/apps/erp/app/routes/x+/items+/substances.tsx
index e0aaf788be..535351c218 100644
--- a/apps/erp/app/routes/x+/items+/substances.tsx
+++ b/apps/erp/app/routes/x+/items+/substances.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getMaterialSubstances } from "~/modules/items";
import { MaterialSubstancesTable } from "~/modules/items/ui/MaterialSubstances";
import type { Handle } from "~/utils/handle";
@@ -24,11 +21,6 @@ export const handle: Handle = {
to: path.to.materialSubstances
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -68,7 +60,7 @@ export default function MaterialSubstancesRoute() {
return (
<VStack spacing={0} className="h-full">
<MaterialSubstancesTable data={materialSubstances} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/tools.tsx b/apps/erp/app/routes/x+/items+/tools.tsx
index 3ebb672154..ddb386ba46 100644
--- a/apps/erp/app/routes/x+/items+/tools.tsx
+++ b/apps/erp/app/routes/x+/items+/tools.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getTools } from "~/modules/items";
import { ToolsTable } from "~/modules/items/ui/Tools";
import { getTagsList } from "~/modules/shared";
@@ -69,7 +69,7 @@ export default function ToolsSearchRoute() {
return (
<VStack spacing={0} className="h-full">
<ToolsTable data={tools} count={count} tags={tags} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/types.tsx b/apps/erp/app/routes/x+/items+/types.tsx
index e640053d10..d671ec5ced 100644
--- a/apps/erp/app/routes/x+/items+/types.tsx
+++ b/apps/erp/app/routes/x+/items+/types.tsx
@@ -6,14 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getMaterialTypes } from "~/modules/items";
import MaterialTypesTable from "~/modules/items/ui/MaterialTypes/MaterialTypesTable";
import type { Handle } from "~/utils/handle";
@@ -27,11 +24,6 @@ export const handle: Handle = {
to: path.to.materialTypes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -72,7 +64,7 @@ export default function MaterialTypesRoute() {
return (
<VStack spacing={0} className="h-full">
<MaterialTypesTable data={materialTypes} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/uom.tsx b/apps/erp/app/routes/x+/items+/uom.tsx
index c4f80a4dcd..62db07dbaa 100644
--- a/apps/erp/app/routes/x+/items+/uom.tsx
+++ b/apps/erp/app/routes/x+/items+/uom.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getUnitOfMeasures } from "~/modules/items";
import { UnitOfMeasuresTable } from "~/modules/items/ui/UnitOfMeasure";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.uoms
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -54,7 +45,7 @@ export default function UnitOfMeasuresRoute() {
return (
<VStack spacing={0} className="h-full">
<UnitOfMeasuresTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/job+/$jobId.events.tsx b/apps/erp/app/routes/x+/job+/$jobId.events.tsx
index 05b1ec287b..c261f1b014 100644
--- a/apps/erp/app/routes/x+/job+/$jobId.events.tsx
+++ b/apps/erp/app/routes/x+/job+/$jobId.events.tsx
@@ -5,13 +5,10 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { useMount, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { RecordOutlet, useMount, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { usePanels } from "~/components/Layout";
import {
getJobOperationsList,
@@ -22,11 +19,6 @@ import { getWorkCentersList } from "~/modules/resources";
import { path, requestReferrer } from "~/utils/path";
import { getGenericQueryFilters } from "~/utils/query";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["jobId"], search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "production"
@@ -110,7 +102,7 @@ export default function ProductionEventsRoute() {
workCenters={workCenters}
/>
</VStack>
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/job+/$jobId.quantities.tsx b/apps/erp/app/routes/x+/job+/$jobId.quantities.tsx
index eb995d0ca1..9cee44eeb7 100644
--- a/apps/erp/app/routes/x+/job+/$jobId.quantities.tsx
+++ b/apps/erp/app/routes/x+/job+/$jobId.quantities.tsx
@@ -5,13 +5,10 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { useMount, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { RecordOutlet, useMount, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { usePanels } from "~/components/Layout";
import {
getJobOperationsList,
@@ -22,11 +19,6 @@ import { ProductionQuantitiesTable } from "~/modules/production/ui/Jobs";
import { path, requestReferrer } from "~/utils/path";
import { getGenericQueryFilters } from "~/utils/query";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["jobId"], search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "production"
@@ -110,7 +102,7 @@ export default function ProductionQuantitiesRoute() {
scrapReasons={scrapReasons}
/>
</VStack>
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/job+/$jobId.tsx b/apps/erp/app/routes/x+/job+/$jobId.tsx
index 453758608a..860d644c78 100644
--- a/apps/erp/app/routes/x+/job+/$jobId.tsx
+++ b/apps/erp/app/routes/x+/job+/$jobId.tsx
@@ -6,15 +6,13 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { activeJobStatuses } from "@carbon/database";
-import { datetime, isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { datetime, redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { Suspense, useMemo } from "react";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { Await, useLoaderData, useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import { ExplorerSkeleton } from "~/components/Skeletons";
import { flattenTree } from "~/components/TreeView";
@@ -97,11 +95,6 @@ export const handle: Handle = {
]
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["jobId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "production",
@@ -205,7 +198,7 @@ export default function JobRoute() {
}
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-hidden w-full">
- <Outlet />
+ <RecordOutlet />
</div>
}
properties={<JobProperties key={jobId} />}
diff --git a/apps/erp/app/routes/x+/job+/_layout.tsx b/apps/erp/app/routes/x+/job+/_layout.tsx
index d4940f3670..90bac320c8 100644
--- a/apps/erp/app/routes/x+/job+/_layout.tsx
+++ b/apps/erp/app/routes/x+/job+/_layout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -26,9 +22,6 @@ export const handle: Handle = {
module: "production"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
await requirePermissions(request, {
view: "production"
@@ -38,5 +31,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function JobRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/journal-entry+/$journalEntryId.tsx b/apps/erp/app/routes/x+/journal-entry+/$journalEntryId.tsx
index ecb66059bb..e7eec4d5c7 100644
--- a/apps/erp/app/routes/x+/journal-entry+/$journalEntryId.tsx
+++ b/apps/erp/app/routes/x+/journal-entry+/$journalEntryId.tsx
@@ -5,13 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import {
getActiveDimensionsWithValues,
getCompaniesInGroup,
@@ -63,11 +61,6 @@ const journalSourceDocumentMap: Record<
}
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["journalEntryId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId, companyGroupId } = await requirePermissions(
request,
@@ -144,7 +137,7 @@ export default function JournalEntryRoute() {
return (
<div className="flex h-[calc(100dvh-var(--topbar-height)-var(--content-inset))] overflow-y-auto scrollbar-hide w-full">
<div className="h-full p-4 w-full max-w-5xl mx-auto">
- <Outlet />
+ <RecordOutlet />
</div>
</div>
);
diff --git a/apps/erp/app/routes/x+/journal-entry+/_layout.tsx b/apps/erp/app/routes/x+/journal-entry+/_layout.tsx
index 880ee868dc..1ef0034f9f 100644
--- a/apps/erp/app/routes/x+/journal-entry+/_layout.tsx
+++ b/apps/erp/app/routes/x+/journal-entry+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function JournalEntryLayout() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/maintenance+/$dispatchId.tsx b/apps/erp/app/routes/x+/maintenance+/$dispatchId.tsx
index fb99760fe1..847e6990b7 100644
--- a/apps/erp/app/routes/x+/maintenance+/$dispatchId.tsx
+++ b/apps/erp/app/routes/x+/maintenance+/$dispatchId.tsx
@@ -7,14 +7,11 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { storage } from "@carbon/files";
import type { JSONContent } from "@carbon/react";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import RiskRegisterCard from "~/modules/quality/ui/RiskRegister/RiskRegisterCard";
import {
@@ -56,11 +53,6 @@ async function getMaintenanceDispatchFiles(
return result.data ?? [];
}
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["dispatchId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources"
@@ -134,7 +126,7 @@ export default function MaintenanceDispatchRoute() {
source="Work Center"
/>
)}
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/maintenance+/_layout.tsx b/apps/erp/app/routes/x+/maintenance+/_layout.tsx
index d9ac835b06..c5f9e19191 100644
--- a/apps/erp/app/routes/x+/maintenance+/_layout.tsx
+++ b/apps/erp/app/routes/x+/maintenance+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function MaintenanceRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx
index 4563952c01..6b0227cc0f 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx
@@ -7,12 +7,8 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { useRouteData } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { useLoaderData, useNavigate, useParams } from "react-router";
import type { MaterialSummary } from "~/modules/items";
import { supplierPartValidator, upsertSupplierPart } from "~/modules/items";
@@ -21,11 +17,6 @@ import { getDatabaseClient } from "~/services/database.server";
import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId", "supplierPartId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
diff --git a/apps/erp/app/routes/x+/material+/$itemId.purchasing.tsx b/apps/erp/app/routes/x+/material+/$itemId.purchasing.tsx
index 339a70d326..05db7d07cc 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.purchasing.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.purchasing.tsx
@@ -7,13 +7,9 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { Suspense } from "react";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { Await, useLoaderData, useParams } from "react-router";
import { useRouteData } from "~/hooks";
import { getBatchProperties } from "~/modules/inventory";
@@ -29,11 +25,6 @@ import { ItemPurchasingForm, SupplierParts } from "~/modules/items/ui/Item";
import { ItemCostHistoryChart } from "~/modules/items/ui/Item/ItemCostHistoryChart";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
diff --git a/apps/erp/app/routes/x+/material+/$itemId.tsx b/apps/erp/app/routes/x+/material+/$itemId.tsx
index b33291a7b1..b3b4e83fd4 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.tsx
@@ -5,15 +5,12 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { useRouteData } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, useRouteData } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Suspense } from "react";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { Await, useLoaderData, useParams } from "react-router";
import { ResizablePanels } from "~/components/Layout";
import type { ItemFile, MaterialSummary } from "~/modules/items";
import {
@@ -43,11 +40,6 @@ export const handle: Handle = {
module: "items"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -242,7 +234,7 @@ export default function MaterialRoute() {
}
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
- <Outlet />
+ <RecordOutlet />
</div>
}
properties={<MaterialProperties key={itemId} />}
diff --git a/apps/erp/app/routes/x+/material+/_layout.tsx b/apps/erp/app/routes/x+/material+/_layout.tsx
index 1aa97235bc..9f95c0a9e7 100644
--- a/apps/erp/app/routes/x+/material+/_layout.tsx
+++ b/apps/erp/app/routes/x+/material+/_layout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import {
getMaterialFormsList,
getMaterialSubstancesList,
@@ -32,9 +28,6 @@ export const handle: Handle = {
module: "items"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
@@ -56,5 +49,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function MaterialRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx
index 51a649c1e0..571a4d15ae 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx
@@ -6,12 +6,7 @@ import { assertIsPost } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { validator } from "@carbon/form";
import { useRouteData } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { useLoaderData, useNavigate, useParams } from "react-router";
import type { PartSummary } from "~/modules/items";
import { supplierPartValidator, upsertSupplierPart } from "~/modules/items";
@@ -20,11 +15,6 @@ import { getDatabaseClient } from "~/services/database.server";
import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId", "supplierPartId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
diff --git a/apps/erp/app/routes/x+/part+/$itemId.purchasing.tsx b/apps/erp/app/routes/x+/part+/$itemId.purchasing.tsx
index 1d2737ea36..e4148909af 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.purchasing.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.purchasing.tsx
@@ -7,13 +7,9 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { Suspense } from "react";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { Await, useLoaderData, useParams } from "react-router";
import { useRouteData } from "~/hooks";
import { getBatchProperties } from "~/modules/inventory";
@@ -29,11 +25,6 @@ import { ItemPurchasingForm, SupplierParts } from "~/modules/items/ui/Item";
import { ItemCostHistoryChart } from "~/modules/items/ui/Item/ItemCostHistoryChart";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
diff --git a/apps/erp/app/routes/x+/part+/$itemId.sales.tsx b/apps/erp/app/routes/x+/part+/$itemId.sales.tsx
index 41c334b673..4f71462fc4 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.sales.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.sales.tsx
@@ -11,12 +11,8 @@ import {
} from "@carbon/ee/rules";
import { validationError, validator } from "@carbon/form";
import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import {
getItemCustomerParts,
@@ -30,11 +26,6 @@ import { SalesRuleAssignmentsList } from "~/modules/sales/ui/SalesRules";
import { getCustomFields, setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
diff --git a/apps/erp/app/routes/x+/part+/$itemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.tsx
index ea3a9d1f6e..f8da3097be 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.tsx
@@ -10,6 +10,7 @@ import {
Input,
InputGroup,
InputLeftElement,
+ RecordOutlet,
Spinner,
Tabs,
TabsContent,
@@ -17,16 +18,13 @@ import {
TabsTrigger,
useRouteData
} from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans, useLingui } from "@lingui/react/macro";
import { Suspense, useState } from "react";
import { LuSearch } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { Await, useLoaderData, useParams } from "react-router";
import { ResizablePanels } from "~/components/Layout";
import { flattenTree } from "~/components/TreeView";
import type { ItemFile, PartSummary } from "~/modules/items";
@@ -71,11 +69,6 @@ export const handle: Handle = {
module: "items"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"], search: ["methodId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -617,7 +610,7 @@ export default function PartRoute() {
}
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-hide w-full">
- <Outlet />
+ <RecordOutlet />
</div>
}
properties={
diff --git a/apps/erp/app/routes/x+/part+/_layout.tsx b/apps/erp/app/routes/x+/part+/_layout.tsx
index 1177d76ffe..5488f2c584 100644
--- a/apps/erp/app/routes/x+/part+/_layout.tsx
+++ b/apps/erp/app/routes/x+/part+/_layout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import { getUnitOfMeasuresList } from "~/modules/items";
import { getLocationsList } from "~/modules/resources";
import type { Handle } from "~/utils/handle";
@@ -28,9 +24,6 @@ export const handle: Handle = {
module: "items"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
@@ -48,5 +41,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function PartRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/payments+/$paymentId.tsx b/apps/erp/app/routes/x+/payments+/$paymentId.tsx
index 71c705d375..24b2e22abc 100644
--- a/apps/erp/app/routes/x+/payments+/$paymentId.tsx
+++ b/apps/erp/app/routes/x+/payments+/$paymentId.tsx
@@ -8,13 +8,9 @@ import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { VStack } from "@carbon/react";
import type { FundingSource } from "@carbon/utils";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { data, useLoaderData } from "react-router";
import {
AvailableCreditsTable,
@@ -46,11 +42,6 @@ export const handle: Handle = {
module: "invoicing"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["paymentId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "invoicing"
@@ -380,6 +371,9 @@ export default function PaymentDetailRoute() {
{!locked && !isRefund && availableCredits.length > 0 && (
<AvailableCreditsTable
+ // The rows are the user's draft over these credits: another party,
+ // currency or set of credits on the same payment starts a new one.
+ key={`${side}:${payment.customerId ?? payment.supplierId ?? payment.employeeId}:${payment.currencyCode}:${availableCredits.map((c) => `${c.id}=${c.remaining}`).join(",")}`}
paymentId={payment.id}
side={side}
currency={baseCurrencyCode}
diff --git a/apps/erp/app/routes/x+/payments+/_layout.tsx b/apps/erp/app/routes/x+/payments+/_layout.tsx
index b77a15252d..653266c746 100644
--- a/apps/erp/app/routes/x+/payments+/_layout.tsx
+++ b/apps/erp/app/routes/x+/payments+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function PaymentsRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/people+/_layout.tsx b/apps/erp/app/routes/x+/people+/_layout.tsx
index aa6ac47be0..2d2ff75290 100644
--- a/apps/erp/app/routes/x+/people+/_layout.tsx
+++ b/apps/erp/app/routes/x+/people+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import usePeopleSubmodules from "~/modules/people/ui/usePeopleSubmodules";
import type { Handle } from "~/utils/handle";
@@ -32,7 +32,7 @@ export const handle: Handle = {
export default function PeopleRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/people+/attributes.list.$categoryId.tsx b/apps/erp/app/routes/x+/people+/attributes.list.$categoryId.tsx
index d44cf663a9..9de6a1443e 100644
--- a/apps/erp/app/routes/x+/people+/attributes.list.$categoryId.tsx
+++ b/apps/erp/app/routes/x+/people+/attributes.list.$categoryId.tsx
@@ -5,13 +5,10 @@
import { assertIsPost, error, notFound } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { data, Outlet, useLoaderData, useNavigate } from "react-router";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { data, useLoaderData, useNavigate } from "react-router";
import { useUrlParams } from "~/hooks";
import {
getAttributeCategory,
@@ -20,11 +17,6 @@ import {
import { AttributeCategoryDetail } from "~/modules/people/ui/Attributes";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["categoryId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "people",
@@ -95,7 +87,7 @@ export default function AttributeCategoryListRoute() {
attributeCategory={attributeCategory}
onClose={onClose}
/>
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/people+/attributes.tsx b/apps/erp/app/routes/x+/people+/attributes.tsx
index 26313ee067..381e41e005 100644
--- a/apps/erp/app/routes/x+/people+/attributes.tsx
+++ b/apps/erp/app/routes/x+/people+/attributes.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
getAttributeCategories,
getAttributeDataTypes
@@ -27,11 +24,6 @@ export const handle: Handle = {
to: path.to.attributes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "people",
@@ -78,7 +70,7 @@ export default function UserAttributesRoute() {
return (
<VStack spacing={0} className="h-full">
<AttributeCategoriesTable data={categories} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/people+/departments.tsx b/apps/erp/app/routes/x+/people+/departments.tsx
index f156de53fc..ac3a21fdfd 100644
--- a/apps/erp/app/routes/x+/people+/departments.tsx
+++ b/apps/erp/app/routes/x+/people+/departments.tsx
@@ -16,22 +16,20 @@ import {
Heading,
HStack,
IconButton,
+ RecordOutlet,
Tabs,
TabsContent,
TabsList,
TabsTrigger
} from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans, useLingui } from "@lingui/react/macro";
import { useCallback, useState } from "react";
import { BsThreeDotsVertical } from "react-icons/bs";
import { LuDownload } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useNavigate } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useNavigate } from "react-router";
import { New } from "~/components";
import { ImportCSVModal } from "~/components/ImportCSVModal";
import { getDepartmentsTree } from "~/modules/people";
@@ -47,9 +45,6 @@ export const handle: Handle = {
to: path.to.departments
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "people",
@@ -173,7 +168,7 @@ export default function Route() {
/>
)}
- <Outlet />
+ <RecordOutlet />
</Tabs>
);
}
diff --git a/apps/erp/app/routes/x+/people+/employee.tsx b/apps/erp/app/routes/x+/people+/employee.tsx
index 40a19aab8c..9e399a7e28 100644
--- a/apps/erp/app/routes/x+/people+/employee.tsx
+++ b/apps/erp/app/routes/x+/people+/employee.tsx
@@ -5,10 +5,10 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import {
getAttributeCategories,
getPeople,
@@ -87,7 +87,7 @@ export default function ResourcesPeopleRoute() {
employeeTypes={employeeTypes}
shifts={shifts}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/people+/holidays.tsx b/apps/erp/app/routes/x+/people+/holidays.tsx
index 7030bc8c31..21e677eb69 100644
--- a/apps/erp/app/routes/x+/people+/holidays.tsx
+++ b/apps/erp/app/routes/x+/people+/holidays.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getHolidays, getHolidayYears } from "~/modules/people";
import { HolidaysTable } from "~/modules/people/ui/Holidays";
import type { Handle } from "~/utils/handle";
@@ -24,11 +21,6 @@ export const handle: Handle = {
to: path.to.holidays
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "people",
@@ -74,7 +66,7 @@ export default function Route() {
return (
<VStack spacing={0} className="h-full">
<HolidaysTable data={holidays} count={count} years={years} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/people+/shifts.tsx b/apps/erp/app/routes/x+/people+/shifts.tsx
index bf9eb0efce..6b3be2a0cd 100644
--- a/apps/erp/app/routes/x+/people+/shifts.tsx
+++ b/apps/erp/app/routes/x+/people+/shifts.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getShifts } from "~/modules/people";
import { ShiftsTable } from "~/modules/people/ui/Shifts";
import { getLocations } from "~/modules/resources/resources.service";
@@ -25,11 +22,6 @@ export const handle: Handle = {
to: path.to.shifts
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "people",
@@ -68,7 +60,7 @@ export default function ShiftsRoute() {
return (
<VStack spacing={0} className="h-full">
<ShiftsTable data={shifts} count={count} locations={locations} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/people+/timecard.tsx b/apps/erp/app/routes/x+/people+/timecard.tsx
index 8d9a293421..b23d226d3b 100644
--- a/apps/erp/app/routes/x+/people+/timecard.tsx
+++ b/apps/erp/app/routes/x+/people+/timecard.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getTimecardEntries } from "~/modules/people";
import { TimecardsTable } from "~/modules/people/ui/Timecards";
import { getCompanySettings } from "~/modules/settings";
@@ -25,11 +22,6 @@ export const handle: Handle = {
to: path.to.peopleTimecard
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "people"
@@ -85,7 +77,7 @@ export default function Route() {
return (
<VStack spacing={0} className="h-full">
<TimecardsTable data={entries} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/person+/$personId.tsx b/apps/erp/app/routes/x+/person+/$personId.tsx
index 521594d301..7c9dd61a88 100644
--- a/apps/erp/app/routes/x+/person+/$personId.tsx
+++ b/apps/erp/app/routes/x+/person+/$personId.tsx
@@ -6,14 +6,11 @@ import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { data, Outlet, useLoaderData } from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { data, useLoaderData } from "react-router";
import {
accountProfileValidator,
getAllAttributeCategories,
@@ -36,11 +33,6 @@ export const handle: Handle = {
module: "people"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["personId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "people"
@@ -122,7 +114,7 @@ export default function PersonRoute() {
attributeCategories={attributeCategories}
timeCardEnabled={timeCardEnabled}
/>
- <Outlet />
+ <RecordOutlet />
</div>
</>
);
diff --git a/apps/erp/app/routes/x+/person+/_layout.tsx b/apps/erp/app/routes/x+/person+/_layout.tsx
index cad6c1188d..7698a6acc9 100644
--- a/apps/erp/app/routes/x+/person+/_layout.tsx
+++ b/apps/erp/app/routes/x+/person+/_layout.tsx
@@ -3,14 +3,8 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import { RecordOutlet, VStack } from "@carbon/react";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
export { RouteErrorBoundary as ErrorBoundary } from "@carbon/react/ErrorBoundary";
@@ -18,9 +12,6 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | People" }];
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
await requirePermissions(request, {
view: "people"
@@ -33,7 +24,7 @@ export default function PersonRoute() {
return (
<div className="flex h-full w-full justify-center bg-card">
<VStack spacing={4} className="h-full p-4 w-full max-w-[80rem]">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
);
diff --git a/apps/erp/app/routes/x+/picking-list+/$pickingListId.tsx b/apps/erp/app/routes/x+/picking-list+/$pickingListId.tsx
index f9368664a5..daa13552f1 100644
--- a/apps/erp/app/routes/x+/picking-list+/$pickingListId.tsx
+++ b/apps/erp/app/routes/x+/picking-list+/$pickingListId.tsx
@@ -5,13 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import {
getPickingList,
getPickingListAvailability,
@@ -38,11 +36,6 @@ export const handle: Handle = {
module: "inventory"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["pickingListId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "inventory"
@@ -99,7 +92,7 @@ export default function PickingListDetailRoute() {
<PickingListHeader />
<div className="flex h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-hide w-full">
<div className="h-full p-4 w-full max-w-5xl mx-auto flex flex-col gap-4 pb-16">
- <Outlet />
+ <RecordOutlet />
</div>
</div>
</div>
diff --git a/apps/erp/app/routes/x+/picking-list+/_layout.tsx b/apps/erp/app/routes/x+/picking-list+/_layout.tsx
index af6d976430..dae3ba6fb5 100644
--- a/apps/erp/app/routes/x+/picking-list+/_layout.tsx
+++ b/apps/erp/app/routes/x+/picking-list+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function PickingListRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/picking-list+/schedule.tsx b/apps/erp/app/routes/x+/picking-list+/schedule.tsx
index 9718d79853..7dce7b0c75 100644
--- a/apps/erp/app/routes/x+/picking-list+/schedule.tsx
+++ b/apps/erp/app/routes/x+/picking-list+/schedule.tsx
@@ -5,12 +5,12 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { useLocalStorage, VStack } from "@carbon/react";
+import { RecordOutlet, useLocalStorage, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { useCallback, useMemo, useState } from "react";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getPickingSchedule } from "~/modules/inventory";
import type {
PickingDisplaySettings,
@@ -116,7 +116,13 @@ export default function PickingScheduleRoute() {
[pickingSchedule]
);
- const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());
+ const [picked, setSelectedIds] = useState<Set<string>>(new Set());
+ // Only what is still on the board: an operation another user has since put
+ // on a list must not be counted or submitted.
+ const selectedIds = useMemo(() => {
+ const onBoard = new Set(data.map((op) => op.jobOperationId));
+ return new Set([...picked].filter((id) => onBoard.has(id)));
+ }, [picked, data]);
const toggleSelection = useCallback((id: string) => {
setSelectedIds((prev) => {
@@ -150,7 +156,7 @@ export default function PickingScheduleRoute() {
selectedIds={selectedIds}
onToggle={toggleSelection}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/priority+/_layout.tsx b/apps/erp/app/routes/x+/priority+/_layout.tsx
index 0bd79fa1d4..80aeab2aa4 100644
--- a/apps/erp/app/routes/x+/priority+/_layout.tsx
+++ b/apps/erp/app/routes/x+/priority+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -22,5 +23,5 @@ export const handle: Handle = {
};
export default function SchedulingRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/priority+/dates.tsx b/apps/erp/app/routes/x+/priority+/dates.tsx
index a967cda34f..eaa52145b0 100644
--- a/apps/erp/app/routes/x+/priority+/dates.tsx
+++ b/apps/erp/app/routes/x+/priority+/dates.tsx
@@ -26,7 +26,7 @@ import {
useLocalStorage,
VStack
} from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import {
endOfMonth,
endOfWeek,
@@ -42,10 +42,7 @@ import { useLocale } from "@react-aria/i18n";
import { replaceEqualDeep } from "@tanstack/react-query";
import { useCallback, useEffect, useMemo, useState } from "react";
import { LuChevronLeft, LuChevronRight, LuSettings2 } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData, useNavigate, useSearchParams } from "react-router";
import { SearchFilter } from "~/components";
import { useLocations } from "~/components/Form/Location";
@@ -76,11 +73,6 @@ export const handle: Handle = {
type ViewType = "week" | "month";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "production",
diff --git a/apps/erp/app/routes/x+/priority+/operations.tsx b/apps/erp/app/routes/x+/priority+/operations.tsx
index 4768262527..6a91a14d63 100644
--- a/apps/erp/app/routes/x+/priority+/operations.tsx
+++ b/apps/erp/app/routes/x+/priority+/operations.tsx
@@ -26,7 +26,6 @@ import {
useMount,
VStack
} from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
import {
getLocalTimeZone,
now,
@@ -43,10 +42,7 @@ import {
LuSettings2,
LuTriangleAlert
} from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { Link, useLoaderData } from "react-router";
import { SearchFilter } from "~/components";
import { Enumerable } from "~/components/Enumerable";
@@ -85,11 +81,6 @@ export const handle: Handle = {
module: "schedule"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "production",
diff --git a/apps/erp/app/routes/x+/procedure+/$id.tsx b/apps/erp/app/routes/x+/procedure+/$id.tsx
index 37c38c69f2..32267a81a1 100644
--- a/apps/erp/app/routes/x+/procedure+/$id.tsx
+++ b/apps/erp/app/routes/x+/procedure+/$id.tsx
@@ -7,18 +7,15 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
import type { JSONContent } from "@carbon/react";
-import { generateHTML, useDebounce } from "@carbon/react";
+import { generateHTML, RecordOutlet, useDebounce } from "@carbon/react";
import { Editor } from "@carbon/react/Editor";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { getLocalTimeZone, today } from "@internationalized/date";
import { msg } from "@lingui/core/macro";
import { useLingui } from "@lingui/react/macro";
import { useEffect, useState } from "react";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useFetcher, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useFetcher, useLoaderData, useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import { useImageUpload, usePermissions, useUser } from "~/hooks";
import { getProcedure, getProcedureVersions } from "~/modules/production";
@@ -41,11 +38,6 @@ export const handle: Handle = {
module: "production"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "production",
@@ -106,7 +98,7 @@ export default function ProcedureRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<ProcedureEditor />
- <Outlet />
+ <RecordOutlet />
</div>
}
properties={
diff --git a/apps/erp/app/routes/x+/procedure+/_layout.tsx b/apps/erp/app/routes/x+/procedure+/_layout.tsx
index 96a7e9e3ff..c6579c532a 100644
--- a/apps/erp/app/routes/x+/procedure+/_layout.tsx
+++ b/apps/erp/app/routes/x+/procedure+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function ProcedureRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/production+/_layout.tsx b/apps/erp/app/routes/x+/production+/_layout.tsx
index 72238cafc2..f7eaff7124 100644
--- a/apps/erp/app/routes/x+/production+/_layout.tsx
+++ b/apps/erp/app/routes/x+/production+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import useProductionSubmodules from "~/modules/production/ui/useProductionSubmodules";
import type { Handle } from "~/utils/handle";
@@ -32,7 +32,7 @@ export const handle: Handle = {
export default function ProductionRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/production+/assemblies.tsx b/apps/erp/app/routes/x+/production+/assemblies.tsx
index 070f8e04e5..0b0d917331 100644
--- a/apps/erp/app/routes/x+/production+/assemblies.tsx
+++ b/apps/erp/app/routes/x+/production+/assemblies.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getAssemblyInstructions } from "~/modules/production";
import AssemblyInstructionsTable from "~/modules/production/ui/Assemblies/AssemblyInstructionsTable";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.assemblyInstructions
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "production",
@@ -57,7 +48,7 @@ export default function AssemblyInstructionsRoute() {
return (
<VStack spacing={0} className="h-full">
<AssemblyInstructionsTable data={instructions} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/production+/batches.tsx b/apps/erp/app/routes/x+/production+/batches.tsx
index e11cdafc0d..05dc2c6ada 100644
--- a/apps/erp/app/routes/x+/production+/batches.tsx
+++ b/apps/erp/app/routes/x+/production+/batches.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
getJobOperationBatches,
getJobOperationBatchMemberStats,
@@ -26,11 +22,6 @@ export const handle: Handle = {
to: path.to.operationBatches
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "production",
@@ -80,7 +71,7 @@ export default function BatchesRoute() {
return (
<VStack spacing={0} className="h-full">
<BatchesTable data={batches} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/production+/demand-forecasts.tsx b/apps/erp/app/routes/x+/production+/demand-forecasts.tsx
index 9a5cdc0bee..4c63628997 100644
--- a/apps/erp/app/routes/x+/production+/demand-forecasts.tsx
+++ b/apps/erp/app/routes/x+/production+/demand-forecasts.tsx
@@ -5,15 +5,12 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { datetime, isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { datetime, redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { usePlanGate } from "~/hooks/usePlanGate";
import { getProductionProjections } from "~/modules/production";
import DemandProjectionsTable from "~/modules/production/ui/DemandProjection/DemandProjectionTable";
@@ -32,11 +29,6 @@ export const handle: Handle = {
export const WEEKS_TO_PROJECT = 12 * 4;
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "production",
@@ -123,7 +115,7 @@ export default function DemandProjectionsRoute() {
locationId={locationId}
periods={periods}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/production+/jobs.tsx b/apps/erp/app/routes/x+/production+/jobs.tsx
index c9262f76c6..9e046e2e31 100644
--- a/apps/erp/app/routes/x+/production+/jobs.tsx
+++ b/apps/erp/app/routes/x+/production+/jobs.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getJobs } from "~/modules/production";
import { JobsTable } from "~/modules/production/ui/Jobs";
import { getLocationsList } from "~/modules/resources";
@@ -99,7 +99,7 @@ export default function JobsRoute() {
tags={tags}
batchesByJobId={batchesByJobId}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/production+/planning.tsx b/apps/erp/app/routes/x+/production+/planning.tsx
index 6302e56013..1fb650924f 100644
--- a/apps/erp/app/routes/x+/production+/planning.tsx
+++ b/apps/erp/app/routes/x+/production+/planning.tsx
@@ -5,14 +5,16 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { ResizablePanel, ResizablePanelGroup, VStack } from "@carbon/react";
-import { datetime, isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import {
+ RecordOutlet,
+ ResizablePanel,
+ ResizablePanelGroup,
+ VStack
+} from "@carbon/react";
+import { datetime, redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import type { ProductionPlanningItem } from "~/modules/production";
import { getProductionPlanning } from "~/modules/production";
import ProductionPlanningTable from "~/modules/production/ui/Planning/ProductionPlanningTable";
@@ -31,11 +33,6 @@ export const handle: Handle = {
to: path.to.productionPlanning
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "production",
@@ -113,7 +110,7 @@ export default function ProductionPlanningRoute() {
periods={periods}
/>
</ResizablePanel>
- <Outlet />
+ <RecordOutlet />
</ResizablePanelGroup>
</VStack>
);
diff --git a/apps/erp/app/routes/x+/production+/procedures.tsx b/apps/erp/app/routes/x+/production+/procedures.tsx
index 46c5726600..cb10e7b021 100644
--- a/apps/erp/app/routes/x+/production+/procedures.tsx
+++ b/apps/erp/app/routes/x+/production+/procedures.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getProcedures } from "~/modules/production";
import ProceduresTable from "~/modules/production/ui/Procedures/ProceduresTable";
import { getTagsList } from "~/modules/shared";
@@ -23,11 +19,6 @@ export const handle: Handle = {
to: path.to.procedures
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "production",
@@ -64,7 +55,7 @@ export default function ProceduresRoute() {
return (
<VStack spacing={0} className="h-full">
<ProceduresTable data={procedures} tags={tags} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/production+/scrap-reasons.tsx b/apps/erp/app/routes/x+/production+/scrap-reasons.tsx
index 132d3c4ecb..b47cd9f8c0 100644
--- a/apps/erp/app/routes/x+/production+/scrap-reasons.tsx
+++ b/apps/erp/app/routes/x+/production+/scrap-reasons.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getScrapReasons } from "~/modules/production";
import ScrapReasonsTable from "~/modules/production/ui/ScrapReasons/ScrapReasonsTable";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.scrapReasons
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "production",
@@ -54,7 +45,7 @@ export default function ScrapReasonsRoute() {
return (
<VStack spacing={0} className="h-full">
<ScrapReasonsTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.$lineId.details.tsx b/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.$lineId.details.tsx
index da1e773c62..6c8f7e2f9f 100644
--- a/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.$lineId.details.tsx
@@ -7,11 +7,12 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import type { JSONContent } from "@carbon/react";
+import { RecordOutlet } from "@carbon/react";
import { getItemReadableId, redirect } from "@carbon/utils";
import { useLingui } from "@lingui/react/macro";
import { Fragment } from "react/jsx-runtime";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData, useParams } from "react-router";
+import { useLoaderData, useParams } from "react-router";
import { DeferredFiles } from "~/components";
import {
getPurchaseInvoice,
@@ -202,7 +203,7 @@ export default function EditPurchaseInvoiceLineRoute() {
)}
</DeferredFiles>
- <Outlet />
+ <RecordOutlet />
</Fragment>
);
}
diff --git a/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.tsx b/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.tsx
index c6a2c6ddd5..835cbd03c7 100644
--- a/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.tsx
+++ b/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.tsx
@@ -5,15 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout";
import { getCurrencyByCode } from "~/modules/accounting";
import {
@@ -53,11 +49,6 @@ export const handle: Handle = {
module: "invoicing"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["invoiceId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId, companyGroupId } = await requirePermissions(
request,
@@ -152,7 +143,7 @@ export default function PurchaseInvoiceRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/purchase-invoice+/_layout.tsx b/apps/erp/app/routes/x+/purchase-invoice+/_layout.tsx
index dd39ac68f0..6ba81e453a 100644
--- a/apps/erp/app/routes/x+/purchase-invoice+/_layout.tsx
+++ b/apps/erp/app/routes/x+/purchase-invoice+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function PurchaseInvoiceRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.$lineId.details.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.$lineId.details.tsx
index 49d22b3622..97721a06f8 100644
--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.$lineId.details.tsx
@@ -8,10 +8,11 @@ import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { getLogger } from "@carbon/logger";
import type { JSONContent } from "@carbon/react";
+import { RecordOutlet } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { Fragment } from "react/jsx-runtime";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData, useParams } from "react-router";
+import { useLoaderData, useParams } from "react-router";
import { CadModel, DeferredFiles } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import {
@@ -240,7 +241,7 @@ export default function EditPurchaseOrderLineRoute() {
viewerClassName="aspect-square min-h-[420px] max-h-[70vh]"
/>
- <Outlet />
+ <RecordOutlet />
</Fragment>
);
}
diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx
index e303ebc011..2e8eeba06b 100644
--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx
+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx
@@ -21,19 +21,15 @@ import { validationError, validator } from "@carbon/form";
import { trigger } from "@carbon/jobs";
import { getLogger } from "@carbon/logger";
import { NotificationEvent } from "@carbon/notifications";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { serverFns } from "@carbon/server-functions";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { renderAsync } from "@react-email/components";
import type { FileObject } from "@supabase/storage-js";
import { parseAcceptLanguage } from "intl-parse-accept-language";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import { getCurrencyByCode, getPaymentTermsList } from "~/modules/accounting";
import { upsertDocument } from "~/modules/documents";
@@ -426,11 +422,6 @@ export async function action(args: ActionFunctionArgs) {
);
}
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["orderId"] })
- ? false
- : args.defaultShouldRevalidate;
-
const toAttachments = (docs: FileObject[], folder: string) =>
docs.map((d) => ({
source: "po" as const,
@@ -623,7 +614,7 @@ export default function PurchaseOrderRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/purchase-order+/_layout.tsx b/apps/erp/app/routes/x+/purchase-order+/_layout.tsx
index f6003bf9f6..121d0fe7a7 100644
--- a/apps/erp/app/routes/x+/purchase-order+/_layout.tsx
+++ b/apps/erp/app/routes/x+/purchase-order+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function PurchaseOrderRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/purchase-return-order+/$id.tsx b/apps/erp/app/routes/x+/purchase-return-order+/$id.tsx
index 36545ed7d4..f95f8de8ff 100644
--- a/apps/erp/app/routes/x+/purchase-return-order+/$id.tsx
+++ b/apps/erp/app/routes/x+/purchase-return-order+/$id.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import {
getPurchaseReturnOrder,
@@ -43,11 +40,6 @@ export const handle: Handle = {
module: "purchasing"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "purchasing"
@@ -104,7 +96,7 @@ export default function PurchaseReturnOrderRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/purchase-return-order+/_layout.tsx b/apps/erp/app/routes/x+/purchase-return-order+/_layout.tsx
index 030c95e9c0..fc1567b13d 100644
--- a/apps/erp/app/routes/x+/purchase-return-order+/_layout.tsx
+++ b/apps/erp/app/routes/x+/purchase-return-order+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function PurchaseReturnOrderRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/purchasing+/_layout.tsx b/apps/erp/app/routes/x+/purchasing+/_layout.tsx
index fc688873eb..f6eb2a9e3b 100644
--- a/apps/erp/app/routes/x+/purchasing+/_layout.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import usePurchasingSubmodules from "~/modules/purchasing/ui/usePurchasingSubmodules";
import type { Handle } from "~/utils/handle";
@@ -32,7 +32,7 @@ export const handle: Handle = {
export default function UsersRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/purchasing+/orders.tsx b/apps/erp/app/routes/x+/purchasing+/orders.tsx
index 7d7d660aeb..8ede5e4153 100644
--- a/apps/erp/app/routes/x+/purchasing+/orders.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/orders.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getPurchaseOrders } from "~/modules/purchasing";
import { PurchaseOrdersTable } from "~/modules/purchasing/ui/PurchaseOrder";
import type { Handle } from "~/utils/handle";
@@ -25,11 +22,6 @@ export const handle: Handle = {
to: path.to.purchaseOrders
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "purchasing",
@@ -77,7 +69,7 @@ export default function PurchaseOrdersSearchRoute() {
return (
<VStack spacing={0} className="h-full">
<PurchaseOrdersTable data={purchasOrders} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/purchasing+/planning.tsx b/apps/erp/app/routes/x+/purchasing+/planning.tsx
index 430abbae2b..826218b8f9 100644
--- a/apps/erp/app/routes/x+/purchasing+/planning.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/planning.tsx
@@ -5,14 +5,16 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { ResizablePanel, ResizablePanelGroup, VStack } from "@carbon/react";
-import { datetime, isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import {
+ RecordOutlet,
+ ResizablePanel,
+ ResizablePanelGroup,
+ VStack
+} from "@carbon/react";
+import { datetime, redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import type { PurchasingPlanningItem } from "~/modules/purchasing";
import { getPurchasingPlanning } from "~/modules/purchasing";
import PurchasingPlanningTable from "~/modules/purchasing/ui/Planning/PurchasingPlanningTable";
@@ -30,11 +32,6 @@ export const handle: Handle = {
to: path.to.purchasingPlanning
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "purchasing",
@@ -112,7 +109,7 @@ export default function PurchasingPlanningRoute() {
periods={periods}
/>
</ResizablePanel>
- <Outlet />
+ <RecordOutlet />
</ResizablePanelGroup>
</VStack>
);
diff --git a/apps/erp/app/routes/x+/purchasing+/quotes.tsx b/apps/erp/app/routes/x+/purchasing+/quotes.tsx
index ba363d64aa..5be3b0786c 100644
--- a/apps/erp/app/routes/x+/purchasing+/quotes.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/quotes.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getSupplierQuotes } from "~/modules/purchasing/purchasing.service";
import { SupplierQuotesTable } from "~/modules/purchasing/ui/SupplierQuote";
import type { Handle } from "~/utils/handle";
@@ -25,11 +22,6 @@ export const handle: Handle = {
to: path.to.supplierQuotes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "purchasing",
@@ -70,7 +62,7 @@ export default function SupplierQuotesRoute() {
return (
<VStack spacing={0} className="h-full">
<SupplierQuotesTable data={quotes} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/purchasing+/rfqs.tsx b/apps/erp/app/routes/x+/purchasing+/rfqs.tsx
index 48586fb573..fb7c32b09f 100644
--- a/apps/erp/app/routes/x+/purchasing+/rfqs.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/rfqs.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getPurchasingRFQs } from "~/modules/purchasing";
import { PurchasingRFQsTable } from "~/modules/purchasing/ui/PurchasingRfq";
import type { Handle } from "~/utils/handle";
@@ -62,7 +62,7 @@ export default function PurchasingRFQsRoute() {
return (
<VStack spacing={0} className="h-full">
<PurchasingRFQsTable data={rfqs} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/purchasing+/supplier-returns.tsx b/apps/erp/app/routes/x+/purchasing+/supplier-returns.tsx
index a5f7a8e6c0..8180ed873f 100644
--- a/apps/erp/app/routes/x+/purchasing+/supplier-returns.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/supplier-returns.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getPurchaseReturnOrders } from "~/modules/purchasing";
import { PurchaseReturnOrdersTable } from "~/modules/purchasing/ui/PurchaseReturnOrders";
import type { Handle } from "~/utils/handle";
@@ -75,7 +75,7 @@ export default function PurchaseReturnOrdersSearchRoute() {
return (
<VStack spacing={0} className="h-full">
<PurchaseReturnOrdersTable data={purchaseReturnOrders} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/purchasing+/supplier-types.tsx b/apps/erp/app/routes/x+/purchasing+/supplier-types.tsx
index 9fbf007b24..8401c75fdc 100644
--- a/apps/erp/app/routes/x+/purchasing+/supplier-types.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/supplier-types.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getSupplierTypes } from "~/modules/purchasing";
import { SupplierTypesTable } from "~/modules/purchasing/ui/SupplierTypes";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.supplierTypes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "purchasing",
@@ -52,7 +43,7 @@ export default function SupplierTypesRoute() {
return (
<VStack spacing={0} className="h-full">
<SupplierTypesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/purchasing+/suppliers.tsx b/apps/erp/app/routes/x+/purchasing+/suppliers.tsx
index 7c8b404c33..f317c6b402 100644
--- a/apps/erp/app/routes/x+/purchasing+/suppliers.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/suppliers.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { indexBy, indexByMapped, pluckUnique, redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import type { SupplierReportContactsBySupplierId } from "~/modules/purchasing";
import { getSupplierReportContacts, getSuppliers } from "~/modules/purchasing";
import { SuppliersTable } from "~/modules/purchasing/ui/Supplier";
@@ -104,7 +104,7 @@ export default function PurchasingSuppliersRoute() {
tags={tags}
supplierReportContacts={supplierReportContacts}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.$lineId.details.tsx b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.$lineId.details.tsx
index fe4bd937ff..848ee6f600 100644
--- a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.$lineId.details.tsx
@@ -9,10 +9,11 @@ import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { getLogger } from "@carbon/logger";
import type { JSONContent } from "@carbon/react";
+import { RecordOutlet } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { Fragment } from "react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData, useParams } from "react-router";
+import { useLoaderData, useParams } from "react-router";
import { CadModel, DeferredFiles } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type { PurchasingRFQ } from "~/modules/purchasing";
@@ -203,7 +204,7 @@ export default function PurchasingRFQLine() {
viewerClassName="aspect-square min-h-[420px] max-h-[70vh]"
/>
- <Outlet />
+ <RecordOutlet />
</Fragment>
);
}
diff --git a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.tsx b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.tsx
index 64179648a3..2e881bda21 100644
--- a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.tsx
+++ b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.tsx
@@ -7,14 +7,11 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
-import { type JSONContent, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { type JSONContent, RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import type { PurchasingRFQLine } from "~/modules/purchasing";
import {
@@ -46,11 +43,6 @@ export const handle: Handle = {
module: "purchasing"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["rfqId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { companyId } = await requirePermissions(request, {
view: "purchasing"
@@ -151,7 +143,7 @@ export default function PurchasingRFQRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/purchasing-rfq+/_layout.tsx b/apps/erp/app/routes/x+/purchasing-rfq+/_layout.tsx
index db317fd7f6..01b3b31e27 100644
--- a/apps/erp/app/routes/x+/purchasing-rfq+/_layout.tsx
+++ b/apps/erp/app/routes/x+/purchasing-rfq+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function PurchasingRFQRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/quality+/_layout.tsx b/apps/erp/app/routes/x+/quality+/_layout.tsx
index 9fb652b399..f4b51985da 100644
--- a/apps/erp/app/routes/x+/quality+/_layout.tsx
+++ b/apps/erp/app/routes/x+/quality+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import useQualitySubmodules from "~/modules/quality/ui/useQualitySubmodules";
import type { Handle } from "~/utils/handle";
@@ -32,7 +32,7 @@ export const handle: Handle = {
export default function QualityRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/actions.tsx b/apps/erp/app/routes/x+/quality+/actions.tsx
index 65ab4b959d..37a0a5ead6 100644
--- a/apps/erp/app/routes/x+/quality+/actions.tsx
+++ b/apps/erp/app/routes/x+/quality+/actions.tsx
@@ -4,10 +4,10 @@
import { requirePermissions } from "@carbon/auth/auth.server";
import { getLogger } from "@carbon/logger";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import {
getIssueTypesList,
getQualityActions,
@@ -73,7 +73,7 @@ export default function ActionsRoute() {
issueTypes={issueTypes}
requiredActions={requiredActions}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/calibrations.tsx b/apps/erp/app/routes/x+/quality+/calibrations.tsx
index 4ea3315296..641a48e686 100644
--- a/apps/erp/app/routes/x+/quality+/calibrations.tsx
+++ b/apps/erp/app/routes/x+/quality+/calibrations.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
getGaugeCalibrationRecords,
getGaugeTypesList
@@ -26,11 +22,6 @@ export const handle: Handle = {
to: path.to.gauges
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "quality",
@@ -75,7 +66,7 @@ export default function GaugesRoute() {
count={count}
types={gaugeTypes}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/documents.tsx b/apps/erp/app/routes/x+/quality+/documents.tsx
index a51eff94ef..6d17580d7a 100644
--- a/apps/erp/app/routes/x+/quality+/documents.tsx
+++ b/apps/erp/app/routes/x+/quality+/documents.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getQualityDocuments } from "~/modules/quality";
import QualityDocumentsTable from "~/modules/quality/ui/Documents/QualityDocumentsTable";
import { getTagsList } from "~/modules/shared";
@@ -23,11 +19,6 @@ export const handle: Handle = {
to: path.to.qualityDocuments
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "quality",
@@ -68,7 +59,7 @@ export default function QualityDocumentsRoute() {
count={count}
tags={tags}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/gauge-types.tsx b/apps/erp/app/routes/x+/quality+/gauge-types.tsx
index 8a80e0596a..fd7925a419 100644
--- a/apps/erp/app/routes/x+/quality+/gauge-types.tsx
+++ b/apps/erp/app/routes/x+/quality+/gauge-types.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getGaugeTypes } from "~/modules/quality";
import GaugeTypesTable from "~/modules/quality/ui/GaugeTypes/GaugeTypesTable";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.gaugeTypes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "quality",
@@ -54,7 +45,7 @@ export default function NonConformanceTypesRoute() {
return (
<VStack spacing={0} className="h-full">
<GaugeTypesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/gauges.tsx b/apps/erp/app/routes/x+/quality+/gauges.tsx
index ef39175038..bb6f44f0d3 100644
--- a/apps/erp/app/routes/x+/quality+/gauges.tsx
+++ b/apps/erp/app/routes/x+/quality+/gauges.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getGauges, getGaugeTypesList } from "~/modules/quality";
import GaugesTable from "~/modules/quality/ui/Gauge/GaugesTable";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.gauges
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "quality",
@@ -63,7 +54,7 @@ export default function GaugesRoute() {
return (
<VStack spacing={0} className="h-full">
<GaugesTable data={gauges} count={count} types={gaugeTypes} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/inspection-plans.tsx b/apps/erp/app/routes/x+/quality+/inspection-plans.tsx
index 8424c76dbc..bf862deba0 100644
--- a/apps/erp/app/routes/x+/quality+/inspection-plans.tsx
+++ b/apps/erp/app/routes/x+/quality+/inspection-plans.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getInspectionDocuments } from "~/modules/quality";
import { InspectionDocumentTable } from "~/modules/quality/ui/InspectionDocument";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.inspectionDocuments
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "quality",
@@ -59,7 +50,7 @@ export default function InspectionDocumentsRoute() {
return (
<VStack spacing={0} className="h-full">
<InspectionDocumentTable data={diagrams} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/inspections.tsx b/apps/erp/app/routes/x+/quality+/inspections.tsx
index 88cbc7581c..2bdffbd59d 100644
--- a/apps/erp/app/routes/x+/quality+/inspections.tsx
+++ b/apps/erp/app/routes/x+/quality+/inspections.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getInspections } from "~/modules/quality";
import InspectionsTable from "~/modules/quality/ui/Inspections/InspectionsTable";
import type { Handle } from "~/utils/handle";
@@ -68,7 +68,7 @@ export default function InspectionsRoute() {
return (
<VStack spacing={0} className="h-full">
<InspectionsTable data={inspections} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/issue-types.tsx b/apps/erp/app/routes/x+/quality+/issue-types.tsx
index 6f13469fcf..437c5cadd0 100644
--- a/apps/erp/app/routes/x+/quality+/issue-types.tsx
+++ b/apps/erp/app/routes/x+/quality+/issue-types.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getIssueTypes } from "~/modules/quality";
import IssueTypesTable from "~/modules/quality/ui/IssueTypes/IssueTypesTable";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.issueTypes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "quality",
@@ -54,7 +45,7 @@ export default function IssueTypesRoute() {
return (
<VStack spacing={0} className="h-full">
<IssueTypesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/issue-workflows.tsx b/apps/erp/app/routes/x+/quality+/issue-workflows.tsx
index 04e077ad26..61ecbafba5 100644
--- a/apps/erp/app/routes/x+/quality+/issue-workflows.tsx
+++ b/apps/erp/app/routes/x+/quality+/issue-workflows.tsx
@@ -3,10 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getIssueWorkflows } from "~/modules/quality";
import IssueWorkflowsTable from "~/modules/quality/ui/IssueWorkflows/IssueWorkflowsTable";
import type { Handle } from "~/utils/handle";
@@ -50,7 +50,7 @@ export default function IssueWorkflowsRoute() {
return (
<VStack spacing={0} className="h-full">
<IssueWorkflowsTable data={procedures} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/issues.tsx b/apps/erp/app/routes/x+/quality+/issues.tsx
index 314ffa6124..87ac72cd2a 100644
--- a/apps/erp/app/routes/x+/quality+/issues.tsx
+++ b/apps/erp/app/routes/x+/quality+/issues.tsx
@@ -6,11 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getIssues, getIssueTypesList } from "~/modules/quality";
import IssuesTable from "~/modules/quality/ui/Issue/IssuesTable";
import type { Handle } from "~/utils/handle";
@@ -69,7 +69,7 @@ export default function IssuesRoute() {
return (
<VStack spacing={0} className="h-full">
<IssuesTable data={issues} count={count} types={types} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/required-actions.tsx b/apps/erp/app/routes/x+/quality+/required-actions.tsx
index f24583ace8..b6b5b413ea 100644
--- a/apps/erp/app/routes/x+/quality+/required-actions.tsx
+++ b/apps/erp/app/routes/x+/quality+/required-actions.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getRequiredActions } from "~/modules/quality";
import RequiredActionsTable from "~/modules/quality/ui/RequiredActions/RequiredActionsTable";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.requiredActions
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "quality",
@@ -54,7 +45,7 @@ export default function RequiredActionsRoute() {
return (
<VStack spacing={0} className="h-full">
<RequiredActionsTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/risks.tsx b/apps/erp/app/routes/x+/quality+/risks.tsx
index 61f26fc8fe..f6b2575fec 100644
--- a/apps/erp/app/routes/x+/quality+/risks.tsx
+++ b/apps/erp/app/routes/x+/quality+/risks.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { data, Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { data, useLoaderData } from "react-router";
import { getRisks } from "~/modules/quality/quality.service";
import type { Risk } from "~/modules/quality/types";
import RiskRegistersTable from "~/modules/quality/ui/RiskRegister/RiskRegistersTable";
@@ -25,11 +22,6 @@ export const handle: Handle = {
to: path.to.risks
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "quality",
@@ -69,7 +61,7 @@ export default function RisksRoute() {
return (
<VStack spacing={0} className="h-full">
<RiskRegistersTable data={risks} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality-document+/$id.tsx b/apps/erp/app/routes/x+/quality-document+/$id.tsx
index 8d3de44b44..76480c9573 100644
--- a/apps/erp/app/routes/x+/quality-document+/$id.tsx
+++ b/apps/erp/app/routes/x+/quality-document+/$id.tsx
@@ -19,11 +19,12 @@ import { validationError, validator } from "@carbon/form";
import { trigger } from "@carbon/jobs";
import { getLogger } from "@carbon/logger";
import { NotificationEvent } from "@carbon/notifications";
+import { RecordOutlet } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { SupabaseClient } from "@supabase/supabase-js";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData, useParams } from "react-router";
+import { useLoaderData, useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import {
getQualityDocument,
@@ -300,7 +301,7 @@ export default function QualityDocumentRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<QualityDocumentEditor />
- <Outlet />
+ <RecordOutlet />
</div>
}
properties={
diff --git a/apps/erp/app/routes/x+/quality-document+/_layout.tsx b/apps/erp/app/routes/x+/quality-document+/_layout.tsx
index f462111c42..322075994b 100644
--- a/apps/erp/app/routes/x+/quality-document+/_layout.tsx
+++ b/apps/erp/app/routes/x+/quality-document+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function QualityDocumentRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
index 382d1c1a9b..83ec00d187 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
@@ -13,12 +13,12 @@ import {
} from "@carbon/ee/rules.server";
import { validationError, validator } from "@carbon/form";
import type { JSONContent } from "@carbon/react";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { breakQuantities, redirect } from "@carbon/utils";
import { useLingui } from "@lingui/react/macro";
import { Fragment, Suspense, useMemo } from "react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
+import { Await, useLoaderData, useParams } from "react-router";
import { CadModel, DeferredFiles } from "~/components";
import type { Tree } from "~/components/TreeView";
import { usePermissions, useRealtime, useRouteData, useUser } from "~/hooks";
@@ -567,7 +567,7 @@ export default function QuoteLine() {
<QuoteLineRiskRegister quoteLineId={lineId} itemId={line.itemId ?? ""} />
- <Outlet />
+ <RecordOutlet />
</Fragment>
);
}
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.tsx
index 67b3abd964..c6a30abcf5 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.tsx
@@ -5,18 +5,15 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import type { DragEndEvent } from "@dnd-kit/core";
import { DndContext } from "@dnd-kit/core";
import { msg } from "@lingui/core/macro";
import type { FileObject } from "@supabase/storage-js";
import type { PostgrestResponse } from "@supabase/supabase-js";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useParams, useSubmit } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useParams, useSubmit } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import { getExchangeRate } from "~/modules/accounting";
import { getSupplierPriceBreaksForItems } from "~/modules/items";
@@ -58,11 +55,6 @@ export const handle: Handle = {
module: "sales"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["quoteId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -267,7 +259,7 @@ export default function QuoteRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-hide w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/quote+/_layout.tsx b/apps/erp/app/routes/x+/quote+/_layout.tsx
index 43df63e44e..1a0cf5659d 100644
--- a/apps/erp/app/routes/x+/quote+/_layout.tsx
+++ b/apps/erp/app/routes/x+/quote+/_layout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -26,9 +22,6 @@ export const handle: Handle = {
module: "sales"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
await requirePermissions(request, {
view: "sales"
@@ -38,5 +31,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function QuoteRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/receipt+/$receiptId.tsx b/apps/erp/app/routes/x+/receipt+/$receiptId.tsx
index c9419f3bad..1282fc0573 100644
--- a/apps/erp/app/routes/x+/receipt+/$receiptId.tsx
+++ b/apps/erp/app/routes/x+/receipt+/$receiptId.tsx
@@ -6,13 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import {
getBatchProperties,
getReceipt,
@@ -38,11 +36,6 @@ export const handle: Handle = {
module: "inventory"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["receiptId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { companyId } = await requirePermissions(request, {
view: "inventory"
@@ -156,7 +149,7 @@ export default function ReceiptRoute() {
<div className="flex h-[calc(100dvh-var(--topbar-height)-var(--content-inset))] overflow-y-auto scrollbar-hide w-full">
<div className="h-full p-4 w-full max-w-5xl mx-auto">
<div className="flex flex-col gap-4 pb-16 w-full">
- <Outlet />
+ <RecordOutlet />
</div>
</div>
</div>
diff --git a/apps/erp/app/routes/x+/receipt+/_layout.tsx b/apps/erp/app/routes/x+/receipt+/_layout.tsx
index e3eab8cffb..5c5cc5f9bc 100644
--- a/apps/erp/app/routes/x+/receipt+/_layout.tsx
+++ b/apps/erp/app/routes/x+/receipt+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function ReceiptRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/reimbursements+/$reimbursementId.tsx b/apps/erp/app/routes/x+/reimbursements+/$reimbursementId.tsx
index aa38c3e37b..a7423ae677 100644
--- a/apps/erp/app/routes/x+/reimbursements+/$reimbursementId.tsx
+++ b/apps/erp/app/routes/x+/reimbursements+/$reimbursementId.tsx
@@ -2,8 +2,9 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -27,7 +28,7 @@ export default function ReimbursementRoute() {
return (
<div className="flex h-[calc(100dvh-var(--topbar-height)-var(--content-inset))] overflow-y-auto scrollbar-hide w-full">
<div className="h-full p-4 w-full max-w-5xl mx-auto">
- <Outlet />
+ <RecordOutlet />
</div>
</div>
);
diff --git a/apps/erp/app/routes/x+/reimbursements+/_layout.tsx b/apps/erp/app/routes/x+/reimbursements+/_layout.tsx
index 6330c4fe7a..a7ff459aca 100644
--- a/apps/erp/app/routes/x+/reimbursements+/_layout.tsx
+++ b/apps/erp/app/routes/x+/reimbursements+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function ReimbursementsLayout() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/reports+/_layout.tsx b/apps/erp/app/routes/x+/reports+/_layout.tsx
index e483c9730c..3e4bc6f29b 100644
--- a/apps/erp/app/routes/x+/reports+/_layout.tsx
+++ b/apps/erp/app/routes/x+/reports+/_layout.tsx
@@ -2,8 +2,9 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import { Outlet } from "react-router";
+
import type { BreadcrumbSegment, Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -29,7 +30,7 @@ export const handle: Handle = {
export default function ReportsRoute() {
return (
<div className="h-full bg-card">
- <Outlet />
+ <RecordOutlet />
</div>
);
}
diff --git a/apps/erp/app/routes/x+/reports+/balance-sheet.tsx b/apps/erp/app/routes/x+/reports+/balance-sheet.tsx
index 4834eef53f..8a45987a22 100644
--- a/apps/erp/app/routes/x+/reports+/balance-sheet.tsx
+++ b/apps/erp/app/routes/x+/reports+/balance-sheet.tsx
@@ -5,7 +5,7 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import {
computeReportPeriodBuckets,
datetime,
@@ -16,7 +16,7 @@ import { msg } from "@lingui/core/macro";
import { useLocale } from "@react-aria/i18n";
import { useState } from "react";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import {
financialReportParamsValidator,
getCompaniesInGroup,
@@ -311,7 +311,7 @@ export default function BalanceSheetRoute() {
search={search}
ledgerPath={path.to.balanceSheetLedger}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/reports+/income-statement.tsx b/apps/erp/app/routes/x+/reports+/income-statement.tsx
index d7ddd4c80d..48b4a0deca 100644
--- a/apps/erp/app/routes/x+/reports+/income-statement.tsx
+++ b/apps/erp/app/routes/x+/reports+/income-statement.tsx
@@ -5,7 +5,7 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import {
computeReportPeriodBuckets,
datetime,
@@ -16,7 +16,7 @@ import { msg } from "@lingui/core/macro";
import { useLocale } from "@react-aria/i18n";
import { useState } from "react";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import {
financialReportParamsValidator,
getCompaniesInGroup,
@@ -260,7 +260,7 @@ export default function IncomeStatementRoute() {
search={search}
ledgerPath={path.to.incomeStatementLedger}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/reports+/inventory-valuation.tsx b/apps/erp/app/routes/x+/reports+/inventory-valuation.tsx
index 117c103571..53f46426e2 100644
--- a/apps/erp/app/routes/x+/reports+/inventory-valuation.tsx
+++ b/apps/erp/app/routes/x+/reports+/inventory-valuation.tsx
@@ -3,12 +3,9 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { datetime, isUnaffectedByNavigation } from "@carbon/utils";
+import { datetime } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import {
getInventoryValuation,
@@ -26,11 +23,6 @@ export const handle: Handle = {
module: "accounting"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "accounting"
diff --git a/apps/erp/app/routes/x+/reports+/trial-balance.tsx b/apps/erp/app/routes/x+/reports+/trial-balance.tsx
index 7e4646c0a3..3c5280d23b 100644
--- a/apps/erp/app/routes/x+/reports+/trial-balance.tsx
+++ b/apps/erp/app/routes/x+/reports+/trial-balance.tsx
@@ -5,12 +5,12 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { datetime, defaultReportRange, redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { useState } from "react";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import type { Chart } from "~/modules/accounting";
import {
financialReportParamsValidator,
@@ -270,7 +270,7 @@ export default function TrialBalanceRoute() {
search={search}
ledgerPath={path.to.trialBalanceLedger}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/_layout.tsx b/apps/erp/app/routes/x+/resources+/_layout.tsx
index f82bbf71dc..3e26770f85 100644
--- a/apps/erp/app/routes/x+/resources+/_layout.tsx
+++ b/apps/erp/app/routes/x+/resources+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import { useResourcesSubmodules } from "~/modules/resources";
import type { Handle } from "~/utils/handle";
@@ -32,7 +32,7 @@ export const handle: Handle = {
export default function ResourcesRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/abilities.tsx b/apps/erp/app/routes/x+/resources+/abilities.tsx
index ecee0711dd..985acd3ee4 100644
--- a/apps/erp/app/routes/x+/resources+/abilities.tsx
+++ b/apps/erp/app/routes/x+/resources+/abilities.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { AbilitiesTable, getAbilities } from "~/modules/resources";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -23,11 +20,6 @@ export const handle: Handle = {
to: path.to.abilities
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -67,7 +59,7 @@ export default function AbilitiesRoute() {
return (
<VStack spacing={0} className="h-full">
<AbilitiesTable data={abilities} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/ability.$id.tsx b/apps/erp/app/routes/x+/resources+/ability.$id.tsx
index a543192233..ee0ac80d75 100644
--- a/apps/erp/app/routes/x+/resources+/ability.$id.tsx
+++ b/apps/erp/app/routes/x+/resources+/ability.$id.tsx
@@ -5,14 +5,11 @@
import { error, notFound } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { AbilityEmployeesTable, getAbility } from "~/modules/resources";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -22,11 +19,6 @@ export const handle: Handle = {
to: path.to.abilities
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "resources",
@@ -53,7 +45,7 @@ export default function AbilityRoute() {
return (
<VStack spacing={0} className="h-full">
<AbilityEmployeesTable ability={ability} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/assignments.assignment.$assignmentId.tsx b/apps/erp/app/routes/x+/resources+/assignments.assignment.$assignmentId.tsx
index a8c9961392..7a142526cf 100644
--- a/apps/erp/app/routes/x+/resources+/assignments.assignment.$assignmentId.tsx
+++ b/apps/erp/app/routes/x+/resources+/assignments.assignment.$assignmentId.tsx
@@ -9,13 +9,9 @@ import { validationError, validator } from "@carbon/form";
import { trigger } from "@carbon/jobs";
import { getLogger } from "@carbon/logger";
import { NotificationEvent } from "@carbon/notifications";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { data, useLoaderData, useNavigate, useParams } from "react-router";
import {
getTrainingAssignment,
@@ -39,11 +35,6 @@ export const handle: Handle = {
to: path.to.trainingAssignments
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["assignmentId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
diff --git a/apps/erp/app/routes/x+/resources+/assignments.tsx b/apps/erp/app/routes/x+/resources+/assignments.tsx
index e093f4e2d6..592014cbf8 100644
--- a/apps/erp/app/routes/x+/resources+/assignments.tsx
+++ b/apps/erp/app/routes/x+/resources+/assignments.tsx
@@ -12,9 +12,10 @@ import {
MENU_ITEM_SHORTCUTS,
MenuIcon,
MenuItem,
+ RecordOutlet,
VStack
} from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans, useLingui } from "@lingui/react/macro";
import type { ColumnDef } from "@tanstack/react-table";
@@ -31,11 +32,8 @@ import {
LuTriangleAlert,
LuUsers
} from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Link, Outlet, useFetcher, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { Link, useFetcher, useLoaderData } from "react-router";
import { Hyperlink, New, Table } from "~/components";
import { usePermissions } from "~/hooks";
import {
@@ -51,9 +49,6 @@ export const handle: Handle = {
to: path.to.trainingAssignments
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -287,7 +282,7 @@ export default function TrainingAssignmentsRoute() {
data={summary}
assignmentsByTraining={assignmentsByTraining}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/contractors.tsx b/apps/erp/app/routes/x+/resources+/contractors.tsx
index cc5d027f3c..2e61bcf553 100644
--- a/apps/erp/app/routes/x+/resources+/contractors.tsx
+++ b/apps/erp/app/routes/x+/resources+/contractors.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
ContractorsTable,
getAbilitiesList,
@@ -27,11 +24,6 @@ export const handle: Handle = {
to: path.to.contractors
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -84,7 +76,7 @@ export default function Route() {
// @ts-expect-error TS2322 - TODO: fix type
abilities={abilities}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/failure-modes.tsx b/apps/erp/app/routes/x+/resources+/failure-modes.tsx
index 235b153067..d50bce14b8 100644
--- a/apps/erp/app/routes/x+/resources+/failure-modes.tsx
+++ b/apps/erp/app/routes/x+/resources+/failure-modes.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getFailureModes } from "~/modules/resources";
import FailureModesTable from "~/modules/resources/ui/FailureModes/FailureModesTable";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.failureModes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -54,7 +45,7 @@ export default function FailureModesRoute() {
return (
<VStack spacing={0} className="h-full">
<FailureModesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/locations.tsx b/apps/erp/app/routes/x+/resources+/locations.tsx
index 22586c678b..43bbf800cf 100644
--- a/apps/erp/app/routes/x+/resources+/locations.tsx
+++ b/apps/erp/app/routes/x+/resources+/locations.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getLocations, LocationsTable } from "~/modules/resources";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -23,11 +20,6 @@ export const handle: Handle = {
to: path.to.locations
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -68,7 +60,7 @@ export default function LocationsRoute() {
return (
<VStack spacing={0} className="h-full">
<LocationsTable data={locations} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/maintenance.tsx b/apps/erp/app/routes/x+/resources+/maintenance.tsx
index 7bd2835a24..d78c3582a7 100644
--- a/apps/erp/app/routes/x+/resources+/maintenance.tsx
+++ b/apps/erp/app/routes/x+/resources+/maintenance.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
getFailureModesList,
getLocationsList,
@@ -26,11 +22,6 @@ export const handle: Handle = {
to: path.to.maintenanceDispatches
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -96,7 +87,7 @@ export default function MaintenanceRoute() {
locations={locations}
locationId={locationId}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/partners.tsx b/apps/erp/app/routes/x+/resources+/partners.tsx
index f318aad83b..ec901d5da4 100644
--- a/apps/erp/app/routes/x+/resources+/partners.tsx
+++ b/apps/erp/app/routes/x+/resources+/partners.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
getAbilitiesList,
getPartners,
@@ -27,11 +24,6 @@ export const handle: Handle = {
to: path.to.partners
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -75,7 +67,7 @@ export default function Route() {
return (
<VStack spacing={0} className="h-full">
<PartnersTable data={partners} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/processes.tsx b/apps/erp/app/routes/x+/resources+/processes.tsx
index d835b13c3a..f6e930a8ff 100644
--- a/apps/erp/app/routes/x+/resources+/processes.tsx
+++ b/apps/erp/app/routes/x+/resources+/processes.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getProcesses, ProcessesTable } from "~/modules/resources";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -23,11 +20,6 @@ export const handle: Handle = {
to: path.to.processes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -68,7 +60,7 @@ export default function ProcessesRoute() {
return (
<VStack spacing={0} className="h-full">
<ProcessesTable data={processes} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/scheduled-maintenance.tsx b/apps/erp/app/routes/x+/resources+/scheduled-maintenance.tsx
index 7fe7ea6b9f..24599da409 100644
--- a/apps/erp/app/routes/x+/resources+/scheduled-maintenance.tsx
+++ b/apps/erp/app/routes/x+/resources+/scheduled-maintenance.tsx
@@ -5,14 +5,10 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { data, Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { data, useLoaderData } from "react-router";
import type { MaintenanceSchedule } from "~/modules/resources";
import {
getLocationsList,
@@ -28,11 +24,6 @@ export const handle: Handle = {
to: path.to.maintenanceSchedules
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -108,7 +99,7 @@ export default function MaintenanceSchedulesRoute() {
locations={locations}
locationId={locationId}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/suggestions.tsx b/apps/erp/app/routes/x+/resources+/suggestions.tsx
index 2fc0406557..3cb3f3a393 100644
--- a/apps/erp/app/routes/x+/resources+/suggestions.tsx
+++ b/apps/erp/app/routes/x+/resources+/suggestions.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getSuggestions, SuggestionsTable } from "~/modules/resources";
import { getTagsList } from "~/modules/shared";
import type { Handle } from "~/utils/handle";
@@ -24,11 +21,6 @@ export const handle: Handle = {
to: path.to.suggestions
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -76,7 +68,7 @@ export default function SuggestionsRoute() {
return (
<VStack spacing={0} className="h-full">
<SuggestionsTable data={suggestions} tags={tags} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/training.tsx b/apps/erp/app/routes/x+/resources+/training.tsx
index 81ca640bae..ce0800fa28 100644
--- a/apps/erp/app/routes/x+/resources+/training.tsx
+++ b/apps/erp/app/routes/x+/resources+/training.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getTrainings, TrainingsTable } from "~/modules/resources";
import { getTagsList } from "~/modules/shared";
import type { Handle } from "~/utils/handle";
@@ -24,11 +21,6 @@ export const handle: Handle = {
to: path.to.trainings
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -79,7 +71,7 @@ export default function TrainingsRoute() {
return (
<VStack spacing={0} className="h-full">
<TrainingsTable data={trainings} count={count} tags={tags} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/work-centers.tsx b/apps/erp/app/routes/x+/resources+/work-centers.tsx
index 8d70c11797..75068dc6fc 100644
--- a/apps/erp/app/routes/x+/resources+/work-centers.tsx
+++ b/apps/erp/app/routes/x+/resources+/work-centers.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getDepartmentsList } from "~/modules/people";
import {
getLocationsList,
@@ -28,11 +25,6 @@ export const handle: Handle = {
to: path.to.workCenters
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -88,7 +80,7 @@ export default function WorkCentersRoute() {
departments={departments}
locations={locations}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/_layout.tsx b/apps/erp/app/routes/x+/sales+/_layout.tsx
index 0127495851..6455937b30 100644
--- a/apps/erp/app/routes/x+/sales+/_layout.tsx
+++ b/apps/erp/app/routes/x+/sales+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import useSalesSubmodules from "~/modules/sales/ui/useSalesSubmodules";
import type { Handle } from "~/utils/handle";
@@ -32,7 +32,7 @@ export const handle: Handle = {
export default function SalesRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/customer-portals.tsx b/apps/erp/app/routes/x+/sales+/customer-portals.tsx
index 4fe866110b..95383cc45a 100644
--- a/apps/erp/app/routes/x+/sales+/customer-portals.tsx
+++ b/apps/erp/app/routes/x+/sales+/customer-portals.tsx
@@ -4,14 +4,10 @@
import { getAppUrl } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { usePlanGate } from "~/hooks/usePlanGate";
import {
CustomerPortalsTable,
@@ -27,11 +23,6 @@ export const handle: Handle = {
to: path.to.customerPortals
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -71,7 +62,7 @@ export default function CustomerPortalsRoute() {
data={data ?? []}
count={count ?? 0}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/customer-statuses.tsx b/apps/erp/app/routes/x+/sales+/customer-statuses.tsx
index 72c075b31f..2d65048557 100644
--- a/apps/erp/app/routes/x+/sales+/customer-statuses.tsx
+++ b/apps/erp/app/routes/x+/sales+/customer-statuses.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getCustomerStatuses } from "~/modules/sales";
import { CustomerStatusesTable } from "~/modules/sales/ui/CustomerStatuses";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.customerStatuses
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -54,7 +45,7 @@ export default function CustomerStatusesRoute() {
return (
<VStack spacing={0} className="h-full">
<CustomerStatusesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/customer-types.tsx b/apps/erp/app/routes/x+/sales+/customer-types.tsx
index ddf8c62de1..ba1628b64d 100644
--- a/apps/erp/app/routes/x+/sales+/customer-types.tsx
+++ b/apps/erp/app/routes/x+/sales+/customer-types.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getCustomerTypes } from "~/modules/sales";
import { CustomerTypesTable } from "~/modules/sales/ui/CustomerTypes";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.customerTypes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -54,7 +45,7 @@ export default function CustomerTypesRoute() {
return (
<VStack spacing={0} className="h-full">
<CustomerTypesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/customers.tsx b/apps/erp/app/routes/x+/sales+/customers.tsx
index b3b153cdbe..a75271cdb0 100644
--- a/apps/erp/app/routes/x+/sales+/customers.tsx
+++ b/apps/erp/app/routes/x+/sales+/customers.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getCustomerStatuses, getCustomers } from "~/modules/sales";
import { CustomersTable } from "~/modules/sales/ui/Customers";
import { getTagsList } from "~/modules/shared";
@@ -75,7 +75,7 @@ export default function SalesCustomersRoute() {
customerStatuses={customerStatuses}
tags={tags}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/no-quote-reasons.tsx b/apps/erp/app/routes/x+/sales+/no-quote-reasons.tsx
index 4455d59f7a..86ffef6cea 100644
--- a/apps/erp/app/routes/x+/sales+/no-quote-reasons.tsx
+++ b/apps/erp/app/routes/x+/sales+/no-quote-reasons.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getNoQuoteReasons } from "~/modules/sales";
import { NoQuoteReasonsTable } from "~/modules/sales/ui/NoQuoteReasons";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.noQuoteReasons
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -54,7 +45,7 @@ export default function ScrapReasonsRoute() {
return (
<VStack spacing={0} className="h-full">
<NoQuoteReasonsTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/orders.tsx b/apps/erp/app/routes/x+/sales+/orders.tsx
index 4c781d3c1b..3af91c0f3e 100644
--- a/apps/erp/app/routes/x+/sales+/orders.tsx
+++ b/apps/erp/app/routes/x+/sales+/orders.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getSalesOrders } from "~/modules/sales";
import { SalesOrdersTable } from "~/modules/sales/ui/SalesOrder";
import type { Handle } from "~/utils/handle";
@@ -69,7 +69,7 @@ export default function SalesOrdersSearchRoute() {
return (
<VStack spacing={0} className="h-full">
<SalesOrdersTable data={salesOrders} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/price-list.tsx b/apps/erp/app/routes/x+/sales+/price-list.tsx
index 89d689e59a..e87665081d 100644
--- a/apps/erp/app/routes/x+/sales+/price-list.tsx
+++ b/apps/erp/app/routes/x+/sales+/price-list.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getBaseCatalog, resolvePriceList } from "~/modules/sales";
import PriceListTable from "~/modules/sales/ui/Pricing/PriceOverridesTable";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.salesPriceList
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -107,7 +98,7 @@ export default function PriceListRoute() {
scopeOptions={scopeOptions}
hasScope={hasScope}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/pricing-rules.tsx b/apps/erp/app/routes/x+/sales+/pricing-rules.tsx
index 65b488d43c..e5e086cfb0 100644
--- a/apps/erp/app/routes/x+/sales+/pricing-rules.tsx
+++ b/apps/erp/app/routes/x+/sales+/pricing-rules.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getPricingRules } from "~/modules/sales";
import PricingRulesTable from "~/modules/sales/ui/Pricing/PricingRulesTable";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.salesPricingRules
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -54,7 +45,7 @@ export default function PricingRulesRoute() {
return (
<VStack spacing={0} className="h-full">
<PricingRulesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/quotes.tsx b/apps/erp/app/routes/x+/sales+/quotes.tsx
index 59ef366937..223d12491a 100644
--- a/apps/erp/app/routes/x+/sales+/quotes.tsx
+++ b/apps/erp/app/routes/x+/sales+/quotes.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getQuotes } from "~/modules/sales";
import { QuotesTable } from "~/modules/sales/ui/Quotes";
import type { Handle } from "~/utils/handle";
@@ -25,11 +22,6 @@ export const handle: Handle = {
to: path.to.quotes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -70,7 +62,7 @@ export default function QuotesRoute() {
return (
<VStack spacing={0} className="h-full">
<QuotesTable data={quotes} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/return-reasons.tsx b/apps/erp/app/routes/x+/sales+/return-reasons.tsx
index fcce91cf62..7d46f0ec3f 100644
--- a/apps/erp/app/routes/x+/sales+/return-reasons.tsx
+++ b/apps/erp/app/routes/x+/sales+/return-reasons.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getReturnReasons } from "~/modules/sales";
import { ReturnReasonsTable } from "~/modules/sales/ui/ReturnReasons";
import type { Handle } from "~/utils/handle";
@@ -22,11 +18,6 @@ export const handle: Handle = {
to: path.to.returnReasons
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -54,7 +45,7 @@ export default function ReturnReasonsRoute() {
return (
<VStack spacing={0} className="h-full">
<ReturnReasonsTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/rfqs.tsx b/apps/erp/app/routes/x+/sales+/rfqs.tsx
index d25869521b..161407d186 100644
--- a/apps/erp/app/routes/x+/sales+/rfqs.tsx
+++ b/apps/erp/app/routes/x+/sales+/rfqs.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getSalesRFQs } from "~/modules/sales";
import { SalesRFQsTable } from "~/modules/sales/ui/SalesRFQ";
import type { Handle } from "~/utils/handle";
@@ -25,11 +22,6 @@ export const handle: Handle = {
to: path.to.salesRfqs
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -70,7 +62,7 @@ export default function RFQsRoute() {
return (
<VStack spacing={0} className="h-full">
<SalesRFQsTable data={rfqs} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/rmas.tsx b/apps/erp/app/routes/x+/sales+/rmas.tsx
index 180207182f..236864a80b 100644
--- a/apps/erp/app/routes/x+/sales+/rmas.tsx
+++ b/apps/erp/app/routes/x+/sales+/rmas.tsx
@@ -5,11 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { useLoaderData } from "react-router";
import { getSalesReturnOrders } from "~/modules/sales";
import { SalesReturnOrdersTable } from "~/modules/sales/ui/SalesReturnOrders";
import type { Handle } from "~/utils/handle";
@@ -68,7 +68,7 @@ export default function SalesReturnOrdersSearchRoute() {
return (
<VStack spacing={0} className="h-full">
<SalesReturnOrdersTable data={salesReturnOrders} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/sales-rules.$id.tsx b/apps/erp/app/routes/x+/sales+/sales-rules.$id.tsx
index b51a76530a..7b95e49bb1 100644
--- a/apps/erp/app/routes/x+/sales+/sales-rules.$id.tsx
+++ b/apps/erp/app/routes/x+/sales+/sales-rules.$id.tsx
@@ -9,12 +9,8 @@ import { requireFeature } from "@carbon/ee/plan.server";
import { upsertEnforcementRule } from "@carbon/ee/rules.server";
import { validationError, validator } from "@carbon/form";
import type { SalesRuleSurface } from "@carbon/utils";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { data, useLoaderData, useNavigate } from "react-router";
import type { z } from "zod";
import { type salesRuleSeverities, salesRuleValidator } from "~/modules/sales";
@@ -22,11 +18,6 @@ import { SalesRuleForm } from "~/modules/sales/ui/SalesRules";
import { getEnforcementRule } from "~/modules/shared";
import { getParams, path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales"
diff --git a/apps/erp/app/routes/x+/sales+/sales-rules.tsx b/apps/erp/app/routes/x+/sales+/sales-rules.tsx
index b7429ccca6..94d48c4ae6 100644
--- a/apps/erp/app/routes/x+/sales+/sales-rules.tsx
+++ b/apps/erp/app/routes/x+/sales+/sales-rules.tsx
@@ -5,13 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { usePlanGate } from "~/hooks/usePlanGate";
import {
SalesRulesGroups,
@@ -29,9 +27,6 @@ export const handle: Handle = {
to: path.to.salesRules
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -75,7 +70,7 @@ export default function SalesRulesRoute() {
return (
<>
<SalesRulesGroups rules={rows as never} />
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.$lineId.details.tsx b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.$lineId.details.tsx
index b724a16bdc..58ed63fa8b 100644
--- a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.$lineId.details.tsx
@@ -14,11 +14,12 @@ import {
} from "@carbon/ee/rules.server";
import { validationError, validator } from "@carbon/form";
import type { JSONContent } from "@carbon/react";
+import { RecordOutlet } from "@carbon/react";
import { getItemReadableId, redirect } from "@carbon/utils";
import { useLingui } from "@lingui/react/macro";
import { Fragment } from "react/jsx-runtime";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData, useParams } from "react-router";
+import { useLoaderData, useParams } from "react-router";
import { DeferredFiles } from "~/components";
import {
getSalesInvoice,
@@ -275,7 +276,7 @@ export default function EditSalesInvoiceLineRoute() {
)}
</DeferredFiles>
- <Outlet />
+ <RecordOutlet />
</Fragment>
);
}
diff --git a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.tsx b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.tsx
index 2ed22f270b..67db4bae8b 100644
--- a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.tsx
+++ b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.tsx
@@ -7,15 +7,11 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import { flash } from "@carbon/auth/session.server";
import { createMappingService } from "@carbon/ee/accounting";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout";
import { getCurrencyByCode } from "~/modules/accounting";
import {
@@ -58,11 +54,6 @@ export const handle: Handle = {
module: "invoicing"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["invoiceId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId, companyGroupId } = await requirePermissions(
request,
@@ -169,7 +160,7 @@ export default function SalesInvoiceRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/sales-invoice+/_layout.tsx b/apps/erp/app/routes/x+/sales-invoice+/_layout.tsx
index 84c0a90daf..0a09a5dcff 100644
--- a/apps/erp/app/routes/x+/sales-invoice+/_layout.tsx
+++ b/apps/erp/app/routes/x+/sales-invoice+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function SalesInvoiceRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx
index 5deadf37da..ab5a0487ba 100644
--- a/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx
@@ -15,12 +15,12 @@ import {
import { validationError, validator } from "@carbon/form";
import { getLogger } from "@carbon/logger";
import type { JSONContent } from "@carbon/react";
-import { Card, CardHeader, CardTitle } from "@carbon/react";
+import { Card, CardHeader, CardTitle, RecordOutlet } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
import { Fragment, Suspense } from "react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
+import { Await, useLoaderData, useParams } from "react-router";
import { CadModel, DeferredFiles } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import { getItemReplenishment } from "~/modules/items";
@@ -372,7 +372,7 @@ export default function EditSalesOrderLineRoute() {
viewerClassName="aspect-square min-h-[420px] max-h-[70vh]"
/>
- <Outlet />
+ <RecordOutlet />
</Fragment>
);
}
diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.tsx
index 400d54c315..3c02bf354b 100644
--- a/apps/erp/app/routes/x+/sales-order+/$orderId.tsx
+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.tsx
@@ -6,14 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import {
getCustomer,
@@ -66,11 +63,6 @@ export const handle: Handle = {
module: "sales"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["orderId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales",
@@ -263,7 +255,7 @@ export default function SalesOrderRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/sales-order+/_layout.tsx b/apps/erp/app/routes/x+/sales-order+/_layout.tsx
index 167e501491..0041a5f15a 100644
--- a/apps/erp/app/routes/x+/sales-order+/_layout.tsx
+++ b/apps/erp/app/routes/x+/sales-order+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function SalesOrderRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/sales-return-order+/$id.tsx b/apps/erp/app/routes/x+/sales-return-order+/$id.tsx
index 2f9da72495..91a2789ef5 100644
--- a/apps/erp/app/routes/x+/sales-return-order+/$id.tsx
+++ b/apps/erp/app/routes/x+/sales-return-order+/$id.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import { getSalesReturnOrder, getSalesReturnOrderLines } from "~/modules/sales";
import {
@@ -35,11 +32,6 @@ export const handle: Handle = {
module: "sales"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "sales"
@@ -89,7 +81,7 @@ export default function SalesReturnOrderRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/sales-return-order+/_layout.tsx b/apps/erp/app/routes/x+/sales-return-order+/_layout.tsx
index d1cfad0da4..52977d8496 100644
--- a/apps/erp/app/routes/x+/sales-return-order+/_layout.tsx
+++ b/apps/erp/app/routes/x+/sales-return-order+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function SalesReturnOrderRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.$lineId.details.tsx b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.$lineId.details.tsx
index 2d674e6b53..bf7e3b6f6a 100644
--- a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.$lineId.details.tsx
@@ -9,11 +9,12 @@ import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { getLogger } from "@carbon/logger";
import type { JSONContent } from "@carbon/react";
+import { RecordOutlet } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { useLingui } from "@lingui/react/macro";
import { Fragment } from "react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData, useParams } from "react-router";
+import { useLoaderData, useParams } from "react-router";
import { CadModel, DeferredFiles } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type { SalesRFQ } from "~/modules/sales";
@@ -195,7 +196,7 @@ export default function SalesRFQLine() {
viewerClassName="aspect-square min-h-[420px] max-h-[70vh]"
/>
- <Outlet />
+ <RecordOutlet />
</Fragment>
);
}
diff --git a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.tsx b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.tsx
index 0a2cf3d9a8..fe533e98ac 100644
--- a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.tsx
+++ b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.tsx
@@ -9,17 +9,14 @@ import { flash } from "@carbon/auth/session.server";
import { supportedModelTypes } from "@carbon/files/cad";
import { getLogger } from "@carbon/logger";
import type { JSONContent } from "@carbon/react";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import type { DragEndEvent } from "@dnd-kit/core";
import { DndContext } from "@dnd-kit/core";
import { msg } from "@lingui/core/macro";
import type { FileObject } from "@supabase/storage-js";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams, useSubmit } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams, useSubmit } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import type { SalesRFQLine } from "~/modules/sales";
import {
@@ -51,11 +48,6 @@ export const handle: Handle = {
module: "sales"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["rfqId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { companyId } = await requirePermissions(request, {
view: "sales"
@@ -205,7 +197,7 @@ export default function SalesRFQRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/sales-rfq+/_layout.tsx b/apps/erp/app/routes/x+/sales-rfq+/_layout.tsx
index a981e8451a..1c46ea8d5a 100644
--- a/apps/erp/app/routes/x+/sales-rfq+/_layout.tsx
+++ b/apps/erp/app/routes/x+/sales-rfq+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function SalesRFQRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/scheduling+/_layout.tsx b/apps/erp/app/routes/x+/scheduling+/_layout.tsx
index 78389765c7..87ecbfcea4 100644
--- a/apps/erp/app/routes/x+/scheduling+/_layout.tsx
+++ b/apps/erp/app/routes/x+/scheduling+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -22,5 +23,5 @@ export const handle: Handle = {
};
export default function SchedulingRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/service+/$itemId.purchasing.tsx b/apps/erp/app/routes/x+/service+/$itemId.purchasing.tsx
index 995a7768e8..0c49b850a6 100644
--- a/apps/erp/app/routes/x+/service+/$itemId.purchasing.tsx
+++ b/apps/erp/app/routes/x+/service+/$itemId.purchasing.tsx
@@ -7,12 +7,8 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { useLoaderData, useParams } from "react-router";
import { useRouteData } from "~/hooks";
import type { SupplierPart } from "~/modules/items";
@@ -26,11 +22,6 @@ import { ItemPurchasingForm, SupplierParts } from "~/modules/items/ui/Item";
import { ItemCostHistoryChart } from "~/modules/items/ui/Item/ItemCostHistoryChart";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
diff --git a/apps/erp/app/routes/x+/service+/$itemId.tsx b/apps/erp/app/routes/x+/service+/$itemId.tsx
index 0e501e0a11..12341f45df 100644
--- a/apps/erp/app/routes/x+/service+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/service+/$itemId.tsx
@@ -10,6 +10,7 @@ import {
Input,
InputGroup,
InputLeftElement,
+ RecordOutlet,
Spinner,
Tabs,
TabsContent,
@@ -17,16 +18,13 @@ import {
TabsTrigger,
useRouteData
} from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans, useLingui } from "@lingui/react/macro";
import { Suspense, useState } from "react";
import { LuSearch } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { Await, useLoaderData, useParams } from "react-router";
import { ResizablePanels } from "~/components/Layout";
import { flattenTree } from "~/components/TreeView";
import type { ItemFile, ServiceSummary } from "~/modules/items";
@@ -56,11 +54,6 @@ export const handle: Handle = {
module: "items"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"], search: ["methodId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -332,7 +325,7 @@ export default function ServiceRoute() {
}
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-hide w-full">
- <Outlet />
+ <RecordOutlet />
</div>
}
properties={<ServiceProperties key={itemId} />}
diff --git a/apps/erp/app/routes/x+/service+/_layout.tsx b/apps/erp/app/routes/x+/service+/_layout.tsx
index f0f33d51ef..c38e0f8c8a 100644
--- a/apps/erp/app/routes/x+/service+/_layout.tsx
+++ b/apps/erp/app/routes/x+/service+/_layout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import { getUnitOfMeasuresList } from "~/modules/items";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -27,9 +23,6 @@ export const handle: Handle = {
module: "items"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
@@ -43,5 +36,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function ServiceRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/settings+/_layout.tsx b/apps/erp/app/routes/x+/settings+/_layout.tsx
index eb473a7947..065688706e 100644
--- a/apps/erp/app/routes/x+/settings+/_layout.tsx
+++ b/apps/erp/app/routes/x+/settings+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import { useSettingsSubmodules } from "~/modules/settings";
import type { Handle } from "~/utils/handle";
@@ -35,7 +35,7 @@ export default function SettingsRoute() {
spacing={0}
className="overflow-y-auto scrollbar-hide h-[calc(100dvh-var(--topbar-height)-var(--content-inset))]"
>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/api-keys.tsx b/apps/erp/app/routes/x+/settings+/api-keys.tsx
index 668ab50087..424663a6b9 100644
--- a/apps/erp/app/routes/x+/settings+/api-keys.tsx
+++ b/apps/erp/app/routes/x+/settings+/api-keys.tsx
@@ -5,13 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { usePlanGate } from "~/hooks/usePlanGate";
import {
ApiKeysTable,
@@ -27,11 +25,6 @@ export const handle: Handle = {
to: path.to.apiKeys
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
update: "users"
@@ -74,7 +67,7 @@ export default function ApiKeysRoute() {
return (
<>
<ApiKeysTable count={count} data={apiKeys} />
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/approval-rules.$id.tsx b/apps/erp/app/routes/x+/settings+/approval-rules.$id.tsx
index 082fccc6d8..56df1d2a45 100644
--- a/apps/erp/app/routes/x+/settings+/approval-rules.$id.tsx
+++ b/apps/erp/app/routes/x+/settings+/approval-rules.$id.tsx
@@ -14,23 +14,14 @@ import {
} from "@carbon/ee/approvals.server";
import { requireFeature } from "@carbon/ee/plan.server";
import { validationError, validator } from "@carbon/form";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { useLoaderData, useNavigate } from "react-router";
import { useUrlParams } from "~/hooks";
import { ApprovalRuleForm } from "~/modules/settings";
import { getParams, path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "settings",
diff --git a/apps/erp/app/routes/x+/settings+/approval-rules.tsx b/apps/erp/app/routes/x+/settings+/approval-rules.tsx
index 57e8266b70..1025921603 100644
--- a/apps/erp/app/routes/x+/settings+/approval-rules.tsx
+++ b/apps/erp/app/routes/x+/settings+/approval-rules.tsx
@@ -7,13 +7,11 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import { flash } from "@carbon/auth/session.server";
import { getApprovalRules } from "@carbon/ee/approvals.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { usePlanGate } from "~/hooks/usePlanGate";
import { ApprovalRules, ApprovalRulesUpgradeOverlay } from "~/modules/settings";
import type { Handle } from "~/utils/handle";
@@ -24,9 +22,6 @@ export const handle: Handle = {
to: path.to.approvalRules
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "settings",
@@ -101,7 +96,7 @@ export default function ApprovalSettingsRoute() {
qdRules={qdRules}
supplierRules={supplierRules}
/>
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/audit-logs.tsx b/apps/erp/app/routes/x+/settings+/audit-logs.tsx
index 465840708c..92e7440286 100644
--- a/apps/erp/app/routes/x+/settings+/audit-logs.tsx
+++ b/apps/erp/app/routes/x+/settings+/audit-logs.tsx
@@ -16,21 +16,19 @@ import {
} from "@carbon/ee/audit.server";
import { requireFeature } from "@carbon/ee/plan.server";
import { getLogger } from "@carbon/logger";
-import { Button, Heading, ScrollArea, VStack } from "@carbon/react";
import {
- isUnaffectedByNavigation,
- redirect,
- redirectExternal
-} from "@carbon/utils";
+ Button,
+ Heading,
+ RecordOutlet,
+ ScrollArea,
+ VStack
+} from "@carbon/react";
+import { redirect, redirectExternal } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { LuHistory } from "react-icons/lu";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Link, Outlet, useLoaderData } from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { Link, useLoaderData } from "react-router";
import { usePlanGate } from "~/hooks/usePlanGate";
import { AuditLogSettings, AuditLogUpgradeOverlay } from "~/modules/settings";
import type { Handle } from "~/utils/handle";
@@ -43,9 +41,6 @@ export const handle: Handle = {
to: path.to.auditLog
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "settings"
@@ -234,7 +229,7 @@ export default function AuditLogRoute() {
archives={archives}
controlled={controlled}
/>
- {enabled && <Outlet />}
+ {enabled && <RecordOutlet />}
</VStack>
</ScrollArea>
);
diff --git a/apps/erp/app/routes/x+/settings+/companies.tsx b/apps/erp/app/routes/x+/settings+/companies.tsx
index 1102a6553a..57d2f219a9 100644
--- a/apps/erp/app/routes/x+/settings+/companies.tsx
+++ b/apps/erp/app/routes/x+/settings+/companies.tsx
@@ -9,24 +9,18 @@ import { flash } from "@carbon/auth/session.server";
import {
Heading,
HStack,
+ RecordOutlet,
Tabs,
TabsContent,
TabsList,
TabsTrigger
} from "@carbon/react";
-import {
- isInternalEmail,
- isUnaffectedByNavigation,
- redirect
-} from "@carbon/utils";
+import { isInternalEmail, redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { useLingui } from "@lingui/react/macro";
import { useCallback } from "react";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useNavigate } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useNavigate } from "react-router";
import { New } from "~/components";
import { getSubsidiaries } from "~/modules/settings";
import {
@@ -41,9 +35,6 @@ export const handle: Handle = {
to: path.to.companies
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { companyGroupId, email } = await requirePermissions(request, {
view: "settings"
@@ -125,7 +116,7 @@ export default function SubsidiariesRoute() {
/>
</TabsContent>
- <Outlet />
+ <RecordOutlet />
</Tabs>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/custom-fields.$table.tsx b/apps/erp/app/routes/x+/settings+/custom-fields.$table.tsx
index b0540baed0..3d16c96e53 100644
--- a/apps/erp/app/routes/x+/settings+/custom-fields.$table.tsx
+++ b/apps/erp/app/routes/x+/settings+/custom-fields.$table.tsx
@@ -5,13 +5,10 @@
import { assertIsPost, error, notFound } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { data, Outlet, useLoaderData, useNavigate } from "react-router";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { data, useLoaderData, useNavigate } from "react-router";
import { useRouteData, useUrlParams } from "~/hooks";
import type { AttributeDataType } from "~/modules/people";
import { CustomFieldsTableDetail, getCustomFields } from "~/modules/settings";
@@ -19,11 +16,6 @@ import { updateCustomFieldsSortOrder } from "~/modules/settings/settings.server"
import { getTagsList } from "~/modules/shared";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["table"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "settings",
@@ -103,7 +95,7 @@ export default function CustomFieldsListRoute() {
dataTypes={routeData?.dataTypes ?? []}
onClose={onClose}
/>
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/custom-fields.tsx b/apps/erp/app/routes/x+/settings+/custom-fields.tsx
index 87f156350b..6fefcefc90 100644
--- a/apps/erp/app/routes/x+/settings+/custom-fields.tsx
+++ b/apps/erp/app/routes/x+/settings+/custom-fields.tsx
@@ -5,15 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect, unchecked } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect, unchecked } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getAttributeDataTypes } from "~/modules/people";
import { CustomFieldsTable, getCustomFieldsTables } from "~/modules/settings";
import type { Handle } from "~/utils/handle";
@@ -25,11 +21,6 @@ export const handle: Handle = {
to: path.to.customFields
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "settings",
@@ -112,7 +103,7 @@ export default function CustomFieldsRoute() {
return (
<VStack spacing={0} className="h-full">
<CustomFieldsTable data={tables} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/integrations.tsx b/apps/erp/app/routes/x+/settings+/integrations.tsx
index 19434ee365..2f0c250797 100644
--- a/apps/erp/app/routes/x+/settings+/integrations.tsx
+++ b/apps/erp/app/routes/x+/settings+/integrations.tsx
@@ -10,15 +10,12 @@ import {
getIntegrationIdsByRole,
quickInstallConnectors
} from "@carbon/ee";
-import { toast } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, toast } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { useLingui } from "@lingui/react/macro";
import { useEffect } from "react";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { data, Outlet, useLoaderData, useSearchParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { data, useLoaderData, useSearchParams } from "react-router";
import { IntegrationsList } from "~/modules/settings";
import { getIntegrationError } from "~/modules/settings/integration-errors";
import { getIntegrationsWithHealth } from "~/modules/settings/settings.server";
@@ -28,9 +25,6 @@ export const config = {
runtime: "nodejs"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "settings"
@@ -131,7 +125,7 @@ export default function IntegrationsRoute() {
availableIntegrations={availableIntegrations}
quickInstallConnectors={quickInstallConnectors}
/>
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/printing.tsx b/apps/erp/app/routes/x+/settings+/printing.tsx
index 4f0b107787..cb216d550d 100644
--- a/apps/erp/app/routes/x+/settings+/printing.tsx
+++ b/apps/erp/app/routes/x+/settings+/printing.tsx
@@ -16,17 +16,19 @@ import {
upsertPrinterRoute
} from "@carbon/printing";
import { invalidatePrinterCache } from "@carbon/printing/printing.server";
-import { Button, Heading, ScrollArea, VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, labelSizes, redirect } from "@carbon/utils";
+import {
+ Button,
+ Heading,
+ RecordOutlet,
+ ScrollArea,
+ VStack
+} from "@carbon/react";
+import { labelSizes, redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { LuPrinter } from "react-icons/lu";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Link, Outlet, useLoaderData } from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { Link, useLoaderData } from "react-router";
import { getLocationsList, getWorkCentersList } from "~/modules/resources";
import { getCompanySettings, printerRouteValidator } from "~/modules/settings";
import { AssignmentsCard, PrintersCard } from "~/modules/settings/ui/Printing";
@@ -39,9 +41,6 @@ export const handle: Handle = {
to: path.to.printingSettings
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "settings"
@@ -268,7 +267,7 @@ export default function PrintingSettingsRoute() {
workCenters={workCenters}
/>
</VStack>
- <Outlet />
+ <RecordOutlet />
</ScrollArea>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/purchasing.tsx b/apps/erp/app/routes/x+/settings+/purchasing.tsx
index 73142d292f..80363e616d 100644
--- a/apps/erp/app/routes/x+/settings+/purchasing.tsx
+++ b/apps/erp/app/routes/x+/settings+/purchasing.tsx
@@ -33,13 +33,14 @@ import {
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans, useLingui } from "@lingui/react/macro";
-import { useCallback, useEffect, useState } from "react";
+import { useCallback, useEffect } from "react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { useFetcher, useLoaderData } from "react-router";
import CompanyDefaultAttachmentsCard from "~/components/CompanyDefaultAttachmentsCard";
import { EmailRecipients, Users } from "~/components/Form";
import Country from "~/components/Form/Country";
import SettingsSectionHeader from "~/components/SettingsSectionHeader";
+import { useSavedToggle } from "~/hooks/useSavedToggle";
import {
accountsPayableBillingAddressValidator,
defaultSupplierCcValidator,
@@ -337,27 +338,34 @@ export default function PurchasingSettingsRoute() {
const toggleFetcher = useFetcher<typeof action>();
- const [apAddressEnabled, setApAddressEnabled] = useState(
+ const apAddressEnabled = useSavedToggle(
+ toggleFetcher,
+ "accountsPayableAddressToggle",
companySettings.accountsPayableAddress ?? false
);
- const [requireSupplierContactAndLocation, setRequireSupplierContact] =
- useState(
- (companySettings as { requireSupplierContactAndLocation?: boolean })
- .requireSupplierContactAndLocation ?? false
- );
+ const requireSupplierContactAndLocation = useSavedToggle(
+ toggleFetcher,
+ "requireSupplierContactAndLocationToggle",
+ (companySettings as { requireSupplierContactAndLocation?: boolean })
+ .requireSupplierContactAndLocation ?? false
+ );
- const [leadTimesOnReceiptEnabled, setLeadTimesOnReceiptEnabled] = useState(
+ const leadTimesOnReceiptEnabled = useSavedToggle(
+ toggleFetcher,
+ "updateLeadTimesOnReceipt",
(companySettings as { updateLeadTimesOnReceipt?: boolean })
.updateLeadTimesOnReceipt ?? false
);
- const [showSupplierReadableIdEnabled, setShowSupplierReadableIdEnabled] =
- useState(companySettings.showSupplierReadableId ?? false);
+ const showSupplierReadableIdEnabled = useSavedToggle(
+ toggleFetcher,
+ "showSupplierReadableIdToggle",
+ companySettings.showSupplierReadableId ?? false
+ );
const handleShowSupplierReadableIdToggle = useCallback(
(checked: boolean) => {
- setShowSupplierReadableIdEnabled(checked);
toggleFetcher.submit(
{ intent: "showSupplierReadableIdToggle", enabled: checked.toString() },
{ method: "POST" }
@@ -368,7 +376,6 @@ export default function PurchasingSettingsRoute() {
const handleRequireSupplierContactToggle = useCallback(
(checked: boolean) => {
- setRequireSupplierContact(checked);
toggleFetcher.submit(
{
intent: "requireSupplierContactAndLocationToggle",
@@ -382,7 +389,6 @@ export default function PurchasingSettingsRoute() {
const handleApAddressToggle = useCallback(
(checked: boolean) => {
- setApAddressEnabled(checked);
toggleFetcher.submit(
{ intent: "accountsPayableAddressToggle", enabled: checked.toString() },
{ method: "POST" }
@@ -393,7 +399,6 @@ export default function PurchasingSettingsRoute() {
const handleLeadTimesOnReceiptToggle = useCallback(
(checked: boolean) => {
- setLeadTimesOnReceiptEnabled(checked);
toggleFetcher.submit(
{
intent: "updateLeadTimesOnReceipt",
diff --git a/apps/erp/app/routes/x+/settings+/quality.tsx b/apps/erp/app/routes/x+/settings+/quality.tsx
index 1fafd1b98d..44a44397dd 100644
--- a/apps/erp/app/routes/x+/settings+/quality.tsx
+++ b/apps/erp/app/routes/x+/settings+/quality.tsx
@@ -31,12 +31,13 @@ import {
import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans, useLingui } from "@lingui/react/macro";
-import { useCallback, useEffect, useState } from "react";
+import { useCallback, useEffect } from "react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { useFetcher, useLoaderData } from "react-router";
import { z } from "zod";
import { Users } from "~/components/Form";
import SettingsSectionHeader from "~/components/SettingsSectionHeader";
+import { useSavedToggle } from "~/hooks/useSavedToggle";
import { getCompanySettings } from "~/modules/settings";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -163,14 +164,15 @@ export default function QualitySettingsRoute() {
const fetcher = useFetcher<typeof action>();
const toggleFetcher = useFetcher<typeof action>();
- const [fourEyesEnabled, setFourEyesEnabled] = useState(
+ const fourEyesEnabled = useSavedToggle(
+ toggleFetcher,
+ "enforceInspectionFourEyes",
(companySettings as { enforceInspectionFourEyes?: boolean })
.enforceInspectionFourEyes ?? false
);
const handleFourEyesToggle = useCallback(
(checked: boolean) => {
- setFourEyesEnabled(checked);
toggleFetcher.submit(
{
intent: "enforceInspectionFourEyes",
diff --git a/apps/erp/app/routes/x+/settings+/sales.tsx b/apps/erp/app/routes/x+/settings+/sales.tsx
index d65eaceb00..d93d020e2d 100644
--- a/apps/erp/app/routes/x+/settings+/sales.tsx
+++ b/apps/erp/app/routes/x+/settings+/sales.tsx
@@ -39,6 +39,7 @@ import { useFetcher, useLoaderData } from "react-router";
import { EmailRecipients, Users } from "~/components/Form";
import Country from "~/components/Form/Country";
import SettingsSectionHeader from "~/components/SettingsSectionHeader";
+import { useSavedToggle } from "~/hooks/useSavedToggle";
import {
accountsReceivableBillingAddressValidator,
defaultCustomerCcValidator,
@@ -298,19 +299,21 @@ export default function SalesSettingsRoute() {
const { companySettings, arBillingAddress } = useLoaderData<typeof loader>();
const fetcher = useFetcher<typeof action>();
const toggleFetcher = useFetcher<typeof action>();
- const [arAddressEnabled, setArAddressEnabled] = useState(
+ const arAddressEnabled = useSavedToggle(
+ toggleFetcher,
+ "accountsReceivableAddressToggle",
companySettings.accountsReceivableAddress ?? false
);
- const [requireCustomerContactAndLocation, setRequireCustomerContact] =
- useState(
- (companySettings as { requireCustomerContactAndLocation?: boolean })
- .requireCustomerContactAndLocation ?? false
- );
+ const requireCustomerContactAndLocation = useSavedToggle(
+ toggleFetcher,
+ "requireCustomerContactAndLocationToggle",
+ (companySettings as { requireCustomerContactAndLocation?: boolean })
+ .requireCustomerContactAndLocation ?? false
+ );
const handleRequireCustomerContactToggle = useCallback(
(checked: boolean) => {
- setRequireCustomerContact(checked);
toggleFetcher.submit(
{
intent: "requireCustomerContactAndLocationToggle",
@@ -324,7 +327,6 @@ export default function SalesSettingsRoute() {
const handleArAddressToggle = useCallback(
(checked: boolean) => {
- setArAddressEnabled(checked);
toggleFetcher.submit(
{
intent: "accountsReceivableAddressToggle",
@@ -336,12 +338,14 @@ export default function SalesSettingsRoute() {
[toggleFetcher]
);
- const [showCustomerReadableIdEnabled, setShowCustomerReadableIdEnabled] =
- useState(companySettings.showCustomerReadableId ?? false);
+ const showCustomerReadableIdEnabled = useSavedToggle(
+ toggleFetcher,
+ "showCustomerReadableIdToggle",
+ companySettings.showCustomerReadableId ?? false
+ );
const handleShowCustomerReadableIdToggle = useCallback(
(checked: boolean) => {
- setShowCustomerReadableIdEnabled(checked);
toggleFetcher.submit(
{ intent: "showCustomerReadableIdToggle", enabled: checked.toString() },
{ method: "POST" }
diff --git a/apps/erp/app/routes/x+/settings+/sequences.tsx b/apps/erp/app/routes/x+/settings+/sequences.tsx
index 4de9c5d87b..4e66408da7 100644
--- a/apps/erp/app/routes/x+/settings+/sequences.tsx
+++ b/apps/erp/app/routes/x+/settings+/sequences.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getSequences, SequencesTable } from "~/modules/settings";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,11 +17,6 @@ export const handle: Handle = {
to: path.to.sequences
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "settings",
@@ -53,7 +44,7 @@ export default function SequencesRoute() {
return (
<VStack spacing={0} className="h-full">
<SequencesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/serial-numbers.tsx b/apps/erp/app/routes/x+/settings+/serial-numbers.tsx
index 819e5c2dfd..f66a56ef5a 100644
--- a/apps/erp/app/routes/x+/settings+/serial-numbers.tsx
+++ b/apps/erp/app/routes/x+/settings+/serial-numbers.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
getItemSerialSequences,
ItemSerialSequencesTable
@@ -24,11 +20,6 @@ export const handle: Handle = {
to: path.to.serialNumberSequences
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "settings",
@@ -56,7 +47,7 @@ export default function SerialNumbersRoute() {
return (
<VStack spacing={0} className="h-full">
<ItemSerialSequencesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/webhooks.tsx b/apps/erp/app/routes/x+/settings+/webhooks.tsx
index 5ef3f6d410..18fa64f0d2 100644
--- a/apps/erp/app/routes/x+/settings+/webhooks.tsx
+++ b/apps/erp/app/routes/x+/settings+/webhooks.tsx
@@ -5,13 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { usePlanGate } from "~/hooks/usePlanGate";
import { getConfig, getWebhooks } from "~/modules/settings";
import {
@@ -27,11 +25,6 @@ export const handle: Handle = {
to: path.to.webhooks
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "settings"
@@ -91,7 +84,7 @@ export default function WebhooksRoute() {
return (
<>
<WebhooksTable count={count} data={webhooks} />
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/shipment+/$shipmentId.tsx b/apps/erp/app/routes/x+/shipment+/$shipmentId.tsx
index 69e025771c..c1cdf62a69 100644
--- a/apps/erp/app/routes/x+/shipment+/$shipmentId.tsx
+++ b/apps/erp/app/routes/x+/shipment+/$shipmentId.tsx
@@ -6,13 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import {
getShipment,
getShipmentLines,
@@ -34,11 +32,6 @@ export const handle: Handle = {
module: "inventory"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["shipmentId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "inventory"
@@ -127,7 +120,7 @@ export default function ShipmentRoute() {
<div className="flex h-[calc(100dvh-var(--topbar-height)-var(--content-inset))] overflow-y-auto scrollbar-hide w-full">
<div className="h-full p-4 w-full max-w-5xl mx-auto">
<div className="flex flex-col gap-4 pb-16 w-full">
- <Outlet />
+ <RecordOutlet />
</div>
</div>
</div>
diff --git a/apps/erp/app/routes/x+/shipment+/_layout.tsx b/apps/erp/app/routes/x+/shipment+/_layout.tsx
index 0b3df539d9..06d548e7dc 100644
--- a/apps/erp/app/routes/x+/shipment+/_layout.tsx
+++ b/apps/erp/app/routes/x+/shipment+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function ShipmentRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/stock-transfer+/$id.tsx b/apps/erp/app/routes/x+/stock-transfer+/$id.tsx
index 6b2fcc16f2..b279e77261 100644
--- a/apps/erp/app/routes/x+/stock-transfer+/$id.tsx
+++ b/apps/erp/app/routes/x+/stock-transfer+/$id.tsx
@@ -6,14 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import type { JSONContent } from "@carbon/react";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useParams } from "react-router";
import { PanelProvider } from "~/components/Layout";
import { getStockTransfer, getStockTransferLines } from "~/modules/inventory";
import StockTransferHeader from "~/modules/inventory/ui/StockTransfers/StockTransferHeader";
@@ -34,11 +31,6 @@ export const handle: Handle = {
module: "inventory"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "inventory"
@@ -93,7 +85,7 @@ export default function StockTransferRoute() {
</VStack>
</div>
</div>
- <Outlet />
+ <RecordOutlet />
</PanelProvider>
);
}
diff --git a/apps/erp/app/routes/x+/stock-transfer+/_layout.tsx b/apps/erp/app/routes/x+/stock-transfer+/_layout.tsx
index 4c44e9426c..8061ce030a 100644
--- a/apps/erp/app/routes/x+/stock-transfer+/_layout.tsx
+++ b/apps/erp/app/routes/x+/stock-transfer+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function StockTransferRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.bank-accounts.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.bank-accounts.tsx
index 6f2c689590..4c54392e44 100644
--- a/apps/erp/app/routes/x+/supplier+/$supplierId.bank-accounts.tsx
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.bank-accounts.tsx
@@ -5,21 +5,13 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import { getSupplierBankAccounts } from "~/modules/purchasing";
import SupplierBankAccounts from "~/modules/purchasing/ui/Supplier/SupplierBankAccounts";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["supplierId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "accounting"
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.contacts.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.contacts.tsx
index 318acda5c9..bce04b0fb5 100644
--- a/apps/erp/app/routes/x+/supplier+/$supplierId.contacts.tsx
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.contacts.tsx
@@ -5,21 +5,13 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import { getSupplierContacts } from "~/modules/purchasing";
import SupplierContacts from "~/modules/purchasing/ui/Supplier/SupplierContacts";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["supplierId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "purchasing"
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.locations.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.locations.tsx
index de537fd3de..1d8828193c 100644
--- a/apps/erp/app/routes/x+/supplier+/$supplierId.locations.tsx
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.locations.tsx
@@ -5,21 +5,13 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
import { getSupplierLocations } from "~/modules/purchasing";
import SupplierLocations from "~/modules/purchasing/ui/Supplier/SupplierLocations";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["supplierId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "purchasing"
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.processes.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.processes.tsx
index b1f48a97f3..617b5ca5e9 100644
--- a/apps/erp/app/routes/x+/supplier+/$supplierId.processes.tsx
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.processes.tsx
@@ -5,21 +5,14 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getSupplierProcessesBySupplier } from "~/modules/purchasing";
import SupplierProcesses from "~/modules/purchasing/ui/Supplier/SupplierProcesses";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["supplierId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "purchasing"
@@ -51,7 +44,7 @@ export default function SupplierPaymentRoute() {
return (
<>
<SupplierProcesses processes={processes} />
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.tsx
index 0158c60b2f..fe6b398f91 100644
--- a/apps/erp/app/routes/x+/supplier+/$supplierId.tsx
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.tsx
@@ -6,13 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+
import {
getSupplier,
getSupplierContacts,
@@ -34,11 +32,6 @@ export const handle: Handle = {
module: "purchasing"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["supplierId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {
view: "purchasing"
@@ -96,7 +89,7 @@ export default function SupplierRoute() {
<SupplierHeader />
<div className="grid grid-cols-1 md:grid-cols-[1fr_4fr] h-full w-full gap-4">
<SupplierSidebar />
- <Outlet />
+ <RecordOutlet />
</div>
</>
);
diff --git a/apps/erp/app/routes/x+/supplier+/_layout.tsx b/apps/erp/app/routes/x+/supplier+/_layout.tsx
index 2fadbc9a6a..ddcf0740ea 100644
--- a/apps/erp/app/routes/x+/supplier+/_layout.tsx
+++ b/apps/erp/app/routes/x+/supplier+/_layout.tsx
@@ -3,15 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import { getShippingTermsList } from "~/modules/inventory";
import { getSupplierTypes } from "~/modules/purchasing";
import type { Handle } from "~/utils/handle";
@@ -29,9 +24,6 @@ export const handle: Handle = {
module: "purchasing"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "purchasing"
@@ -55,7 +47,7 @@ export default function SupplierRoute() {
return (
<div className="flex h-full w-full justify-center bg-card">
<VStack spacing={4} className="h-full p-4 w-full max-w-[80rem]">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
);
diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx
index 1c3312ff21..74c611226c 100644
--- a/apps/erp/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx
@@ -9,11 +9,11 @@ import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { getLogger } from "@carbon/logger";
import type { JSONContent } from "@carbon/react";
-import { useRouteData } from "@carbon/react";
+import { RecordOutlet, useRouteData } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { Fragment } from "react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { Outlet, useLoaderData, useParams } from "react-router";
+import { useLoaderData, useParams } from "react-router";
import { DeferredFiles } from "~/components";
import type {
SupplierQuote,
@@ -210,7 +210,7 @@ export default function SupplierQuoteLine() {
)}
</DeferredFiles>
- <Outlet />
+ <RecordOutlet />
</Fragment>
);
}
diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.tsx
index 22d11c0aca..d3c804ee42 100644
--- a/apps/erp/app/routes/x+/supplier-quote+/$id.tsx
+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.tsx
@@ -6,14 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import { getCurrencyByCode, getExchangeRate } from "~/modules/accounting";
import {
@@ -46,11 +43,6 @@ export const handle: Handle = {
module: "purchasing"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { companyId, companyGroupId } = await requirePermissions(request, {
view: "purchasing"
@@ -180,7 +172,7 @@ export default function SupplierQuoteRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<VStack spacing={4} className="p-4">
- <Outlet />
+ <RecordOutlet />
</VStack>
</div>
}
diff --git a/apps/erp/app/routes/x+/supplier-quote+/_layout.tsx b/apps/erp/app/routes/x+/supplier-quote+/_layout.tsx
index b26ea2b469..43c94d47c0 100644
--- a/apps/erp/app/routes/x+/supplier-quote+/_layout.tsx
+++ b/apps/erp/app/routes/x+/supplier-quote+/_layout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -26,9 +22,6 @@ export const handle: Handle = {
module: "purchasing"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
await requirePermissions(request, {
view: "purchasing"
@@ -38,5 +31,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function SupplierQuoteRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/templates+/$type.tsx b/apps/erp/app/routes/x+/templates+/$type.tsx
index 6a9c986cfa..bb8bfb2a0f 100644
--- a/apps/erp/app/routes/x+/templates+/$type.tsx
+++ b/apps/erp/app/routes/x+/templates+/$type.tsx
@@ -18,12 +18,7 @@ import {
} from "@carbon/documents/template";
import { validationError, validator } from "@carbon/form";
import type { JSONContent } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { data, useLoaderData } from "react-router";
import { DocumentTemplateEditor } from "~/components/DocumentTemplateEditor";
import { usePermissions } from "~/hooks";
@@ -47,11 +42,6 @@ export const handle: Handle = {
breadcrumb: (params: { type?: string }) => getDocumentLabel(params.type ?? "")
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["type"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "settings",
diff --git a/apps/erp/app/routes/x+/templates+/_layout.tsx b/apps/erp/app/routes/x+/templates+/_layout.tsx
index a1d100ef20..5ca7a792cb 100644
--- a/apps/erp/app/routes/x+/templates+/_layout.tsx
+++ b/apps/erp/app/routes/x+/templates+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -23,7 +24,7 @@ export const handle: Handle = {
export default function TemplatesRoute() {
return (
<div className="h-full w-full bg-card">
- <Outlet />
+ <RecordOutlet />
</div>
);
}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx
index 3482ba58de..bf568f7b52 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx
@@ -7,12 +7,8 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validator } from "@carbon/form";
import { useRouteData } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import { redirect } from "@carbon/utils";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { useLoaderData, useNavigate, useParams } from "react-router";
import type { ToolSummary } from "~/modules/items";
import { supplierPartValidator, upsertSupplierPart } from "~/modules/items";
@@ -21,11 +17,6 @@ import { getDatabaseClient } from "~/services/database.server";
import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId", "supplierPartId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.tsx b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.tsx
index d409110d1e..29cbc23120 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.tsx
@@ -7,13 +7,9 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { Suspense } from "react";
-import type {
- ActionFunctionArgs,
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { Await, useLoaderData, useParams } from "react-router";
import { useRouteData } from "~/hooks";
import { getBatchProperties } from "~/modules/inventory";
@@ -29,11 +25,6 @@ import { ItemPurchasingForm, SupplierParts } from "~/modules/items/ui/Item";
import { ItemCostHistoryChart } from "~/modules/items/ui/Item/ItemCostHistoryChart";
import { path } from "~/utils/path";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.tsx
index 4edcab6530..2c4e41d0e7 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.tsx
@@ -10,6 +10,7 @@ import {
Input,
InputGroup,
InputLeftElement,
+ RecordOutlet,
Spinner,
Tabs,
TabsContent,
@@ -17,16 +18,13 @@ import {
TabsTrigger,
useRouteData
} from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { Trans, useLingui } from "@lingui/react/macro";
import { Suspense, useState } from "react";
import { LuSearch } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { Await, useLoaderData, useParams } from "react-router";
import { ResizablePanels } from "~/components/Layout";
import { flattenTree } from "~/components/TreeView";
import type { ItemFile, ToolSummary } from "~/modules/items";
@@ -66,11 +64,6 @@ export const handle: Handle = {
module: "items"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["itemId"], search: ["methodId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -579,7 +572,7 @@ export default function ToolRoute() {
}
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-hide w-full">
- <Outlet />
+ <RecordOutlet />
</div>
}
properties={<ToolProperties key={itemId} />}
diff --git a/apps/erp/app/routes/x+/tool+/_layout.tsx b/apps/erp/app/routes/x+/tool+/_layout.tsx
index 7ad6f8e51b..e35806c576 100644
--- a/apps/erp/app/routes/x+/tool+/_layout.tsx
+++ b/apps/erp/app/routes/x+/tool+/_layout.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- MetaFunction,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet } from "react-router";
+import type { LoaderFunctionArgs, MetaFunction } from "react-router";
+
import { getUnitOfMeasuresList } from "~/modules/items";
import { getLocationsList } from "~/modules/resources";
import type { Handle } from "~/utils/handle";
@@ -28,9 +24,6 @@ export const handle: Handle = {
module: "items"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args) ? false : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts"
@@ -48,5 +41,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function ToolRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/traceability+/_layout.tsx b/apps/erp/app/routes/x+/traceability+/_layout.tsx
index 8427ed0497..022c7b92ad 100644
--- a/apps/erp/app/routes/x+/traceability+/_layout.tsx
+++ b/apps/erp/app/routes/x+/traceability+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function TraceabilityLayout() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/training+/$id.tsx b/apps/erp/app/routes/x+/training+/$id.tsx
index 7d50903a98..5cc43c8ffe 100644
--- a/apps/erp/app/routes/x+/training+/$id.tsx
+++ b/apps/erp/app/routes/x+/training+/$id.tsx
@@ -7,18 +7,15 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
import type { JSONContent } from "@carbon/react";
-import { generateHTML, useDebounce } from "@carbon/react";
+import { generateHTML, RecordOutlet, useDebounce } from "@carbon/react";
import { Editor } from "@carbon/react/Editor";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { redirect } from "@carbon/utils";
import { getLocalTimeZone, today } from "@internationalized/date";
import { msg } from "@lingui/core/macro";
import { useLingui } from "@lingui/react/macro";
import { useEffect, useState } from "react";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useFetcher, useLoaderData, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useFetcher, useLoaderData, useParams } from "react-router";
import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import { useImageUpload, usePermissions, useUser } from "~/hooks";
import {
@@ -43,11 +40,6 @@ export const handle: Handle = {
module: "resources"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["id"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "resources",
@@ -100,7 +92,7 @@ export default function TrainingRoute() {
content={
<div className="bg-card h-[calc(100dvh-var(--topbar-height)-var(--header-height)-var(--content-inset))] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
<TrainingEditor />
- <Outlet />
+ <RecordOutlet />
</div>
}
properties={<TrainingProperties key={`properties-${id}`} />}
diff --git a/apps/erp/app/routes/x+/training+/_layout.tsx b/apps/erp/app/routes/x+/training+/_layout.tsx
index e8c96710cf..5bd4aa4407 100644
--- a/apps/erp/app/routes/x+/training+/_layout.tsx
+++ b/apps/erp/app/routes/x+/training+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function ResourcesRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/users+/_layout.tsx b/apps/erp/app/routes/x+/users+/_layout.tsx
index b56c94ed3e..e78b148032 100644
--- a/apps/erp/app/routes/x+/users+/_layout.tsx
+++ b/apps/erp/app/routes/x+/users+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import { useUsersSubmodules } from "~/modules/users";
import type { Handle } from "~/utils/handle";
@@ -32,7 +32,7 @@ export const handle: Handle = {
export default function UsersRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/users+/customers.tsx b/apps/erp/app/routes/x+/users+/customers.tsx
index 8ba09b9631..d694eb43c9 100644
--- a/apps/erp/app/routes/x+/users+/customers.tsx
+++ b/apps/erp/app/routes/x+/users+/customers.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getCustomerTypes } from "~/modules/sales";
import {
CustomerAccountsTable,
@@ -28,11 +25,6 @@ export const handle: Handle = {
to: path.to.customerAccounts
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "users",
@@ -79,7 +71,7 @@ export default function UsersCustomersRoute() {
customerTypes={customerTypes}
unrevokedInviteEmails={unrevokedInviteEmails}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/users+/employee-types.tsx b/apps/erp/app/routes/x+/users+/employee-types.tsx
index 5c58c46a7f..5c54e1232e 100644
--- a/apps/erp/app/routes/x+/users+/employee-types.tsx
+++ b/apps/erp/app/routes/x+/users+/employee-types.tsx
@@ -3,14 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { usePlanGate } from "~/hooks/usePlanGate";
import {
EmployeeTypesTable,
@@ -26,11 +22,6 @@ export const handle: Handle = {
to: path.to.employeeTypes
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "users",
@@ -68,7 +59,7 @@ export default function EmployeeTypesRoute() {
return (
<VStack spacing={0} className="h-full">
<EmployeeTypesTable data={data ?? []} count={count ?? 0} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/users+/employees.tsx b/apps/erp/app/routes/x+/users+/employees.tsx
index 3e803d2dd8..93566afd8a 100644
--- a/apps/erp/app/routes/x+/users+/employees.tsx
+++ b/apps/erp/app/routes/x+/users+/employees.tsx
@@ -6,14 +6,11 @@ import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { getLogger } from "@carbon/logger";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
EmployeesTable,
getEmployees,
@@ -30,11 +27,6 @@ export const handle: Handle = {
to: path.to.employeeAccounts
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "users",
@@ -112,7 +104,7 @@ export default function UsersEmployeesRoute() {
unrevokedInviteEmails={unrevokedInviteEmails}
mfaEnrolledUserIds={mfaEnrolledUserIds}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/users+/groups.tsx b/apps/erp/app/routes/x+/users+/groups.tsx
index afdfd2e159..05fb06cb46 100644
--- a/apps/erp/app/routes/x+/users+/groups.tsx
+++ b/apps/erp/app/routes/x+/users+/groups.tsx
@@ -5,15 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import { arrayToTree } from "performant-array-to-tree";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { data, Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { data, useLoaderData } from "react-router";
import type { Group } from "~/modules/users";
import { GroupsTable, getGroups } from "~/modules/users";
import type { Handle } from "~/utils/handle";
@@ -25,11 +21,6 @@ export const handle: Handle = {
to: path.to.groups
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "users",
@@ -72,7 +63,7 @@ export default function GroupsRoute() {
return (
<VStack spacing={0} className="h-full">
<GroupsTable data={groups} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/users+/operators.tsx b/apps/erp/app/routes/x+/users+/operators.tsx
index e7123fb183..5c85bcf98a 100644
--- a/apps/erp/app/routes/x+/users+/operators.tsx
+++ b/apps/erp/app/routes/x+/users+/operators.tsx
@@ -5,8 +5,8 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { Checkbox, MenuIcon, MenuItem } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { Checkbox, MenuIcon, MenuItem, RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
import { useLingui } from "@lingui/react/macro";
import type { ColumnDef } from "@tanstack/react-table";
@@ -18,11 +18,8 @@ import {
LuUser,
LuUserCheck
} from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData, useNavigate } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData, useNavigate } from "react-router";
import { EmployeeAvatar, New, Table } from "~/components";
import { Enumerable } from "~/components/Enumerable";
import { usePermissions, useUrlParams } from "~/hooks";
@@ -40,11 +37,6 @@ export const handle: Handle = {
to: path.to.operators
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "users",
@@ -232,7 +224,7 @@ export default function ConsoleOperatorsRoute() {
count={count}
employeeTypes={employeeTypes}
/>
- <Outlet />
+ <RecordOutlet />
</>
);
}
diff --git a/apps/erp/app/routes/x+/users+/suppliers.tsx b/apps/erp/app/routes/x+/users+/suppliers.tsx
index d55491cd9b..cda5e55f05 100644
--- a/apps/erp/app/routes/x+/users+/suppliers.tsx
+++ b/apps/erp/app/routes/x+/users+/suppliers.tsx
@@ -5,14 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet, VStack } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import { getSupplierTypes } from "~/modules/purchasing";
import {
getSuppliers,
@@ -28,11 +25,6 @@ export const handle: Handle = {
to: path.to.supplierAccounts
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "users",
@@ -93,7 +85,7 @@ export default function UsersSuppliersRoute() {
supplierTypes={supplierTypes}
unrevokedInviteEmails={unrevokedInviteEmails}
/>
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.tsx b/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.tsx
index 9c2953a230..6cd137f7af 100644
--- a/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.tsx
+++ b/apps/erp/app/routes/x+/warehouse-transfer+/$transferId.tsx
@@ -5,13 +5,11 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { isUnaffectedByNavigation, redirect } from "@carbon/utils";
+import { RecordOutlet } from "@carbon/react";
+import { redirect } from "@carbon/utils";
import { msg } from "@lingui/core/macro";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useParams } from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
+import { useParams } from "react-router";
import {
getWarehouseTransfer,
getWarehouseTransferLines
@@ -35,11 +33,6 @@ export const handle: Handle = {
module: "inventory"
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["transferId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
view: "inventory"
@@ -91,7 +84,7 @@ export default function WarehouseTransferRoute() {
<div className="flex h-[calc(100dvh-var(--topbar-height)-var(--content-inset))] overflow-y-auto scrollbar-hide w-full">
<div className="h-full p-4 w-full max-w-5xl mx-auto">
<div className="flex flex-col gap-4 pb-16 w-full">
- <Outlet />
+ <RecordOutlet />
</div>
</div>
</div>
diff --git a/apps/erp/app/routes/x+/warehouse-transfer+/_layout.tsx b/apps/erp/app/routes/x+/warehouse-transfer+/_layout.tsx
index c463cb3c8d..b3a30f25a9 100644
--- a/apps/erp/app/routes/x+/warehouse-transfer+/_layout.tsx
+++ b/apps/erp/app/routes/x+/warehouse-transfer+/_layout.tsx
@@ -2,9 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,5 +22,5 @@ export const handle: Handle = {
};
export default function WarehouseTransferRoute() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/apps/erp/app/routes/x+/workflow+/_layout.tsx b/apps/erp/app/routes/x+/workflow+/_layout.tsx
index 99fe1aa1f4..f46d82b43d 100644
--- a/apps/erp/app/routes/x+/workflow+/_layout.tsx
+++ b/apps/erp/app/routes/x+/workflow+/_layout.tsx
@@ -2,8 +2,9 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import { RecordOutlet } from "@carbon/react";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import type { Handle } from "~/utils/handle";
export { RouteErrorBoundary as ErrorBoundary } from "@carbon/react/ErrorBoundary";
@@ -22,7 +23,7 @@ export const handle: Handle = {
export default function WorkflowRoute() {
return (
<div className="h-full w-full bg-background">
- <Outlet />
+ <RecordOutlet />
</div>
);
}
diff --git a/apps/erp/app/routes/x+/workflows+/_layout.tsx b/apps/erp/app/routes/x+/workflows+/_layout.tsx
index 572506720c..ac0445f176 100644
--- a/apps/erp/app/routes/x+/workflows+/_layout.tsx
+++ b/apps/erp/app/routes/x+/workflows+/_layout.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { VStack } from "@carbon/react";
+import { RecordOutlet, VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet } from "react-router";
+
import { GroupedContentSidebar } from "~/components/Layout";
import useWorkflowsSubmodules from "~/modules/workflows/ui/useWorkflowsSubmodules";
import type { Handle } from "~/utils/handle";
@@ -32,7 +32,7 @@ export const handle: Handle = {
export default function WorkflowsRoute() {
return (
<VStack spacing={0} className="h-full">
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/workflows+/runs.tsx b/apps/erp/app/routes/x+/workflows+/runs.tsx
index bf033449ec..4db3b0bc64 100644
--- a/apps/erp/app/routes/x+/workflows+/runs.tsx
+++ b/apps/erp/app/routes/x+/workflows+/runs.tsx
@@ -4,13 +4,9 @@
import { requirePermissions } from "@carbon/auth/auth.server";
import { requireFeature } from "@carbon/ee/plan.server";
-import { VStack } from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
-import { Outlet, useLoaderData } from "react-router";
+import { RecordOutlet, VStack } from "@carbon/react";
+import type { LoaderFunctionArgs } from "react-router";
+import { useLoaderData } from "react-router";
import {
getWorkflowRunRecordNames,
getWorkflowRuns
@@ -19,11 +15,6 @@ import WorkflowRunsTable from "~/modules/workflows/ui/Runs/WorkflowRunsTable";
import { path } from "~/utils/path";
import { getGenericQueryFilters } from "~/utils/query";
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { search: "all" })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "workflows",
@@ -74,7 +65,7 @@ export default function WorkflowRunsRoute() {
return (
<VStack spacing={0} className="h-full">
<WorkflowRunsTable data={data} count={count} />
- <Outlet />
+ <RecordOutlet />
</VStack>
);
}
diff --git a/apps/mes/app/components/Kanban/Kanban.tsx b/apps/mes/app/components/Kanban/Kanban.tsx
index 4f4611aacd..90c30a2761 100644
--- a/apps/mes/app/components/Kanban/Kanban.tsx
+++ b/apps/mes/app/components/Kanban/Kanban.tsx
@@ -3,6 +3,7 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { ClientOnly } from "@carbon/react";
+import { withUnorderedLast } from "@carbon/utils";
import type {
Announcements,
DragEndEvent,
@@ -19,7 +20,7 @@ import {
} from "@dnd-kit/core";
import { arrayMove, SortableContext } from "@dnd-kit/sortable";
import { useLingui } from "@lingui/react/macro";
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { createPortal } from "react-dom";
import { BoardContainer, ColumnCard } from "./components/ColumnCard";
import type { Column, DisplaySettings, Item } from "./types";
@@ -51,27 +52,25 @@ const Kanban = ({
...displaySettings
}: KanbanProps) => {
const { t } = useLingui();
- const [columnOrder, setColumnOrder] = useState<string[]>(() => {
- // Get stored column order from localStorage
- const storedOrder = localStorage.getItem(COLUMN_ORDER_KEY);
- if (storedOrder) {
- const parsedOrder = JSON.parse(storedOrder) as string[];
- // Add any new columns that aren't in stored order
- const newOrder = [...parsedOrder];
- columns.forEach((col) => {
- if (!newOrder.includes(col.id)) {
- newOrder.push(col.id);
- }
- });
- return newOrder;
- }
- return columns.map((col) => col.id);
+ // Only the order the user chose is state. The columns come from the loader
+ // and change while the board is open (a filter, a work center's first
+ // operation): one copied in at mount never showed a column that arrived later.
+ const [storedOrder, setStoredOrder] = useState<string[]>(() => {
+ const stored = localStorage.getItem(COLUMN_ORDER_KEY);
+ return stored ? (JSON.parse(stored) as string[]) : [];
});
+ const columnOrder = useMemo(
+ () =>
+ withUnorderedLast(
+ storedOrder,
+ columns.map((col) => col.id)
+ ),
+ [storedOrder, columns]
+ );
- // Update localStorage when column order changes
useEffect(() => {
- localStorage.setItem(COLUMN_ORDER_KEY, JSON.stringify(columnOrder));
- }, [columnOrder]);
+ localStorage.setItem(COLUMN_ORDER_KEY, JSON.stringify(storedOrder));
+ }, [storedOrder]);
const [activeColumn, setActiveColumn] = useState<Column | null>(null);
@@ -206,12 +205,10 @@ const Kanban = ({
const isActiveAColumn = activeData?.type === "column";
if (!isActiveAColumn) return;
- setColumnOrder((prevOrder) => {
- const activeColumnIndex = prevOrder.findIndex((id) => id === activeId);
- const overColumnIndex = prevOrder.findIndex((id) => id === overId);
-
- return arrayMove(prevOrder, activeColumnIndex, overColumnIndex);
- });
+ const activeColumnIndex = columnOrder.findIndex((id) => id === activeId);
+ const overColumnIndex = columnOrder.findIndex((id) => id === overId);
+ if (activeColumnIndex < 0 || overColumnIndex < 0) return;
+ setStoredOrder(arrayMove(columnOrder, activeColumnIndex, overColumnIndex));
}
};
diff --git a/apps/mes/app/components/SearchFilter.tsx b/apps/mes/app/components/SearchFilter.tsx
index 28396d63cd..5fe9e09b29 100644
--- a/apps/mes/app/components/SearchFilter.tsx
+++ b/apps/mes/app/components/SearchFilter.tsx
@@ -9,7 +9,7 @@ import {
InputLeftElement,
useDebounce
} from "@carbon/react";
-import { useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { LuSearch } from "react-icons/lu";
import { useUrlParams } from "~/hooks";
@@ -19,11 +19,24 @@ type SearchFilterProps = InputProps & {
const SearchFilter = ({ param, size, ...props }: SearchFilterProps) => {
const [params, setParams] = useUrlParams();
- const [query, setQuery] = useState(params.get(param) || "");
+ const urlQuery = params.get(param) || "";
+ const [query, setQuery] = useState(urlQuery);
+ // What this input last wrote to the URL. A different value there came from
+ // elsewhere (a saved view, back/forward, a link) and replaces the text; our
+ // own write arriving late must not undo what was typed since.
+ const written = useRef(urlQuery);
const debounceQuery = useDebounce((q: string) => {
+ written.current = q.trim();
setParams({ [param]: q.trim() });
}, 500);
+ useEffect(() => {
+ if (urlQuery !== written.current) {
+ written.current = urlQuery;
+ setQuery(urlQuery);
+ }
+ }, [urlQuery]);
+
return (
<InputGroup size={size}>
<InputLeftElement>
diff --git a/apps/mes/app/routes/x+/dispatch.$dispatchId.tsx b/apps/mes/app/routes/x+/dispatch.$dispatchId.tsx
index e1f34667e1..69ea65f04e 100644
--- a/apps/mes/app/routes/x+/dispatch.$dispatchId.tsx
+++ b/apps/mes/app/routes/x+/dispatch.$dispatchId.tsx
@@ -21,16 +21,13 @@ import {
useDisclosure,
VStack
} from "@carbon/react";
-import { groupBy, isUnaffectedByNavigation } from "@carbon/utils";
+import { groupBy } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
import { useMemo } from "react";
import { BsExclamationSquareFill } from "react-icons/bs";
import { FaCheck, FaPause, FaPlay } from "react-icons/fa6";
import { LuArrowLeft, LuCheck, LuCirclePlus, LuX } from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { Link, useFetcher, useLoaderData } from "react-router";
import { z } from "zod";
import { HighPriorityIcon } from "~/assets/icons/HighPriorityIcon";
@@ -63,11 +60,6 @@ export const handle: Handle = {
]
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["dispatchId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId, userId } = await requirePermissions(request, {});
const { dispatchId } = params;
diff --git a/apps/mes/app/routes/x+/picking.$pickingListId.tsx b/apps/mes/app/routes/x+/picking.$pickingListId.tsx
index 89ca43de69..1bd4ca604a 100644
--- a/apps/mes/app/routes/x+/picking.$pickingListId.tsx
+++ b/apps/mes/app/routes/x+/picking.$pickingListId.tsx
@@ -41,7 +41,6 @@ import {
toast,
VStack
} from "@carbon/react";
-import { isUnaffectedByNavigation } from "@carbon/utils";
import { Trans } from "@lingui/react/macro";
import { Suspense, useEffect, useMemo, useState } from "react";
import {
@@ -53,10 +52,7 @@ import {
LuTriangleAlert,
LuUndo2
} from "react-icons/lu";
-import type {
- LoaderFunctionArgs,
- ShouldRevalidateFunction
-} from "react-router";
+import type { LoaderFunctionArgs } from "react-router";
import { Await, useFetcher, useLoaderData } from "react-router";
import { Enumerable } from "~/components/Enumerable";
import ItemThumbnail from "~/components/ItemThumbnail";
@@ -82,11 +78,6 @@ export const handle: Handle = {
]
};
-export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
- isUnaffectedByNavigation(args, { params: ["pickingListId"] })
- ? false
- : args.defaultShouldRevalidate;
-
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {});
const pickingListId = params.pickingListId!;
diff --git a/apps/mes/app/routes/x+/picking.tsx b/apps/mes/app/routes/x+/picking.tsx
index c42830b10e..c7970eaeb4 100644
--- a/apps/mes/app/routes/x+/picking.tsx
+++ b/apps/mes/app/routes/x+/picking.tsx
@@ -2,8 +2,8 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { Outlet } from "react-router";
+import { RecordOutlet } from "@carbon/react";
export default function PickingLayout() {
- return <Outlet />;
+ return <RecordOutlet />;
}
diff --git a/packages/checks/src/conformance/baseline.json b/packages/checks/src/conformance/baseline.json
index 94a6150e2d..f6c48a1906 100644
--- a/packages/checks/src/conformance/baseline.json
+++ b/packages/checks/src/conformance/baseline.json
@@ -342,7 +342,6 @@
"no-raw-rounding::apps/erp/app/modules/agent/ui/greetings.ts::return GREETINGS[Math.floor(Math.random() * GREETINGS.length)]();",
"no-raw-rounding::apps/erp/app/modules/documents/documents.service.ts::size = Math.round(converted.data.size / 1024);",
"no-raw-rounding::apps/erp/app/modules/documents/ui/Documents/DocumentCreateForm.tsx::formData.append(\"size\", Math.round(size / 1024).toString());",
- "no-raw-rounding::apps/erp/app/modules/inventory/ui/Inventory/InventoryStorageUnits.tsx::Math.round(",
"no-raw-rounding::apps/erp/app/modules/inventory/ui/Receipts/ReceiptLines.tsx::formData.append(\"size\", Math.round(file.size / 1024).toString());",
"no-raw-rounding::apps/erp/app/modules/inventory/ui/Traceability/utils.ts::if (q >= 1000) return `${(q / 1000).toFixed(1)}k`;",
"no-raw-rounding::apps/erp/app/modules/inventory/ui/Traceability/utils.ts::return q.toFixed(1);",
@@ -586,6 +585,29 @@
"no-required-column-without-default::20241210214820_purchasing-redux.sql::ADD COLUMN \"supplierInteractionId\" TEXT NOT NULL",
"no-required-column-without-default::20241210214820_purchasing-redux.sql::ADD COLUMN IF NOT EXISTS \"supplierInteractionId\" TEXT NOT NULL",
"no-required-column-without-default::20260402000000_journal-entries.sql::ADD COLUMN \"journalEntryId\" TEXT NOT NULL",
+ "no-state-copy-of-loader-data::apps/erp/app/modules/production/ui/Jobs/JobProperties.tsx::const [deadlineType, setDeadlineType] = useState<string>(",
+ "no-state-copy-of-loader-data::apps/erp/app/modules/production/ui/Jobs/JobProperties.tsx::const [type, setType] = useState<MethodItemType>(",
+ "no-state-copy-of-loader-data::apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSummary.tsx::const [openItems, setOpenItems] = useState<string[]>(",
+ "no-state-copy-of-loader-data::apps/erp/app/modules/quality/ui/Documents/QualityDocumentEditor.tsx::const [content, setContent] = useState<JSONContent>(",
+ "no-state-copy-of-loader-data::apps/erp/app/modules/quality/ui/Documents/QualityDocumentEditor.tsx::const [documentName, setDocumentName] = useState(",
+ "no-state-copy-of-loader-data::apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchProperties.tsx::const [currentOeeImpact, setCurrentOeeImpact] = useState<string>(",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/onboarding+/industry.tsx::const [selectedIndustryId, setSelectedIndustryId] = useState<string>(",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/onboarding+/theme.tsx::const [theme, setTheme] = useState<ThemeValue>(initialTheme as \"zinc\");",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/share+/quote.$id.tsx::const [openItems, setOpenItems] = useState<string[]>(() => {",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/share+/supplier-quote.$id.tsx::const [openItems, setOpenItems] = useState<string[]>(() =>",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/accounting+/periods.generate.tsx::const [year, setYear] = useState(defaultFiscalYear);",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx::const [balanceAnchor] = useState(initialBalanceAnchor);",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx::const [hasNewer, setHasNewer] = useState(initialHasNewer);",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx::const [hasOlder, setHasOlder] = useState(initialHasOlder);",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/inventory+/quantities+/$itemId.activity.tsx::useState<ItemLedger[]>(initialItemLedgers);",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/priority+/dates.tsx::const [items, setItems] = useState<JobItem[]>(initialItems);",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/priority+/operations.tsx::const [items, setItems] = useState<Item[]>(initialItems);",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/procedure+/$id.tsx::const [content, setContent] = useState<JSONContent>(",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/procedure+/$id.tsx::const [procedureName, setProcedureName] = useState(",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/settings+/sales.tsx::const [digitalQuoteEnabled, setDigitalQuoteEnabled] = useState(",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/training+/$id.tsx::const [content, setContent] = useState<JSONContent>(",
+ "no-state-copy-of-loader-data::apps/erp/app/routes/x+/training+/$id.tsx::const [trainingName, setTrainingName] = useState(",
+ "no-state-copy-of-loader-data::apps/mes/app/routes/x+/operations.tsx::const [items, setItems] = useState<Item[]>(initialItems);",
"no-unguarded-submit::apps/erp/app/components/AvatarMenu.tsx::<button type=\"submit\" className=\"w-full h-full flex items-center\">",
"no-unguarded-submit::apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.tsx::<Button type=\"submit\" disabled={!isStepValid} variant={isLastStep && destructive ? \"destructive\" : \"primary\"} >",
"no-unguarded-submit::apps/erp/app/components/Layout/Topbar/Breadcrumbs.tsx::<button type=\"submit\">",
diff --git a/packages/checks/src/conformance/no-bare-outlet.test.ts b/packages/checks/src/conformance/no-bare-outlet.test.ts
new file mode 100644
index 0000000000..35c6da02f3
--- /dev/null
+++ b/packages/checks/src/conformance/no-bare-outlet.test.ts
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { describe, expect, it } from "vitest";
+import { noBareOutlet } from "./no-bare-outlet";
+
+const scan = (
+ contents: string,
+ file = "apps/erp/app/routes/x+/part+/$itemId.tsx"
+) => noBareOutlet.scan(file, contents);
+
+describe("noBareOutlet", () => {
+ it("flags a plain outlet in a route under /x, in either app", () => {
+ expect(scan(" return <Outlet />;\n")).toHaveLength(1);
+ expect(
+ scan(
+ "<div>\n <Outlet context={ctx} />\n</div>\n",
+ "apps/mes/app/routes/x+/picking.tsx"
+ )[0]!.line
+ ).toBe(2);
+ });
+
+ it("accepts the record outlet, a keyed outlet and a mention in a comment", () => {
+ expect(scan(" return <RecordOutlet />;\n")).toEqual([]);
+ expect(scan(" <Outlet key={companyId} />\n")).toEqual([]);
+ expect(
+ scan(" // No <Outlet /> here: the detail is a full page\n")
+ ).toEqual([]);
+ });
+
+ it("leaves routes outside /x and components alone", () => {
+ expect(
+ scan("<Outlet />", "apps/erp/app/routes/_public+/_layout.tsx")
+ ).toEqual([]);
+ expect(
+ scan("<Outlet />", "apps/erp/app/modules/items/ui/Item/SupplierParts.tsx")
+ ).toEqual([]);
+ });
+});
diff --git a/packages/checks/src/conformance/no-bare-outlet.ts b/packages/checks/src/conformance/no-bare-outlet.ts
new file mode 100644
index 0000000000..3603755474
--- /dev/null
+++ b/packages/checks/src/conformance/no-bare-outlet.ts
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import type { ConformanceCheck, Violation } from "../check";
+
+// React Router keeps a route's components mounted when only its params change
+// (part A to part B, one order line to the next). Whatever the page seeded once
+// from its record — a form's default values, an editor's initial content, a
+// `useState` copy — then belongs to the previous record: a notes editor showed
+// record A's notes on record B and the first keystroke saved them there.
+// `RecordOutlet` remounts the page when it is shown for a different record.
+const ROUTES = /^apps\/(?:erp|mes)\/app\/routes\/x\+\//;
+const OUTLET = /<Outlet(?=[\s/>])([^>]*)>/g;
+
+export const noBareOutlet: ConformanceCheck = {
+ id: "no-bare-outlet",
+ description:
+ "a route under /x renders RecordOutlet, which remounts its page when the record changes",
+ provenance: {
+ deprecates: "<Outlet />",
+ replacedBy: '<RecordOutlet /> from "@carbon/react"',
+ since: "2026-10-06"
+ },
+ scan(file: string, contents: string): Violation[] {
+ if (!ROUTES.test(file)) return [];
+ const violations: Violation[] = [];
+ for (const match of contents.matchAll(OUTLET)) {
+ // An outlet with its own key already says when its page remounts (the
+ // shell keys on the company).
+ if (/\bkey=/.test(match[1]!)) continue;
+ const line = contents.slice(0, match.index).split("\n").length;
+ const text = contents.split("\n")[line - 1]?.trim() ?? "";
+ if (text.startsWith("//") || text.startsWith("*")) continue;
+ violations.push({
+ file,
+ line,
+ snippet: text,
+ message:
+ 'Render `<RecordOutlet />` from "@carbon/react": a plain outlet keeps the page mounted when the record changes, with the previous record\'s form and editor state'
+ });
+ }
+ return violations;
+ }
+};
diff --git a/packages/checks/src/conformance/no-raw-revalidator.ts b/packages/checks/src/conformance/no-raw-revalidator.ts
index 934fbbccea..8ae33f2226 100644
--- a/packages/checks/src/conformance/no-raw-revalidator.ts
+++ b/packages/checks/src/conformance/no-raw-revalidator.ts
@@ -4,12 +4,10 @@
import type { ConformanceCheck, Violation } from "../check";
-// React Router's `revalidate()` during the navigation that follows a save
-// restarts that navigation without the submission. Every layout whose
-// `shouldRevalidate` skips a plain navigation then keeps its data from before
-// the save: a new quote line was missing from the quote's explorer until a
-// reload, because the save's own realtime broadcast revalidated mid-redirect.
-// `useRevalidator` from `@carbon/query` holds the call until the router is idle.
+// React Router's `revalidate()` during an action drops the fetcher's redirect,
+// and during the navigation that follows a save it restarts that navigation
+// without the submission. `useRevalidator` from `@carbon/query` holds the call
+// until the router is idle.
const ROUTER_IMPORT =
/import\s*(?:type\s*)?\{([^}]*)\}\s*from\s*["']react-router["']/g;
// The wrapper itself: the one place that takes React Router's.
@@ -35,7 +33,7 @@ export const noRawRevalidator: ConformanceCheck = {
line,
snippet: contents.split("\n")[line - 1]?.trim() ?? "",
message:
- 'Import `useRevalidator` from "@carbon/query": React Router\'s restarts the navigation after a save and the layouts skip their reload'
+ "Import `useRevalidator` from \"@carbon/query\": React Router's can drop a save's redirect or restart the navigation that follows it"
});
}
return violations;
diff --git a/packages/checks/src/conformance/no-state-copy-of-loader-data.test.ts b/packages/checks/src/conformance/no-state-copy-of-loader-data.test.ts
new file mode 100644
index 0000000000..a289080687
--- /dev/null
+++ b/packages/checks/src/conformance/no-state-copy-of-loader-data.test.ts
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { describe, expect, it } from "vitest";
+import { noStateCopyOfLoaderData } from "./no-state-copy-of-loader-data";
+
+const scan = (contents: string) =>
+ noStateCopyOfLoaderData.scan("apps/erp/app/routes/x+/thing.tsx", contents);
+
+describe("noStateCopyOfLoaderData", () => {
+ it("flags state seeded from loader data, directly or in an initialiser", () => {
+ expect(
+ scan(
+ `const { rows, total: count } = useLoaderData<typeof loader>();\nconst [list, setList] = useState(rows);\nconst [n] = useState<number>(() => count + 1);\n`
+ ).map((v) => v.line)
+ ).toEqual([2, 3]);
+ });
+
+ it("flags state seeded from route data", () => {
+ const violations = scan(
+ `const routeData = useRouteData<{ lines: Line[] }>(path.to.quote(id));\nconst [selected, setSelected] = useState(() =>\n routeData?.lines.reduce(toSelection, {})\n);\n`
+ );
+ expect(violations).toHaveLength(1);
+ expect(violations[0]!.message).toContain("routeData");
+ });
+
+ it("accepts state that does not read the loaded data", () => {
+ expect(
+ scan(
+ `const { rows } = useLoaderData<typeof loader>();\nconst [open, setOpen] = useState(false);\nconst [picks, setPicks] = useState<Record<string, number>>({});\nconst [draft, setDraft] = useState({ rows: [] });\nconst total = useMemo(() => sum(rows), [rows]);\n`
+ )
+ ).toEqual([]);
+ });
+
+ it("does not take a property of the same name for the data", () => {
+ expect(
+ scan(
+ `const { rows } = useLoaderData<typeof loader>();\nconst [view, setView] = useState(settings.rows);\n`
+ )
+ ).toEqual([]);
+ });
+
+ it("ignores a file that loads nothing", () => {
+ expect(scan(`const [list, setList] = useState(props.rows);\n`)).toEqual([]);
+ });
+});
diff --git a/packages/checks/src/conformance/no-state-copy-of-loader-data.ts b/packages/checks/src/conformance/no-state-copy-of-loader-data.ts
new file mode 100644
index 0000000000..2b54e3b5e1
--- /dev/null
+++ b/packages/checks/src/conformance/no-state-copy-of-loader-data.ts
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import type { ConformanceCheck, Violation } from "../check";
+
+// `useState(initial)` reads `initial` once. Seeded from loader or route data,
+// the state is a copy that no reload updates: a quote's totals kept a deleted
+// line until the page was reloaded, because they were summed from lines copied
+// into state at mount. Loaded data changes under a mounted component all the
+// time (a save's revalidation, a realtime reload, a layout that reloads after
+// its page mounts).
+//
+// What to write instead:
+// - a value computed from the data: compute it during render (`useMemo`);
+// - the user's own choices over the data: keep only the choices in state and
+// combine them with the current data during render;
+// - a draft the user edits: render it in a component keyed on what it drafts.
+//
+// This sees only a hook result used by name in the same file. A copy seeded
+// from a prop is not found.
+const SOURCE =
+ /const\s+(\{[^}]*\}|\w+)\s*=\s*use(?:LoaderData|RouteData|RouteLoaderData)\b/g;
+const STATE = /\buseState\s*(?:<[^;(]*?>)?\s*\(/g;
+
+function boundNames(pattern: string): string[] {
+ if (!pattern.startsWith("{")) return [pattern];
+ return pattern
+ .slice(1, -1)
+ .split(",")
+ .map((part) => part.trim())
+ .filter(Boolean)
+ .map((part) =>
+ part
+ .replace(/^\.\.\./, "")
+ .split(":")
+ .pop()!
+ .split("=")[0]!
+ .trim()
+ )
+ .filter((name) => /^\w+$/.test(name));
+}
+
+/** The text between the parenthesis at `open` and its match. */
+function argument(contents: string, open: number): string {
+ let depth = 0;
+ for (let i = open; i < contents.length && i < open + 2000; i++) {
+ const char = contents[i];
+ if (char === "(") depth++;
+ else if (char === ")" && --depth === 0) return contents.slice(open + 1, i);
+ }
+ return "";
+}
+
+export const noStateCopyOfLoaderData: ConformanceCheck = {
+ id: "no-state-copy-of-loader-data",
+ description:
+ "state must not be seeded from loader or route data: it is a copy no reload updates",
+ provenance: {
+ deprecates: "useState(valueFrom(useLoaderData() | useRouteData()))",
+ replacedBy:
+ "a value computed during render, or a component keyed on what it drafts",
+ since: "2026-10-06"
+ },
+ scan(file: string, contents: string): Violation[] {
+ if (!file.endsWith(".tsx")) return [];
+ const names = [...contents.matchAll(SOURCE)].flatMap((match) =>
+ boundNames(match[1]!)
+ );
+ if (names.length === 0) return [];
+ const used = new RegExp(`(?<![.\\w])(?:${names.join("|")})\\b(?!\\s*:)`);
+
+ const violations: Violation[] = [];
+ for (const match of contents.matchAll(STATE)) {
+ const open = match.index + match[0].length - 1;
+ const initial = argument(contents, open);
+ const name = initial.match(used)?.[0];
+ if (!name) continue;
+ const line = contents.slice(0, match.index).split("\n").length;
+ violations.push({
+ file,
+ line,
+ snippet: contents.split("\n")[line - 1]?.trim() ?? "",
+ message: `State seeded from \`${name}\` (loader or route data) is a copy that no reload updates. Compute it during render, or keep only the user's input in state`
+ });
+ }
+ return violations;
+ }
+};
diff --git a/packages/checks/src/run.ts b/packages/checks/src/run.ts
index 64b3e22544..91019ffa9c 100644
--- a/packages/checks/src/run.ts
+++ b/packages/checks/src/run.ts
@@ -20,6 +20,7 @@ import {
type ManagedFunction,
noAuthzDdlInMigrations
} from "./conformance/no-authz-ddl-in-migrations";
+import { noBareOutlet } from "./conformance/no-bare-outlet";
import { noDbClientInService } from "./conformance/no-db-client-in-service";
import { noDefaultOnEffects } from "./conformance/no-default-on-effects";
import { noDerivedPercentColumn } from "./conformance/no-derived-percent-column";
@@ -43,6 +44,7 @@ import { noRawRedirect } from "./conformance/no-raw-redirect";
import { noRawRevalidator } from "./conformance/no-raw-revalidator";
import { noRawRounding } from "./conformance/no-raw-rounding";
import { noRequiredColumnWithoutDefault } from "./conformance/no-required-column-without-default";
+import { noStateCopyOfLoaderData } from "./conformance/no-state-copy-of-loader-data";
import { noUnguardedSubmit } from "./conformance/no-unguarded-submit";
import { noUnroundedTrackedQuantity } from "./conformance/no-unrounded-tracked-quantity";
import { noUnscopedKyselyWrite } from "./conformance/no-unscoped-kysely-write";
@@ -175,7 +177,9 @@ export function collectFindings(root: string = repoRoot()): Finding[] {
]),
...scanAll(loadTypescriptFiles(root), [
noRawRevalidator,
- noInlineSensorOptions
+ noInlineSensorOptions,
+ noBareOutlet,
+ noStateCopyOfLoaderData
]),
...scanAll(loadTypescriptFiles(root, ROUTE_ROOTS), [
indexRedirectBeforeLoaders
diff --git a/packages/form/src/ValidatedForm.tsx b/packages/form/src/ValidatedForm.tsx
index 0b2990384a..453d32e861 100644
--- a/packages/form/src/ValidatedForm.tsx
+++ b/packages/form/src/ValidatedForm.tsx
@@ -295,6 +295,9 @@ export function ValidatedForm<
}: FormProps<DataType, Subaction>) {
const formId = useFormId(id);
const providedDefaultValues = useDeepEqualsMemo(unMemoizedDefaults);
+ // See `ownsState`. State, not a ref: the fields must render again once it
+ // is true. A form with no `id` has a key of its own and owns it from the start.
+ const [ownsState, setOwnsState] = useState(id === undefined);
const contextValue = useMemo<InternalFormContextValue>(
() => ({
formId,
@@ -302,9 +305,18 @@ export function ValidatedForm<
subaction,
defaultValuesProp: providedDefaultValues,
fetcher,
- validatorSchema: validator
+ validatorSchema: validator,
+ ownsState
}),
- [action, fetcher, formId, providedDefaultValues, subaction, validator]
+ [
+ action,
+ fetcher,
+ formId,
+ ownsState,
+ providedDefaultValues,
+ subaction,
+ validator
+ ]
);
const formStateValue = useMemo(
() => ({ isDisabled, isReadOnly }),
@@ -362,6 +374,7 @@ export function ValidatedForm<
// There must be a nice way to avoid this.
useIsomorphicLayoutEffect(() => {
registerForm(formId);
+ setOwnsState(true);
return () => cleanupForm(formId);
}, [cleanupForm, formId, registerForm]);
diff --git a/packages/form/src/internal/formContext.ts b/packages/form/src/internal/formContext.ts
index 1f619ea6aa..f36a75f00b 100644
--- a/packages/form/src/internal/formContext.ts
+++ b/packages/form/src/internal/formContext.ts
@@ -13,6 +13,13 @@ export type InternalFormContextValue = {
defaultValuesProp?: { [fieldName: string]: any };
fetcher?: FetcherWithComponents<unknown>;
validatorSchema?: z.ZodTypeAny;
+ /**
+ * False until this form instance has registered its own state. A form with a
+ * fixed `id` shares its store key with the instance it replaces (a keyed
+ * remount for another record), and that one's state is still there on the
+ * new instance's first render. Absent for a context built outside a form.
+ */
+ ownsState?: boolean;
};
export const InternalFormContext =
diff --git a/packages/form/src/internal/hooks.ts b/packages/form/src/internal/hooks.ts
index 7ac3c7c373..ca1f91b94f 100644
--- a/packages/form/src/internal/hooks.ts
+++ b/packages/form/src/internal/hooks.ts
@@ -55,11 +55,23 @@ export function useErrorResponseForForm({
return null;
}
+/**
+ * True once the stored state is this form instance's own and holds its
+ * defaults. Read this, never `isHydrated` alone: on the first render of a form
+ * that replaces another with the same fixed `id`, the store still holds the
+ * previous form's values, and an input mounted with them kept showing the
+ * previous record (a receipt's form showed the last receipt's number).
+ */
+export const useIsFormHydrated = (context: InternalFormContextValue) => {
+ const hydrated = useFormStore(context.formId, (state) => state.isHydrated);
+ return hydrated && (context.ownsState ?? true);
+};
+
export const useFieldErrorsForForm = (
context: InternalFormContextValue
): Hydratable<FieldErrors | undefined> => {
const response = useErrorResponseForForm(context);
- const hydrated = useFormStore(context.formId, (state) => state.isHydrated);
+ const hydrated = useIsFormHydrated(context);
return hydratable.from(response?.fieldErrors, hydrated);
};
@@ -86,8 +98,8 @@ export const useDefaultValuesFromLoader = ({
export const useDefaultValuesForForm = (
context: InternalFormContextValue
): Hydratable<{ [fieldName: string]: any }> => {
- const { formId, defaultValuesProp } = context;
- const hydrated = useFormStore(formId, (state) => state.isHydrated);
+ const { defaultValuesProp } = context;
+ const hydrated = useIsFormHydrated(context);
const errorResponse = useErrorResponseForForm(context);
const defaultValuesFromLoader = useDefaultValuesFromLoader(context);
diff --git a/packages/form/src/internal/state/controlledFields.ts b/packages/form/src/internal/state/controlledFields.ts
index 2228231974..6164dc0838 100644
--- a/packages/form/src/internal/state/controlledFields.ts
+++ b/packages/form/src/internal/state/controlledFields.ts
@@ -4,7 +4,7 @@
import { useCallback, useEffect } from "react";
import type { InternalFormContextValue } from "../formContext";
-import { useFieldDefaultValue } from "../hooks";
+import { useFieldDefaultValue, useIsFormHydrated } from "../hooks";
import { useFormStore } from "./storeHooks";
import type { InternalFormId } from "./types";
@@ -15,10 +15,7 @@ export const useControlledFieldValue = (
const value = useFormStore(context.formId, (state) =>
state.controlledFields.getValue(field)
);
- const isFormHydrated = useFormStore(
- context.formId,
- (state) => state.isHydrated
- );
+ const isFormHydrated = useIsFormHydrated(context);
const defaultValue = useFieldDefaultValue(field, context);
return isFormHydrated ? value : defaultValue;
diff --git a/packages/jobs/src/inngest/functions/tasks/company-restore.ts b/packages/jobs/src/inngest/functions/tasks/company-restore.ts
index 9c9b893ddf..ba577284af 100644
--- a/packages/jobs/src/inngest/functions/tasks/company-restore.ts
+++ b/packages/jobs/src/inngest/functions/tasks/company-restore.ts
@@ -3,7 +3,10 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { getCarbonServiceRole } from "@carbon/auth/client.server";
-import { CHANGE_LOGGED_TABLES } from "@carbon/database/realtime-tables";
+import {
+ CHANGE_LOGGED_TABLES,
+ REALTIME_TABLES
+} from "@carbon/database/realtime-tables";
import { requireBackupsEntitlement } from "@carbon/ee/backups.server";
import { getLogger } from "@carbon/logger";
import { chunkArray } from "@carbon/utils";
@@ -243,6 +246,28 @@ export async function wipeAndLoad(
CHANGE_LOGGED_TABLES.map((table) => ({ companyId, table, rowId: null }))
)
.execute();
+
+ // The log only answers a client that asks, and an open tab asks when a
+ // broadcast tells it to. With triggers off none was sent: after a template
+ // was reverted, a tab kept the reverted parts in its pickers for up to an
+ // hour, and creating a job with one of them failed. Say on every table's
+ // topic that it changed in bulk (null ids): a list reads the log again and
+ // a page reloads. Sent with the transaction, so nothing hears of a restore
+ // that rolled back.
+ const realtime = await sql<{ present: boolean }>`
+ SELECT to_regprocedure('realtime.send(jsonb,text,text,boolean)') IS NOT NULL AS present
+ `.execute(trx);
+ if (realtime.rows[0]?.present) {
+ await sql`
+ SELECT realtime.send(
+ jsonb_build_object('table', t, 'op', 'UPDATE', 'ids', NULL, 'parents', NULL),
+ 'UPDATE',
+ 'company:' || ${companyId} || ':' || t,
+ true
+ )
+ FROM unnest(${[...REALTIME_TABLES]}::text[]) AS t
+ `.execute(trx);
+ }
});
return { rows: inserted, idRewrite };
diff --git a/packages/query/AGENTS.md b/packages/query/AGENTS.md
index cd7bc1b3c7..7635ce478a 100644
--- a/packages/query/AGENTS.md
+++ b/packages/query/AGENTS.md
@@ -39,7 +39,7 @@ pnpm --filter @carbon/query test
| `cachedApiQuery(url)` | The same read from an event handler or an effect |
| `useAction({ onSuccess, onError, onSettled })` | A mutation fetcher with callbacks. `onSettled` runs whenever a submission finishes, also when the action redirects and returns no data; `onSuccess` / `onError` need data |
| `setClientCompanyId(companyId, userId)` / `getCompanyId` | The shell layout sets both during render; the `companyId` cookie is httpOnly and unreadable in the browser. A different user empties the cache; leaving a company drops its loader entries |
-| `useRevalidator()` | React Router's `useRevalidator`, held while a fetcher is submitting or a navigation is in flight. The only one app code may import (`no-raw-revalidator` check): a revalidation during the redirect after a save restarts it as a plain navigation and the layouts skip their reload |
+| `useRevalidator()` | React Router's `useRevalidator`, held while a fetcher is submitting or a navigation is in flight. The only one app code may import (`no-raw-revalidator` check): a revalidation during an action drops the fetcher's redirect, and one during the navigation after a save restarts that navigation |
| `createInvalidationMiddleware({ getCache, skipPaths })` | Root `clientMiddleware`; skip POSTs that change no data (`/refresh-session`) |
| `RouteRealtime`, `useRealtimeTable`, `useTableChanges`, `useRealtimeRevalidator` | Realtime over private broadcast topics. Reloads go through `useRevalidator`, so they wait for a save in flight. A route entry `{ table, column, param }` and a `<name>Id=eq.` filter follow one record's rows only (`matchesFilter`) |
| `useRealtimeChannel` | One channel with retry, `private` and `onSubscribed(isReconnect)`. It reconnects when the tab returns after 5 minutes hidden or with a channel that is not joined — every reconnect reloads the page's data, so time in another tab does not |
diff --git a/packages/query/src/useRevalidator.ts b/packages/query/src/useRevalidator.ts
index d6a5935c9d..bbb3e4f5d0 100644
--- a/packages/query/src/useRevalidator.ts
+++ b/packages/query/src/useRevalidator.ts
@@ -18,13 +18,11 @@ let held = false;
* `useRevalidator` whose `revalidate` never starts during a save. Import this
* one, never React Router's (the `no-raw-revalidator` check enforces it).
*
- * A revalidation that starts during a save does harm twice over:
+ * A revalidation that starts during a save does harm:
* - during the action, React Router drops the fetcher's redirect;
* - during the navigation that follows the save, it restarts that navigation
- * without the submission. The restarted one looks like a plain navigation,
- * so every layout whose `shouldRevalidate` skips those keeps its data from
- * before the save (a new quote line was missing from the quote's explorer
- * until a reload: the save's own realtime broadcast arrived mid-redirect).
+ * without the submission, so the page loads twice and anything that reads
+ * "this follows a save" from the navigation no longer sees it.
*
* A call made while a fetcher is submitting or a navigation is in flight is
* held and runs once the router is idle. The promise of a held call resolves
diff --git a/packages/react/AGENTS.md b/packages/react/AGENTS.md
index 0957259b06..b4795adc3c 100644
--- a/packages/react/AGENTS.md
+++ b/packages/react/AGENTS.md
@@ -43,9 +43,10 @@ import { Button, Card, HStack, VStack, IconButton, cn } from "@carbon/react";
- **Overlays**: `Drawer`, `Modal`, `ModalDrawer` (unified drawer/modal), `BottomSheet`, `Popover`. A controlled `Modal`/`Drawer` with no `onOpenChange` cannot be dismissed and shows no close button; never pass a handler that does nothing (`no-noop-open-change` check). A route rendered as a modal or drawer closes with `useCloseRoute()` (back when this tab has history, else the parent route), not `navigate(-1)`
- **App nav**: `NavRail` is the primary left nav of both the ERP and MES shells (56px icon rail, expands after a 150ms mouse hover or when pinned via `SidebarProvider` (⌘B unless `keyboardShortcut={false}`, as in the ERP), left drawer below md that closes itself on navigation). Optional `header` (use `NavRailBrand` for a logo + name) and `footer` slots; `NavRailGroup` adds a titled section that shows as a divider while collapsed. Entries are `NavRailItem` (a button, or `asChild` for a trigger/link) and `NavRailLink`; `label` is a string and doubles as the accessible name. A Radix menu/popover opened from a `NavRailItem` keeps the rail as it was (open or collapsed) until it closes. Render inside `SidebarProvider`; the shadcn-style `Sidebar*` primitives remain for other layouts
- **Links that prefetch**: `PrefetchLink` is a React Router `Link` that prefetches its destination when the pointer goes down on it. Use it instead of `<Link prefetch="intent">`, which prefetches on a 100 ms hover and so runs a page's loaders for every row the mouse passes over. The click reuses the prefetch only because `prefetchCacheMiddleware` (`@carbon/utils`, in each app's root `middleware`) gives a prefetch response a few seconds of private cache; without it both requests reach the server and the click waits behind the prefetch. `NavRailLink` and both apps' `Hyperlink` already use it
+- **Record outlet**: `RecordOutlet` is the `<Outlet>` of every route under `/x`. It remounts the page inside it when that page is shown for a different record (the params of the route in the outlet, not of a drawer below it), so nothing seeded from the previous record survives. A plain `<Outlet>` there fails the `no-bare-outlet` check
- **Data**: `Table` (TanStack), chart components via sub-exports (`@carbon/react/Chart`)
- **Rich text**: `@carbon/react/Editor` and `@carbon/react/RichText` (wraps `@carbon/tiptap`)
-- **Error boundary**: `@carbon/react/ErrorBoundary` — `RouteErrorBoundary` (exported as `ErrorBoundary` from a module layout so a failed loader shows inside the app shell) and `RootErrorBoundary` (drop-in root `ErrorBoundary` for RR v7 that maps 404 / other HTTP / thrown `Error` to a styled screen) plus its parts (`ErrorScreen`, `GlitchHeading`, `StatusReadout`, `MagneticLink`, `NoiseOverlay`). Wrap it in the app's `Document` and pass `env` so `window.env` is set (the client crashes hydration otherwise). Copy is intentionally hardcoded English, not i18n.
+- **Error boundary**: `@carbon/react/ErrorBoundary` — `RouteErrorBoundary` (exported as `ErrorBoundary` from a module layout so a failed loader shows inside the app shell; it shows the status code and, for a 4xx, the message the server threw — `routeErrorCopy` — so throw a `Response` whose body says what was wrong. A 5xx or thrown `Error` gets generic copy) and `RootErrorBoundary` (drop-in root `ErrorBoundary` for RR v7 that maps 404 / other HTTP / thrown `Error` to a styled screen) plus its parts (`ErrorScreen`, `GlitchHeading`, `StatusReadout`, `MagneticLink`, `NoiseOverlay`). Wrap it in the app's `Document` and pass `env` so `window.env` is set (the client crashes hydration otherwise). Copy is intentionally hardcoded English, not i18n.
- **Polish**: shadows over borders, `tabular-nums` for dynamic numbers, `active:scale-[0.98]` on pressables, `text-balance`/`text-pretty` for text wrapping
## Cross-References
diff --git a/packages/react/src/ErrorBoundary/RouteErrorBoundary.tsx b/packages/react/src/ErrorBoundary/RouteErrorBoundary.tsx
index 05c259692e..57607680c7 100644
--- a/packages/react/src/ErrorBoundary/RouteErrorBoundary.tsx
+++ b/packages/react/src/ErrorBoundary/RouteErrorBoundary.tsx
@@ -3,8 +3,9 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { useEffect } from "react";
-import { isRouteErrorResponse, useNavigate, useRouteError } from "react-router";
+import { useNavigate, useRouteError } from "react-router";
import { Button } from "../Button";
+import { routeErrorCopy } from "./routeErrorCopy";
/**
* The boundary for a route that renders inside the app shell:
@@ -25,8 +26,7 @@ export function RouteErrorBoundary() {
console.error("[RouteErrorBoundary]", error);
}, [error]);
- const notFound = isRouteErrorResponse(error) && error.status === 404;
- const status = isRouteErrorResponse(error) ? error.status : undefined;
+ const { status, title, message, canRetry } = routeErrorCopy(error);
return (
<div
@@ -34,20 +34,18 @@ export function RouteErrorBoundary() {
className="flex h-full w-full flex-col items-center justify-center gap-4 p-8 text-center"
>
<div className="flex flex-col gap-1">
- <h2 className="text-lg font-medium text-foreground">
- {notFound
- ? "This page could not be found"
- : "This page failed to load"}
- </h2>
+ {status && (
+ <span className="font-mono text-xs text-muted-foreground tabular-nums">
+ {status}
+ </span>
+ )}
+ <h2 className="text-lg font-medium text-foreground">{title}</h2>
<p className="max-w-md text-sm text-muted-foreground text-balance">
- {notFound
- ? "It may have been moved or deleted, or it belongs to another company."
- : "Something went wrong on our side. Trying again usually fixes it."}
- {status && !notFound ? ` (${status})` : null}
+ {message}
</p>
</div>
<div className="flex gap-2">
- {!notFound && (
+ {canRetry && (
<Button variant="primary" onClick={() => navigate(0)}>
Try again
</Button>
diff --git a/packages/react/src/ErrorBoundary/routeErrorCopy.test.ts b/packages/react/src/ErrorBoundary/routeErrorCopy.test.ts
new file mode 100644
index 0000000000..ecca50dda9
--- /dev/null
+++ b/packages/react/src/ErrorBoundary/routeErrorCopy.test.ts
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { describe, expect, it } from "vitest";
+import { routeErrorCopy } from "./routeErrorCopy";
+
+// The shape `isRouteErrorResponse` accepts.
+const response = (status: number, data: unknown) => ({
+ status,
+ statusText: "",
+ internal: false,
+ data
+});
+
+describe("routeErrorCopy", () => {
+ it("shows the server's message and the code for a 4xx", () => {
+ expect(
+ routeErrorCopy(response(404, "The item could not be found."))
+ ).toEqual({
+ status: 404,
+ title: "Not found",
+ message: "The item could not be found.",
+ canRetry: false
+ });
+ expect(
+ routeErrorCopy(response(400, { message: "Quantity is required" }))
+ ).toMatchObject({ status: 400, message: "Quantity is required" });
+ });
+
+ it("falls back to the status's own copy when the body says nothing", () => {
+ const copy = routeErrorCopy(response(404, "Not found"));
+ expect(copy.title).toBe("Not found");
+ expect(copy.message).toMatch(/moved or deleted/);
+ expect(routeErrorCopy(response(403, "")).title).toBe(
+ "You do not have access to this"
+ );
+ });
+
+ it("does not show React Router's own message", () => {
+ const copy = routeErrorCopy({
+ ...response(405, 'Error: You made a POST request to "/x/job"'),
+ internal: true
+ });
+ expect(copy.status).toBe(405);
+ expect(copy.message).not.toMatch(/POST/);
+ });
+
+ it("never shows the text of a 5xx or a thrown Error", () => {
+ for (const error of [
+ response(500, 'relation "item" does not exist'),
+ new Error("secret")
+ ]) {
+ const copy = routeErrorCopy(error);
+ expect(copy.message).toMatch(/on our side/);
+ expect(copy.canRetry).toBe(true);
+ }
+ expect(routeErrorCopy(response(500, "x")).status).toBe(500);
+ expect(routeErrorCopy(new Error("x")).status).toBeUndefined();
+ });
+});
diff --git a/packages/react/src/ErrorBoundary/routeErrorCopy.ts b/packages/react/src/ErrorBoundary/routeErrorCopy.ts
new file mode 100644
index 0000000000..f1aab3279c
--- /dev/null
+++ b/packages/react/src/ErrorBoundary/routeErrorCopy.ts
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { isRouteErrorResponse } from "react-router";
+
+export type RouteErrorCopy = {
+ status?: number;
+ title: string;
+ message: string;
+ /** Trying again can help: the failure was on our side, not in the request. */
+ canRetry: boolean;
+};
+
+// Bodies that only repeat the status and say nothing about what failed.
+const GENERIC_BODIES = new Set(["", "not found", "bad request", "forbidden"]);
+
+const TITLES: Record<number, string> = {
+ 401: "You are signed out",
+ 403: "You do not have access to this",
+ 404: "Not found"
+};
+
+const MESSAGES: Record<number, string> = {
+ 401: "Sign in again to continue.",
+ 403: "Ask an administrator of this company for the permission.",
+ 404: "This page may have been moved or deleted, or it belongs to another company."
+};
+
+/**
+ * What the route error screen says for a thrown value.
+ *
+ * A 4xx is about the request, so the server's own message is shown: a save
+ * that named a deleted record must not read as a missing page. A 5xx or a
+ * thrown `Error` keeps the generic copy, since its text is internal detail.
+ */
+export function routeErrorCopy(error: unknown): RouteErrorCopy {
+ if (
+ !isRouteErrorResponse(error) ||
+ error.status < 400 ||
+ error.status >= 500
+ ) {
+ return {
+ status: isRouteErrorResponse(error) ? error.status : undefined,
+ title: "Something went wrong",
+ message:
+ "Something went wrong on our side. Trying again usually fixes it.",
+ canRetry: true
+ };
+ }
+
+ // React Router's own 4xx (no route, no action) carries developer text.
+ const detail = isInternal(error) ? undefined : responseMessage(error.data);
+ return {
+ status: error.status,
+ title: TITLES[error.status] ?? "This request could not be completed",
+ message:
+ detail ??
+ MESSAGES[error.status] ??
+ "The request was refused. Go back and try again.",
+ canRetry: false
+ };
+}
+
+function isInternal(error: object): boolean {
+ return "internal" in error && error.internal === true;
+}
+
+function responseMessage(data: unknown): string | undefined {
+ const text =
+ typeof data === "string"
+ ? data
+ : data && typeof data === "object" && "message" in data
+ ? data.message
+ : undefined;
+ if (typeof text !== "string") return undefined;
+ const trimmed = text.trim();
+ return GENERIC_BODIES.has(trimmed.toLowerCase()) ? undefined : trimmed;
+}
diff --git a/packages/react/src/RecordOutlet.test.tsx b/packages/react/src/RecordOutlet.test.tsx
new file mode 100644
index 0000000000..bf6769c889
--- /dev/null
+++ b/packages/react/src/RecordOutlet.test.tsx
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { renderToStaticMarkup } from "react-dom/server";
+import type { RouteObject } from "react-router";
+import {
+ createStaticHandler,
+ createStaticRouter,
+ Outlet,
+ StaticRouterProvider
+} from "react-router";
+import { describe, expect, it } from "vitest";
+import { routeParamNames, useRecordOutletKey } from "./RecordOutlet";
+
+describe("routeParamNames", () => {
+ it("names the record and the page's own params", () => {
+ expect(
+ routeParamNames("routes/x+/purchase-order+/$orderId.$lineId.details")
+ ).toEqual(["orderId", "lineId"]);
+ });
+
+ it("leaves out a drawer's param: the page behind it has none of its own", () => {
+ expect(routeParamNames("routes/x+/part+/$itemId.purchasing")).toEqual([
+ "itemId"
+ ]);
+ });
+
+ it("is empty for a route with no params, so its outlet never remounts", () => {
+ expect(routeParamNames("routes/x+/part+/_layout")).toEqual([]);
+ });
+});
+
+// Each layout prints the key its outlet would get, then renders the outlet.
+function Layout({ name }: { name: string }) {
+ const key = useRecordOutletKey();
+ return (
+ <>
+ <i data-layout={name} data-key={key ?? "none"} />
+ <Outlet />
+ </>
+ );
+}
+
+// The app's own shape, with the ids flat routes give: a module layout, a
+// record layout, a page, a page that is itself a list with a drawer below it,
+// and an order whose lines are pages.
+const routes: RouteObject[] = [
+ {
+ id: "routes/x+/part+/_layout",
+ path: "/x/part",
+ element: <Layout name="module" />,
+ children: [
+ {
+ id: "routes/x+/part+/$itemId",
+ path: ":itemId",
+ element: <Layout name="record" />,
+ children: [
+ {
+ id: "routes/x+/part+/$itemId.details",
+ path: "details",
+ element: <b />
+ },
+ {
+ id: "routes/x+/part+/$itemId.purchasing",
+ path: "purchasing",
+ element: <Layout name="page" />,
+ children: [
+ {
+ id: "routes/x+/part+/$itemId.purchasing.$supplierPartId",
+ path: ":supplierPartId",
+ element: <b />
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ id: "routes/x+/purchase-order+/$orderId",
+ path: "/x/purchase-order/:orderId",
+ element: <Layout name="order" />,
+ children: [
+ {
+ id: "routes/x+/purchase-order+/$orderId.$lineId.details",
+ path: ":lineId/details",
+ element: <b />
+ }
+ ]
+ }
+];
+
+async function keysAt(path: string): Promise<Record<string, string>> {
+ const handler = createStaticHandler(routes);
+ const context = await handler.query(new Request(`http://localhost${path}`));
+ if (context instanceof Response) throw new Error("unexpected redirect");
+ const html = renderToStaticMarkup(
+ <StaticRouterProvider
+ router={createStaticRouter(handler.dataRoutes, context)}
+ context={context}
+ hydrate={false}
+ />
+ );
+ return Object.fromEntries(
+ [...html.matchAll(/data-layout="(\w+)" data-key="([^"]*)"/g)].map(
+ (match) => [match[1]!, match[2]!]
+ )
+ );
+}
+
+describe("useRecordOutletKey", () => {
+ it("changes with the record, so the record's page remounts", async () => {
+ const a = await keysAt("/x/part/A/details");
+ const b = await keysAt("/x/part/B/details");
+ expect(a.module).toBe("A");
+ expect(b.module).toBe("B");
+ expect(a.record).toBe("A");
+ expect(b.record).toBe("B");
+ });
+
+ it("stays the same from one page of a record to another", async () => {
+ const details = await keysAt("/x/part/A/details");
+ const purchasing = await keysAt("/x/part/A/purchasing");
+ // The record layout itself stays mounted; only its outlet's route differs,
+ // and React remounts a different element type on its own.
+ expect(details.module).toBe(purchasing.module);
+ expect(details.record).toBe(purchasing.record);
+ });
+
+ it("does not change when a drawer opens over the page", async () => {
+ const page = await keysAt("/x/part/A/purchasing");
+ const drawer = await keysAt("/x/part/A/purchasing/SP1");
+ expect(drawer.module).toBe(page.module);
+ expect(drawer.record).toBe(page.record);
+ });
+
+ it("changes for the drawer itself when it shows another row", async () => {
+ const one = await keysAt("/x/part/A/purchasing/SP1");
+ const two = await keysAt("/x/part/A/purchasing/SP2");
+ expect(one.page).toBe("A/SP1");
+ expect(two.page).toBe("A/SP2");
+ });
+
+ it("changes from one line of an order to the next", async () => {
+ const one = await keysAt("/x/purchase-order/PO1/L1/details");
+ const two = await keysAt("/x/purchase-order/PO1/L2/details");
+ expect(one.order).toBe("PO1/L1");
+ expect(two.order).toBe("PO1/L2");
+ });
+});
diff --git a/packages/react/src/RecordOutlet.tsx b/packages/react/src/RecordOutlet.tsx
new file mode 100644
index 0000000000..ab053da2c3
--- /dev/null
+++ b/packages/react/src/RecordOutlet.tsx
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { useContext } from "react";
+import type { OutletProps } from "react-router";
+import {
+ Outlet,
+ UNSAFE_RouteContext,
+ useMatches,
+ useParams
+} from "react-router";
+
+/** The `$param` names in a flat-routes route id (`…/$orderId.$lineId.details`). */
+export function routeParamNames(routeId: string): string[] {
+ return [...routeId.matchAll(/\$(\w+)/g)].map((match) => match[1]!);
+}
+
+/**
+ * `<Outlet>` for a route with a param in its path: the page in it remounts
+ * when it is shown for a different record.
+ *
+ * React Router keeps a route's components mounted when only its params change
+ * (part A to part B, one order line to the next). Everything seeded once from
+ * the record then belongs to the previous one: a form's default values, an
+ * editor's initial content, a `useState` copy. A notes editor showed record
+ * A's notes on record B, and the first keystroke saved them there.
+ *
+ * The key is the params of the route rendered in the outlet, not of the routes
+ * below it: a drawer that opens over the page adds a param and must not
+ * remount the page behind it. The layout's own chrome (header, explorer,
+ * properties) is outside the outlet and stays mounted.
+ */
+export function RecordOutlet(props: OutletProps) {
+ return <Outlet key={useRecordOutletKey()} {...props} />;
+}
+
+/** The key `RecordOutlet` gives its page: the params of the route shown in it. */
+export function useRecordOutletKey(): string | undefined {
+ const params = useParams();
+ // The matches down to the route that renders this outlet; the next one is
+ // the route shown in it.
+ const depth = useContext(UNSAFE_RouteContext).matches.length;
+ const child = useMatches()[depth];
+ return child
+ ? routeParamNames(child.id)
+ .map((name) => params[name])
+ .join("/")
+ : undefined;
+}
diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsx
index 22c05dc611..12a622012d 100644
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@ -376,6 +376,7 @@ import { VStack } from "./VStack";
export * from "./Acknowledge";
export * from "./hooks";
+export * from "./RecordOutlet";
export {
Accordion,
AccordionContent,
diff --git a/packages/utils/AGENTS.md b/packages/utils/AGENTS.md
index 87a5334696..5da847ed56 100644
--- a/packages/utils/AGENTS.md
+++ b/packages/utils/AGENTS.md
@@ -61,7 +61,7 @@ pnpm --filter @carbon/utils typecheck
| `format` | The ONLY place display/input digit counts are chosen: `moneyFormatOptions` (settlement — the currency's decimals are floor AND ceiling), `rateFormatOptions` (per-unit RATE — those decimals are only the floor, ceiling is `SCALE`), the `PERCENT_FORMAT` / `PERCENT_POINTS_FORMAT` / `SCALE_FORMAT` constants, `cldrCurrencyDecimals`, their `format*` helpers, and `INPUT_FORMAT` / `INPUT_STEP` for editable fields. Call sites pick a KIND, never a digit count |
| `string` | Slugify, truncate, camelCase/titleCase conversions |
| `items` | Item lookups and `getReadableIdWithRevision` (`readableId.revision`) |
-| `revalidate` | `shouldRevalidate` predicates: `isSearchParamOnlyNavigation` (root loaders), `isUnaffectedByNavigation` (detail layouts — names the route/search params the loader reads) |
+| `revalidate` | `shouldRevalidate` predicates: `isSearchParamOnlyNavigation` (the root loader only; layouts do not skip their loaders, see `coding-conventions.md` → Routes) |
| `prefetch` | `prefetchCacheMiddleware` — root `middleware` of every app: a prefetch response (`Sec-Purpose: prefetch`) gets `private, max-age=5`, so the click reuses it instead of asking again and waiting behind it. Navigations and revalidations stay uncached |
| `redirect` | `redirect(to, init?)` — the only redirect a loader or action uses: a path on this origin, anything else lands on the home page (`no-raw-redirect` check); `redirectExternal(url, init?)` to leave the origin on purpose with a URL the server built; `safePath(to, fallback)` for a destination that is stored or forwarded rather than redirected to. `redirectBeforeLoaders(loader)` — route middleware for an index route that only redirects, so the redirect runs before its parents' loaders |
| `status` | Status resolution, status color mapping |
diff --git a/packages/utils/src/arrays.test.ts b/packages/utils/src/arrays.test.ts
new file mode 100644
index 0000000000..5adc36ea8c
--- /dev/null
+++ b/packages/utils/src/arrays.test.ts
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { describe, expect, it } from "vitest";
+import { withPathIds, withUnorderedLast } from "./arrays";
+
+describe("withUnorderedLast", () => {
+ it("keeps the saved order and appends an id that arrived later", () => {
+ expect(withUnorderedLast(["b", "a"], ["a", "b", "c"])).toEqual([
+ "b",
+ "a",
+ "c"
+ ]);
+ });
+
+ it("uses the current order when nothing was saved", () => {
+ expect(withUnorderedLast([], ["a", "b"])).toEqual(["a", "b"]);
+ });
+
+ it("keeps a saved id that is not current, so it returns to its place", () => {
+ expect(withUnorderedLast(["a", "hidden", "b"], ["a", "b"])).toEqual([
+ "a",
+ "hidden",
+ "b"
+ ]);
+ });
+
+ it("names each id once", () => {
+ const order = withUnorderedLast(["a", "b"], ["b", "a", "c"]);
+ expect(new Set(order).size).toBe(order.length);
+ });
+});
+
+describe("withPathIds", () => {
+ type Node = { id: string; children: Node[] };
+ const leaf = (id: string): Node => ({ id, children: [] });
+ // One sub-assembly object used under two parents, as the builder produces.
+ const shared: Node = { id: "sub", children: [leaf("bolt")] };
+ const tree = (): Node[] => [
+ { id: "root", children: [{ id: "a", children: [shared] }, shared] }
+ ];
+ const ids = (nodes: Node[]): string[] =>
+ nodes.flatMap((n) => [n.id, ...ids(n.children)]);
+
+ it("gives every place a node appears an id of its own", () => {
+ const all = ids(withPathIds(tree()));
+ expect(new Set(all).size).toBe(all.length);
+ expect(all).toContain("root/a/sub/bolt");
+ expect(all).toContain("root/sub/bolt");
+ });
+
+ it("gives the same ids on every load", () => {
+ expect(ids(withPathIds(tree()))).toEqual(ids(withPathIds(tree())));
+ });
+
+ it("tells apart a node listed twice under one parent", () => {
+ const all = ids(
+ withPathIds([{ id: "root", children: [leaf("x"), leaf("x")] }])
+ );
+ expect(all).toEqual(["root", "root/x", "root/x#1"]);
+ });
+
+ it("does not change the tree it was given", () => {
+ const input = tree();
+ withPathIds(input);
+ expect(ids(input)).toEqual(["root", "a", "sub", "bolt", "sub", "bolt"]);
+ });
+});
diff --git a/packages/utils/src/arrays.ts b/packages/utils/src/arrays.ts
index 685a68ddbb..bcd6553a3d 100644
--- a/packages/utils/src/arrays.ts
+++ b/packages/utils/src/arrays.ts
@@ -115,3 +115,42 @@ export function indexByMapped<T, K, V>(
}
return out;
}
+
+/**
+ * A saved order of ids, followed by the current ids it does not name yet.
+ *
+ * For a list whose order the user chose and saved (a board's columns) but whose
+ * members come from loaded data: an id that appears later takes its place at
+ * the end instead of being left out. Ids the saved order names that are not
+ * current are kept, so a column hidden by a filter returns to its place.
+ */
+export function withUnorderedLast(
+ savedOrder: readonly string[],
+ currentIds: readonly string[]
+): string[] {
+ const known = new Set(savedOrder);
+ return [...savedOrder, ...currentIds.filter((id) => !known.has(id))];
+}
+
+/**
+ * A copy of a tree in which every node's id is the path to it.
+ *
+ * For a tree built from rows where one row can sit in several places (a
+ * sub-assembly used twice): each place needs an id of its own, and the id must
+ * be the same on every load. A random id per load changes the React key of
+ * every row, so a list keyed on it is torn down and rebuilt whenever its
+ * loader runs. A node that repeats under one parent gets `#n` on the path.
+ */
+export function withPathIds<N extends { id: string; children: N[] }>(
+ nodes: N[],
+ path = ""
+): N[] {
+ const seen = new Map<string, number>();
+ return nodes.map((node) => {
+ const count = seen.get(node.id) ?? 0;
+ seen.set(node.id, count + 1);
+ const base = path ? `${path}/${node.id}` : node.id;
+ const id = count === 0 ? base : `${base}#${count}`;
+ return { ...node, id, children: withPathIds(node.children, id) };
+ });
+}
diff --git a/packages/utils/src/revalidate.test.ts b/packages/utils/src/revalidate.test.ts
index 00f6400d7e..2d01cf0858 100644
--- a/packages/utils/src/revalidate.test.ts
+++ b/packages/utils/src/revalidate.test.ts
@@ -3,10 +3,7 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { describe, expect, it } from "vitest";
-import {
- isSearchParamOnlyNavigation,
- isUnaffectedByNavigation
-} from "./revalidate";
+import { isSearchParamOnlyNavigation } from "./revalidate";
const url = (href: string) => new URL(href, "https://erp.test");
@@ -74,62 +71,3 @@ describe("isSearchParamOnlyNavigation", () => {
).toBe(true);
});
});
-
-describe("isUnaffectedByNavigation", () => {
- const nav = (
- from: string,
- to: string,
- itemIds: [string, string] = ["a", "a"],
- formMethod?: string
- ) =>
- isUnaffectedByNavigation(
- {
- currentUrl: url(from),
- nextUrl: url(to),
- currentParams: { itemId: itemIds[0] },
- nextParams: { itemId: itemIds[1] },
- formMethod
- },
- { params: ["itemId"], search: ["methodId"] }
- );
-
- it("is true when nothing the loader reads changed", () => {
- expect(nav("/x/part/a/details", "/x/part/a/planning")).toBe(true);
- expect(nav("/x/part/a/make/m1", "/x/part/a/make/m2?materialId=x")).toBe(
- true
- );
- });
-
- it("is false when a param or search param the loader reads changed", () => {
- expect(nav("/x/part/a/details", "/x/part/b/details", ["a", "b"])).toBe(
- false
- );
- expect(nav("/x/part/a/details", "/x/part/a/details?methodId=m")).toBe(
- false
- );
- });
-
- it("is false for a revalidation or a mutation", () => {
- expect(nav("/x/part/a/details", "/x/part/a/details")).toBe(false);
- expect(
- nav("/x/part/a/details", "/x/part/a/planning", ["a", "a"], "POST")
- ).toBe(false);
- });
-
- it('compares the whole query string with search "all"', () => {
- const list = (from: string, to: string) =>
- isUnaffectedByNavigation(
- {
- currentUrl: url(from),
- nextUrl: url(to),
- currentParams: {},
- nextParams: {}
- },
- { search: "all" }
- );
- expect(list("/x/items/parts?sort=a", "/x/items/parts/new?sort=a")).toBe(
- true
- );
- expect(list("/x/items/parts?sort=a", "/x/items/parts/new")).toBe(false);
- });
-});
diff --git a/packages/utils/src/revalidate.ts b/packages/utils/src/revalidate.ts
index 21acae1a04..50c4d99118 100644
--- a/packages/utils/src/revalidate.ts
+++ b/packages/utils/src/revalidate.ts
@@ -29,39 +29,4 @@ export function isSearchParamOnlyNavigation({
return currentUrl.pathname === nextUrl.pathname;
}
-/**
- * True when a GET navigation left the route params and search params a layout
- * loader reads unchanged (`search: "all"` for one that reads the whole query
- * string). Single fetch otherwise re-runs every matched loader on every
- * navigation. Mutations and `useRevalidator().revalidate()` are never
- * "unaffected".
- */
-export function isUnaffectedByNavigation(
- {
- currentUrl,
- nextUrl,
- currentParams,
- nextParams,
- formMethod
- }: {
- currentUrl: URL;
- nextUrl: URL;
- currentParams: Record<string, string | undefined>;
- nextParams: Record<string, string | undefined>;
- formMethod?: string;
- },
- reads: { params?: string[]; search?: string[] | "all" } = {}
-) {
- if (formMethod && formMethod !== "GET") return false;
- if (currentUrl.href === nextUrl.href) return false;
- const { params = [], search = [] } = reads;
- if (!params.every((key) => currentParams[key] === nextParams[key])) {
- return false;
- }
- if (search === "all") return currentUrl.search === nextUrl.search;
- return search.every(
- (key) => currentUrl.searchParams.get(key) === nextUrl.searchParams.get(key)
- );
-}
-
export const SHELL_MAX_AGE_MS = 5 * 60 * 1000;