-
Notifications
You must be signed in to change notification settings - Fork 51
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 #538
The head ref may contain hidden characters: "part3-\uC870\uC5F0\uC544-week15"
[조연아] week15 #538
Changes from all commits
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 |
---|---|---|
@@ -1,44 +1,22 @@ | ||
import React, { useContext } from "react"; | ||
import DataListItem from "./DataListItem"; | ||
import styles from "./DataList.module.css"; | ||
import LocaleContext from "../../contexts/LocaleContext"; | ||
import SearchContext from "../../contexts/SearchContext"; | ||
import { Folder } from "@/types/folderMenuListTypes"; | ||
export type Data = Folder[] | [] | undefined; | ||
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.
|
||
|
||
type DataListProps = { | ||
folderIdKey: string | undefined; | ||
data: Data; | ||
}; | ||
|
||
export default function DataList({ folderIdKey }: DataListProps) { | ||
const { LinkSDataArr } = useContext(LocaleContext); | ||
export default function DataList({ folderIdKey, data }: DataListProps) { | ||
const { inputValue, handleInputFunc } = useContext(SearchContext); | ||
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.
|
||
|
||
if (!folderIdKey) { | ||
return ( | ||
<div className={styles.container}> | ||
{LinkSDataArr?.map((data) => { | ||
const { folderId, linksdata } = data; | ||
|
||
if (!folderId) { | ||
return linksdata?.map((item) => { | ||
const { url, title, description } = item; | ||
if ( | ||
url?.includes(inputValue) || | ||
title?.includes(inputValue) || | ||
description?.includes(inputValue) | ||
) | ||
return <DataListItem key={item.id} item={item} />; | ||
}); | ||
} | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className={styles.container}> | ||
{LinkSDataArr?.filter((data) => data.folderId === Number(folderIdKey)) | ||
?.map((data) => data.linksdata)[0] | ||
?.map((item) => { | ||
{data?.map((item) => { | ||
const { url, title, description } = item; | ||
if ( | ||
url?.includes(inputValue) || | ||
|
@@ -47,6 +25,21 @@ export default function DataList({ folderIdKey }: DataListProps) { | |
) | ||
return <DataListItem key={item.id} item={item} />; | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className={styles.container}> | ||
{data?.map((item) => { | ||
const { url, title, description } = item; | ||
if ( | ||
url?.includes(inputValue) || | ||
title?.includes(inputValue) || | ||
description?.includes(inputValue) | ||
) | ||
return <DataListItem key={item.id} item={item} />; | ||
})} | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,40 +1,43 @@ | ||||||||||||||||||||
import React, { useContext } from "react"; | ||||||||||||||||||||
import Button from "../button/Button"; | ||||||||||||||||||||
import styles from "./FolderMenuList.module.css"; | ||||||||||||||||||||
import LocaleContext from "../../contexts/LocaleContext"; | ||||||||||||||||||||
import Plus from "@/public/images/plus.svg"; | ||||||||||||||||||||
|
||||||||||||||||||||
import { useRouter } from "next/router"; | ||||||||||||||||||||
import { FolderMenuListProps } from "@/types/folderMenuListTypes"; | ||||||||||||||||||||
|
||||||||||||||||||||
export default function FolderMenuList() { | ||||||||||||||||||||
const { LinkSDataArr, folderIdKey } = useContext(LocaleContext); | ||||||||||||||||||||
export default function FolderMenuList({ | ||||||||||||||||||||
folderMenu, | ||||||||||||||||||||
folderId, | ||||||||||||||||||||
}: { | ||||||||||||||||||||
folderMenu: FolderMenuListProps[] | undefined; | ||||||||||||||||||||
folderId: string | undefined; | ||||||||||||||||||||
}) { | ||||||||||||||||||||
const router = useRouter(); | ||||||||||||||||||||
Comment on lines
+11
to
15
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. nit
Suggested change
|
||||||||||||||||||||
// const { id } = router.query; | ||||||||||||||||||||
|
||||||||||||||||||||
return ( | ||||||||||||||||||||
<div className={styles.container}> | ||||||||||||||||||||
<div className={styles.sub__container}> | ||||||||||||||||||||
{LinkSDataArr?.map((item) => { | ||||||||||||||||||||
const { folderId, folderName } = item; | ||||||||||||||||||||
{folderMenu?.map((item) => { | ||||||||||||||||||||
const { id, name } = item; | ||||||||||||||||||||
|
||||||||||||||||||||
let isActive = false; | ||||||||||||||||||||
if (String(folderId) === folderIdKey) { | ||||||||||||||||||||
isActive = true; | ||||||||||||||||||||
} | ||||||||||||||||||||
if (folderId === "" && !folderIdKey) { | ||||||||||||||||||||
if (id === Number(folderId)) { | ||||||||||||||||||||
isActive = true; | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
return ( | ||||||||||||||||||||
<Button | ||||||||||||||||||||
isActive={isActive} | ||||||||||||||||||||
onClick={() => { | ||||||||||||||||||||
router.push(`/folder/${folderId}`); | ||||||||||||||||||||
if (id === 0) { | ||||||||||||||||||||
router.push("/folder"); | ||||||||||||||||||||
return; | ||||||||||||||||||||
} | ||||||||||||||||||||
router.push(`/folder/${id}`); | ||||||||||||||||||||
}} | ||||||||||||||||||||
// key={item.folderId} | ||||||||||||||||||||
key={folderId} | ||||||||||||||||||||
key={id} | ||||||||||||||||||||
> | ||||||||||||||||||||
{folderName} | ||||||||||||||||||||
{name} | ||||||||||||||||||||
</Button> | ||||||||||||||||||||
); | ||||||||||||||||||||
})} | ||||||||||||||||||||
|
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.
안쓰는 주석은 지워주세요!