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

refactor: document type #271

Merged
merged 17 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
2 changes: 1 addition & 1 deletion src/app/(routes)/document/[id]/(main)/@header/default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const Header = () => {
title="노트를 삭제할까요?"
content={
<Text typography="text1-medium">
{data?.name} 노트와{' '}
{data?.documentName} 노트와{' '}
<span className="text-text-wrong">{data?.totalQuizCount}개의 문제</span>가{' '}
<br />
모두 삭제됩니다.
Expand Down
2 changes: 1 addition & 1 deletion src/features/document/components/document-type-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Icon from '@/shared/components/custom/icon'
import { cn } from '@/shared/lib/utils'

interface Props {
type: Document.Item['documentType']
type: Document.ListItem['documentType']
containerClassName: HTMLElement['className']
iconClassName: HTMLElement['className']
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import stripMarkdown from 'strip-markdown'

interface DocumentProps {
id: number
createType: Document.Item['documentType']
createType: Document.ListItem['documentType']
title: string
content: string
quizCount: number
Expand Down
2 changes: 1 addition & 1 deletion src/features/pages/documents-in-directory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const DocumentsInDirectory = () => {
quizCount={document.totalQuizCount}
characterCount={document.characterCount}
directory={document.directory.name}
className={cn(idx === 9 && 'mb-[30px]')}
className={cn(idx === data.documents.length - 1 && 'mb-[30px]')}
reviewCount={document.reviewNeededQuizCount}
/>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/features/pages/modify-document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ModifyDocument = () => {

return (
<>
<TitleInput prevTitle={data?.name} />
<TitleInput prevTitle={data?.documentName} />

<div className="sticky top-[54px] z-10 flex items-center justify-between bg-background-base-02 px-[16px] py-[11px]">
<div className="flex items-center">
Expand Down
2 changes: 1 addition & 1 deletion src/features/search/components/search-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cn } from '@/shared/lib/utils'
import DocumentTypeIcon from '@/features/document/components/document-type-icon'

interface Props {
createType: Document.Item['documentType']
createType: Document.ListItem['documentType']
documentTitle: string
matchingSentence: string
resultType: 'document' | 'quiz'
Expand Down
27 changes: 18 additions & 9 deletions src/types/document.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,27 @@ type Quiz = {
quizType: QuizType
}

type DocumentItem = {
type DocumentBase = {
id: number
documentType: CreateType
name: string
documentName?: string
status: DocumentStatus
previewContent?: string
content: string
characterCount: number
totalQuizCount: number
updatedAt: string
characterCount: number
directory: Directory
updatedAt: string
}

type DocumentDetailItem = DocumentBase & {
documentName: string
content: string
quizzes: Quiz[]
}

type DocumentListItem = DocumentBase & {
name: string
documentType: CreateType
previewContent: string
createdAt: string
reviewNeededQuizCount: number
}

Expand Down Expand Up @@ -159,8 +167,9 @@ interface SearchDocumentsResponse {
}

declare namespace Document {
type Item = DocumentItem
type List = DocumentItem[]
type Item = DocumentDetailItem
type List = DocumentListItem[]
type ListItem = DocumentListItem
Copy link
Member

Choose a reason for hiding this comment

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

너무 좋은데요?
네이밍만 조금 더 직관적으로 바뀌면 좋을 것 같아요!
예를들면 아래와 같은..?
Document.DetailItem
Document.ItemInList
Document.List

Copy link
Contributor Author

Choose a reason for hiding this comment

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

좋아요👍👍

type Status = DocumentStatus
type Sort = SortOption

Expand Down