@c1m-public/dash-site-kit 0.2.0 → 0.2.1
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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/next/data-layer.js +2 -6
- package/dist/validation/directory.d.ts +14 -0
- package/dist/validation/directory.js +16 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type { LeadsProvider } from "./ports/leads.js";
|
|
|
20
20
|
export type { LeadPortalProvider } from "./ports/lead-portal.js";
|
|
21
21
|
export type { PlansProvider } from "./ports/plans.js";
|
|
22
22
|
export type { ProfileProvider } from "./ports/profile.js";
|
|
23
|
-
export { validateDirectoryKey, validateRegionFilter } from "./validation/directory.js";
|
|
23
|
+
export { selectDirectoryRegion, validateDirectoryKey, validateRegionFilter, } from "./validation/directory.js";
|
|
24
24
|
export { LEAD_LIMITS, validateLeadForm } from "./validation/leads.js";
|
|
25
25
|
export type { LeadField, LeadValidationResult, ValidatedLead } from "./validation/leads.js";
|
|
26
26
|
export { formatMoney } from "./format.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { validateDirectoryKey, validateRegionFilter } from "./validation/directory.js";
|
|
1
|
+
export { selectDirectoryRegion, validateDirectoryKey, validateRegionFilter, } from "./validation/directory.js";
|
|
2
2
|
export { LEAD_LIMITS, validateLeadForm } from "./validation/leads.js";
|
|
3
3
|
export { formatMoney } from "./format.js";
|
|
4
4
|
export * from "./url-policy.js";
|
package/dist/next/data-layer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import { cache } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { selectDirectoryRegion, validateDirectoryKey } from "../validation/directory.js";
|
|
4
4
|
import { createC1MBootstrapProvider } from "./providers/bootstrap.js";
|
|
5
5
|
import { createC1MDirectoryProvider } from "./providers/directory.js";
|
|
6
6
|
import { createC1MLeadPortalProvider } from "./providers/lead-portal.js";
|
|
@@ -33,11 +33,7 @@ export function createDashDataLayer(options) {
|
|
|
33
33
|
listDirectoryRegions,
|
|
34
34
|
listDirectory,
|
|
35
35
|
async getDirectoryRegion(code) {
|
|
36
|
-
|
|
37
|
-
if (!key)
|
|
38
|
-
return undefined;
|
|
39
|
-
const regions = await listDirectoryRegions();
|
|
40
|
-
return regions.find((region) => region.code === key);
|
|
36
|
+
return selectDirectoryRegion(await listDirectoryRegions(), code);
|
|
41
37
|
},
|
|
42
38
|
async getDirectoryProfile(idOrSlug) {
|
|
43
39
|
// Validate before the hop: an unusable key is a 404 here, not a
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
export declare function validateDirectoryKey(value: unknown): string | null;
|
|
2
2
|
export declare function validateRegionFilter(value: unknown): string | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Pick the region a landing page should render, or `undefined` for "no such
|
|
5
|
+
* page". A region with **no providers** is absent rather than empty: the page
|
|
6
|
+
* exists to list the providers serving that area, so rendering a bare one is
|
|
7
|
+
* worse than a 404, and both commissioned sites' e2e suites assert an empty
|
|
8
|
+
* region is never linked.
|
|
9
|
+
*
|
|
10
|
+
* Pure and exported so this rule has one home and can be tested directly —
|
|
11
|
+
* inside the data layer it was closed over and unreachable from a test.
|
|
12
|
+
*/
|
|
13
|
+
export declare function selectDirectoryRegion<T extends {
|
|
14
|
+
code: string;
|
|
15
|
+
count: number;
|
|
16
|
+
}>(regions: readonly T[], code: unknown): T | undefined;
|
|
@@ -13,3 +13,19 @@ export function validateDirectoryKey(value) {
|
|
|
13
13
|
export function validateRegionFilter(value) {
|
|
14
14
|
return validateDirectoryKey(value) ?? undefined;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Pick the region a landing page should render, or `undefined` for "no such
|
|
18
|
+
* page". A region with **no providers** is absent rather than empty: the page
|
|
19
|
+
* exists to list the providers serving that area, so rendering a bare one is
|
|
20
|
+
* worse than a 404, and both commissioned sites' e2e suites assert an empty
|
|
21
|
+
* region is never linked.
|
|
22
|
+
*
|
|
23
|
+
* Pure and exported so this rule has one home and can be tested directly —
|
|
24
|
+
* inside the data layer it was closed over and unreachable from a test.
|
|
25
|
+
*/
|
|
26
|
+
export function selectDirectoryRegion(regions, code) {
|
|
27
|
+
const key = validateRegionFilter(code);
|
|
28
|
+
if (!key)
|
|
29
|
+
return undefined;
|
|
30
|
+
return regions.find((region) => region.code === key && region.count > 0);
|
|
31
|
+
}
|