@metron-labs/quote-react 0.1.60 → 0.1.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,5 +3,10 @@ import type { FixedBasketLine } from "../../components/estimators/useFixedBasket
3
3
  import type { EstimatorRequirement } from "./types";
4
4
  /** The catalogue search for this line's fixed product, or null when the active client has none. */
5
5
  export declare function fixedProductSearch(tool: EstimatorToolId, requirement: EstimatorRequirement): string | null;
6
+ /**
7
+ * Whether a calculator should offer an option to the active client. A client with fixed products
8
+ * for that calculator is only offered what it stocks; any other client sees every option.
9
+ */
10
+ export declare function offersOption(tool: EstimatorToolId, key: string): boolean;
6
11
  /** Basket lines when every line has a fixed product, so the calculator can skip the matching step. */
7
12
  export declare function fixedBasketLines(tool: EstimatorToolId, requirements: EstimatorRequirement[]): FixedBasketLine[] | null;
@@ -12,9 +12,10 @@ const FIXED_PRODUCTS = {
12
12
  "NZ4Y-ZMSQ": {
13
13
  "brick-block": { "brick-common": "105499", "brick-engineering-red": "1654", "brick-engineering-blue": "1723", block: "501", "mortar-cement": "1762 cement", "mortar-sand": "564 building sand" },
14
14
  // Primed MDF, 4.4m lengths. Ogee and torus come in 119mm skirting / 69mm architrave; the other
15
- // profiles only in 94mm and 144mm, so the nearer usable width is taken. FORT has no ovolo.
15
+ // profiles only in 94mm and 144mm, so the nearer usable width is taken. FORT has no ovolo, so
16
+ // the architrave calculator doesn't offer it (see offersOption).
16
17
  skirting: { "skirting-chamfered": "1525", "skirting-ogee": "135 primed mdf ogee", "skirting-pencil-round": "892", "skirting-torus": "1941" },
17
- architrave: { "architrave-ogee": "134 primed mdf ogee", "architrave-ovolo": "1531", "architrave-pencil-round": "1896", "architrave-square-edge": "118 primed mdf square", "architrave-torus": "1531" },
18
+ architrave: { "architrave-ogee": "134 primed mdf ogee", "architrave-pencil-round": "1896", "architrave-square-edge": "118 primed mdf square", "architrave-torus": "1531" },
18
19
  // Board keys come from the board type; see fixedProductSearch.
19
20
  plasterboard: { standard: "1647", moisture: "11 moisture plasterboard", fire: "14 fire plasterboard", sound: "1769", screws: "131160", tape: "1766", adhesive: "108439" },
20
21
  insulation: { "insulation-floor": "152187", "insulation-ground": "442", "insulation-wall": "147", "insulation-roof": "442", "insulation-loft": "152180" },
@@ -38,6 +39,14 @@ export function fixedProductSearch(tool, requirement) {
38
39
  const key = tool === "plasterboard" && requirement.key === "board" ? requirement.label.split(" ")[0].toLowerCase() : requirement.key;
39
40
  return table[key] ?? null;
40
41
  }
42
+ /**
43
+ * Whether a calculator should offer an option to the active client. A client with fixed products
44
+ * for that calculator is only offered what it stocks; any other client sees every option.
45
+ */
46
+ export function offersOption(tool, key) {
47
+ const table = FIXED_PRODUCTS[getQuoteConfig().client ?? ""]?.[tool];
48
+ return !table || key in table;
49
+ }
41
50
  /** Basket lines when every line has a fixed product, so the calculator can skip the matching step. */
42
51
  export function fixedBasketLines(tool, requirements) {
43
52
  const lines = requirements.map((requirement) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metron-labs/quote-react",
3
- "version": "0.1.60",
3
+ "version": "0.1.61",
4
4
  "description": "Metron Labs quote and estimating calculator components for React",
5
5
  "license": "UNLICENSED",
6
6
  "sideEffects": [