diff --git a/.gitignore b/.gitignore index 4d29575..eab411a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ # misc .DS_Store -.env.local +.env .env.development.local .env.test.local .env.production.local diff --git a/package.json b/package.json index 3f00b82..f77f02a 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@testing-library/user-event": "^14.5.1", "polished": "^4.2.2", "react": "^18.2.0", + "react-cookie": "^6.1.1", "react-dom": "^18.2.0", "react-icons": "^4.12.0", "react-responsive": "^9.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 382e31c..e86dc35 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ dependencies: react: specifier: ^18.2.0 version: 18.2.0 + react-cookie: + specifier: ^6.1.1 + version: 6.1.1(react@18.2.0) react-dom: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) @@ -2231,6 +2234,10 @@ packages: dependencies: '@types/node': 20.9.0 + /@types/cookie@0.5.4: + resolution: {integrity: sha512-7z/eR6O859gyWIAjuvBWFzNURmf2oPBmJlfVWkwehU5nzIyjwBsTh7WMmEEV4JFnHuQ3ex4oyTvfKzcyJVDBNA==} + dev: false + /@types/eslint-scope@3.7.7: resolution: {integrity: sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==} dependencies: @@ -2270,6 +2277,13 @@ packages: dependencies: '@types/node': 20.9.0 + /@types/hoist-non-react-statics@3.3.5: + resolution: {integrity: sha512-SbcrWzkKBw2cdwRTwQAswfpB9g9LJWfjtUeW/jvNwbhC8cpmmNYVePa+ncbUe0rGTQ7G3Ff6mYUN2VMfLVr+Sg==} + dependencies: + '@types/react': 18.2.37 + hoist-non-react-statics: 3.3.2 + dev: false + /@types/html-minifier-terser@6.1.0: resolution: {integrity: sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==} @@ -5009,6 +5023,12 @@ packages: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true + /hoist-non-react-statics@3.3.2: + resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==} + dependencies: + react-is: 16.13.1 + dev: false + /hoopy@0.1.4: resolution: {integrity: sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==} engines: {node: '>= 6.0.0'} @@ -7598,6 +7618,17 @@ packages: semver: 5.7.2 dev: true + /react-cookie@6.1.1(react@18.2.0): + resolution: {integrity: sha512-fuFRpf8LH6SfmVMowDUIRywJF5jAUDUWrm0EI5VdXfTl5bPcJ7B0zWbuYpT0Tvikx7Gs18MlvAT+P+744dUz2g==} + peerDependencies: + react: '>= 16.3.0' + dependencies: + '@types/hoist-non-react-statics': 3.3.5 + hoist-non-react-statics: 3.3.2 + react: 18.2.0 + universal-cookie: 6.1.1 + dev: false + /react-dev-utils@12.0.1(eslint@8.53.0)(typescript@5.3.2)(webpack@5.89.0): resolution: {integrity: sha512-84Ivxmr17KjUupyqzFode6xKhjwuEJDROWKJy/BthkL7Wn6NJ8h4WE6k/exAv6ImS+0oZLRRW5j/aINMHyeGeQ==} engines: {node: '>=14'} @@ -8928,6 +8959,13 @@ packages: dependencies: crypto-random-string: 2.0.0 + /universal-cookie@6.1.1: + resolution: {integrity: sha512-33S9x3CpdUnnjwTNs2Fgc41WGve2tdLtvaK2kPSbZRc5pGpz2vQFbRWMxlATsxNNe/Cy8SzmnmbuBM85jpZPtA==} + dependencies: + '@types/cookie': 0.5.4 + cookie: 0.5.0 + dev: false + /universalify@0.2.0: resolution: {integrity: sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==} engines: {node: '>= 4.0.0'} diff --git a/src/api/cookie.js b/src/api/cookie.js new file mode 100644 index 0000000..f4759c3 --- /dev/null +++ b/src/api/cookie.js @@ -0,0 +1,15 @@ +import { Cookies } from 'react-cookie'; + +const cookies = new Cookies(); + +export const setCookie = (key, value) => { + cookies.set(key, value, { path: '/' }); +}; + +export const getCookie = (key) => { + return cookies.get(key); +}; + +export const removeCookie = (key) => { + cookies.remove(key, { path: '/' }); +}; \ No newline at end of file diff --git a/src/component/login/LoginTemplate.jsx b/src/component/login/LoginTemplate.jsx index c8b48ac..df34219 100644 --- a/src/component/login/LoginTemplate.jsx +++ b/src/component/login/LoginTemplate.jsx @@ -6,53 +6,52 @@ import googleLogo from '../resource/logo_google.png'; import WhiteBox from './WhiteBox' -function LoginTemplate () { - //추후 api 변경 시 같이 변경하기 - const login = ({socialtype}) => { - try { - window.location.replace( - import.meta.env.REACT_APP_BE_HOST + `/api/v1/auth/login/oauth-types/${socialtype}`, - ); - } catch (error) { - console.error("유효하지 않은 URL입니다!", error); - } - }; +function LoginTemplate() { + const login = (socialtype) => { + try { + window.location.replace( + `${process.env.REACT_APP_BE_HOST}/api/v1/auth/login/oauth-types/${socialtype}` + ); + } catch (error) { + console.error("유효하지 않은 URL입니다!", error); + } + }; - return ( - //align-items: center -> 적용이 안되는 문제로 우선 삭제 -