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

[김보경] week20 #1074

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7957f20
feat: next.js 패키지를 설치 하였습니다
bokeeeey May 5, 2024
02c202a
feat: classNames 라이브러리를 설치 하였습니다
bokeeeey May 5, 2024
29f134c
feat: sass 라이브러리를 설치 하였습니다
bokeeeey May 5, 2024
4b9f084
feat: RootLayout을 생성하였습니다
bokeeeey May 5, 2024
6f48abd
feat: landing layout의 header를 구현 하였습니다
bokeeeey May 5, 2024
bd90151
feat: Landing Page를 제작 하였습니다
bokeeeey May 6, 2024
5a65de4
feat: 로그인 회원가입 페이지 주소를 추가 하였습니다
bokeeeey May 6, 2024
6fa05cc
feat: React Hook Form 라이브러리를 설치 하였습니다
bokeeeey May 6, 2024
68f1805
feat: TanstackQuery 라이브러리를 설치 하였습니다.
bokeeeey May 6, 2024
894190e
feat: Input 컴포넌트를 제작 하였습니다.
bokeeeey May 6, 2024
562b154
feat: SignInPage의 UI제작을 완료 하였습니다
bokeeeey May 6, 2024
de4f531
feat: InputField의 SuffixIcon을 추가 하였습니다
bokeeeey May 6, 2024
b25da3f
feat: react query devtools를 설치 하였습니다
bokeeeey May 6, 2024
fb7d064
feat: queryProvider를 추가 하였습니다.
bokeeeey May 8, 2024
5d6f8cf
feat: sign-in form의 기능구현을 완료 하였습니다
bokeeeey May 8, 2024
07675bd
feat: AuthComponent의 LinkBox를 만들었습니다
bokeeeey May 8, 2024
59fcccf
feat: sign-up 페이지의 기능구현을 완료 하였습니다
bokeeeey May 9, 2024
04db723
Fix: SignUpForm의 onChange를 onBlur로 수정하였습니다
bokeeeey May 9, 2024
a42851a
Feat: token유무의 리다이렉트 로직을 추가하였습니다
bokeeeey May 9, 2024
e0d9e8e
Fix: localStorage 대신 cookie 저장으로 변경
bokeeeey May 11, 2024
d9a5a7f
Feat: jsCookie 라이브러리를 설치 하였습니다
bokeeeey May 11, 2024
77bc329
Feat: GNB 조건부 렌더링과 serverSideProps 셋팅 완료했습니다.
bokeeeey May 11, 2024
c135b4f
Feat: landingPage의 serverSideProps를 추가하였습니다
bokeeeey May 12, 2024
db00780
Fix: ServerSideProps 에러 수정
bokeeeey May 12, 2024
9946466
Fix: 폴더구조 변경과 App.ts의 Tanstack Query선언 방식을 변경하였습니다.
bokeeeey May 16, 2024
4b6e50e
Fix: getServerSideProps를 리액트쿼리로 변경하였습니다
bokeeeey May 17, 2024
8f97f02
Feat: FavoriteButton을 추가 하였습니다.
bokeeeey May 18, 2024
5295e61
Feat: LinksList를 생성하였습니다
bokeeeey May 18, 2024
acc2b80
Feat: FavoriteButton 클릭에 의한 LinksList변경을 구현하였습니다
bokeeeey May 18, 2024
dee970c
Fix: hydrateState 사용으로 prefetch를 진행하였습니다
bokeeeey May 18, 2024
82fbead
Feat: Next-Ui skeleton을 설치 하였습니다
bokeeeey May 18, 2024
57ae781
Feat: LinksEmptyCase를 추가 하였습니다
bokeeeey May 18, 2024
170b2a7
merge: 컨플릭트 해결
bokeeeey Jun 11, 2024
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
18 changes: 18 additions & 0 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,21 @@ export async function getLinksData(token: string) {
throw error;
}
}

// FolderId LinksData
export async function getFolderIdLinksData(folderId: number | null) {
if (!folderId) {
return null;
}

try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_BASE_URL}/folders/${folderId}/links`
);

return await response.json();
} catch (error) {
console.error("getFolderIdLinksData 실패", error);
throw error;
}
}
24 changes: 21 additions & 3 deletions src/components/folder/Folder.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
import { Suspense, useState } from "react";

import { FavoriteButtonList } from "./LinksList/FavoriteButtonList";
import type { Favorite, TLink } from "@/src/types/type";
import LinksList from "./LinksList/LinksList";
import { useQuery } from "@tanstack/react-query";
import { getFolderIdLinksData } from "@/src/apis";

interface FolderProps {
favorites?: Favorite[];
linksData?: TLink[];
}

export default function Folder({ favorites, linksData }: FolderProps) {
// console.log(linksData);
const [folderId, setFolderId] = useState<number | null>(null);

const { data: folderIdLinksData } = useQuery({
queryKey: ["linksData", folderId],
queryFn: () => getFolderIdLinksData(folderId),
enabled: folderId !== null,
});

const handleFavoriteClick = (favorite?: Favorite | null) => {
console.log(favorite);
if (favorite) {
setFolderId(favorite.id);
return;
}

setFolderId(null);
Comment on lines +10 to +15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (favorite) {
setFolderId(favorite.id);
return;
}
setFolderId(null);
setFolderId(favorite?.id ?? null);

};

return (
Expand All @@ -20,7 +35,10 @@ export default function Folder({ favorites, linksData }: FolderProps) {
favorites={favorites}
handleFavoriteClick={handleFavoriteClick}
/>
<LinksList linksData={linksData} />

<Suspense fallback={<div>로딩중이에요~</div>}>
<LinksList linksData={folderId ? folderIdLinksData : linksData} />
</Suspense>
</>
);
}
2 changes: 2 additions & 0 deletions src/components/folder/LinksList/LinksList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface LinksListProps {
}

export default function LinksList({ linksData }: LinksListProps) {
console.log(linksData);

return (
<section className={cn("linkList")}>
{linksData?.map((link) => (
Expand Down