Skip to content
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
14 changes: 14 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"react-dom": "^19.2.0",
"react-router-dom": "^7.11.0",
"react-spinners": "^0.17.0",
"react-toastify": "^11.0.5",
"tailwind-merge": "^3.4.0",
"tailwindcss": "^4.1.18",
"vite-plugin-svgr": "^4.5.0",
Expand Down
13 changes: 12 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import { RouterProvider } from "react-router-dom";
import router from "./routes";
import { Slide, ToastContainer } from "react-toastify";

function App() {
return (
<div className="w-full min-h-dvh mx-auto overflow-y-auto bg-bgPrimary">
<main className=" max-w-480 mx-auto px-14 ">
<main className="">
<RouterProvider router={router} />
</main>
<ToastContainer
position="top-center"
autoClose={1000}
toastClassName={() =>
"flex items-center justify-between p-4 px-8 rounded-lg bg-white text-black shadow-md"
}
progressClassName={"bg-red-500"}
hideProgressBar={true}
transition={Slide}
/>
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/assets/icons/alert2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/layout/OnboardingLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import clsx from "clsx";
export const OnboardingLayout = () => {
const { pathname } = useLocation();
return (
<div className=" min-h-screen flex flex-col items-center pt-7">
<div className=" min-h-screen flex flex-col items-center pt-7 max-w-480 mx-auto px-14">
<Header className={clsx(pathname === "/login" ? "pb-24" : "pb-2")} />
<Outlet />
</div>
Expand Down
12 changes: 8 additions & 4 deletions src/layout/SystemLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import { SystemHeader } from "../shared/SystemHeader";

export const SystemLayout = () => {
return (
<div className=" min-h-screen flex flex-col ">
<SystemHeader />
<Outlet />
</div>
<>
<div className="w-full bg-white">
<SystemHeader />
</div>
<div className="max-w-480 mx-auto px-14 min-h-screen bg-bgPrimary items-center">
<Outlet />
</div>
</>
);
};
6 changes: 4 additions & 2 deletions src/lib/my.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {
useMutation,
useQuery,
useQueryClient,
useSuspenseQuery,
} from "@tanstack/react-query";
Expand All @@ -20,11 +21,12 @@ export const getMyProfile = async () => {
return data;
};

export const useGetMyProfile = () => {
return useSuspenseQuery({
export const useGetMyProfile = (enabled?: boolean) => {
return useQuery({
queryKey: ["my", "profile"],
queryFn: getMyProfile,
select: res => res.data,
enabled,
});
};

Expand Down
11 changes: 4 additions & 7 deletions src/lib/recommendation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
useMutation,
useQueryClient,
useSuspenseQuery,
} from "@tanstack/react-query";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import api from "./api";

//추천 게시글 조회
Expand All @@ -11,11 +7,12 @@ export const getRecommendPostList = async () => {
return data;
};

export const useGetRecommendPostList = () => {
return useSuspenseQuery({
export const useGetRecommendPostList = (isLogin: boolean) => {
return useQuery({
queryKey: ["posts", "my", "recommend"],
queryFn: getRecommendPostList,
select: res => res.data,
enabled: isLogin,
});
};

Expand Down
8 changes: 7 additions & 1 deletion src/pages/Login/KakaoLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { useEffect } from "react";
import { useNavigate, useSearchParams } from "react-router-dom";
import useUserStore from "../../store/useUserStore";
import { useOnboardingStore } from "../../store/useOnboardingStore";
import { toast } from "react-toastify";
import Alert from "@/assets/icons/alert2.svg";

export const KakaoLogin = () => {
const [searchParams] = useSearchParams();
Expand All @@ -13,10 +15,14 @@ export const KakaoLogin = () => {
const token = searchParams.get("token");
const isMember = searchParams.get("registered");
const email = searchParams.get("email") ?? undefined;
console.log(email);
// console.log(email);
setTemp({ email });
setUser({ accessToken: token, isNewMember: isMember });
if (!token) {
toast.info("로그인에 실패했어요. 다시 로그인해 주세요.", {
icon: <img src={Alert} alt="login으로 이동" />,
});

navigate("/login");
}
if (isMember === "false") {
Expand Down
31 changes: 15 additions & 16 deletions src/pages/home/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
import { TabSelectList } from "./components/TabSelectList";
import { CompanyFilterList } from "./components/CompanyFilterList";
import { InterestFilterList } from "./components/InterestFilterList";
import { PostCardList } from "./components/PostCardList";
import { Suspense, useState } from "react";
import { useCompanyStore } from "../../store/uesCompanyStore";
import { useGetCompany } from "../../lib/company";
import { useGetMyInterest } from "../../lib/my";
import { usePostRecommendPostList } from "../../lib/recommendation";
import { TAB_MAP } from "../../constants/tab";
import { Loading } from "../../shared/Loading";
import { useNavigate, useSearchParams } from "react-router-dom";
import { useDebounce } from "../../hooks/useDebouce";
import { SearchPostList } from "./components/SearchPostList";
import useUserStore from "../../store/useUserStore";
import { toast } from "react-toastify";
import Alert from "@/assets/icons/alert2.svg";
import { SkeletonList } from "../../shared/SkeletonList";
import { InterestPage } from "./components/InterestPage";
export const HomePage = () => {
const [selectedTab, setSelectedTab] = useState(0);
const [modal, setModal] = useState(false);
const { companies, toggleCompany } = useCompanyStore();

const { data: companyData } = useGetCompany();
const { data: myInterest } = useGetMyInterest();
const { mutate: postRecommendList, isPending: isRefreshing } =
usePostRecommendPostList();

const maxCompany = companyData?.companies.slice(0, 8) ?? [];

const [searchParams] = useSearchParams();
const searchQuery = searchParams.get("search");
console.log(searchQuery);
// console.log(searchQuery);
const debouncedInput = useDebounce(searchQuery, 200);
const { user } = useUserStore();
const isLogin = !!user?.accessToken;
const navigate = useNavigate();
const handleTabChange = (tab: number) => {
if (tab === 1 && !isLogin) {
toast.info("로그인이 필요한 서비스입니다.", {
icon: <img src={Alert} alt="login으로 이동" />,
});
navigate("/login");
return;
}
Expand All @@ -42,6 +46,7 @@ export const HomePage = () => {

return (
<div className="bg-bgPrimary py-12 " onClick={() => setModal(false)}>
{/* <SkeletonCard /> */}
{debouncedInput && debouncedInput.trim() !== "" ? (
<Suspense fallback={<Loading />}>
<SearchPostList query={debouncedInput ?? ""} />
Expand Down Expand Up @@ -69,21 +74,15 @@ export const HomePage = () => {
</>
)}
{/* 나와맞는 게시글 */}
{selectedTab === 1 && (
<>
<InterestFilterList
myInterest={myInterest}
{selectedTab === 1 && isLogin && (
<Suspense fallback={<SkeletonList />}>
<InterestPage
onRefresh={postRecommendList}
isRefreshing={isRefreshing}
/>
{isRefreshing ? (
<Loading />
) : (
<Suspense fallback={<Loading />}>
<PostCardList selectedTab={1} />
</Suspense>
)}
</>
</Suspense>
)}

{(selectedTab === 2 || selectedTab === 3) && (
<PostCardList selectedTab={selectedTab} />
)}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/components/CompaniesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const CompaniesModal = ({ companyData }: CompaniesModalProps) => {
}
}, [companies]);

console.log(companies);
// console.log(companies);
return (
<section
className="relative h-130 w-125 shadow-ds100 rounded-2xl overflow-hidden bg-white z-250"
Expand Down
27 changes: 27 additions & 0 deletions src/pages/home/components/InterestPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { useGetMyInterest } from "../../../lib/my";
import { SkeletonList } from "../../../shared/SkeletonList";
import { InterestFilterList } from "./InterestFilterList";
import { PostCardList } from "./PostCardList";

interface InterestPageProps {
onRefresh: () => void;
isRefreshing: boolean;
}

export const InterestPage = ({
onRefresh,
isRefreshing,
}: InterestPageProps) => {
const { data: myInterest } = useGetMyInterest();

return (
<>
<InterestFilterList myInterest={myInterest} onRefresh={onRefresh} />
{isRefreshing ? (
<SkeletonList /> // 반복되는 Skeleton UI는 별도 컴포넌트로 빼면 깔끔합니다.
) : (
<PostCardList selectedTab={1} />
)}
</>
);
};
7 changes: 5 additions & 2 deletions src/pages/home/components/PostCardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useGetRecommendPostList } from "../../../lib/recommendation";
import type { CardItemProps, PostResponseDto } from "../../../types/post";
import { CardItem } from "../../../shared/CardItem";
import { Loading } from "../../../shared/Loading";
import useUserStore from "../../../store/useUserStore";

interface PostCardListProps {
selectedTab: number;
Expand All @@ -18,7 +19,9 @@ export const PostCardList = ({ selectedTab }: PostCardListProps) => {
const companyQuery = useInfiniteCompaniesPosts({ companies });
const recentQuery = useInfinitePosts({ sortBy: "LATEST" });
const popularQuery = useInfinitePosts({ sortBy: "POPULAR" });
const { data: recommendData } = useGetRecommendPostList();
const { user } = useUserStore();
const isLogin = !!user?.accessToken;
const { data: recommendData } = useGetRecommendPostList(isLogin);

const activeQuery = [companyQuery, null, recentQuery, popularQuery][
selectedTab
Expand All @@ -45,7 +48,7 @@ export const PostCardList = ({ selectedTab }: PostCardListProps) => {
(page: PostResponseDto) => page.data.posts,
) ?? []);

console.log(posts);
// console.log(posts);

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/components/SearchPostList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const SearchPostList = ({ query }: SearchPostListProps) => {
return <div className="py-20 text-center">검색 결과가 없습니다.</div>;
}

console.log(searchData);
// console.log(searchData);
return (
<div>
<ul className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-4 mt-10">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/components/TabSelectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const TabSelectList = ({
tagList,
}: TabSelectList) => {
return (
<div className={clsx("flex justify-start", className)}>
<div className={clsx("flex justify-start gap-2", className)}>
{tagList.map((item, idx) => {
return (
<TabBtn
Expand Down
2 changes: 1 addition & 1 deletion src/pages/mypage/MyInterstListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const MyIntersListPage = () => {

const posts = data?.flatMap(page => page.data.bookmarks) ?? [];

console.log(posts);
// console.log(posts);

return (
<div className="py-12">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/mypage/SettingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const SettingPage = () => {
},
];
const { data: user } = useGetMyProfile();
console.log(user);
// console.log(user);
return (
<div className="px-20 pb-8">
<section className="mt-16 mb-8 bg-white p-8 rounded-xl border border-bgNormal">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/mypage/components/ProfileEditHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ProfileEditHeader = ({

const [name, setName] = useState(nickName);
const [introduce, setIntroduce] = useState(description);
console.log(name, introduce);
// console.log(name, introduce);

return (
<div>
Expand Down
2 changes: 0 additions & 2 deletions src/pages/onboarding/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export const Onboarding = () => {
};
const isNicknameValid = nickname.length >= 2;
const BtnAble = !isNicknameValid || !check;
console.log(BtnAble, "버튼");
console.log(email);

return (
<div className=" ">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/onboarding/OnboardingTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const OnboardingTag = () => {
});
};

console.log(tag);
// console.log(tag);

return (
<div className="flex flex-col items-center">
Expand Down
Loading