sales-frontend-components 0.0.62 → 0.0.64
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 +60 -30
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +61 -31
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs.js
CHANGED
|
@@ -1058,8 +1058,34 @@ const SEARCH_SECTIONS = [
|
|
|
1058
1058
|
{ value: "response", label: "\uC751\uB2F5" },
|
|
1059
1059
|
{ value: "error", label: "\uC5D0\uB7EC" }
|
|
1060
1060
|
];
|
|
1061
|
+
const getLogInfo = (log) => {
|
|
1062
|
+
if (log.holdStatus === "held") {
|
|
1063
|
+
if ("request" in log) {
|
|
1064
|
+
return log.request;
|
|
1065
|
+
}
|
|
1066
|
+
if ("response" in log) {
|
|
1067
|
+
return log.response;
|
|
1068
|
+
}
|
|
1069
|
+
if ("error" in log) {
|
|
1070
|
+
return log.error;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
return log;
|
|
1074
|
+
};
|
|
1061
1075
|
const NetworkLog = ({ onClose }) => {
|
|
1062
|
-
const {
|
|
1076
|
+
const {
|
|
1077
|
+
requests,
|
|
1078
|
+
responses,
|
|
1079
|
+
errors,
|
|
1080
|
+
clear,
|
|
1081
|
+
isHold,
|
|
1082
|
+
toggleHold,
|
|
1083
|
+
heldRequests,
|
|
1084
|
+
heldResponses,
|
|
1085
|
+
heldErrors,
|
|
1086
|
+
playAllRequests,
|
|
1087
|
+
playAllResponses
|
|
1088
|
+
} = salesFrontendApi.useDebugStore();
|
|
1063
1089
|
const [searchTerm, setSearchTerm] = React.useState("");
|
|
1064
1090
|
const [searchSection, setSearchSection] = React.useState(SEARCH_SECTIONS[0]?.value);
|
|
1065
1091
|
const allLogs = React.useMemo(() => {
|
|
@@ -1067,52 +1093,61 @@ const NetworkLog = ({ onClose }) => {
|
|
|
1067
1093
|
requests.forEach((req) => logs.push({ ...req, type: "request" }));
|
|
1068
1094
|
responses.forEach((res) => logs.push({ ...res, type: "response" }));
|
|
1069
1095
|
errors.forEach((err) => logs.push({ ...err, type: "error" }));
|
|
1096
|
+
heldRequests.forEach((req) => logs.push({ ...req, type: "request", holdStatus: "held" }));
|
|
1097
|
+
heldResponses.forEach((res) => logs.push({ ...res, type: "response", holdStatus: "held" }));
|
|
1098
|
+
heldErrors.forEach((err) => logs.push({ ...err, type: "error", holdStatus: "held" }));
|
|
1070
1099
|
logs.sort((a, b) => {
|
|
1071
|
-
const
|
|
1072
|
-
const
|
|
1100
|
+
const aInfo = getLogInfo(a);
|
|
1101
|
+
const bInfo = getLogInfo(b);
|
|
1102
|
+
const aTime = "startTime" in aInfo ? aInfo.startTime : 0;
|
|
1103
|
+
const bTime = "startTime" in bInfo ? bInfo.startTime : 0;
|
|
1073
1104
|
return bTime - aTime;
|
|
1074
1105
|
});
|
|
1075
1106
|
return logs;
|
|
1076
|
-
}, [requests, responses, errors]);
|
|
1107
|
+
}, [requests, responses, errors, heldRequests, heldResponses, heldErrors]);
|
|
1077
1108
|
const filteredLogs = React.useMemo(() => {
|
|
1078
1109
|
if (!searchTerm) {
|
|
1079
1110
|
return allLogs;
|
|
1080
1111
|
}
|
|
1081
1112
|
const lowercasedTerm = searchTerm.toLowerCase();
|
|
1082
1113
|
return allLogs.filter((log) => {
|
|
1114
|
+
const logInfo = getLogInfo(log);
|
|
1083
1115
|
switch (searchSection) {
|
|
1084
1116
|
case "url":
|
|
1085
|
-
return
|
|
1117
|
+
return logInfo.url?.toLowerCase().includes(lowercasedTerm);
|
|
1086
1118
|
case "headers":
|
|
1087
|
-
return "headers" in
|
|
1119
|
+
return "headers" in logInfo && logInfo.headers && JSON.stringify(logInfo.headers)?.toLowerCase().includes(lowercasedTerm);
|
|
1088
1120
|
case "params":
|
|
1089
|
-
return "params" in
|
|
1121
|
+
return "params" in logInfo && logInfo.params && JSON.stringify(logInfo.params)?.toLowerCase().includes(lowercasedTerm);
|
|
1090
1122
|
case "data":
|
|
1091
|
-
return "data" in
|
|
1123
|
+
return "data" in logInfo && logInfo.data && log.type === "request" && JSON.stringify(logInfo.data)?.toLowerCase().includes(lowercasedTerm);
|
|
1092
1124
|
case "response":
|
|
1093
|
-
return "data" in
|
|
1125
|
+
return "data" in logInfo && logInfo.data && log.type === "response" && JSON.stringify(logInfo.data)?.toLowerCase().includes(lowercasedTerm);
|
|
1094
1126
|
case "error":
|
|
1095
|
-
return log.type === "error" && JSON.stringify(
|
|
1127
|
+
return log.type === "error" && JSON.stringify(logInfo)?.toLowerCase().includes(lowercasedTerm);
|
|
1096
1128
|
case "all":
|
|
1097
1129
|
default:
|
|
1098
|
-
return JSON.stringify(
|
|
1130
|
+
return JSON.stringify(logInfo).toLowerCase().includes(lowercasedTerm);
|
|
1099
1131
|
}
|
|
1100
1132
|
});
|
|
1101
1133
|
}, [allLogs, searchTerm, searchSection]);
|
|
1102
1134
|
const renderLogSummary = (log) => {
|
|
1135
|
+
const logInfo = getLogInfo(log);
|
|
1136
|
+
const prefix = log.holdStatus === "held" ? "[HELD] " : "";
|
|
1103
1137
|
if (log.type === "request") {
|
|
1104
|
-
return
|
|
1138
|
+
return `${prefix}[REQ] ${logInfo.method.toUpperCase()} ${logInfo.url}`;
|
|
1105
1139
|
}
|
|
1106
|
-
if (log.type === "response" && "status" in
|
|
1107
|
-
return
|
|
1140
|
+
if (log.type === "response" && "status" in logInfo) {
|
|
1141
|
+
return `${prefix}[RES] ${logInfo.method.toUpperCase()} ${logInfo.url} - ${logInfo.status}`;
|
|
1108
1142
|
}
|
|
1109
|
-
if (log.type === "error" && "message" in
|
|
1110
|
-
return
|
|
1143
|
+
if (log.type === "error" && "message" in logInfo) {
|
|
1144
|
+
return `${prefix}[ERR] ${logInfo.method.toUpperCase()} ${logInfo.url} - ${logInfo.message}`;
|
|
1111
1145
|
}
|
|
1112
1146
|
return "Unknown Log";
|
|
1113
1147
|
};
|
|
1114
1148
|
const renderLogContent = (log) => {
|
|
1115
|
-
|
|
1149
|
+
const logInfo = getLogInfo(log);
|
|
1150
|
+
return /* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(logInfo, null, 2) });
|
|
1116
1151
|
};
|
|
1117
1152
|
return /* @__PURE__ */ jsxRuntime.jsxs(salesFrontendDesignSystem.Modal.Root, { isOpen: true, onClose, modalSize: "full-screen", children: [
|
|
1118
1153
|
/* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Modal.Overlay, {}),
|
|
@@ -1130,8 +1165,13 @@ const NetworkLog = ({ onClose }) => {
|
|
|
1130
1165
|
onChange: (e) => setSearchTerm(e.target.value)
|
|
1131
1166
|
}
|
|
1132
1167
|
),
|
|
1168
|
+
/* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Checkbox, { id: "hold-checkbox", checked: isHold, onChange: toggleHold, size: "small", variant: "main", children: "Hold" }),
|
|
1133
1169
|
/* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Button, { variant: "neutral", appearance: "outline", size: "xsmall", onClick: clear, children: "clear" })
|
|
1134
1170
|
] }),
|
|
1171
|
+
isHold && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "row" }, children: [
|
|
1172
|
+
/* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Button, { size: "xsmall", onClick: () => playAllRequests(), variant: "primary", appearance: "outline", children: "REQ Resolve" }),
|
|
1173
|
+
/* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Button, { size: "xsmall", onClick: () => playAllResponses(), variant: "primary", appearance: "outline", children: "RES Resolve" })
|
|
1174
|
+
] }),
|
|
1135
1175
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles$3["log-list"], children: filteredLogs.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { children: "\uD45C\uC2DC\uD560 \uB85C\uADF8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4." }) : /* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Accordion.Root, { children: filteredLogs.map((log, index) => /* @__PURE__ */ jsxRuntime.jsxs(salesFrontendDesignSystem.Accordion.Item, { children: [
|
|
1136
1176
|
/* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Accordion.HeaderButton, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: styles$3["log-summary"], children: renderLogSummary(log) }) }),
|
|
1137
1177
|
/* @__PURE__ */ jsxRuntime.jsx(salesFrontendDesignSystem.Accordion.Content, { variant: "text", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles$3["log-content"], children: renderLogContent(log) }) })
|
|
@@ -1448,21 +1488,11 @@ const menuItems = [
|
|
|
1448
1488
|
|
|
1449
1489
|
const useEnvironment = () => {
|
|
1450
1490
|
const [envInfo, setEnvInfo] = React.useState({
|
|
1451
|
-
env: "
|
|
1491
|
+
env: "prd"
|
|
1452
1492
|
});
|
|
1453
1493
|
React.useEffect(() => {
|
|
1454
1494
|
const { hostname } = window.location;
|
|
1455
|
-
|
|
1456
|
-
if (hostname.includes("localhost") || hostname.includes("127.0.0.1")) {
|
|
1457
|
-
currentEnv = "local";
|
|
1458
|
-
} else if (hostname.includes("dev.")) {
|
|
1459
|
-
currentEnv = "dev";
|
|
1460
|
-
} else if (hostname.includes("stg.")) {
|
|
1461
|
-
currentEnv = "stage";
|
|
1462
|
-
} else {
|
|
1463
|
-
currentEnv = "prod";
|
|
1464
|
-
}
|
|
1465
|
-
setEnvInfo({ env: currentEnv });
|
|
1495
|
+
setEnvInfo({ env: salesFrontendUtils.getEnvironmentFromHostname(hostname) });
|
|
1466
1496
|
}, []);
|
|
1467
1497
|
return envInfo;
|
|
1468
1498
|
};
|
|
@@ -1479,7 +1509,7 @@ const DebugTool = ({ onLogin, envOverride, menuItemsOverride }) => {
|
|
|
1479
1509
|
const menuItems$1 = menuItemsOverride || menuItems;
|
|
1480
1510
|
const [isMenuOpen, setMenuOpen] = React.useState(false);
|
|
1481
1511
|
const [activeFeature, setActiveFeature] = React.useState(null);
|
|
1482
|
-
const isVisible = ["local", "dev", "
|
|
1512
|
+
const isVisible = ["local", "dev", "stg"].includes(env);
|
|
1483
1513
|
const handleMenuClick = (itemComponent) => {
|
|
1484
1514
|
setActiveFeature(() => itemComponent);
|
|
1485
1515
|
setMenuOpen(false);
|