Skip to content

Commit d8b536a

Browse files
authored
[#134] ♻️ 타입 파일 디렉토리 구조 수정 (#135)
* [#99] ✨ add Pagination component * [#99] ✨ add usePagination hook * [#99] 💄 update chevron-right svg with currentColor attribute * [#99] ♻️ refactor button from using label and icons props to children props * [#99] ♻️ reflect changes in Clickable on module content component * [#99] ✅ add Pagination stories * [#99] ✨ add extended twMerge due to the issue with merging custom classes * [#99] ♻️ apply extended twMerge in clickable to test if it works * [#99] ♻️ separate resuable interface (UsePagination) * [#99] ♻️ replace clsx with twMergeEx in Pagination component * [#99] ♻️ add conditional className handling function in Pagination component' * [#99] 🚚 rename UsePaginationReturn into PaginationState * [#134] 🚚 rename api related type locations to types/api/... * [#134] 🔧 update generate:types scripts with type saving path * [#134] 🚚 reflect location change of type files on import lines
1 parent 81b2332 commit d8b536a

File tree

17 files changed

+43
-23
lines changed

17 files changed

+43
-23
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"format": "prettier --write .",
6969
"test": "jest",
7070
"commit": "cz",
71-
"generate:types": "openapi-typescript http://43.202.50.174:8080/v3/api-docs --output src/types/apiSchema.types.d.ts",
71+
"generate:types": "openapi-typescript http://43.202.50.174:8080/v3/api-docs --output src/types/api/apiSchema.types.d.ts",
7272
"storybook": "storybook dev -p 6006",
7373
"build-storybook": "storybook build",
7474
"chromatic": "npx chromatic"

src/app/(pages)/sign-in/page.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
import { SubmitHandler, useForm } from 'react-hook-form'
44

5-
import { SignInRequest } from '@/types/auth.types'
5+
import { SignInRequest } from '@/types/api/auth.types'
66
import { useSignInMutation } from 'queries/useSignIn'
77

8-
98
export default function LoginPage(): JSX.Element {
10-
119
const {
1210
register,
1311
handleSubmit,

src/app/(pages)/sign-up/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useRouter } from 'next/navigation'
44

55
import { SubmitHandler, useForm } from 'react-hook-form'
66

7-
import { SignUpRequest } from '@/types/auth.types'
7+
import { SignUpRequest } from '@/types/api/auth.types'
88
import { useSignUpMutation } from 'queries/useSignUp'
99

1010
export default function SignUpPage(): JSX.Element {

src/app/api/auth/sign-in/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NextResponse } from 'next/server'
22

3-
import { SignInRequest, SignInResponseResult } from '@/types/auth.types'
3+
import { SignInRequest, SignInResponseResult } from '@/types/api/auth.types'
44

55
import { backendApi } from '@/services/api'
66

src/hooks/usePagination.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState } from 'react'
22

33
import type { PaginationState } from '@/types/hooks'
44

5-
interface UsePaginationProps {
5+
export interface UsePaginationProps {
66
totalItems: number // 전체 아이템 수
77
itemsPerPage: number // 페이지당 아이템 수
88
buttonsPerPage?: number // 한 번에 보여줄 페이지네이션 버튼 수 (기본값: 10)

src/services/auth/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SignInRequest, SignUpRequest } from '@/types/auth.types'
1+
import { SignInRequest, SignUpRequest } from '@/types/api/auth.types'
22

33
import { backendApi, proxyApi } from '@/services/api'
44

src/stories/shared/pagination/Pagination.stories.tsx

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,50 @@ import { Meta, StoryObj } from '@storybook/react'
22

33
import { Pagination } from '@/components/shared/pagination'
44

5-
import { usePagination } from '@/hooks/usePagination'
5+
import { UsePaginationProps, usePagination } from '@/hooks/usePagination'
66

77
export default {
8-
title: 'Shared/Pagination/Pagination',
8+
title: 'Shared/Pagination',
99
component: Pagination,
1010
argTypes: {
11-
currentPage: { control: { type: 'number', min: 1 }, defaultValue: 1 },
12-
totalPages: { control: { type: 'number', min: 1 }, defaultValue: 5 },
13-
hasNextPage: { control: 'boolean', defaultValue: true },
14-
hasPreviousPage: { control: 'boolean', defaultValue: false },
11+
totalItems: { control: 'number', defaultValue: 100 },
12+
itemsPerPage: { control: 'number', defaultValue: 6 },
13+
buttonsPerPage: { control: 'number', defaultValue: 10 },
1514
},
1615
} as Meta
1716

18-
export const Default: StoryObj = {
17+
const PaginationWrapper = ({
18+
totalItems,
19+
itemsPerPage,
20+
buttonsPerPage = 10,
21+
}: UsePaginationProps) => {
22+
const paginationState = usePagination({
23+
totalItems,
24+
itemsPerPage,
25+
buttonsPerPage,
26+
})
27+
28+
return (
29+
<div className='p-4'>
30+
<Pagination {...paginationState} />
31+
<div className='text-sm mt-4 text-gray-700'>
32+
<p>
33+
<strong>현재 페이지:</strong> {paginationState.currentPage}
34+
</p>
35+
<p>
36+
<strong>현재 그룹:</strong>{' '}
37+
{Math.ceil(paginationState.currentPage / buttonsPerPage)}
38+
</p>
39+
</div>
40+
</div>
41+
)
42+
}
43+
44+
export const Default: StoryObj<UsePaginationProps> = {
1945
args: {
20-
currentPage: 1,
21-
pageButtons: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
22-
totalPages: 5,
23-
hasNextPageGroup: true,
24-
hasPreviousPageGroup: true,
25-
goToPage: (page: number) => alert(`Go to page: ${page}`),
26-
goToNextPageGroup: () => alert('Next page'),
27-
goToPreviousPageGroup: () => alert('Previous page'),
46+
totalItems: 100,
47+
itemsPerPage: 6,
48+
buttonsPerPage: 10,
2849
},
50+
render: args => <PaginationWrapper {...args} />,
2951
}

0 commit comments

Comments
 (0)