-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#9] 독서 노트 작성 화면 개발 #10
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2388677
feat: 독서 노트 생성 페이지 추가
2scent 2199e67
refactor: Book.id -> Book.isbn으로 변경
2scent fd63da6
feat: 도서 클릭 시 독서 노트 생성 페이지로 이동
2scent 785888f
feat: 독서 노트 생성 페이지 경로 수정
2scent 73c99ce
feat: BookDetail에 description 추가
2scent 8260391
feat: bookQueries.detail 추가
2scent 96c4c3d
feat: 독서 노트 생성 페이지에서 도서 조회
2scent 7a09ca7
refactor: BookNoteForm 컴포넌트 분리
2scent a16db80
feat: 독서 정보 스텝 정리
2scent 50c310a
feat: 책 평가 스텝 정리
2scent b33ca5d
feat: 독후감 스텝 정리
2scent 5401efc
feat: 인용구 스텝 정리
2scent a8173ff
feat: 공개 설정 스텝 정리
2scent 54c417e
chore: react-hook-form 패키지 추가
2scent 68562a8
refactor: 폼 액션을 각 스텝 컴포넌트에서 포함하도록 수정
2scent 8eecf7f
refactor: BookNoteForm 폴더 이동
2scent 7c8d05b
chore: ts-pattern 패키지 추가
2scent c03d52f
refactor: BookNoteForm을 ts-pattern으로 리팩토링
2scent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { BookNoteCreatePage as default } from '@/pages/book-note-create'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export { default as BookCard } from './ui/BookCard'; | ||
export { default as BookList } from './ui/BookList'; | ||
export type { Book } from './model/book'; | ||
export type { Book, BookDetail } from './model/book'; | ||
export { BookListTab } from './model/book-list-tab'; | ||
export { bookQueries } from './api/book-queries'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { default as BookNoteForm } from './ui/book-note-form'; | ||
export { default as BookNoteForm } from './ui/BookNoteForm/BookNoteForm'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const BookNoteFormStep = { | ||
READING_INFO: 'READING_INFO', | ||
RATING: 'RATING', | ||
REVIEW: 'REVIEW', | ||
QUOTES: 'QUOTES', | ||
VISIBILITY: 'VISIBILITY', | ||
} as const; | ||
|
||
export type BookNoteFormStep = (typeof BookNoteFormStep)[keyof typeof BookNoteFormStep]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ReadingStatus } from './reading-status'; | ||
|
||
export interface BookNoteFormValues { | ||
readingStatus: ReadingStatus; | ||
startDate: Date; | ||
endDate: Date; | ||
recommended: boolean | null; | ||
overallRating: number; | ||
content: string; | ||
quotes: { text: string; page: string }[]; | ||
visibility: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const ReadingStatus = { | ||
WANT_TO_READ: 'WANT_TO_READ', | ||
READING: 'READING', | ||
READ: 'READ', | ||
ON_HOLD: 'ON_HOLD', | ||
DROPPED: 'DROPPED', | ||
} as const; | ||
|
||
export type ReadingStatus = (typeof ReadingStatus)[keyof typeof ReadingStatus]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
import { useParams } from 'next/navigation'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import { match } from 'ts-pattern'; | ||
import { bookQueries } from '@/entities/book'; | ||
import { BookNoteFormStep } from '../../model/book-note-form-step'; | ||
import ReadingInfoStep from './step/ReadingInfoStep'; | ||
import RatingStep from './step/RatingStep'; | ||
import ReviewStep from './step/ReviewStep'; | ||
import QuotesStep from './step/QuotesStep'; | ||
import VisibilityStep from './step/VisibilityStep'; | ||
|
||
export default function BookNoteForm() { | ||
const [step, setStep] = useState<BookNoteFormStep>(BookNoteFormStep.READING_INFO); | ||
|
||
const { isbn } = useParams<{ isbn: string }>()!; | ||
|
||
const { data: book } = useSuspenseQuery(bookQueries.detail(isbn)); | ||
|
||
return ( | ||
<div className="mx-auto w-full max-w-4xl space-y-8 p-4 md:p-6"> | ||
{match(step) | ||
.with(BookNoteFormStep.READING_INFO, () => ( | ||
<ReadingInfoStep | ||
book={book} | ||
onNext={() => setStep(BookNoteFormStep.RATING)} | ||
/> | ||
)) | ||
.with(BookNoteFormStep.RATING, () => ( | ||
<RatingStep | ||
onPrevious={() => setStep(BookNoteFormStep.READING_INFO)} | ||
onNext={() => setStep(BookNoteFormStep.REVIEW)} | ||
/> | ||
)) | ||
.with(BookNoteFormStep.REVIEW, () => ( | ||
<ReviewStep | ||
onPrevious={() => setStep(BookNoteFormStep.RATING)} | ||
onNext={() => setStep(BookNoteFormStep.QUOTES)} | ||
/> | ||
)) | ||
.with(BookNoteFormStep.QUOTES, () => ( | ||
<QuotesStep | ||
onPrevious={() => setStep(BookNoteFormStep.REVIEW)} | ||
onNext={() => setStep(BookNoteFormStep.VISIBILITY)} | ||
/> | ||
)) | ||
.with(BookNoteFormStep.VISIBILITY, () => <VisibilityStep onPrevious={() => setStep(BookNoteFormStep.QUOTES)} />) | ||
.exhaustive()} | ||
</div> | ||
); | ||
} |
39 changes: 39 additions & 0 deletions
39
src/features/book-note/ui/BookNoteForm/BookNoteFormActions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Button } from '@/shared/ui/button'; | ||
|
||
interface BookNoteFormActionsProps { | ||
previousLabel?: string; | ||
nextLabel?: string; | ||
previousDisabled?: boolean; | ||
nextDisabled?: boolean; | ||
onPrevious?: () => void; | ||
onNext?: () => void; | ||
} | ||
|
||
export default function BookNoteFormActions({ | ||
previousLabel = '이전', | ||
nextLabel = '다음', | ||
previousDisabled, | ||
nextDisabled, | ||
onPrevious, | ||
onNext, | ||
}: BookNoteFormActionsProps) { | ||
return ( | ||
<div className="flex justify-between pt-6"> | ||
<Button | ||
type="button" | ||
onClick={onPrevious} | ||
variant="outline" | ||
disabled={previousDisabled} | ||
> | ||
{previousLabel} | ||
</Button> | ||
<Button | ||
type="button" | ||
disabled={nextDisabled} | ||
onClick={onNext} | ||
> | ||
{nextLabel} | ||
</Button> | ||
</div> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './BookNoteForm'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.