From 29eca292224489757710ae5014c41a79184e91c1 Mon Sep 17 00:00:00 2001 From: "focp212@naver.com" Date: Mon, 13 Oct 2025 16:03:56 +0900 Subject: [PATCH] test --- .../ui/fund-account/transfer-list-wrap.tsx | 2 +- src/hooks/useAppBridge.tsx | 85 +++---------------- src/shared/ui/assets/css/style-fix.css | 6 ++ src/types/bridge.ts | 1 + src/utils/api.ts | 26 +++++- src/utils/appBridge.ts | 4 + src/widgets/navigation/footer.tsx | 21 ++++- src/widgets/sub-layout/index.tsx | 18 ++++ 8 files changed, 85 insertions(+), 78 deletions(-) diff --git a/src/entities/additional-service/ui/fund-account/transfer-list-wrap.tsx b/src/entities/additional-service/ui/fund-account/transfer-list-wrap.tsx index 839c65a..52f5405 100644 --- a/src/entities/additional-service/ui/fund-account/transfer-list-wrap.tsx +++ b/src/entities/additional-service/ui/fund-account/transfer-list-wrap.tsx @@ -227,7 +227,7 @@ export const FundAccountTransferListWrap = () => { -
+
{ getListDateGroup() }
diff --git a/src/hooks/useAppBridge.tsx b/src/hooks/useAppBridge.tsx index 159ad0b..d2274ca 100644 --- a/src/hooks/useAppBridge.tsx +++ b/src/hooks/useAppBridge.tsx @@ -43,6 +43,7 @@ interface UseAppBridgeReturn { // 토큰 요청 requestToken: () => Promise; + requestRefreshToken: () => Promise; // 간편 인증 등록 registerBiometric: () => Promise; @@ -146,15 +147,6 @@ export const useAppBridge = (): UseAppBridgeReturn => { return appBridge.safeCall(() => appBridge.setStorage(key, value)); }, [isNativeEnvironment]); - /* - const getStorage = useCallback(async (key: string): Promise => { - if (!isNativeEnvironment) { - const item = localStorage.getItem(key); - return item ? JSON.parse(item) : null; - } - return appBridge.safeCall(() => appBridge.getStorage(key), null); - }, [isNativeEnvironment]); - */ const removeStorage = useCallback(async (key: string): Promise => { if (!isNativeEnvironment) { localStorage.removeItem(key); @@ -177,6 +169,13 @@ export const useAppBridge = (): UseAppBridgeReturn => { return appBridge.safeCall(() => appBridge.requestToken()); }, [isNativeEnvironment]); + const requestRefreshToken = useCallback(async (): Promise => { + if (!isNativeEnvironment) { + throw new Error('Token refresh request is only available in native environment'); + } + return appBridge.safeCall(() => appBridge.requestRefreshToken()); + }, [isNativeEnvironment]); + const registerBiometric = useCallback(async (): Promise => { if (!isNativeEnvironment) { throw new Error('Biometric auth is only available in native environment'); @@ -198,72 +197,7 @@ export const useAppBridge = (): UseAppBridgeReturn => { } return appBridge.safeCall(() => appBridge.closeBiometricRegistrationPopup()); }, [isNativeEnvironment]); - - /* - const openCamera = useCallback(async ( - options?: { quality?: number; allowEdit?: boolean } - ): Promise => { - if (!isNativeEnvironment) { - throw new Error('Camera access is only available in native environment'); - } - const result = await appBridge.safeCall(() => appBridge.openCamera(options), ''); - return result || ''; - }, [isNativeEnvironment]); - - const openGallery = useCallback(async ( - options?: { multiple?: boolean; maxCount?: number } - ): Promise => { - if (!isNativeEnvironment) { - throw new Error('Gallery access is only available in native environment'); - } - const result = await appBridge.safeCall(() => appBridge.openGallery(options), []); - return result || []; - }, [isNativeEnvironment]); - - const getLocation = useCallback(async ( - options?: { enableHighAccuracy?: boolean; timeout?: number } - ): Promise => { - if (!isNativeEnvironment) { - // 웹 환경에서는 HTML5 Geolocation API 사용 - return new Promise((resolve, reject) => { - if (!navigator.geolocation) { - reject(new Error('Geolocation is not supported')); - return; - } - - navigator.geolocation.getCurrentPosition( - (position) => { - resolve({ - latitude: position.coords.latitude, - longitude: position.coords.longitude, - accuracy: position.coords.accuracy, - timestamp: position.timestamp - }); - }, - (error) => reject(error), - { - enableHighAccuracy: options?.enableHighAccuracy || false, - timeout: options?.timeout || 10000 - } - ); - }); - } - - const result = await appBridge.safeCall(() => appBridge.getLocation(options)); - if (!result) { - throw new Error('Failed to get location'); - } - return result; - }, [isNativeEnvironment]); - - const getContacts = useCallback(async (): Promise => { - if (!isNativeEnvironment) { - throw new Error('Contact access is only available in native environment'); - } - const result = await appBridge.safeCall(() => appBridge.getContacts(), []); - return result || []; - }, [isNativeEnvironment]); - */ + const shareContent = useCallback(async (content: ShareContent): Promise => { if (!isNativeEnvironment) { // 웹 환경에서는 Web Share API 사용 (지원되는 경우) @@ -318,6 +252,7 @@ export const useAppBridge = (): UseAppBridgeReturn => { shareContent, logout, requestToken, + requestRefreshToken, registerBiometric, openBiometricRegistrationPopup, closeBiometricRegistrationPopup diff --git a/src/shared/ui/assets/css/style-fix.css b/src/shared/ui/assets/css/style-fix.css index b636e3e..3cefecd 100644 --- a/src/shared/ui/assets/css/style-fix.css +++ b/src/shared/ui/assets/css/style-fix.css @@ -130,4 +130,10 @@ main.home-main{ } .menu-category{ position: relative; +} +.date-group{ + margin-bottom: 0; +} +.pb-86{ + padding-bottom: 86px; } \ No newline at end of file diff --git a/src/types/bridge.ts b/src/types/bridge.ts index 32fedd5..0e4fe8f 100644 --- a/src/types/bridge.ts +++ b/src/types/bridge.ts @@ -37,6 +37,7 @@ export enum BridgeMessageType { // 토큰 요청 REQUEST_TOKEN = 'requestToken', + REQUEST_REFRESH_TOKEN = 'requestRefreshToken', // 카메라/갤러리 OPEN_CAMERA = 'openCamera', diff --git a/src/utils/api.ts b/src/utils/api.ts index 5539708..1d31ae6 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -2,6 +2,7 @@ import axios, { AxiosInstance, AxiosResponse, AxiosError, AxiosRequestConfig } f import { ApiResponse, ApiErrorResponse, FileUploadProgress, FileUploadResponse } from '@/types'; import { tokenManager } from './tokenManager'; import config from '@/config'; +import { useAppBridge } from '@/hooks'; class ApiClient { private instance: AxiosInstance; @@ -11,6 +12,9 @@ class ApiClient { reject: (error?: unknown) => void; }> = []; + private isNativeEnvironment: boolean; + private requestRefreshToken: () => Promise; + constructor() { this.instance = axios.create({ baseURL: config.api.baseURL, @@ -21,7 +25,19 @@ class ApiClient { }, }); + /* + + const { + isNativeEnvironment, + openBiometricRegistrationPopup, + requestRefreshToken, + logout + } = useAppBridge(); + this.isNativeEnvironment = isNativeEnvironment; + this.requestRefreshToken = requestRefreshToken; + this.setupInterceptors(); + */ } private setupInterceptors(): void { @@ -57,7 +73,14 @@ class ApiClient { originalRequest._retry = true; this.isRefreshing = true; - + + console.log('refreshToken!!'); + /* + this.requestRefreshToken().then((token) => { + console.log('requestRefreshToken +[' + JSON.stringify(token) + ']' ); + }); + + try { const newToken = await this.refreshAccessToken(); this.processQueue(null, newToken); @@ -72,6 +95,7 @@ class ApiClient { } finally { this.isRefreshing = false; } + */ } return Promise.reject(this.handleError(error)); diff --git a/src/utils/appBridge.ts b/src/utils/appBridge.ts index ced2e42..ee19d73 100644 --- a/src/utils/appBridge.ts +++ b/src/utils/appBridge.ts @@ -157,6 +157,10 @@ class AppBridge { return this.sendMessage(BridgeMessageType.REQUEST_TOKEN); } + async requestRefreshToken(): Promise { + return this.sendMessage(BridgeMessageType.REQUEST_REFRESH_TOKEN); + } + // 공유 관련 async shareContent(content: ShareContent): Promise { return this.sendMessage(BridgeMessageType.SHARE_CONTENT, content); diff --git a/src/widgets/navigation/footer.tsx b/src/widgets/navigation/footer.tsx index 277f9d4..cb0484d 100644 --- a/src/widgets/navigation/footer.tsx +++ b/src/widgets/navigation/footer.tsx @@ -6,6 +6,7 @@ import { FooterItemActiveKey } from '@/entities/common/model/types'; import { useEffect, useState } from 'react'; +import { useAppBridge } from '@/hooks'; export const FooterNavigation = ({ setMenuOn, @@ -14,16 +15,34 @@ export const FooterNavigation = ({ }: FooterProps) => { const { navigate } = useNavigate(); const [isFooterOn, setIsFooterOn] = useState(false); + + const { + isNativeEnvironment, + openBiometricRegistrationPopup, + requestRefreshToken, + logout + } = useAppBridge(); const onClickToNavigate = (path?: string) => { if(!!path){ - navigate(path); + if(path === PATHS.settlement.list){ + callRefresh(); + } + else{ + navigate(path); + } + } }; const onClickToOpenMenu = () => { setFavoriteEdit(false); setMenuOn(true); }; + const callRefresh = () => { + requestRefreshToken().then((token) => { + console.log('requestRefreshToken +[' + JSON.stringify(token) + ']' ); + }); + } const buttonItems = [ { diff --git a/src/widgets/sub-layout/index.tsx b/src/widgets/sub-layout/index.tsx index dc9759e..00ba490 100644 --- a/src/widgets/sub-layout/index.tsx +++ b/src/widgets/sub-layout/index.tsx @@ -119,9 +119,27 @@ export const SubLayout = () => { } setLoginSuccess(true); setHeaderNavigationKey(headerNavigationKey + 1); + + reLogin(); }); }; + + const reLogin = () => { + console.log('reLogin'); + let userInfo = useStore.getState().UserStore.userInfo; + if(userInfo.accessTokenExpiresIn){ + let accessTokenExpiresIn = userInfo.accessTokenExpiresIn; + let timer = setTimeout(() => { + if(isNativeEnvironment){ + handleRequestToken(); + } + else{ + handleLogin(); + } + }, accessTokenExpiresIn * 1000); + } + }; const handleLogin = useCallback(async () => { const userParmas = {