@oatfi/ui 0.6.0 → 0.8.0
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.cjs.js +177 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +111 -8
- package/dist/index.esm.js +173 -4
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -2045,16 +2045,24 @@ const DECLINED = /* @__PURE__ */ new Set([
|
|
|
2045
2045
|
"DECLINED",
|
|
2046
2046
|
"DENIED",
|
|
2047
2047
|
"ERROR",
|
|
2048
|
+
"MANUAL_REVIEW_DECLINED",
|
|
2048
2049
|
"N/A",
|
|
2049
2050
|
"REJECTED"
|
|
2050
2051
|
]);
|
|
2052
|
+
function classifyUnderwritingStatus(status) {
|
|
2053
|
+
if (status === "PROCESSING") return "processing";
|
|
2054
|
+
if (status === "APPROVED") return "approved";
|
|
2055
|
+
if (status && DECLINED.has(status)) return "declined";
|
|
2056
|
+
return "review";
|
|
2057
|
+
}
|
|
2051
2058
|
function UnderwritingStatus({
|
|
2052
2059
|
status,
|
|
2053
2060
|
creditLimit,
|
|
2054
2061
|
children,
|
|
2055
2062
|
testId
|
|
2056
2063
|
}) {
|
|
2057
|
-
|
|
2064
|
+
const outcome = classifyUnderwritingStatus(status);
|
|
2065
|
+
if (outcome === "processing") {
|
|
2058
2066
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": testId, children: [
|
|
2059
2067
|
/* @__PURE__ */ jsxRuntime.jsx(H3, { children: "Your application is being reviewed" }),
|
|
2060
2068
|
/* @__PURE__ */ jsxRuntime.jsxs(Stack, { width: "100%", alignItems: "center", gap: "16px", children: [
|
|
@@ -2063,7 +2071,7 @@ function UnderwritingStatus({
|
|
|
2063
2071
|
] })
|
|
2064
2072
|
] });
|
|
2065
2073
|
}
|
|
2066
|
-
if (
|
|
2074
|
+
if (outcome === "approved") {
|
|
2067
2075
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": testId, children: [
|
|
2068
2076
|
/* @__PURE__ */ jsxRuntime.jsx(H3, { children: "Congrats!" }),
|
|
2069
2077
|
/* @__PURE__ */ jsxRuntime.jsxs(Body200, { children: [
|
|
@@ -2077,7 +2085,7 @@ function UnderwritingStatus({
|
|
|
2077
2085
|
children
|
|
2078
2086
|
] });
|
|
2079
2087
|
}
|
|
2080
|
-
if (
|
|
2088
|
+
if (outcome === "declined") {
|
|
2081
2089
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": testId, children: [
|
|
2082
2090
|
/* @__PURE__ */ jsxRuntime.jsx(H3, { children: "Sorry, we cannot approve your application" }),
|
|
2083
2091
|
/* @__PURE__ */ jsxRuntime.jsx(Body200, { children: "We are sorry to inform you that we cannot approve your application. Please try again later." })
|
|
@@ -2367,6 +2375,167 @@ function AchVerificationConsent({
|
|
|
2367
2375
|
] });
|
|
2368
2376
|
}
|
|
2369
2377
|
|
|
2378
|
+
const AMBER = "#F59E0B";
|
|
2379
|
+
const CYAN = "#22D3EE";
|
|
2380
|
+
const GREY = "#9CA3AF";
|
|
2381
|
+
const GREEN = "#22C55E";
|
|
2382
|
+
const WHITE = "#FFFFFF";
|
|
2383
|
+
const INK = "#141312";
|
|
2384
|
+
const RED = "#DC2626";
|
|
2385
|
+
const ENVIRONMENT_MISMATCH_BORDER = RED;
|
|
2386
|
+
const ENVIRONMENT_TAGS = Object.freeze({
|
|
2387
|
+
production: Object.freeze({ label: "PROD", name: "Production", fill: WHITE, ink: INK }),
|
|
2388
|
+
staging: Object.freeze({ label: "STG", name: "Staging", fill: AMBER, ink: INK }),
|
|
2389
|
+
qa: Object.freeze({ label: "QA", name: "QA", fill: CYAN, ink: INK }),
|
|
2390
|
+
development: Object.freeze({ label: "DEV", name: "Development", fill: GREY, ink: INK }),
|
|
2391
|
+
local: Object.freeze({ label: "LOCAL", name: "Local", fill: GREEN, ink: INK })
|
|
2392
|
+
});
|
|
2393
|
+
const UNKNOWN_ENVIRONMENT_TAG = Object.freeze({
|
|
2394
|
+
label: "?",
|
|
2395
|
+
name: "Unknown",
|
|
2396
|
+
fill: WHITE,
|
|
2397
|
+
ink: INK
|
|
2398
|
+
});
|
|
2399
|
+
const INVALID_API_TAG = Object.freeze({
|
|
2400
|
+
label: "?",
|
|
2401
|
+
name: "Unknown",
|
|
2402
|
+
fill: RED,
|
|
2403
|
+
ink: WHITE
|
|
2404
|
+
});
|
|
2405
|
+
const ALIASES = /* @__PURE__ */ new Map([
|
|
2406
|
+
["production", "production"],
|
|
2407
|
+
["prod", "production"],
|
|
2408
|
+
["staging", "staging"],
|
|
2409
|
+
["stg", "staging"],
|
|
2410
|
+
["qa", "qa"],
|
|
2411
|
+
["development", "development"],
|
|
2412
|
+
["dev", "development"],
|
|
2413
|
+
["local", "local"]
|
|
2414
|
+
]);
|
|
2415
|
+
const normalizeEnvironment = (value) => {
|
|
2416
|
+
const key = value?.trim().toLowerCase();
|
|
2417
|
+
return key && ALIASES.get(key) || null;
|
|
2418
|
+
};
|
|
2419
|
+
const resolveComponentEnvTag = ({
|
|
2420
|
+
bundleEnv,
|
|
2421
|
+
apiEnv
|
|
2422
|
+
}) => {
|
|
2423
|
+
const apiValue = apiEnv?.trim();
|
|
2424
|
+
if (!apiValue) return null;
|
|
2425
|
+
const api = normalizeEnvironment(apiValue);
|
|
2426
|
+
if (!api) return { kind: "invalid-api", apiEnv: apiValue };
|
|
2427
|
+
const bundleValue = bundleEnv?.trim();
|
|
2428
|
+
const bundle = normalizeEnvironment(bundleValue);
|
|
2429
|
+
const apiTag = ENVIRONMENT_TAGS[api];
|
|
2430
|
+
if (bundleValue && !bundle) {
|
|
2431
|
+
return { kind: "split", bundleEnv: null, bundle: UNKNOWN_ENVIRONMENT_TAG, api: apiTag };
|
|
2432
|
+
}
|
|
2433
|
+
if (bundle === "local" && api !== "local" && api !== "production") {
|
|
2434
|
+
return { kind: "local", api: apiTag };
|
|
2435
|
+
}
|
|
2436
|
+
if (bundle && bundle !== api) {
|
|
2437
|
+
return { kind: "split", bundleEnv: bundle, bundle: ENVIRONMENT_TAGS[bundle], api: apiTag };
|
|
2438
|
+
}
|
|
2439
|
+
if (api === "production") return null;
|
|
2440
|
+
return { kind: "single", tag: apiTag };
|
|
2441
|
+
};
|
|
2442
|
+
const environmentDebug = (value) => {
|
|
2443
|
+
const env = normalizeEnvironment(value);
|
|
2444
|
+
if (env) return env;
|
|
2445
|
+
const raw = value?.trim();
|
|
2446
|
+
return raw ? `unrecognised:${raw}` : "unknown";
|
|
2447
|
+
};
|
|
2448
|
+
const describeComponentEnv = ({ bundleEnv, apiEnv, ref, sha }) => [
|
|
2449
|
+
`bundle=${environmentDebug(bundleEnv)}`,
|
|
2450
|
+
`api=${environmentDebug(apiEnv)}`,
|
|
2451
|
+
`ref=${ref || "unknown"}`,
|
|
2452
|
+
`sha=${sha || "unknown"}`
|
|
2453
|
+
].join(" ");
|
|
2454
|
+
const environmentTitle = (value) => {
|
|
2455
|
+
const env = normalizeEnvironment(value);
|
|
2456
|
+
if (env) return ENVIRONMENT_TAGS[env].name;
|
|
2457
|
+
const raw = value?.trim();
|
|
2458
|
+
return raw ? `Unrecognised "${raw}"` : "Unknown";
|
|
2459
|
+
};
|
|
2460
|
+
const describeComponentEnvTitle = ({
|
|
2461
|
+
bundleEnv,
|
|
2462
|
+
apiEnv,
|
|
2463
|
+
ref,
|
|
2464
|
+
sha
|
|
2465
|
+
}) => {
|
|
2466
|
+
const build = [ref, sha].filter(Boolean).join(", ");
|
|
2467
|
+
return `Bundle: ${environmentTitle(bundleEnv)}${build ? ` (${build})` : ""} \xB7 API: ${environmentTitle(apiEnv)}`;
|
|
2468
|
+
};
|
|
2469
|
+
|
|
2470
|
+
const FONT_SIZE = { small: 9, medium: 11 };
|
|
2471
|
+
const PADDING_X = { small: 6, medium: 8 };
|
|
2472
|
+
const FONT_FAMILY = 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
|
|
2473
|
+
const BORDER_WIDTH = 1.5;
|
|
2474
|
+
const base = (size) => ({
|
|
2475
|
+
display: "inline-flex",
|
|
2476
|
+
alignItems: "stretch",
|
|
2477
|
+
boxSizing: "border-box",
|
|
2478
|
+
fontFamily: FONT_FAMILY,
|
|
2479
|
+
fontSize: FONT_SIZE[size],
|
|
2480
|
+
fontWeight: 800,
|
|
2481
|
+
letterSpacing: "0.1em",
|
|
2482
|
+
lineHeight: 1.4,
|
|
2483
|
+
whiteSpace: "nowrap",
|
|
2484
|
+
borderRadius: 0
|
|
2485
|
+
});
|
|
2486
|
+
const half = (tag, label, size) => /* @__PURE__ */ jsxRuntime.jsx("span", { style: { padding: `2px ${PADDING_X[size]}px`, background: tag.fill, color: tag.ink }, children: label });
|
|
2487
|
+
const EnvironmentTag = ({
|
|
2488
|
+
bundleEnv,
|
|
2489
|
+
apiEnv,
|
|
2490
|
+
buildRef,
|
|
2491
|
+
buildSha,
|
|
2492
|
+
size = "small",
|
|
2493
|
+
testId = "oatfi-env-tag"
|
|
2494
|
+
}) => {
|
|
2495
|
+
const result = resolveComponentEnvTag({ bundleEnv, apiEnv });
|
|
2496
|
+
if (!result) return null;
|
|
2497
|
+
const title = describeComponentEnvTitle({ bundleEnv, apiEnv, ref: buildRef, sha: buildSha });
|
|
2498
|
+
const chip = (border, children) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2499
|
+
"span",
|
|
2500
|
+
{
|
|
2501
|
+
role: "note",
|
|
2502
|
+
"aria-label": `Environment: ${title}`,
|
|
2503
|
+
"data-testid": testId,
|
|
2504
|
+
"data-env-kind": result.kind,
|
|
2505
|
+
title,
|
|
2506
|
+
style: { ...base(size), border: `${BORDER_WIDTH}px solid ${border}` },
|
|
2507
|
+
children
|
|
2508
|
+
}
|
|
2509
|
+
);
|
|
2510
|
+
switch (result.kind) {
|
|
2511
|
+
case "single":
|
|
2512
|
+
return chip(result.tag.fill, half(result.tag, result.tag.label, size));
|
|
2513
|
+
case "local":
|
|
2514
|
+
return chip(
|
|
2515
|
+
ENVIRONMENT_TAGS.local.fill,
|
|
2516
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2517
|
+
half(ENVIRONMENT_TAGS.local, ENVIRONMENT_TAGS.local.label, size),
|
|
2518
|
+
half(result.api, `API ${result.api.label}`, size)
|
|
2519
|
+
] })
|
|
2520
|
+
);
|
|
2521
|
+
case "invalid-api":
|
|
2522
|
+
return chip(
|
|
2523
|
+
INVALID_API_TAG.fill,
|
|
2524
|
+
half(INVALID_API_TAG, `API ${INVALID_API_TAG.label}`, size)
|
|
2525
|
+
);
|
|
2526
|
+
case "split": {
|
|
2527
|
+
const bundleLabel = result.bundleEnv === "local" ? "LOCAL" : `BUNDLE ${result.bundle.label}`;
|
|
2528
|
+
return chip(
|
|
2529
|
+
ENVIRONMENT_MISMATCH_BORDER,
|
|
2530
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2531
|
+
half(result.bundle, bundleLabel, size),
|
|
2532
|
+
half(result.api, `API ${result.api.label}`, size)
|
|
2533
|
+
] })
|
|
2534
|
+
);
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
};
|
|
2538
|
+
|
|
2370
2539
|
const PreviewCard = styled.div`
|
|
2371
2540
|
display: flex;
|
|
2372
2541
|
gap: 2rem;
|
|
@@ -2465,6 +2634,7 @@ exports.DropdownContainer = DropdownContainer;
|
|
|
2465
2634
|
exports.DropdownItem = DropdownItem;
|
|
2466
2635
|
exports.DropdownList = DropdownList;
|
|
2467
2636
|
exports.EmailInput = EmailInput;
|
|
2637
|
+
exports.EnvironmentTag = EnvironmentTag;
|
|
2468
2638
|
exports.FieldsGrid = FieldsGrid;
|
|
2469
2639
|
exports.FileInput = FileInput;
|
|
2470
2640
|
exports.FlexColumnWrapper = FlexColumnWrapper;
|
|
@@ -2512,7 +2682,11 @@ exports.ThemeProvider = ThemeProvider;
|
|
|
2512
2682
|
exports.UnderwritingStatus = UnderwritingStatus;
|
|
2513
2683
|
exports.UploadZone = UploadZone;
|
|
2514
2684
|
exports.buildMuiTheme = buildMuiTheme;
|
|
2685
|
+
exports.classifyUnderwritingStatus = classifyUnderwritingStatus;
|
|
2515
2686
|
exports.defaultTheme = defaultTheme;
|
|
2687
|
+
exports.describeComponentEnv = describeComponentEnv;
|
|
2688
|
+
exports.describeComponentEnvTitle = describeComponentEnvTitle;
|
|
2516
2689
|
exports.mergeBranding = mergeBranding;
|
|
2690
|
+
exports.resolveComponentEnvTag = resolveComponentEnvTag;
|
|
2517
2691
|
exports.useTheme = useTheme;
|
|
2518
2692
|
//# sourceMappingURL=index.cjs.js.map
|