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

✨ 액세스 토큰 추가 #16

Merged
merged 6 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
.eslintrc.cjs
mocks
mocks
index.d.ts
10 changes: 10 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
declare module '*.svg' {
const content: React.FC<React.SVGProps<SVGElement>>;
export default content;
}

export declare global {
interface Window {
setAccessToken: (accessToken: string) => void;
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"axios": "^1.6.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "6.22.2"
"react-router-dom": "6.22.2",
"zustand": "^4.5.2"
},
"devDependencies": {
"@tanstack/eslint-plugin-query": "^5.28.11",
Expand Down
5 changes: 5 additions & 0 deletions src/app/webview/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { setAccessToken } from '@/shared/store';

export function initWebViewInfo() {
window.setAccessToken = setAccessToken;
}
2 changes: 2 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ReactDOM from 'react-dom/client';

import App from './app/App';
import { initWebViewInfo } from './app/webview';

async function enableMocking() {
if (import.meta.env.PROD) {
Expand All @@ -13,5 +14,6 @@ async function enableMocking() {
}

enableMocking().then(() => {
initWebViewInfo();
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
});
23 changes: 23 additions & 0 deletions src/shared/store/auth/auth-store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { create } from 'zustand';
import { devtools } from 'zustand/middleware';

interface AuthState {
accessToken: string | undefined;
}

const useAuthStore = create<AuthState>()(
devtools(
(): AuthState => ({
accessToken: undefined,
}),
{ name: 'auth-store' },
),
);

export function setAccessToken(accessToken: string) {
useAuthStore.setState(() => ({ accessToken }), false, 'auth/setAccessToken');
}

export function getAccessToken() {
return useAuthStore.getState().accessToken;
}
1 change: 1 addition & 0 deletions src/shared/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { setAccessToken, getAccessToken } from './auth/auth-store';
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"@public/*": ["public/*"]
}
},
"include": ["src"],
"include": ["src", "index.d.ts"],
"references": [{ "path": "./tsconfig.node.json" }]
}
27 changes: 12 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1677,11 +1677,6 @@ emoji-regex@^10.3.0:
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-10.3.0.tgz#76998b9268409eb3dae3de989254d456e70cfe23"
integrity sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==

emoji-regex@^10.3.0:
version "10.3.0"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-10.3.0.tgz#76998b9268409eb3dae3de989254d456e70cfe23"
integrity sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==

emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
Expand Down Expand Up @@ -2786,16 +2781,6 @@ json5@^2.2.3:
object.assign "^4.1.4"
object.values "^1.1.6"

"jsx-ast-utils@^2.4.1 || ^3.0.0":
version "3.3.5"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz#4766bd05a8e2a11af222becd19e15575e52a853a"
integrity sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==
dependencies:
array-includes "^3.1.6"
array.prototype.flat "^1.3.1"
object.assign "^4.1.4"
object.values "^1.1.6"

keyv@^4.5.3:
version "4.5.4"
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93"
Expand Down Expand Up @@ -4056,6 +4041,11 @@ url-parse@^1.5.3:
querystringify "^2.1.1"
requires-port "^1.0.0"

[email protected]:
version "1.2.0"
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a"
integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==

[email protected]:
version "1.5.0"
resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-1.5.0.tgz#7f74dadfecb15bca016c5ce5ef85e5cc4b82abf2"
Expand Down Expand Up @@ -4295,3 +4285,10 @@ yocto-queue@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.0.0.tgz#7f816433fb2cbc511ec8bf7d263c3b58a1a3c251"
integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==

zustand@^4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.5.2.tgz#fddbe7cac1e71d45413b3682cdb47b48034c3848"
integrity sha512-2cN1tPkDVkwCy5ickKrI7vijSjPksFRfqS6237NzT0vqSsztTNnQdHw9mmN7uBdk3gceVXU0a+21jFzFzAc9+g==
dependencies:
use-sync-external-store "1.2.0"
Loading