sales-frontend-components 0.0.81 → 0.0.83
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 +202 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +76 -3
- package/dist/index.esm.js +202 -3
- package/dist/index.esm.js.map +1 -1
- package/package.json +10 -10
package/dist/index.cjs.js
CHANGED
|
@@ -16,6 +16,7 @@ var styles$6 = require('./modal/pre-standard/employee-search-modal/employee-sear
|
|
|
16
16
|
var styles$7 = require('./modal/pre-standard/job-vehicle-search-modal/job-vehicle-search-modal.module.scss');
|
|
17
17
|
var styles$8 = require('./modal/pre-standard/vehicle-search-modal/vehicle-search-modal.module.scss');
|
|
18
18
|
var styles$9 = require('./modal/standard/customer-search/customer-search.module.scss');
|
|
19
|
+
var salesFrontendUtils = require('sales-frontend-utils');
|
|
19
20
|
|
|
20
21
|
const FormCheckboxButton = ({
|
|
21
22
|
name,
|
|
@@ -2579,6 +2580,204 @@ const CustomerSearch = ({ onSelect }) => {
|
|
|
2579
2580
|
] });
|
|
2580
2581
|
};
|
|
2581
2582
|
|
|
2583
|
+
const VERIFICATION_CODES = {
|
|
2584
|
+
SUCCESS: "0000",
|
|
2585
|
+
USER_CANCEL: "9000",
|
|
2586
|
+
TOKEN_ERROR: "9001",
|
|
2587
|
+
CAMERA_PERMISSION: "9002",
|
|
2588
|
+
ATTEMPT_EXCEEDED: "9003",
|
|
2589
|
+
SERVER_ERROR: "9999"
|
|
2590
|
+
};
|
|
2591
|
+
const useRemoteIdentityVerification = ({
|
|
2592
|
+
rivEnv,
|
|
2593
|
+
rivOrigin,
|
|
2594
|
+
tokenRequestParams,
|
|
2595
|
+
apiConfig,
|
|
2596
|
+
onCancel,
|
|
2597
|
+
onError,
|
|
2598
|
+
onSuccess,
|
|
2599
|
+
rivSearchParams
|
|
2600
|
+
}) => {
|
|
2601
|
+
const rivHost = rivOrigin ?? `https://${rivEnv === "prd" ? "" : rivEnv === "stg" ? "qa" : "dev"}riv.hanwhalife.com`;
|
|
2602
|
+
const createRemoteIdentityVerificationUrl = async () => {
|
|
2603
|
+
const response = await method.getRemoteIdentityVerificationSystemToken(tokenRequestParams, apiConfig);
|
|
2604
|
+
const { accessToken, remoteIdentityVerificationSystemRequestId } = response.data;
|
|
2605
|
+
const urlParams = new URLSearchParams({
|
|
2606
|
+
authorization: accessToken,
|
|
2607
|
+
rivsRqstId: remoteIdentityVerificationSystemRequestId,
|
|
2608
|
+
...rivSearchParams
|
|
2609
|
+
});
|
|
2610
|
+
return { fullUrl: `${rivHost}/?${urlParams.toString()}`, rivsRqstId: remoteIdentityVerificationSystemRequestId };
|
|
2611
|
+
};
|
|
2612
|
+
const createMessageHandler = ({ rivsRqstId }, cleanup) => {
|
|
2613
|
+
return (event) => {
|
|
2614
|
+
try {
|
|
2615
|
+
const response = typeof event.data === "string" ? JSON.parse(decodeURIComponent(event.data)) : event.data;
|
|
2616
|
+
if (response.command !== "webClose") {
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
const { result, code } = response.args;
|
|
2620
|
+
switch (code) {
|
|
2621
|
+
case VERIFICATION_CODES.USER_CANCEL:
|
|
2622
|
+
console.log("=====\uC0AC\uC6A9\uC790 \uC885\uB8CC!=====", { result, code });
|
|
2623
|
+
onCancel?.({ result, code });
|
|
2624
|
+
cleanup?.();
|
|
2625
|
+
break;
|
|
2626
|
+
case VERIFICATION_CODES.TOKEN_ERROR:
|
|
2627
|
+
case VERIFICATION_CODES.CAMERA_PERMISSION:
|
|
2628
|
+
case VERIFICATION_CODES.ATTEMPT_EXCEEDED:
|
|
2629
|
+
case VERIFICATION_CODES.SERVER_ERROR:
|
|
2630
|
+
console.log("=====\uBE44\uB300\uBA74\uC778\uC99D \uC2E4\uD328!=====", { result, code });
|
|
2631
|
+
onError?.({ result, code });
|
|
2632
|
+
cleanup?.();
|
|
2633
|
+
break;
|
|
2634
|
+
case VERIFICATION_CODES.SUCCESS:
|
|
2635
|
+
console.log("=====\uBE44\uB300\uBA74\uC778\uC99D \uC131\uACF5!=====", { result, code });
|
|
2636
|
+
onSuccess?.({ result, code }, { rivsRqstId });
|
|
2637
|
+
cleanup?.();
|
|
2638
|
+
break;
|
|
2639
|
+
default:
|
|
2640
|
+
console.warn("Unknown verification code:", code);
|
|
2641
|
+
}
|
|
2642
|
+
} catch (error) {
|
|
2643
|
+
console.error("Failed to parse postMessage:", error);
|
|
2644
|
+
}
|
|
2645
|
+
};
|
|
2646
|
+
};
|
|
2647
|
+
return {
|
|
2648
|
+
createRemoteIdentityVerificationUrl,
|
|
2649
|
+
createMessageHandler
|
|
2650
|
+
};
|
|
2651
|
+
};
|
|
2652
|
+
const useRemoteIdentityVerificationIframe = (config) => {
|
|
2653
|
+
const { createMessageHandler, createRemoteIdentityVerificationUrl } = useRemoteIdentityVerification(config);
|
|
2654
|
+
const { isOpen, openModal, closeModal } = salesFrontendDesignSystem.useModalState();
|
|
2655
|
+
const [remoteIdentityVerificationUrl, setRemoteIdentityVerificationUrl] = React.useState("");
|
|
2656
|
+
const [rivsRqstId, setRivsRqstId] = React.useState("");
|
|
2657
|
+
const [isCreatingUrl, setIsCreatingUrl] = React.useState(false);
|
|
2658
|
+
const [isIframeLoaded, setIsIframeLoaded] = React.useState(false);
|
|
2659
|
+
const createIframeUrl = async () => {
|
|
2660
|
+
if (remoteIdentityVerificationUrl || isCreatingUrl) {
|
|
2661
|
+
return;
|
|
2662
|
+
}
|
|
2663
|
+
setIsCreatingUrl(true);
|
|
2664
|
+
setIsIframeLoaded(false);
|
|
2665
|
+
try {
|
|
2666
|
+
const { fullUrl, rivsRqstId: rivsRqstId2 } = await createRemoteIdentityVerificationUrl();
|
|
2667
|
+
setRemoteIdentityVerificationUrl(fullUrl);
|
|
2668
|
+
setRivsRqstId(rivsRqstId2);
|
|
2669
|
+
} catch (error) {
|
|
2670
|
+
console.error("Failed to create URL:", error);
|
|
2671
|
+
throw error;
|
|
2672
|
+
} finally {
|
|
2673
|
+
setIsCreatingUrl(false);
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2676
|
+
const openRivIframe = async () => {
|
|
2677
|
+
try {
|
|
2678
|
+
await createIframeUrl();
|
|
2679
|
+
openModal();
|
|
2680
|
+
} catch (error) {
|
|
2681
|
+
console.error("openRivIframe error::", error);
|
|
2682
|
+
await salesFrontendDesignSystem.ModalUtils.alert("\uBE44\uB300\uBA74 \uC778\uC99D URL \uC0DD\uC131\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4. \uB2E4\uC2DC \uC2DC\uB3C4\uD574\uC8FC\uC138\uC694.");
|
|
2683
|
+
}
|
|
2684
|
+
};
|
|
2685
|
+
const closeRivIframe = () => {
|
|
2686
|
+
setRemoteIdentityVerificationUrl("");
|
|
2687
|
+
setRivsRqstId("");
|
|
2688
|
+
setIsIframeLoaded(false);
|
|
2689
|
+
closeModal();
|
|
2690
|
+
};
|
|
2691
|
+
React.useEffect(() => {
|
|
2692
|
+
if (!remoteIdentityVerificationUrl) {
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
const messageHandler = createMessageHandler({ rivsRqstId }, closeRivIframe);
|
|
2696
|
+
salesFrontendUtils.MessageEventManager.getInstance().registerHandler("riv-iframe-handler", messageHandler);
|
|
2697
|
+
return () => salesFrontendUtils.MessageEventManager.getInstance().unregisterHandler("riv-iframe-handler");
|
|
2698
|
+
}, [remoteIdentityVerificationUrl, rivsRqstId]);
|
|
2699
|
+
const RivIframe = ({
|
|
2700
|
+
width = "100%",
|
|
2701
|
+
height = "100%",
|
|
2702
|
+
...iframeProps
|
|
2703
|
+
}) => {
|
|
2704
|
+
if (!remoteIdentityVerificationUrl) {
|
|
2705
|
+
return null;
|
|
2706
|
+
}
|
|
2707
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2708
|
+
"iframe",
|
|
2709
|
+
{
|
|
2710
|
+
src: remoteIdentityVerificationUrl,
|
|
2711
|
+
width,
|
|
2712
|
+
height,
|
|
2713
|
+
allow: "camera *;",
|
|
2714
|
+
onLoad: () => setIsIframeLoaded(true),
|
|
2715
|
+
...iframeProps
|
|
2716
|
+
}
|
|
2717
|
+
);
|
|
2718
|
+
};
|
|
2719
|
+
const RivModalIframe = ({
|
|
2720
|
+
width = "100%",
|
|
2721
|
+
height = "100%",
|
|
2722
|
+
loadingComponent,
|
|
2723
|
+
...iframeProps
|
|
2724
|
+
}) => {
|
|
2725
|
+
const isLoading = isCreatingUrl || !!remoteIdentityVerificationUrl && !isIframeLoaded;
|
|
2726
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(salesFrontendDesignSystem.Modal.Root, { isOpen, children: [
|
|
2727
|
+
isLoading && (loadingComponent || /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Loading.Wait, { bodyText: "\uBD88\uB7EC\uC624\uB294 \uC911" })),
|
|
2728
|
+
/* @__PURE__ */ jsxRuntime.jsx(RivIframe, { width, height, allow: "camera *;", ...iframeProps })
|
|
2729
|
+
] }) });
|
|
2730
|
+
};
|
|
2731
|
+
return {
|
|
2732
|
+
RivModalIframe,
|
|
2733
|
+
RivIframe,
|
|
2734
|
+
openRivIframe,
|
|
2735
|
+
closeRivIframe,
|
|
2736
|
+
remoteIdentityVerificationUrl,
|
|
2737
|
+
isCreatingUrl,
|
|
2738
|
+
isFullyLoaded: isIframeLoaded
|
|
2739
|
+
};
|
|
2740
|
+
};
|
|
2741
|
+
const useRemoteIdentityVerificationPopup = (config) => {
|
|
2742
|
+
const { createRemoteIdentityVerificationUrl, createMessageHandler } = useRemoteIdentityVerification(config);
|
|
2743
|
+
const [isCreatingUrl, setIsCreatingUrl] = React.useState(false);
|
|
2744
|
+
const [rivsRqstId, setRivsRqstId] = React.useState("");
|
|
2745
|
+
const popupRef = React.useRef(null);
|
|
2746
|
+
const openPopup = async (target = "_blank", features) => {
|
|
2747
|
+
if (popupRef.current && !popupRef.current.closed) {
|
|
2748
|
+
popupRef.current.close();
|
|
2749
|
+
}
|
|
2750
|
+
setIsCreatingUrl(true);
|
|
2751
|
+
try {
|
|
2752
|
+
const { fullUrl, rivsRqstId: rivsRqstId2 } = await createRemoteIdentityVerificationUrl();
|
|
2753
|
+
const popup = window.open(fullUrl, target, features);
|
|
2754
|
+
if (!popup) {
|
|
2755
|
+
await salesFrontendDesignSystem.ModalUtils.alert("\uD31D\uC5C5\uC774 \uCC28\uB2E8\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uD31D\uC5C5\uC744 \uD5C8\uC6A9\uD574\uC8FC\uC138\uC694.");
|
|
2756
|
+
return;
|
|
2757
|
+
}
|
|
2758
|
+
setRivsRqstId(rivsRqstId2);
|
|
2759
|
+
popupRef.current = popup;
|
|
2760
|
+
} catch (error) {
|
|
2761
|
+
console.error("openPopup error::", error);
|
|
2762
|
+
await salesFrontendDesignSystem.ModalUtils.alert("\uBE44\uB300\uBA74 \uC778\uC99D URL \uC0DD\uC131\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4. \uB2E4\uC2DC \uC2DC\uB3C4\uD574\uC8FC\uC138\uC694.");
|
|
2763
|
+
} finally {
|
|
2764
|
+
setIsCreatingUrl(false);
|
|
2765
|
+
}
|
|
2766
|
+
};
|
|
2767
|
+
const cleanPopup = () => {
|
|
2768
|
+
popupRef.current = null;
|
|
2769
|
+
};
|
|
2770
|
+
React.useEffect(() => {
|
|
2771
|
+
const messageHandler = createMessageHandler({ rivsRqstId }, cleanPopup);
|
|
2772
|
+
salesFrontendUtils.MessageEventManager.getInstance().registerHandler("riv-popup-handler", messageHandler);
|
|
2773
|
+
return () => salesFrontendUtils.MessageEventManager.getInstance().unregisterHandler("riv-popup-handler");
|
|
2774
|
+
}, [rivsRqstId]);
|
|
2775
|
+
return {
|
|
2776
|
+
openPopup,
|
|
2777
|
+
isCreatingUrl
|
|
2778
|
+
};
|
|
2779
|
+
};
|
|
2780
|
+
|
|
2582
2781
|
exports.Attachment = Attachment;
|
|
2583
2782
|
exports.BankStockSearchModal = BankStockSearchModal;
|
|
2584
2783
|
exports.CustomerSearch = CustomerSearch;
|
|
@@ -2601,5 +2800,8 @@ exports.useBankStockSearch = useBankStockSearch;
|
|
|
2601
2800
|
exports.useCamera = useCamera;
|
|
2602
2801
|
exports.useCanvasPaint = useCanvasPaint;
|
|
2603
2802
|
exports.useJobVehicleSearchModal = useJobVehicleSearchModal;
|
|
2803
|
+
exports.useRemoteIdentityVerification = useRemoteIdentityVerification;
|
|
2804
|
+
exports.useRemoteIdentityVerificationIframe = useRemoteIdentityVerificationIframe;
|
|
2805
|
+
exports.useRemoteIdentityVerificationPopup = useRemoteIdentityVerificationPopup;
|
|
2604
2806
|
exports.useSearchAddress = useSearchAddress;
|
|
2605
2807
|
//# sourceMappingURL=index.cjs.js.map
|