-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9f25bc
commit 4900ee1
Showing
7 changed files
with
374 additions
and
69 deletions.
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
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import { GetItems } from '@/services/item/item' | ||
|
||
const ApiEndPoint = { | ||
login: () => '/login', | ||
test: () => '/test', | ||
items: (cursorId: number) => `/items?cursorId=${cursorId}`, | ||
} as const | ||
|
||
export default ApiEndPoint |
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,254 @@ | ||
[ | ||
{ | ||
"_id": 1, | ||
"cardId": 1, | ||
"cardTitle": "갤럭시 16 팝니다", | ||
"itemName": "갤럭시 16", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 19, | ||
"priceRange": "10000-50000", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 2, | ||
"cardId": 2, | ||
"cardTitle": "아이폰 17 팝니다", | ||
"itemName": "아이폰 17", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 18, | ||
"priceRange": "10만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 3, | ||
"cardId": 3, | ||
"cardTitle": "아이폰 18 팝니다", | ||
"itemName": "아이폰 18", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 17, | ||
"priceRange": "20만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 4, | ||
"cardId": 1, | ||
"cardTitle": "갤럭시 16 팝니다", | ||
"itemName": "갤럭시 16", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 19, | ||
"priceRange": "10000-50000", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 5, | ||
"cardId": 2, | ||
"cardTitle": "아이폰 17 팝니다", | ||
"itemName": "아이폰 17", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 18, | ||
"priceRange": "10만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 6, | ||
"cardId": 3, | ||
"cardTitle": "아이폰 18 팝니다", | ||
"itemName": "아이폰 18", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 17, | ||
"priceRange": "20만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 7, | ||
"cardId": 1, | ||
"cardTitle": "갤럭시 16 팝니다", | ||
"itemName": "갤럭시 16", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 19, | ||
"priceRange": "10000-50000", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 8, | ||
"cardId": 2, | ||
"cardTitle": "아이폰 17 팝니다", | ||
"itemName": "아이폰 17", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 18, | ||
"priceRange": "10만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 9, | ||
"cardId": 3, | ||
"cardTitle": "아이폰 18 팝니다", | ||
"itemName": "아이폰 18", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 17, | ||
"priceRange": "20만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 10, | ||
"cardId": 1, | ||
"cardTitle": "갤럭시 16 팝니다", | ||
"itemName": "갤럭시 16", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 19, | ||
"priceRange": "10000-50000", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 11, | ||
"cardId": 2, | ||
"cardTitle": "아이폰 17 팝니다", | ||
"itemName": "아이폰 17", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 18, | ||
"priceRange": "10만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 3, | ||
"cardId": 3, | ||
"cardTitle": "아이폰 18 팝니다", | ||
"itemName": "아이폰 18", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 17, | ||
"priceRange": "20만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 1, | ||
"cardId": 1, | ||
"cardTitle": "갤럭시 16 팝니다", | ||
"itemName": "갤럭시 16", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 19, | ||
"priceRange": "10000-50000", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 2, | ||
"cardId": 2, | ||
"cardTitle": "아이폰 17 팝니다", | ||
"itemName": "아이폰 17", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 18, | ||
"priceRange": "10만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 3, | ||
"cardId": 3, | ||
"cardTitle": "아이폰 18 팝니다", | ||
"itemName": "아이폰 18", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 17, | ||
"priceRange": "20만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 1, | ||
"cardId": 1, | ||
"cardTitle": "갤럭시 16 팝니다", | ||
"itemName": "갤럭시 16", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 19, | ||
"priceRange": "10000-50000", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 2, | ||
"cardId": 2, | ||
"cardTitle": "아이폰 17 팝니다", | ||
"itemName": "아이폰 17", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 18, | ||
"priceRange": "10만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 3, | ||
"cardId": 3, | ||
"cardTitle": "아이폰 18 팝니다", | ||
"itemName": "아이폰 18", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 17, | ||
"priceRange": "20만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 1, | ||
"cardId": 1, | ||
"cardTitle": "갤럭시 16 팝니다", | ||
"itemName": "갤럭시 16", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 19, | ||
"priceRange": "10000-50000", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 2, | ||
"cardId": 2, | ||
"cardTitle": "아이폰 17 팝니다", | ||
"itemName": "아이폰 17", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 18, | ||
"priceRange": "10만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
}, | ||
{ | ||
"_id": 3, | ||
"cardId": 3, | ||
"cardTitle": "아이폰 18 팝니다", | ||
"itemName": "아이폰 18", | ||
"createdAt": "2023-11-01T08:08:00", | ||
"modifiedAt": "2023-11-01T08:08:00", | ||
"dibCount": 17, | ||
"priceRange": "20만원대", | ||
"image": "이미지 링크", | ||
"status": "EXCHANGEABLE" | ||
} | ||
] |
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,3 +1,4 @@ | ||
import { itemHandlers } from './itemHandler' | ||
import { testHandlers } from './testHandler' | ||
|
||
export const handlers = [...testHandlers] | ||
export const handlers = [...testHandlers, ...itemHandlers] |
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,21 @@ | ||
import { rest } from 'msw' | ||
import { Environment } from '@/config/environment' | ||
import items from '@/lib/msw/mocks/data/items.json' | ||
|
||
const baseUrl = Environment.apiAddress() | ||
|
||
export const itemHandlers = [ | ||
rest.get(`${baseUrl}/items`, async (req, res, ctx) => { | ||
const queryString = req.url.search | ||
const cursorId = queryString.slice(10) | ||
const currentPage = Number(cursorId) | ||
const PAGE_SIZE = 5 | ||
const filterdItems = items.filter( | ||
(item, index) => | ||
index >= currentPage * PAGE_SIZE && | ||
index < (currentPage + 1) * PAGE_SIZE, | ||
) | ||
|
||
return res(ctx.status(200), ctx.json(filterdItems)) | ||
}), | ||
] |
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,16 @@ | ||
import ApiEndPoint from '@/config/apiEndPoint' | ||
import apiClient from '../apiClient' | ||
|
||
export type GetItems = { | ||
categories: string[] | ||
priceRange: string | ||
name: string | ||
cursorId: number | ||
} | ||
|
||
const getItems = async ({ cursorId }: GetItems) => { | ||
const response = await apiClient.get(ApiEndPoint.items(cursorId)) | ||
return response | ||
} | ||
|
||
export { getItems } |