diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 854cdff7..89873c3d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -10,6 +10,8 @@ env: VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VITE_API_URL: ${{ secrets.VITE_API_URL }} + VITE_DEMO_EMAIL: ${{ secrets.VITE_DEMO_EMAIL }} + VITE_DEMO_PASSWORD: ${{ secrets.VITE_DEMO_PASSWORD }} jobs: Vercel-Deploy : @@ -21,6 +23,8 @@ jobs: - name: Create .env run: | echo "VITE_API_URL=$VITE_API_URL" > .env + echo "VITE_DEMO_EMAIL=$VITE_DEMO_EMAIL" >> .env + echo "VITE_DEMO_PASSWORD=$VITE_DEMO_PASSWORD" >> .env - name: Vercel pull (prod) run: npx vercel pull --yes --environment=production --token=$VERCEL_TOKEN diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5581e79..58584b6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ env: VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VITE_API_URL: ${{ secrets.VITE_API_URL }} + VITE_DEMO_EMAIL : ${{ secrets.VITE_DEMO_EMAIL }} + VITE_DEMO_PASSWORD: ${{ secrets.VITE_DEMO_PASSWORD }} jobs: Test-And-Build: @@ -88,6 +90,8 @@ jobs: - name: Create .env run: | echo "VITE_API_URL=$VITE_API_URL" > .env + echo "VITE_DEMO_EMAIL=$VITE_DEMO_EMAIL" >> .env + echo "VITE_DEMO_PASSWORD=$VITE_DEMO_PASSWORD" >> .env - name: Run build run: npm run build @@ -104,6 +108,8 @@ jobs: - name: Create .env run: | echo "VITE_API_URL=$VITE_API_URL" > .env + echo "VITE_DEMO_EMAIL=$VITE_DEMO_EMAIL" >> .env + echo "VITE_DEMO_PASSWORD=$VITE_DEMO_PASSWORD" >> .env - name: Vercel pull (preview) run: npx vercel pull --yes --environment=preview --token=$VERCEL_TOKEN diff --git a/src/features/auth/pages/LoginPage.tsx b/src/features/auth/pages/LoginPage.tsx index ed8a12e5..e0fbfeb5 100644 --- a/src/features/auth/pages/LoginPage.tsx +++ b/src/features/auth/pages/LoginPage.tsx @@ -1,10 +1,10 @@ -import React, { useState, useContext } from 'react'; +import { useState, useContext, type SyntheticEvent } from 'react'; import { AuthContext } from '@/AuthContext.ts'; import { useNavigate } from 'react-router-dom'; -import { login } from '../api/auth.api.ts'; import { useAuthedClient } from '@shared/hooks/useAuthClient.ts'; import AuthShell from '@features/auth/components/AuthShell.tsx'; import { useAlertStore } from '@shared/store/useAlertStore.ts'; +import { login } from '@features/auth/api/auth.api.ts'; export default function LoginPage() { const { setToken } = useContext(AuthContext); @@ -14,12 +14,7 @@ export default function LoginPage() { const openAlertModal = useAlertStore((s) => s.action.openAlertModal); - const onSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - setSubmitting(true); // 중복 클릭을 방지 - const form = new FormData(e.target as HTMLFormElement); - const email = String(form.get('email') || ''); // 비어 있으면 공백 문자열 - const password = String(form.get('password') || ''); + const fetchLogin = async (email: string, password: string) => { try { const result = await login({ email, password }, client); // 서버에서 accessToken을 받기 setToken(result.accessToken, result.refreshToken); @@ -35,6 +30,26 @@ export default function LoginPage() { } }; + const demoLogin = async () => { + setSubmitting(true); + + const email = import.meta.env.VITE_DEMO_EMAIL as string; + const password = import.meta.env.VITE_DEMO_PASSWORD as string; + await fetchLogin(email, password); + }; + + const onSubmit = async (e: SyntheticEvent) => { + e.preventDefault(); + + setSubmitting(true); + const form = new FormData(e.target as HTMLFormElement); + + const email = String(form.get('email') || ''); // 비어 있으면 공백 문자열 + const password = String(form.get('password') || ''); + + await fetchLogin(email, password); + }; + return (
- {/* 입력 필드 그룹 */}
- {/* 이메일 */}
- {/* 비밀번호 */}
- {/* 로그인 버튼 */} - + + {submitting ? '로그인 중...' : '로그인'} + + + + - {/* 하단 링크 */}
diff --git a/src/features/dashboard/container/LongViewContainer.tsx b/src/features/dashboard/container/LongViewContainer.tsx index 3bac7998..5ac143c7 100644 --- a/src/features/dashboard/container/LongViewContainer.tsx +++ b/src/features/dashboard/container/LongViewContainer.tsx @@ -11,7 +11,7 @@ export default function LongViewContainer({ }: { title: string; description: string; - detailUrl: string; + detailUrl?: string; className?: string; children: ReactNode; }) { @@ -22,7 +22,7 @@ export default function LongViewContainer({ className )} > - + {detailUrl && }

{title}

{description}

diff --git a/src/lib/utils/authRequest.ts b/src/lib/utils/authRequest.ts index 695eb4d7..62067ea1 100644 --- a/src/lib/utils/authRequest.ts +++ b/src/lib/utils/authRequest.ts @@ -96,6 +96,7 @@ export async function authRequest( } catch (err: any) { if (err.name === 'AbortError') return null; console.error(err.message ?? err); + setToken('', ''); throw err; } }