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

fix: 책추가 버튼 활성화 조건 수정 #72

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions components/bookcase/NoCards.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from "@emotion/styled";

import { BookcasePathKey } from "../../types/bookcase";
import Empty from "./cardSection/Empty";
import { Empty } from "../common";

interface NoCardsProps {
navIndex: BookcasePathKey;
Expand All @@ -11,7 +11,10 @@ export default function NoCards(props: NoCardsProps) {

return (
<StDefaultSection>
<Empty navIndex={navIndex} />
<Empty
text={navIndex === "/book" ? "아직 읽은 책이 없어요." : "이 단계의 책이 없어요."}
buttonVisible={navIndex === "/book"}
/>
</StDefaultSection>
);
}
Expand Down
74 changes: 0 additions & 74 deletions components/bookcase/cardSection/Empty.tsx

This file was deleted.

1 change: 0 additions & 1 deletion components/bookcase/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export { default as StickyHeader } from "./addBook/StickyHeader";
export { default as Cards } from "./Cards";
export { default as AddBookCard } from "./cardSection/AddBookCard";
export { default as BookCard } from "./cardSection/BookCard";
export { default as Empty } from "./cardSection/Empty";
export { default as Navigation } from "./Navigation";
export { default as NoCards } from "./NoCards";
26 changes: 14 additions & 12 deletions components/common/Empty.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import styled from "@emotion/styled";
import Link from "next/link";
import { useRouter } from "next/router";

import { ImgEmptyBook } from "../../public/assets/images";
import { DefaultButton } from "./styled/Button";
import { ImageWrapper } from "./styled/Img";
export default function Empty() {
const { asPath } = useRouter();

interface EmptyProps {
text: string;
buttonVisible: boolean;
}

export default function Empty({ text, buttonVisible }: EmptyProps) {
return (
<StArticle>
<StImg thumbnail={ImgEmptyBook.src} />
<StH3>{asPath === "/bookcase" || asPath === "/main" ? "아직 읽은 책이 없어요." : "이 단계의 책이 없어요."}</StH3>
<StH3>{text}</StH3>

<StParagraph>
북스테어즈만의 독서법을 통해
<br /> 지식을 얻고 독서의 매력을 느껴보세요
</StParagraph>
{asPath === "/bookcase" ||
(asPath === "/main" && (
<StAddBookBtn>
<Link href="/bookcase/add-book">
<StLink>+ 책 추가</StLink>
</Link>
</StAddBookBtn>
))}
{buttonVisible && (
<StAddBookBtn>
<Link href="/bookcase/add-book">
<StLink>+ 책 추가</StLink>
</Link>
</StAddBookBtn>
)}
</StArticle>
);
}
Expand Down
2 changes: 1 addition & 1 deletion components/main/RecentBooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function RecentBooks() {
<BookCard key={bookInfo.reviewId} bookcaseInfo={bookInfo} navIndex={"/main"} />
))
) : (
<Empty />
<Empty text="아직 읽은 책이 없어요." buttonVisible={true} />
)}
</StBookWrapper>
</section>
Expand Down
9 changes: 4 additions & 5 deletions core/atom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ export const isLoginState = atom<boolean>({
export const navigatingBookInfoState = atom<NavigatingBookInfoState>({
key: StateType.NAVIGATING_BOOK_INFO_STATE,
default: {
reviewId: "62b5581c1b74916b7a94efc8",
title: "북노오오오오오트으으으으",
fromUrl: "/main",
fromSt: "/main",
reviewSt: 2,
reviewId: "",
title: "",
fromUrl: "",
fromSt: null,
},
effects_UNSTABLE: [persistAtom],
});
2 changes: 1 addition & 1 deletion pages/bookcase/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function Bookcase() {
const { fromSt } = navigatingBookInfo;

const { isLogin } = useUser();
const [navIndex, setNavIndex] = useState<BookcasePathKey>(fromSt);
const [navIndex, setNavIndex] = useState<BookcasePathKey>(fromSt || "/book");
const { bookcaseInfo, isLoading, isError } = useGetBookInfo(navIndex);

const handleChangeNavIndex = (idx: BookcasePathKey) => {
Expand Down
2 changes: 1 addition & 1 deletion types/bookcase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface NavigatingBookInfoState {
reviewId: string;
title: string;
fromUrl: string;
fromSt: BookcasePathKey;
fromSt: BookcasePathKey | null;
reviewSt?: 2 | 3 | 4;
}

Expand Down