Skip to content

Commit 3fe7b41

Browse files
authored
Merge pull request #131 from TEAM-COMFIT/dev
[Deploy] 2μ°¨ 배포 πŸš€
2 parents a1fc32b + 0618b65 commit 3fe7b41

222 files changed

Lines changed: 8013 additions & 1247 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€Ž.husky/pre-commitβ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/sh
22

3-
export PATH="/opt/homebrew/bin:$PATH"
4-
53
echo "🐢 Husky pre-commit μ‹€ν–‰"
6-
pnpm exec lint-staged || exit 1
7-
echo "πŸŽ‰ lint-staged 톡과"
4+
pnpm exec lint-staged || exit 1
5+
echo "πŸŽ‰ lint-staged 톡과"

β€Žsrc/app/App.tsxβ€Ž

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
import { Suspense } from "react";
12
import { RouterProvider } from "react-router-dom";
23

4+
import { LoadingPage } from "@/pages/fallback/loading-page";
5+
36
import { router } from "./routes/app-router";
47

58
const App = () => {
6-
return <RouterProvider router={router} />;
9+
return (
10+
<Suspense fallback={<LoadingPage />}>
11+
<RouterProvider router={router} />
12+
</Suspense>
13+
);
714
};
815

916
export default App;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { useEffect } from "react";
2+
import { useLocation } from "react-router-dom";
3+
4+
import { ROUTES } from "@/app/routes/paths";
5+
import { useReportStore } from "@/features/experience-matching/store/report.store";
6+
7+
export const StoreResetListener = () => {
8+
const location = useLocation();
9+
const reset = useReportStore((state) => state.reset);
10+
11+
useEffect(() => {
12+
if (location.pathname !== ROUTES.EXPERIENCE_MATCHING) {
13+
reset();
14+
}
15+
}, [location.pathname, reset]);
16+
17+
return null;
18+
};
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
import { createBrowserRouter } from "react-router-dom";
22

3+
import { NotFoundPage } from "@/pages/fallback/not-found-page";
4+
5+
import AuthGuard from "./auth-guard";
36
import { protectedRoutes } from "./protected-routes";
4-
import { publicRoutes } from "./public-routes";
7+
import { guestRoutes, publicRoutes } from "./public-routes";
58
import { RootLayout } from "./root-layout";
69

10+
// import { useAuthStore } from "../store";
711
export const router = createBrowserRouter([
812
{
913
path: "/",
1014
element: <RootLayout />,
1115
children: [
1216
...publicRoutes,
13-
14-
// TODO: auth에 λ”°λ₯Έ 처리 μΆ”κ°€
15-
...protectedRoutes,
16-
// TODO: paths μ΄μ™Έμ˜ 경둜 μ ‘κ·Ό μ‹œ error 처리
17+
{
18+
element: <AuthGuard type="guest" />,
19+
children: [...guestRoutes],
20+
},
21+
{
22+
element: <AuthGuard type="private" />,
23+
children: [...protectedRoutes],
24+
},
25+
{
26+
path: "*",
27+
element: <NotFoundPage />,
28+
},
1729
],
1830
},
1931
]);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useLocation, Navigate, Outlet } from "react-router-dom";
2+
3+
import { useAuthStore } from "../store";
4+
5+
interface AuthGuardProps {
6+
type?: "private" | "guest";
7+
}
8+
9+
const AuthGuard = ({ type = "private" }: AuthGuardProps) => {
10+
const isLoggedIn = useAuthStore((state) => state.isLoggedIn);
11+
const location = useLocation();
12+
13+
if (location.pathname === "/mypage") return <Outlet />;
14+
15+
// 둜그인이 λ˜μ–΄μžˆμ§€ μ•Šμ€λ° private κ²½λ‘œμ— μ ‘κ·Όν•˜λŠ” 경우 λ§‰μŒ
16+
if (type === "private" && !isLoggedIn) {
17+
return <Navigate to="/login" state={{ from: location }} replace />;
18+
}
19+
20+
// 이미 λ‘œκ·ΈμΈλ˜μ–΄ μžˆλŠ”λ° guest κ²½λ‘œμ— μ ‘κ·Όν•˜λŠ” 경우 λ§‰μŒ
21+
if (type === "guest" && isLoggedIn) {
22+
return <Navigate to="/" replace />;
23+
}
24+
25+
return <Outlet />;
26+
};
27+
28+
export default AuthGuard;

β€Žsrc/app/routes/paths.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const ROUTES = {
22
HOME: "/",
33
LOGIN: "/login",
4-
LOGIN_AUTH: "/oauth/kakao/callback",
4+
LOGIN_AUTH: "/api/v1/oauth/kakao/callback",
55
LANDING: "/landing",
66
ONBOARDING: "/onboarding",
77
COMPANY: (id = ":id") => `/company/${id}`, // κΈ°μ—… 상세

β€Žsrc/app/routes/protected-routes.tsxβ€Ž

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,49 @@
1-
import { ExperiencePage } from "@/pages/experience/experience-page";
2-
import { ExperienceDetailPage } from "@/pages/experience-detail/experience-detail-page";
3-
import { ExperienceMatchingPage } from "@/pages/experience-matching/experience-matching-page";
4-
import { MatchingDetailPage } from "@/pages/matching-detail/matching-detail-page";
5-
import { MatchingListPage } from "@/pages/matching-list/matching-list-page";
6-
import { MyPage } from "@/pages/my-page/my-page";
7-
import { OnboardingPage } from "@/pages/onboarding/onboarding-page";
1+
import { lazy } from "react";
82

93
import { ROUTES } from "./paths";
104

5+
const OnboardingPage = lazy(() =>
6+
import("@/pages/onboarding/onboarding-page").then((module) => ({
7+
default: module.OnboardingPage,
8+
}))
9+
);
10+
11+
const ExperienceMatchingPage = lazy(() =>
12+
import("@/pages/experience-matching/experience-matching-page").then(
13+
(module) => ({ default: module.ExperienceMatchingPage })
14+
)
15+
);
16+
17+
const MatchingListPage = lazy(() =>
18+
import("@/pages/matching-list/matching-list-page").then((module) => ({
19+
default: module.MatchingListPage,
20+
}))
21+
);
22+
23+
const MatchingDetailPage = lazy(() =>
24+
import("@/pages/matching-detail/matching-detail-page").then((module) => ({
25+
default: module.MatchingDetailPage,
26+
}))
27+
);
28+
29+
const ExperiencePage = lazy(() =>
30+
import("@/pages/experience/experience-page").then((module) => ({
31+
default: module.ExperiencePage,
32+
}))
33+
);
34+
35+
const ExperienceDetailPage = lazy(() =>
36+
import("@/pages/experience-detail/experience-detail-page").then((module) => ({
37+
default: module.ExperienceDetailPage,
38+
}))
39+
);
40+
41+
const MyPage = lazy(() =>
42+
import("@/pages/my-page/my-page").then((module) => ({
43+
default: module.MyPage,
44+
}))
45+
);
46+
1147
export const protectedRoutes = [
1248
{ path: ROUTES.ONBOARDING, element: <OnboardingPage /> },
1349
{ path: ROUTES.EXPERIENCE_MATCHING, element: <ExperienceMatchingPage /> },
Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,44 @@
1-
import { CompanyDetailPage } from "@/pages/company-detail/company-detail-page";
2-
import { HomePage } from "@/pages/home/home-page";
3-
import { LandingPage } from "@/pages/landing/landing-page";
4-
import { KakaoLoginPage } from "@/pages/login/kakao-login-page";
5-
import { LoginPage } from "@/pages/login/login-page";
1+
import { lazy } from "react";
62

73
import { ROUTES } from "./paths";
84

9-
export const publicRoutes = [
5+
const LoginPage = lazy(() =>
6+
import("@/pages/login/login-page").then((module) => ({
7+
default: module.LoginPage,
8+
}))
9+
);
10+
11+
const KakaoLoginPage = lazy(() =>
12+
import("@/pages/login/kakao-login-page").then((module) => ({
13+
default: module.KakaoLoginPage,
14+
}))
15+
);
16+
17+
const LandingPage = lazy(() =>
18+
import("@/pages/landing/landing-page").then((module) => ({
19+
default: module.LandingPage,
20+
}))
21+
);
22+
23+
const HomePage = lazy(() =>
24+
import("@/pages/home/home-page").then((module) => ({
25+
default: module.HomePage,
26+
}))
27+
);
28+
29+
const CompanyDetailPage = lazy(() =>
30+
import("@/pages/company-detail/company-detail-page").then((module) => ({
31+
default: module.CompanyDetailPage,
32+
}))
33+
);
34+
35+
export const guestRoutes = [
1036
{ path: ROUTES.LOGIN, element: <LoginPage /> },
1137
{ path: ROUTES.LOGIN_AUTH, element: <KakaoLoginPage /> },
12-
{ path: ROUTES.LANDING, element: <LandingPage /> },
38+
];
1339

40+
export const publicRoutes = [
41+
{ path: ROUTES.LANDING, element: <LandingPage /> },
1442
{ path: ROUTES.HOME, element: <HomePage /> },
1543
{ path: ROUTES.COMPANY(), element: <CompanyDetailPage /> },
1644
];

β€Žsrc/app/routes/root-layout.tsxβ€Ž

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
import { Outlet } from "react-router-dom";
22

3-
import useDevice from "@/shared/model/use-device";
43
import { Header } from "@widgets/index";
54

6-
import { themeVars } from "../styles";
5+
import { StoreResetListener } from "../providers/store-reset-listener";
76

87
export const RootLayout = () => {
9-
const { isMobile } = useDevice();
108
return (
119
<>
10+
<StoreResetListener />
1211
<Header />
13-
<main
14-
style={{
15-
marginTop: !isMobile ? themeVars.height.header : "0",
16-
}}
17-
>
12+
<main>
1813
<Outlet />
1914
</main>
2015
</>

β€Žsrc/app/store/index.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { useAuthStore } from "@shared/model/auth";
1+
export { useAuthStore } from "@/shared/model/store";

0 commit comments

Comments
Β (0)