sales-frontend-components 0.0.78 → 0.0.80

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
@@ -1390,7 +1390,7 @@ const testSignatureBase64Data = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA
1390
1390
  const cx$8 = classNames.bind(styles$3);
1391
1391
  const { InputBox: InputBox$1, Input: Input$1 } = salesFrontendDesignSystem.FormCore;
1392
1392
  const AddressSearchInitialText = () => {
1393
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1393
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$8("search-result-list"), children: [
1394
1394
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx$8("guide-title"), children: "\uC774\uB807\uAC8C \uAC80\uC0C9\uD574 \uBCF4\uC138\uC694." }),
1395
1395
  /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: cx$8("guide"), children: [
1396
1396
  /* @__PURE__ */ jsxRuntime.jsx("li", { children: "\uB3C4\uB85C\uBA85/\uC9C0\uBA85\uACFC \uAC74\uBB3C\uBC88\uD638\uB97C \uD568\uAED8 \uC785\uB825\uD574\uC8FC\uC138\uC694" }),
@@ -1408,38 +1408,36 @@ const AddressSearchResult = ({
1408
1408
  searchKeyword,
1409
1409
  selectedAddress
1410
1410
  }) => {
1411
- const [filterList, setFilterList] = React.useState([]);
1412
- React.useEffect(() => {
1413
- const filterList2 = addressSearchList.filter(
1414
- (item) => item.address.includes(searchKeyword) || item.oldAddress.includes(searchKeyword)
1415
- ) || [];
1416
- setFilterList(filterList2);
1417
- }, [addressSearchList, searchKeyword]);
1418
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1411
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$8("search-result-list"), children: [
1419
1412
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx$8("guide-title"), children: [
1420
1413
  "\uCD1D ",
1421
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-primary", children: filterList.length }),
1414
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-primary", children: addressSearchList.length }),
1422
1415
  "\uAC74\uC758 \uAC80\uC0C9\uACB0\uACFC"
1423
1416
  ] }),
1424
- filterList.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1417
+ addressSearchList.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1425
1418
  salesFrontendDesignSystem.RadioGroup,
1426
1419
  {
1427
- items: filterList.map((item) => ({
1428
- value: item.address,
1429
- select: item.address === selectedAddress?.address && item.zipCode === selectedAddress?.zipCode,
1430
- label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$8("search-result"), children: [
1431
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$8("zipcode"), children: [
1432
- " ",
1433
- highlightOnSearchKeyword$1(item.zipCode, searchKeyword)
1420
+ items: addressSearchList.map((item) => {
1421
+ return {
1422
+ value: JSON.stringify(item),
1423
+ select: item.roadNameBaseAddress === selectedAddress?.roadNameBaseAddress && item.roadNameDetailAddress === selectedAddress?.roadNameDetailAddress && item.mainBuildingName === selectedAddress?.mainBuildingName,
1424
+ label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$8("search-result"), children: [
1425
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx$8("zipcode"), children: highlightOnSearchKeyword$1(`${item.firstPostalCode}${item.secondPostalCode}`, searchKeyword) }),
1426
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx$8("divider") }),
1427
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$8("address-info"), children: [
1428
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx$8("address"), children: highlightOnSearchKeyword$1(
1429
+ `${item.roadNameBaseAddress} ${item.roadNameDetailAddress} ${item.mainBuildingName}`,
1430
+ searchKeyword
1431
+ ) }),
1432
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx$8("old-address"), children: highlightOnSearchKeyword$1(
1433
+ `${item.landNumberBaseAddress} ${item.landNumberDetailAddress}`,
1434
+ searchKeyword
1435
+ ) })
1436
+ ] })
1434
1437
  ] }),
1435
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx$8("divider") }),
1436
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$8("address-info"), children: [
1437
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx$8("address"), children: highlightOnSearchKeyword$1(item.address, searchKeyword) }),
1438
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx$8("old-address"), children: highlightOnSearchKeyword$1(item.oldAddress, searchKeyword) })
1439
- ] })
1440
- ] }),
1441
- id: item.address
1442
- })),
1438
+ id: JSON.stringify(item)
1439
+ };
1440
+ }),
1443
1441
  className: cx$8("radio-group"),
1444
1442
  name: "address-search",
1445
1443
  size: "medium",
@@ -1447,7 +1445,7 @@ const AddressSearchResult = ({
1447
1445
  onChange
1448
1446
  }
1449
1447
  ),
1450
- filterList.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1448
+ addressSearchList.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1451
1449
  "`",
1452
1450
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-primary", children: searchKeyword }),
1453
1451
  "`\uC5D0 \uB300\uD55C \uAC80\uC0C9\uACB0\uACFC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
@@ -1455,30 +1453,52 @@ const AddressSearchResult = ({
1455
1453
  ] });
1456
1454
  };
1457
1455
  const AddressSearchDetailInput = ({
1458
- selectedAddress,
1456
+ addressStandardizationList,
1459
1457
  onDetailChange,
1458
+ onStandardizationChange,
1460
1459
  step,
1461
1460
  detailAddressInput
1462
1461
  }) => {
1463
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1464
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1465
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1466
- " ",
1467
- selectedAddress.zipCode
1468
- ] }),
1469
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1470
- "|",
1471
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: `${selectedAddress.address}` })
1472
- ] })
1473
- ] }),
1474
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1462
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$8("search-result-list"), children: [
1463
+ /* @__PURE__ */ jsxRuntime.jsx(
1464
+ salesFrontendDesignSystem.RadioGroup,
1465
+ {
1466
+ items: addressStandardizationList.map((item) => {
1467
+ return {
1468
+ value: JSON.stringify(item),
1469
+ select: true,
1470
+ label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$8("search-result"), children: [
1471
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx$8("zipcode"), children: `${item.firstPostalCode}${item.secondPostalCode}` }),
1472
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx$8("divider") }),
1473
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx$8("address-info"), children: [
1474
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx$8("address"), children: `${item.baseAddress} ${item.detailAddress}` }),
1475
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx$8("old-address"), children: `${item.baseAddress} ${item.detailAddress}` })
1476
+ ] })
1477
+ ] }),
1478
+ id: JSON.stringify(item)
1479
+ };
1480
+ }),
1481
+ className: cx$8("radio-group"),
1482
+ name: "address-search-standardization",
1483
+ size: "medium",
1484
+ defaultValue: "",
1485
+ onChange: onStandardizationChange
1486
+ }
1487
+ ),
1488
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "d-flex gap-medium items-center", children: [
1475
1489
  /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.FormField.Label, { id: "detail", style: { width: "90px" }, children: "\uC0C1\uC138\uC8FC\uC18C" }),
1476
1490
  /* @__PURE__ */ jsxRuntime.jsx(
1477
- Input$1,
1491
+ salesFrontendDesignSystem.FormField.TextField,
1478
1492
  {
1493
+ rootProps: {
1494
+ style: {
1495
+ display: "flex",
1496
+ flex: 1
1497
+ }
1498
+ },
1479
1499
  placeholder: "\uC0C1\uC138\uC8FC\uC18C \uC785\uB825",
1480
1500
  onChange: onDetailChange,
1481
- size: "large",
1501
+ size: "small",
1482
1502
  value: detailAddressInput,
1483
1503
  ...step === "detail-input" && { autoFocus: true }
1484
1504
  }
@@ -1501,7 +1521,9 @@ function AddressComponent({ isOpen, onClose, setValue }) {
1501
1521
  setDetail,
1502
1522
  search,
1503
1523
  searchInput,
1504
- selectedAddress
1524
+ selectedAddress,
1525
+ onStandardizationChange,
1526
+ addressStandardizationList
1505
1527
  } = useSearchAddress({
1506
1528
  setValue,
1507
1529
  onClose,
@@ -1528,7 +1550,7 @@ function AddressComponent({ isOpen, onClose, setValue }) {
1528
1550
  AddressSearchResult,
1529
1551
  {
1530
1552
  onChange: onSelectChange,
1531
- addressSearchList: addressSearchList || [],
1553
+ addressSearchList,
1532
1554
  searchKeyword: addressSearchKeyword,
1533
1555
  selectedAddress
1534
1556
  }
@@ -1536,7 +1558,8 @@ function AddressComponent({ isOpen, onClose, setValue }) {
1536
1558
  addressSearchStep === "detail-input" && selectedAddress && /* @__PURE__ */ jsxRuntime.jsx(
1537
1559
  AddressSearchDetailInput,
1538
1560
  {
1539
- selectedAddress,
1561
+ addressStandardizationList,
1562
+ onStandardizationChange,
1540
1563
  onDetailChange: setDetail,
1541
1564
  step: addressSearchStep,
1542
1565
  detailAddressInput
@@ -1565,21 +1588,48 @@ function AddressComponent({ isOpen, onClose, setValue }) {
1565
1588
  function useSearchAddress({ setValue, onClose, isOpen }) {
1566
1589
  const [searchKeyword, setSearchKeyword] = React.useState("");
1567
1590
  const [step, setStep] = React.useState("initial");
1568
- const [selectedAddress, setSelectedAddress] = React.useState(null);
1591
+ const [selectedAddress, setSelectedAddress] = React.useState();
1592
+ const [selectedStandardizationAddress, setSelectedStandardizationAddress] = React.useState();
1569
1593
  const [searchInput, setSearchInput] = React.useState("");
1570
1594
  const [detailAddressInput, setDetailAddressInput] = React.useState("");
1571
- const { data: addressList } = method.useSearchModalAddressQuery({ searchKeyword });
1595
+ const [displayList, setDisplayList] = React.useState([]);
1596
+ const [searchType, setSearchType] = React.useState("address");
1597
+ const [standardizationParams, setStandardizationParams] = React.useState({
1598
+ firstPostalCode: "",
1599
+ secondPostalCode: "",
1600
+ baseAddress: "",
1601
+ detailAddress: "",
1602
+ roadNameYn: "Y"
1603
+ });
1604
+ const { data: addressData } = method.useSearchAddressQuery(
1605
+ { searchKeyWord: searchKeyword },
1606
+ { enabled: !!searchKeyword && searchType === "address" }
1607
+ );
1608
+ const { data: postalData } = method.useSearchPostalCodeQuery(
1609
+ { searchWordName: searchKeyword },
1610
+ { enabled: !!searchKeyword && searchType === "postalcode" }
1611
+ );
1612
+ const { data: standardizedData } = method.useSearchAddressStandardizationQuery(standardizationParams, {
1613
+ enabled: !!standardizationParams?.baseAddress
1614
+ });
1572
1615
  const [nextButtonDisabled, setNextButtonDisabled] = React.useState(false);
1573
1616
  const onNext = () => {
1574
1617
  if (step === "search-result") {
1575
1618
  setStep("detail-input");
1576
1619
  setNextButtonDisabled(true);
1620
+ if (selectedAddress) {
1621
+ setStandardizationParams({
1622
+ firstPostalCode: selectedAddress.firstPostalCode,
1623
+ secondPostalCode: selectedAddress.secondPostalCode,
1624
+ baseAddress: selectedAddress.roadNameBaseAddress,
1625
+ detailAddress: selectedAddress.roadNameDetailAddress,
1626
+ roadNameYn: "Y"
1627
+ });
1628
+ }
1577
1629
  } else {
1578
- setValue({
1579
- address: selectedAddress?.address || "",
1580
- oldAddress: selectedAddress?.oldAddress || "",
1581
- zipCode: selectedAddress?.zipCode || "",
1582
- detail: detailAddressInput || ""
1630
+ selectedStandardizationAddress && setValue({
1631
+ ...selectedStandardizationAddress,
1632
+ detailAddressInput
1583
1633
  });
1584
1634
  onClose();
1585
1635
  }
@@ -1594,9 +1644,11 @@ function useSearchAddress({ setValue, onClose, isOpen }) {
1594
1644
  return;
1595
1645
  }
1596
1646
  if (searchInput && searchInput.length > 1) {
1647
+ const isNumeric = /^[0-9]+$/.test(searchInput);
1648
+ setSearchType(isNumeric ? "postalcode" : "address");
1597
1649
  setSearchKeyword(searchInput);
1598
1650
  setStep("search-result");
1599
- setSelectedAddress(null);
1651
+ setSelectedAddress(void 0);
1600
1652
  setDetailAddressInput("");
1601
1653
  setNextButtonDisabled(true);
1602
1654
  }
@@ -1607,19 +1659,23 @@ function useSearchAddress({ setValue, onClose, isOpen }) {
1607
1659
  }
1608
1660
  };
1609
1661
  const onSelectChange = (e) => {
1610
- const selectedAddress2 = e.target.value;
1611
- if (selectedAddress2) {
1612
- const adr = addressList?.find((addr) => {
1613
- return addr.address === selectedAddress2;
1614
- });
1615
- setSelectedAddress(adr || null);
1662
+ const selected = e.target.value;
1663
+ if (selected) {
1664
+ setSelectedAddress(JSON.parse(selected));
1665
+ setNextButtonDisabled(false);
1666
+ }
1667
+ };
1668
+ const onStandardizationChange = (e) => {
1669
+ const selected = e.target.value;
1670
+ if (selected) {
1671
+ setSelectedStandardizationAddress(JSON.parse(selected));
1616
1672
  setNextButtonDisabled(false);
1617
1673
  }
1618
1674
  };
1619
1675
  const onClear = React.useCallback(() => {
1620
1676
  setSearchKeyword("");
1621
1677
  setSearchInput("");
1622
- setSelectedAddress(null);
1678
+ setSelectedAddress(void 0);
1623
1679
  setDetailAddressInput("");
1624
1680
  setStep("initial");
1625
1681
  }, []);
@@ -1632,19 +1688,39 @@ function useSearchAddress({ setValue, onClose, isOpen }) {
1632
1688
  setNextButtonDisabled(true);
1633
1689
  }
1634
1690
  };
1691
+ React.useEffect(() => {
1692
+ if (searchType === "address" && addressData?.data?.addressList) {
1693
+ setDisplayList(addressData.data.addressList);
1694
+ } else if (searchType === "postalcode" && postalData?.data?.postalCodeList) {
1695
+ console.log("transformedList", postalData.data.postalCodeList);
1696
+ const transformedList = postalData.data.postalCodeList.map((p) => ({
1697
+ firstPostalCode: p.originalNumber1PostalCode,
1698
+ secondPostalCode: p.originalNumber2PostalCode,
1699
+ roadNameBaseAddress: p.roadNameBaseAddress,
1700
+ roadNameDetailAddress: p.roadNameDetailAddress,
1701
+ landNumberBaseAddress: p.landNumberBaseAddress,
1702
+ landNumberDetailAddress: p.landNumberDetailAddress,
1703
+ mainBuildingName: p.mainBuildingName
1704
+ }));
1705
+ setDisplayList(transformedList);
1706
+ }
1707
+ }, [addressData, postalData, searchType]);
1635
1708
  React.useEffect(() => {
1636
1709
  if (isOpen) {
1637
- setSelectedAddress(null);
1710
+ setSelectedAddress(void 0);
1638
1711
  setDetailAddressInput("");
1639
1712
  setStep("initial");
1640
1713
  setSearchKeyword("");
1641
1714
  }
1642
1715
  }, [isOpen]);
1643
1716
  return {
1717
+ addressStandardizationList: standardizedData?.data?.addressStandardizationList || [],
1718
+ selectedStandardizationAddress,
1719
+ onStandardizationChange,
1644
1720
  onAddressSearchClear: onClear,
1645
1721
  onAddressSearchNext: onNext,
1646
1722
  addressSearchKeyword: searchKeyword,
1647
- addressSearchList: addressList,
1723
+ addressSearchList: displayList,
1648
1724
  addressSearchStep: step,
1649
1725
  selectedAddress,
1650
1726
  addressSearchOnValueChange: onSelectChange,
@@ -1659,7 +1735,7 @@ function useSearchAddress({ setValue, onClose, isOpen }) {
1659
1735
  };
1660
1736
  }
1661
1737
  const useAddressComponent = () => {
1662
- const [fullAddress, setFullAddress] = React.useState(null);
1738
+ const [fullAddress, setFullAddress] = React.useState();
1663
1739
  const { isOpen, closeModal, openModal } = salesFrontendDesignSystem.useModalState();
1664
1740
  const AddressSearchComponent = () => /* @__PURE__ */ jsxRuntime.jsx(AddressComponent, { isOpen, onClose: closeModal, setValue: setFullAddress });
1665
1741
  return {