-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
24 changed files
with
494 additions
and
26 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
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 @@ | ||
## 작성요령 | ||
|
||
API파일을 각 기능단위별로 분리해서 관리하고 있습니다. | ||
|
||
아래 형태를 유지하며 작성해주세요. | ||
|
||
```tsx | ||
// 기능명은 앞글자 대문자로. | ||
const 기능명 = { | ||
Get: {}, | ||
Post: {}, | ||
Put: {}, | ||
Patch: {}, | ||
Delete: {}, | ||
}; | ||
``` |
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 @@ | ||
const Contents = { | ||
Get: {}, | ||
Post: {}, | ||
Put: {}, | ||
Patch: {}, | ||
Delete: {}, | ||
}; | ||
|
||
export default Contents; |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import styled from 'styled-components'; | ||
|
||
export default function ContentCard() { | ||
return ( | ||
<S.ContentCard> | ||
<img /> | ||
</S.ContentCard> | ||
); | ||
} | ||
|
||
const S = { | ||
ContentCard: styled.div``, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { FaSearch } from 'react-icons/fa'; | ||
import { TfiClose } from 'react-icons/tfi'; | ||
import { useLocation, useNavigate } from 'react-router-dom'; | ||
|
||
export default function MarketSearchInput() { | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
const inputRef = React.useRef<HTMLInputElement>(null); | ||
|
||
const urlSearchParams = new URLSearchParams(location.search); | ||
const currentInputState = urlSearchParams.get('searchKeyword'); | ||
const [isFocusedOn, setIsFocusedOn] = React.useState(() => !currentInputState); | ||
|
||
const handleSearchMarket = () => { | ||
if (!inputRef.current) return; | ||
if (!inputRef.current?.value) { | ||
urlSearchParams.delete('searchKeyword'); | ||
} else { | ||
urlSearchParams.set('searchKeyword', inputRef.current?.value); | ||
} | ||
setIsFocusedOn(false); | ||
navigate({ pathname: location.pathname, search: urlSearchParams.has('searchKeyword') ? `?${urlSearchParams}` : '' }, { replace: true }); | ||
}; | ||
|
||
const handleClearSearchMarket = () => { | ||
if (!inputRef.current) return; | ||
setIsFocusedOn(true); | ||
inputRef.current.value = ''; | ||
navigate({ pathname: location.pathname, search: '' }, { replace: true }); | ||
}; | ||
|
||
const handleKeyUpMarketEvent = (event: React.KeyboardEvent) => { | ||
if (event.key === 'Enter') { | ||
handleSearchMarket(); | ||
} | ||
}; | ||
|
||
const handleFocusEvent = () => { | ||
setIsFocusedOn(true); | ||
}; | ||
|
||
const handleBlurEvent = () => { | ||
setIsFocusedOn(!currentInputState); | ||
}; | ||
|
||
React.useEffect(function initializeInputValue() { | ||
if (!inputRef.current) return; | ||
inputRef.current.value = currentInputState as string; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
return ( | ||
<S.MarketSearchInput onBlur={handleBlurEvent}> | ||
<input ref={inputRef} onKeyDown={handleKeyUpMarketEvent} onFocus={handleFocusEvent} /> | ||
{isFocusedOn ? ( | ||
<FaSearch cursor="pointer" size={25} onClick={handleSearchMarket} /> | ||
) : ( | ||
<TfiClose size={25} onClick={handleClearSearchMarket} /> | ||
)} | ||
</S.MarketSearchInput> | ||
); | ||
} | ||
|
||
const S = { | ||
MarketSearchInput: styled.div` | ||
position: sticky; | ||
z-index: 3; | ||
height: 50px; | ||
top: -10px; | ||
display: flex; | ||
align-items: center; | ||
gap: 10px; | ||
background-color: ${(props) => props.theme.colors.white}; | ||
input { | ||
width: 100%; | ||
height: 30px; | ||
border: 1px solid ${(props) => props.theme.colors.black}; | ||
padding-left: 10px; | ||
} | ||
`, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { http } from 'msw'; | ||
import { commonUrl } from '..'; | ||
import CustomResponse from '../utils/customResponse'; | ||
import { contentsList } from '../fakeDatabase/resources/contents'; | ||
|
||
const contentsUrl = (path?: string) => `${commonUrl(`/contents${path ?? ''}`)}`; | ||
|
||
const contentsGetHandler = [ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
http.get(`${contentsUrl()}`, ({ request }) => { | ||
// try { | ||
// const urlObj = new URL(request.url); | ||
// const params = urlObj.searchParams; | ||
// const searchKeyword = params.get('searchKeyword'); | ||
// if (params.has('searchKeyword')) { | ||
// const searchedMarketList = marketList.filter((marketElement) => { | ||
// return ( | ||
// marketElement.title.toLowerCase().includes((searchKeyword as string).toLowerCase()) || | ||
// marketElement.address.toLowerCase().includes((searchKeyword as string).toLowerCase()) | ||
// ); | ||
// }); | ||
// return CustomResponse({ | ||
// value: searchedMarketList, | ||
// message: '성공!', | ||
// code: 200, | ||
// }); | ||
// } | ||
// } catch (error: any) { | ||
// console.log(error); | ||
// return CustomResponse({ value: undefined, message: error, code: 500 }); | ||
// } | ||
return CustomResponse({ value: contentsList, message: '성공!', code: 200 }); | ||
}), | ||
]; | ||
|
||
export default contentsGetHandler; |
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,5 @@ | ||
import contentsGetHandler from './contentsGetHandler'; | ||
|
||
const contentsHandler = [...contentsGetHandler]; | ||
|
||
export default contentsHandler; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## fakeDatabase | ||
|
||
가짜 데이터베이스이고 로컬스토리지에 정보를 저장합니다. | ||
|
||
아래 객체의 형태로 데이터를 조회 및 조작합니다. | ||
|
||
```tsx | ||
const 도메인명Database = { | ||
Get: {}, | ||
Post: {}, | ||
Put: {}, | ||
Patch: {}, | ||
Delete: {}, | ||
}; | ||
``` |
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,8 @@ | ||
const databaseKey = { | ||
userList: 'user-list', | ||
contentsList: 'contents-list', | ||
coordinateList: 'coordinate-list', | ||
marketList: 'market-list', | ||
}; | ||
|
||
export default databaseKey; |
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,11 @@ | ||
import { initializeContentsDatabase } from './resources/contents'; | ||
import { initializeCoordinateDatabase } from './resources/coordinate'; | ||
import { initializeMarketDatabase } from './resources/market'; | ||
|
||
const databaseInitializer = () => { | ||
initializeMarketDatabase(); | ||
initializeCoordinateDatabase(); | ||
initializeContentsDatabase(); | ||
}; | ||
|
||
export default databaseInitializer; |
Oops, something went wrong.