Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 웹뷰 브릿지 추가 및 웹뷰 공연 생성 대응 #254

Merged
merged 36 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5f43237
feat: 웹뷰 브릿지 작업을 위한 패키지 추가 및 초기 설정
alstn2468 Nov 6, 2024
8bde7fc
Merge branch 'develop' into feat/webview-bridge
alstn2468 Dec 7, 2024
53e1d64
feat: 브릿지 함수 정의 추가
alstn2468 Dec 7, 2024
5af8091
fix: 파일 확장자 수정
alstn2468 Dec 7, 2024
1401bd1
chore: 웹뷰 테스트용 버튼 추가
alstn2468 Dec 7, 2024
b06027f
feat: 안드로이드에서도 함수이름 하나로 통합
alstn2468 Dec 7, 2024
21e557b
feat: 안드로이드에서 문자열로 바꿔서 전달
alstn2468 Dec 7, 2024
220b8a1
feat: sendCommand 도 다시 추가
alstn2468 Dec 7, 2024
b7856f6
feat: 메서드 이름 postMessage로 변경
alstn2468 Dec 7, 2024
77a2413
feat: 데이터 받았을 때 얼럿 추가
alstn2468 Dec 7, 2024
0568ea1
feat: 토큰 갱신도 호출
alstn2468 Dec 7, 2024
d04384f
refac: 브릿지 코드 리팩토링
alstn2468 Dec 11, 2024
3d9d974
feat: vConsole 초기화 코드 추가
alstn2468 Dec 11, 2024
516c47f
feat: 로깅 코드 추가
alstn2468 Dec 11, 2024
22fc0d7
feat: 로깅 개선
alstn2468 Dec 11, 2024
c499d10
feat: 웹뷰 브릿지 코드 뜯어고침
alstn2468 Dec 11, 2024
9a5fd8b
chore: 중복 상수 제거
alstn2468 Dec 11, 2024
760c58e
refac: 함수 분리 작업 추가
alstn2468 Dec 11, 2024
e110611
feat: 타임아웃 및 웹뷰 아닐 떄 에러 로깅 추가
alstn2468 Dec 11, 2024
dcd94b7
feat: 논 널 어썰션 제거 및 함수 주입 수정
alstn2468 Dec 11, 2024
3311da9
feat: 에러로깅 수정
alstn2468 Dec 11, 2024
4b4f603
chore: 불필요 상수 제거
alstn2468 Dec 11, 2024
b6ad757
fix: 상수 및 브릿지 함수 초기화 코드 복구
alstn2468 Dec 14, 2024
82e70ca
chore: 유틸 함수 폴더 통일
alstn2468 Dec 14, 2024
6f2e5f9
feat: 웹뷰일 때 토큰 갱신 로직 추가
alstn2468 Dec 14, 2024
93ab66d
feat: 공연 생성 이후 이동 로직 추가
alstn2468 Dec 14, 2024
345f014
feat: 에러 처리 보강 및 쿠키 기반 제거
alstn2468 Dec 15, 2024
971e3e0
feat: 웹에서 역직렬화 로젝 제거
alstn2468 Dec 15, 2024
3da2663
fix: 대소문자 이슈로 에러 인스턴스 이른 수정
alstn2468 Dec 15, 2024
b0ad3bf
fix: 웹뷰일 때 로그인 체크 제거
alstn2468 Dec 15, 2024
ac88133
fix: 린트 경고 수정
alstn2468 Dec 15, 2024
09cbd33
fix: max-warnings 옵션 제거
alstn2468 Dec 15, 2024
f3eb376
feat: 공연 생성 이후 뒤로간 다음에 상세 이동
alstn2468 Dec 15, 2024
bd7528e
feat: 웹뷰 테스트용 버튼 제거 및 홈 이동 호출 제거
alstn2468 Dec 31, 2024
2816474
Merge branch 'develop' into feat/webview-bridge
alstn2468 Dec 31, 2024
8309887
fix: 타입 오류 수정
alstn2468 Dec 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 102 additions & 10 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
- `packages/config-typescript`: 각 패키지에서 공통적으로 사용될 TypeScript 관련 설정이 포함된 패키지입니다.
- `packages/icon`: 공통적으로 사용될 아이콘 컴포넌트가 포함된 패키지입니다.
- `packages/ui`: 공통적으로 사용될 디자인 컴포넌트가 포함된 패키지입니다.
- `packages/ui`: 공통적으로 사용될 웹뷰 브릿지가 포함된 패키지입니다.
8 changes: 5 additions & 3 deletions apps/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives",
"lint:fix": "TIMING=1 eslint . --ext ts,tsx --fix",
"type-check": "tsc --noEmit",
"preview": "vite preview"
},
"dependencies": {
"@boolti/api": "*",
"@boolti/bridge": "*",
"@boolti/icon": "*",
"@boolti/ui": "*",
"@dnd-kit/core": "^6.1.0",
Expand All @@ -27,21 +28,22 @@
"date-fns": "^3.3.1",
"framer-motion": "^11.2.10",
"jotai": "^2.8.3",
"js-cookie": "^3.0.5",
"jwt-decode": "^4.0.0",
"lodash.debounce": "^4.0.8",
"qrcode.react": "^3.1.0",
"react": "^18.2.0",
"react-daum-postcode": "^3.1.3",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-error-boundary": "^4.1.2",
"react-hook-form": "^7.50.0",
"react-intersection-observer": "^9.8.0",
"react-pdf": "^9.0.0",
"react-router-dom": "^6.21.3",
"react-select": "^5.8.0",
"react-tooltip": "^5.26.3",
"the-new-css-reset": "^1.11.2"
"the-new-css-reset": "^1.11.2",
"vconsole": "^3.15.1"
},
"devDependencies": {
"@boolti/eslint-config": "*",
Expand Down
6 changes: 5 additions & 1 deletion apps/admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ import ShowTicketPage from './pages/ShowTicketPage';
import ShowReservationPage from './pages/ShowReservationPage';
import ShowSettlementPage from './pages/ShowSettlementPage';
import ShowEnterancePage from './pages/ShowEnterancePage';
import { initVConsole } from './utils/vConsole';
import { checkIsWebView } from '@boolti/bridge';

setDefaultOptions({ locale: ko });

initVConsole();

const publicRoutes = [
{
element: (
Expand Down Expand Up @@ -97,7 +101,7 @@ const publicRoutes = [
const PrivateRoute = () => {
const { isLogin } = useAuthAtom();

if (!isLogin()) {
if (!isLogin() && !checkIsWebView()) {
return <Navigate to={PATH.LOGIN} replace />;
}

Expand Down
68 changes: 3 additions & 65 deletions apps/admin/src/atoms/useAuthAtom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import Cookies from 'js-cookie';
import { LOCAL_STORAGE, COOKIES } from '@boolti/api';
import { LOCAL_STORAGE } from '@boolti/api';
import { atom, useAtom } from 'jotai';
import { useEffect } from 'react';

const storageMethod = {
getItem: (key: string, initialValue: string | null) => {
Expand All @@ -15,41 +13,9 @@ const storageMethod = {
},
};

const accessTokenAtom = atom<string | null>(
(() => {
const accessTokenFromCookie = Cookies.get(COOKIES.ACCESS_TOKEN);
const accessTokenFromStorage = storageMethod.getItem(LOCAL_STORAGE.ACCESS_TOKEN, null);
const accessTokenAtom = atom<string | null>(null);

if (accessTokenFromCookie) {
localStorage.setItem(LOCAL_STORAGE.ACCESS_TOKEN, accessTokenFromCookie);
return accessTokenFromCookie;
}

if (accessTokenFromStorage) {
return accessTokenFromStorage;
}

return null;
})(),
);

const refreshTokenAtom = atom<string | null>(
(() => {
const refreshTokenFromCookie = Cookies.get(COOKIES.ACCESS_TOKEN);
const refreshTokenFromStorage = storageMethod.getItem(LOCAL_STORAGE.REFRESH_TOKEN, null);

if (refreshTokenFromCookie) {
localStorage.setItem(LOCAL_STORAGE.REFRESH_TOKEN, refreshTokenFromCookie);
return refreshTokenFromCookie;
}

if (refreshTokenFromStorage) {
return refreshTokenFromStorage;
}

return null;
})(),
);
const refreshTokenAtom = atom<string | null>(null);

export const useAuthAtom = () => {
const [accessToken, setAccessToken] = useAtom(accessTokenAtom);
Expand All @@ -65,40 +31,12 @@ export const useAuthAtom = () => {
const removeToken = () => {
storageMethod.removeItem(LOCAL_STORAGE.ACCESS_TOKEN);
storageMethod.removeItem(LOCAL_STORAGE.REFRESH_TOKEN);
Cookies.remove(COOKIES.ACCESS_TOKEN);
Cookies.remove(COOKIES.REFRESH_TOKEN);
setAccessToken(null);
setRefreshToken(null);
};

const isLogin = () => !!accessToken && !!refreshToken;

useEffect(() => {
const handler = ({ key, newValue }: StorageEvent) => {
switch (key) {
case LOCAL_STORAGE.ACCESS_TOKEN: {
setAccessToken(newValue);
newValue
? Cookies.set(COOKIES.ACCESS_TOKEN, newValue)
: Cookies.remove(COOKIES.ACCESS_TOKEN);
return;
}
case LOCAL_STORAGE.REFRESH_TOKEN: {
setRefreshToken(newValue);
newValue
? Cookies.set(COOKIES.REFRESH_TOKEN, newValue)
: Cookies.remove(COOKIES.REFRESH_TOKEN);
return;
}
}
};
window.addEventListener('storage', handler);

return () => {
window.removeEventListener('storage', handler);
};
}, [setAccessToken, setRefreshToken]);

return {
setToken,
removeToken,
Expand Down
Loading
Loading