sales-frontend-components 0.0.102 → 0.0.104

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.esm.js CHANGED
@@ -8,7 +8,7 @@ import styles from './modal/standard/address-search/select-address.module.scss';
8
8
  import styles$1 from './modal/standard/bank-stock-search/bank-stock-search-modal.module.scss';
9
9
  import styles$2 from './modal/standard/customer-search/customer-search.module.scss';
10
10
  import styles$3 from './modal/standard/nationality-search/select-nationality.module.scss';
11
- import { isClient, MessageEventManager, getCookie, getDeviceModel, getOSVersion, getOSName, getBrowserVersion, getOrCreateDeviceId, isSalesPortal, getFormFactorFromUserAgent, isWebView } from 'sales-frontend-utils';
11
+ import { isClient, MessageEventManager, isFpPlannerApp, getCookie, getDeviceModel, getOSVersion, getOSName, getBrowserVersion, getOrCreateDeviceId, isSalesPortal, getFormFactorFromUserAgent, isWebView } from 'sales-frontend-utils';
12
12
  import styles$4 from './modal/standard/visa-search/select-visa.module.scss';
13
13
  import { useQuery } from '@tanstack/react-query';
14
14
  import styles$5 from './modal/pre-standard/dea-customer-search-modal/dea-customer-search-modal.module.scss';
@@ -4015,21 +4015,28 @@ const createPureWebClientSession = async () => {
4015
4015
  };
4016
4016
  };
4017
4017
  const createWebviewClientSession = async () => {
4018
- const isLoggedIn = !!(await Bridge.native.getAccessToken()).accessToken;
4018
+ let appInfo = null;
4019
+ try {
4020
+ appInfo = await Bridge.native.getAppInfo();
4021
+ } catch (error) {
4022
+ console.warn("[createWebviewClientSession] getAppInfo \uC2E4\uD328, \uCFE0\uD0A4 \uAC12\uC73C\uB85C fallback:", error);
4023
+ }
4024
+ const isLoggedIn = isFpPlannerApp() ? !!getCookie("accessToken") : !!(await Bridge.native.getAccessToken()).accessToken;
4025
+ const formFactor = appInfo?.["X-Channel-FormFactor"]?.toLowerCase() ?? getCookie("formFactor")?.toLowerCase() ?? getFormFactor();
4026
+ const loginChannel = appInfo?.["X-Channel-LoginChannel"] ?? getCookie("loginChannel") ?? "DSP";
4019
4027
  return {
4020
4028
  isInitialized: true,
4021
4029
  isLoggedIn,
4022
4030
  isWebView: true,
4023
- acceptLanguage: "ko",
4024
- formFactor: getCookie("formFactor") || getFormFactor(),
4025
- deviceId: getCookie("deviceId"),
4026
- //! App
4027
- appVersion: getCookie("appVersion"),
4028
- loginType: getCookie("loginType"),
4029
- platformName: getCookie("platformName"),
4030
- platformVersion: getCookie("platformVersion"),
4031
- deviceModel: getCookie("deviceModel"),
4032
- loginChannel: getCookie("loginChannel") ?? "MSP"
4031
+ acceptLanguage: appInfo?.["Accept-Language"] ?? "ko",
4032
+ formFactor,
4033
+ deviceId: appInfo?.["X-Channel-DeviceId"] ?? getCookie("deviceId"),
4034
+ appVersion: appInfo?.["X-Channel-AppVersion"] ?? getCookie("appVersion"),
4035
+ loginType: appInfo?.["X-Channel-LoginType"] ?? getCookie("loginType"),
4036
+ platformName: appInfo?.["X-Channel-PlatformName"] ?? getCookie("platformName"),
4037
+ platformVersion: appInfo?.["X-Channel-PlatformVersion"] ?? getCookie("platformVersion"),
4038
+ deviceModel: appInfo?.["X-Channel-DeviceModel"] ?? getCookie("deviceModel"),
4039
+ loginChannel
4033
4040
  };
4034
4041
  };
4035
4042
  const getLoginUserInfo = async () => {
@@ -4048,7 +4055,7 @@ const getLoginUserInfo = async () => {
4048
4055
  };
4049
4056
 
4050
4057
  const useSetupClientSession = () => {
4051
- const { isInitialized } = useClientSession();
4058
+ const { isInitialized, isLoggedIn } = useClientSession();
4052
4059
  const setClientSession = useSetClientSession();
4053
4060
  useEffect(() => {
4054
4061
  if (isInitialized) {
@@ -4066,19 +4073,25 @@ const useSetupClientSession = () => {
4066
4073
  setClientSession(await createPureWebClientSession());
4067
4074
  }
4068
4075
  console.log("[useSetupClientSession] \uAE30\uBCF8 \uC138\uC158 \uC124\uC815 \uC644\uB8CC");
4069
- if (getCookie("accessToken")) {
4070
- console.log("[useSetupClientSession] \uC0AC\uC6A9\uC790 \uD504\uB85C\uD544 \uB85C\uB4DC \uC2DC\uC791...");
4071
- const userInfo = await getLoginUserInfo();
4072
- if (userInfo) {
4073
- setClientSession(userInfo);
4074
- }
4075
- }
4076
4076
  } catch (error) {
4077
4077
  console.error("[useSetupClientSession] \uCD08\uAE30\uD654 \uC2E4\uD328:", error);
4078
4078
  }
4079
4079
  };
4080
4080
  initialize();
4081
4081
  }, [isInitialized, setClientSession]);
4082
+ useEffect(() => {
4083
+ if (!isInitialized || !isLoggedIn) {
4084
+ return;
4085
+ }
4086
+ const loadUserInfo = async () => {
4087
+ console.log("[useSetupClientSession] \uC0AC\uC6A9\uC790 \uD504\uB85C\uD544 \uB85C\uB4DC \uC2DC\uC791...");
4088
+ const userInfo = await getLoginUserInfo();
4089
+ if (userInfo) {
4090
+ setClientSession(userInfo);
4091
+ }
4092
+ };
4093
+ loadUserInfo();
4094
+ }, [isInitialized, isLoggedIn, setClientSession]);
4082
4095
  return isInitialized ?? false;
4083
4096
  };
4084
4097