sales-frontend-components 0.0.80 → 0.0.82

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 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,
@@ -283,6 +284,73 @@ function JobSearchCategory({ filteredJobs, onJobSelect, searchTerm }) {
283
284
  ] }) });
284
285
  }
285
286
 
287
+ function JobSearchDetail({ occupationTypeCode, occupationIndustryCode }) {
288
+ const { data: detail } = method.useSearchOccupationDetailQuery({
289
+ occupationIndustryCode,
290
+ occupationIndustryTypeCode: occupationTypeCode
291
+ });
292
+ if (!detail || !detail.data) {
293
+ return null;
294
+ }
295
+ const {
296
+ /** @description 직종해설내용 */
297
+ occupationExplanationContent,
298
+ /** @description 직업예시명 */
299
+ occupationExampleName,
300
+ /** @description 위험등급명 */
301
+ riskGradeName,
302
+ /** @description 위험등급코드 */
303
+ riskGradeCode,
304
+ /** @description 상해위험등급코드명 */
305
+ injuryRiskGradeCodeName,
306
+ /** @description 상해위험등급코드 */
307
+ injuryRiskGradeCode,
308
+ /** @description 입원등급코드명 */
309
+ hospitalizationGradeCodeName,
310
+ /** @description 입원등급코드 */
311
+ hospitalizationGradeCode,
312
+ /** @description 상해직종코드 */
313
+ injuryOccupationCode
314
+ } = detail.data;
315
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Table, { variant: "horizontal", children: /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
316
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
317
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-small", children: "\uC9C1\uC885 \uD574\uC124" }),
318
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-small", children: occupationExplanationContent })
319
+ ] }),
320
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
321
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-small", children: "\uC9C1\uC885 \uC608\uC2DC" }),
322
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-small", children: occupationExampleName })
323
+ ] }),
324
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
325
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-small", children: "\uC704\uD5D8 \uB4F1\uAE09" }),
326
+ /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-small", children: [
327
+ riskGradeName,
328
+ "(",
329
+ riskGradeCode,
330
+ ")"
331
+ ] })
332
+ ] }),
333
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
334
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-small", children: "\uC785\uC6D0 \uB4F1\uAE09" }),
335
+ /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-small", children: [
336
+ hospitalizationGradeCodeName,
337
+ "(",
338
+ hospitalizationGradeCode,
339
+ ")"
340
+ ] })
341
+ ] }),
342
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
343
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-small", children: "\uC0C1\uD574 \uB4F1\uAE09" }),
344
+ /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-small", children: [
345
+ injuryRiskGradeCodeName,
346
+ "(",
347
+ injuryRiskGradeCode,
348
+ ")"
349
+ ] })
350
+ ] })
351
+ ] }) }) });
352
+ }
353
+
286
354
  const cx$d = classNames.bind(styles);
287
355
  function JobSearchFavorite({ filteredJobs, onJobSelect }) {
288
356
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$d("popular-jobs"), children: [
@@ -308,7 +376,13 @@ function JobSearchFavorite({ filteredJobs, onJobSelect }) {
308
376
  ]
309
377
  }
310
378
  ) }),
311
- /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Accordion.Content, { variant: "text", children: "\uD56D\uBAA9 1 \uB0B4\uC6A9" })
379
+ /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Accordion.Content, { variant: "text", children: /* @__PURE__ */ jsxRuntime.jsx(
380
+ JobSearchDetail,
381
+ {
382
+ occupationTypeCode: job.occupationTypeCode || "",
383
+ occupationIndustryCode: job.occupationIndustryCode
384
+ }
385
+ ) })
312
386
  ]
313
387
  },
314
388
  `item-${job.occupationIndustryCode}-${index}`
@@ -341,22 +415,13 @@ function JobSearchResult({ filteredJobs, onJobSelect, searchTerm }) {
341
415
  children: highlightOnSearchKeyword$1(job.occupationIndustryName, searchTerm)
342
416
  }
343
417
  ) }) }),
344
- /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Accordion.Content, { variant: "text", children: /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Table, { variant: "horizontal", children: /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
345
- /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
346
- /* @__PURE__ */ jsxRuntime.jsx("th", { children: "\uD5E4\uB354 1" }),
347
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-24", children: "1\uD589 1\uBC88\uC9F8" }),
348
- /* @__PURE__ */ jsxRuntime.jsx("th", { children: "\uD5E4\uB354 1-2" }),
349
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-24 ", children: "1\uD589 2\uBC88\uC9F8" })
350
- ] }),
351
- /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
352
- /* @__PURE__ */ jsxRuntime.jsx("th", { children: "\uD5E4\uB354 2" }),
353
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "pl-24 pr-16", colSpan: 3, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "d-flex-center-center", children: [
354
- "2\uD589 1\uBC88\uC9F8 ",
355
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 pipe-left", children: "\uC11C\uBE0C\uD14D\uC2A4\uD2B8" }),
356
- /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Button, { variant: "neutral", size: "xsmall", appearance: "outline", children: "\uBC84\uD2BC\uBA85" })
357
- ] }) })
358
- ] })
359
- ] }) }) })
418
+ /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Accordion.Content, { variant: "text", children: /* @__PURE__ */ jsxRuntime.jsx(
419
+ JobSearchDetail,
420
+ {
421
+ occupationTypeCode: job.occupationTypeCode || "",
422
+ occupationIndustryCode: job.occupationIndustryCode
423
+ }
424
+ ) })
360
425
  ]
361
426
  },
362
427
  job.occupationIndustryCode
@@ -2386,34 +2451,20 @@ const JobSearchModal = ({ onClose }) => {
2386
2451
  ] });
2387
2452
  };
2388
2453
 
2389
- const mockCustomers = [
2390
- { customerId: "1", customerName: "\uAE40\uD55C\uD654", birthDate: "1999.01.01", genderCode: "\uB0A8\uC131" },
2391
- {
2392
- customerId: "2",
2393
- customerName: "\uAE40\uD55C\uD654\uC0DD\uBA85",
2394
- birthDate: "1989.01.01",
2395
- genderCode: "\uC5EC\uC131",
2396
- baseAddress: "\uC11C\uC6B8\uC2DC \uB9C8\uD3EC\uAD6C"
2397
- },
2398
- {
2399
- customerId: "3",
2400
- customerName: "\uAE40\uD55C\uD654\uC190\uD574\uBCF4\uD5D8",
2401
- birthDate: "1999.01.01",
2402
- genderCode: "\uB0A8\uC131",
2403
- baseAddress: "\uC11C\uC6B8\uC2DC \uB9C8\uD3EC\uAD6C"
2404
- }
2405
- ];
2406
2454
  const useCustomerSearch = (onSelect) => {
2407
2455
  const { triggerRef, isOpen, setIsOpen, DropDown } = salesFrontendDesignSystem.useDropDown();
2408
2456
  const [searchKeyword, setSearchKeyword] = React.useState("");
2409
2457
  const [searchInput, setSearchInput] = React.useState("");
2410
2458
  const [customerList, setCustomerList] = React.useState([]);
2411
2459
  const [selectedCustomer, setSelectedCustomer] = React.useState(null);
2460
+ const { data } = method.useSearchCustomerListQuery({ customerName: searchKeyword });
2412
2461
  const search = () => {
2413
2462
  if (searchInput.length >= 2) {
2414
2463
  setSearchKeyword(searchInput);
2415
- const filtered = mockCustomers.filter((c) => c.customerName?.toLowerCase().includes(searchInput.toLowerCase()));
2416
- setCustomerList(filtered);
2464
+ const filtered = data?.data?.custList?.filter(
2465
+ (c) => c.customerName?.toLowerCase().includes(searchInput.toLowerCase())
2466
+ );
2467
+ setCustomerList(filtered || []);
2417
2468
  setIsOpen(true);
2418
2469
  } else {
2419
2470
  setCustomerList([]);
@@ -2529,6 +2580,204 @@ const CustomerSearch = ({ onSelect }) => {
2529
2580
  ] });
2530
2581
  };
2531
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
+
2532
2781
  exports.Attachment = Attachment;
2533
2782
  exports.BankStockSearchModal = BankStockSearchModal;
2534
2783
  exports.CustomerSearch = CustomerSearch;
@@ -2551,5 +2800,8 @@ exports.useBankStockSearch = useBankStockSearch;
2551
2800
  exports.useCamera = useCamera;
2552
2801
  exports.useCanvasPaint = useCanvasPaint;
2553
2802
  exports.useJobVehicleSearchModal = useJobVehicleSearchModal;
2803
+ exports.useRemoteIdentityVerification = useRemoteIdentityVerification;
2804
+ exports.useRemoteIdentityVerificationIframe = useRemoteIdentityVerificationIframe;
2805
+ exports.useRemoteIdentityVerificationPopup = useRemoteIdentityVerificationPopup;
2554
2806
  exports.useSearchAddress = useSearchAddress;
2555
2807
  //# sourceMappingURL=index.cjs.js.map