-
Notifications
You must be signed in to change notification settings - Fork 44
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
[김보민] week15 #481
The head ref may contain hidden characters: "part3-\uAE40\uBCF4\uBBFC-week15"
[김보민] week15 #481
Changes from all commits
7df1dd8
84b3a04
c7a717b
41d45f7
75fb1ed
670dde7
ee1368f
3bf2356
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ | |
|
||
# misc | ||
.DS_Store | ||
._.DS_Store | ||
**/.DS_Store | ||
**/._.DS_Store | ||
*.pem | ||
|
||
# debug | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "5-Weekly-Mission" | ||
"baseUrl": "src" | ||
}, | ||
"include": ["5-Weekly-Mission"] | ||
"include": ["src"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { | ||
Header, | ||
SearchBar, | ||
Footer, | ||
LinkInput, | ||
LinkList, | ||
Sorting, | ||
ErrorComponent, | ||
FolderTitle, | ||
} from "../../src/components"; | ||
import { getData } from "../../src/utils"; | ||
import styles from "src/styles/folder.module.scss"; | ||
import { useEffect, useState } from "react"; | ||
import classNames from "classnames/bind"; | ||
import { useRouter } from "next/router"; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
function FolderPage() { | ||
const [linksByQuery, setLinksByQuery] = useState([]); | ||
const [Folders, setFolders] = useState([]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 상태 변수는 카멜 케이스로, 소문자로 시작하도록 일관성을 맞춰주세요~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 37, 39번째줄도요! |
||
const [user, setUser] = useState([]); | ||
const [searchKeyWord, setSearchKeyWord] = useState(""); | ||
const [name, setName] = useState(""); | ||
|
||
const router = useRouter(); | ||
const { folderId } = router.query; | ||
|
||
/* 받아온 배열이 비어있을 경우 체크. */ | ||
function checkArrayBlank(array) { | ||
return !Array.isArray(array) || array.length === 0; | ||
} | ||
|
||
/* 쿼리id로 받은 링크들, 유저데이터, 선택한 폴더 이름 데이터 가져오기*/ | ||
async function fetchData() { | ||
const linkUrl = `/links?folderId=${folderId}`; | ||
const FolderUrl = `/folders/${folderId}`; | ||
|
||
const Folders = await getData("/folders"); | ||
const linksByQuery = await getData(linkUrl); | ||
const user = await getData("/users"); | ||
const name = await getData(FolderUrl); | ||
|
||
setLinksByQuery(linksByQuery.data.folder); | ||
setUser(user.data[0]); | ||
setName(name.data[0].name); | ||
setFolders(Folders.data.folder); | ||
Comment on lines
+44
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. folderid 가 변경될 때 fetchData 가 실행되면서 전체 폴더, 폴더에 있는 링크들, 유저, 폴더 정보 요렇게 총 네가지를 다시 불러오고 있습니다. |
||
} | ||
|
||
useEffect(() => { | ||
fetchData(); | ||
}, [folderId]); | ||
|
||
return ( | ||
<div> | ||
<Header userEmail={user.email} /> | ||
<LinkInput folders={Folders} /> | ||
<div className={cx("contents-wrapper")}> | ||
<SearchBar | ||
searchKeyWord={searchKeyWord} | ||
setSearchKeyWord={setSearchKeyWord} | ||
/> | ||
<div className={cx("links-wrapper")}> | ||
<Sorting folders={Folders} folderId={folderId} /> | ||
<FolderTitle name={name} /> | ||
{checkArrayBlank(linksByQuery) ? ( | ||
<ErrorComponent /> | ||
) : ( | ||
<LinkList | ||
searchKeyWord={searchKeyWord} | ||
links={linksByQuery} | ||
createdTime="created_at" | ||
image="image_source" | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
<Footer /> | ||
</div> | ||
); | ||
} | ||
|
||
export default FolderPage; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. index 와 folderId 페이지로 나눠주신 이유가 있나용? 파일명 컨벤션 중에 optional 로 segment 값을 받을 수 있는게 있습니다. 요걸로 하나의 페이지로 작업해볼 수 있을 것 같습니다! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { | ||
Header, | ||
SearchBar, | ||
Footer, | ||
LinkInput, | ||
LinkList, | ||
Sorting, | ||
ErrorComponent, | ||
FolderTitle, | ||
} from "../../src/components"; | ||
import { checkAccessToken, getData } from "../../src/utils"; | ||
import styles from "src/styles/folder.module.scss"; | ||
import { useEffect, useState } from "react"; | ||
import classNames from "classnames/bind"; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
function FolderPage() { | ||
const [searchKeyWord, setSearchKeyWord] = useState(""); | ||
const [user, setUser] = useState(""); | ||
const [Folders, setFolders] = useState(""); | ||
const [AllLinks, setAllLinks] = useState(""); | ||
|
||
function checkArrayBlank(array) { | ||
return array.length && array.length !== 0 ? false : true; | ||
} | ||
|
||
async function fetchData() { | ||
const user = await getData("/users"); | ||
const Folders = await getData("/folders"); | ||
const AllLinks = await getData("/links"); | ||
|
||
setUser(user.data[0]); | ||
setFolders(Folders.data.folder); | ||
setAllLinks(AllLinks.data.folder); | ||
} | ||
|
||
useEffect(() => { | ||
/* AccessToken없으면 signin페이지로 이동*/ | ||
if (!checkAccessToken("signInToken")) { | ||
location.href = "signin"; | ||
} | ||
fetchData(); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<Header userEmail={user.email} /> | ||
<LinkInput folders={Folders} /> | ||
<div className={cx("contents-wrapper")}> | ||
<SearchBar | ||
searchKeyWord={searchKeyWord} | ||
setSearchKeyWord={setSearchKeyWord} | ||
/> | ||
<div className={cx("links-wrapper")}> | ||
<Sorting folders={Folders} /> | ||
<FolderTitle name={"전체"} /> | ||
{checkArrayBlank(AllLinks) ? ( | ||
<ErrorComponent /> | ||
) : ( | ||
<LinkList | ||
searchKeyWord={searchKeyWord} | ||
links={AllLinks} | ||
createdTime="created_at" | ||
image="image_source" | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
<Footer /> | ||
</div> | ||
); | ||
} | ||
|
||
export default FolderPage; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import styles from "src/styles/SharedPage.module.scss"; | ||
import classNames from "classnames/bind"; | ||
import { | ||
Header, | ||
FolderInfo, | ||
SearchBar, | ||
LinkList, | ||
Footer, | ||
} from "../src/components"; | ||
import { getLinkList, getData, ApiUrl } from "../src/utils"; | ||
import { useEffect, useState } from "react"; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
function SharedPage() { | ||
const [links, setLinks] = useState([]); | ||
const [user, setUser] = useState([]); | ||
const [searchKeyWord, setSearchKeyWord] = useState(""); | ||
|
||
const getUserData = async () => { | ||
const { links } = await getLinkList(); | ||
const user = await getData(ApiUrl.sampleUser); | ||
setLinks(links); | ||
setUser(user); | ||
}; | ||
|
||
useEffect(() => { | ||
getUserData(); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<Header userEmail={user.email} /> | ||
<FolderInfo userName={user.name} /> | ||
<div className={cx("contents-wrapper")}> | ||
<SearchBar | ||
searchKeyWord={searchKeyWord} | ||
setSearchKeyWord={setSearchKeyWord} | ||
/> | ||
<LinkList | ||
searchKeyWord={searchKeyWord} | ||
links={links} | ||
createdTime="createdAt" | ||
image="imageSource" | ||
/> | ||
</div> | ||
<Footer /> | ||
</> | ||
); | ||
} | ||
|
||
export default SharedPage; |
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.
pages 폴더도 src 하위로 옮겨주세요~