-
Notifications
You must be signed in to change notification settings - Fork 117
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
[김준영] Week16 #1067
The head ref may contain hidden characters: "part3-\uAE40\uC900\uC601-week16"
[김준영] Week16 #1067
Changes from all commits
4171e38
693f044
6e07087
3b533b9
0ecb820
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,30 +42,31 @@ const CardList = ({ links }: { links: TLink[] | undefined }) => { | |
// loadLinks(); | ||
// }, [currentFolder, keyword]); | ||
|
||
if (links?.length === 0) return <NoLink />; | ||
if (!links || links?.length === 0) return <NoLink />; | ||
return ( | ||
<CardListContainer> | ||
{links?.map((link) => { | ||
const createdAt = link.created_at || link.createdAt; | ||
const imageSource = link.image_source || link.imageSource; | ||
{links && | ||
links.map((link) => { | ||
const createdAt = link.created_at || link.createdAt; | ||
const imageSource = link.image_source || link.imageSource; | ||
|
||
const createdDate = new Date(createdAt as string); | ||
const currentDate = new Date(); | ||
const createdDate = new Date(createdAt as string); | ||
const currentDate = new Date(); | ||
|
||
return ( | ||
<Card | ||
key={link.id} | ||
id={link.id} | ||
cardImage={imageSource} | ||
cardTime={{ | ||
createdDateString: formatDate(createdDate), | ||
timeDifference: getTimeDifference(createdDate, currentDate), | ||
}} | ||
cardDescription={link.description || ""} | ||
cardUrl={link.url} | ||
/> | ||
); | ||
})} | ||
return ( | ||
<Card | ||
key={link.id} | ||
id={link.id} | ||
cardImage={imageSource} | ||
cardTime={{ | ||
createdDateString: formatDate(createdDate), | ||
timeDifference: getTimeDifference(createdDate, currentDate), | ||
}} | ||
cardDescription={link.description || ""} | ||
cardUrl={link.url} | ||
/> | ||
); | ||
})} | ||
Comment on lines
+56
to
+69
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. 뭔가 Prettier, Lint 룰이 변경되었나보군요! 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. 들여쓰기 뎁스는 보통 실무에서 4보다는 2를 더 많이 사용하곤 합니다~ |
||
</CardListContainer> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import React from "react"; | ||
import React, { useEffect } from "react"; | ||
import Tag from "@/components/folder/tag/Tag"; | ||
import styled from "styled-components"; | ||
import { useFolder } from "@/contexts/FolderContext"; | ||
import { TFolder } from "@/utils/types"; | ||
import { getFolderInfo } from "@/utils/api"; | ||
|
||
const TagListContainer = styled.div` | ||
width: 90%; | ||
|
@@ -12,13 +13,28 @@ const TagListContainer = styled.div` | |
gap: 10px; | ||
`; | ||
|
||
const TagList = ({ foldersInfo }: { foldersInfo: TFolder[] }) => { | ||
const TagList = ({ | ||
foldersInfo, | ||
folderId, | ||
}: { | ||
foldersInfo: TFolder[]; | ||
folderId: number; | ||
}) => { | ||
const { currentFolder, setCurrentFolder } = useFolder(); | ||
|
||
const handleClickTag = (id: number, name: string) => { | ||
setCurrentFolder({ id, name }); | ||
}; | ||
|
||
const loadFolder = async () => { | ||
const res = await getFolderInfo(folderId); | ||
setCurrentFolder({ id: res.id, name: res.name }); | ||
}; | ||
|
||
useEffect(() => { | ||
loadFolder(); | ||
}, []); | ||
|
||
return ( | ||
<TagListContainer> | ||
<Tag | ||
|
@@ -29,7 +45,7 @@ const TagList = ({ foldersInfo }: { foldersInfo: TFolder[] }) => { | |
> | ||
전체 | ||
</Tag> | ||
{foldersInfo.length !== 0 | ||
{foldersInfo | ||
? foldersInfo.map((folder) => { | ||
Comment on lines
-32
to
+48
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. 리뷰 반영 굳 입니다! 👍 |
||
return ( | ||
<Tag | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { | ||
createContext, | ||
ReactNode, | ||
useContext, | ||
useMemo, | ||
useState, | ||
} from "react"; | ||
|
||
export type MyInfo = { | ||
id: number; | ||
created_at: string; | ||
name: string; | ||
image_source: string; | ||
email: string; | ||
auth_id: string; | ||
}; | ||
|
||
type MyInfoContextValue = { | ||
myInfo: MyInfo; | ||
setMyInfo: (value: MyInfo) => void; | ||
}; | ||
|
||
const MyInfoContext = createContext<MyInfoContextValue>({ | ||
myInfo: { | ||
id: 0, | ||
created_at: "", | ||
name: "", | ||
image_source: "", | ||
email: "", | ||
auth_id: "", | ||
}, | ||
setMyInfo: () => {}, | ||
}); | ||
|
||
export const MyInfoProvider = ({ children }: { children: ReactNode }) => { | ||
const [myInfo, setMyInfo] = useState({ | ||
id: 0, | ||
created_at: "", | ||
name: "", | ||
image_source: "", | ||
email: "", | ||
auth_id: "", | ||
}); | ||
|
||
const value = useMemo(() => ({ myInfo, setMyInfo }), [myInfo]); | ||
|
||
return ( | ||
<MyInfoContext.Provider value={value}>{children}</MyInfoContext.Provider> | ||
); | ||
}; | ||
|
||
export const useMyInfo = () => { | ||
const context = useContext(MyInfoContext); | ||
if (!context) { | ||
throw new Error(""); | ||
} | ||
Comment on lines
+54
to
+56
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. 에러 메시지에 "" 보다는 아래처럼 조금 더 구체적인 메시지가 담기면 향후 디버깅에 보다 수월할거에요~
|
||
return context; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,25 +2,10 @@ | |
const nextConfig = { | ||
reactStrictMode: true, | ||
images: { | ||
domains: [ | ||
"jasonwatmore.com", | ||
"codeit-images.codeit.com", | ||
"codeit-frontend.codeit.com", | ||
"reactjs.org", | ||
"assets.vercel.com", | ||
"tanstack.com", | ||
"storybook.js.org", | ||
"testing-library.com", | ||
"*.*", | ||
"static.cdninstagram.com", | ||
"s.pstatic.net", | ||
], | ||
remotePatterns: [ | ||
{ | ||
protocol: "https", | ||
hostname: "bootcamp-api.codeit.kr", | ||
port: "", | ||
pathname: "/api/**", //**는 해당 경로 뒤에 모든 경로, | ||
hostname: "**", | ||
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. 리뷰 반영 굳! 👍 |
||
}, | ||
], | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
import "@/styles/globals.css"; | ||
import type {AppProps} from "next/app"; | ||
import {FolderProvider} from "@/contexts/FolderContext"; | ||
import type { AppProps } from "next/app"; | ||
import { FolderProvider } from "@/contexts/FolderContext"; | ||
import { MyInfoProvider } from "@/contexts/MyInfoContext"; | ||
|
||
declare global { | ||
interface Window { | ||
Kakao: any; | ||
} | ||
interface Window { | ||
Kakao: any; | ||
} | ||
} | ||
|
||
export default function App({Component, pageProps}: AppProps) { | ||
return ( | ||
<FolderProvider> | ||
<Component {...pageProps} /> | ||
</FolderProvider> | ||
); | ||
export default function App({ Component, pageProps }: AppProps) { | ||
return ( | ||
<MyInfoProvider> | ||
<FolderProvider> | ||
<Component {...pageProps} /> | ||
</FolderProvider> | ||
</MyInfoProvider> | ||
); | ||
} |
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.
뭔가 Prettier, Lint 룰이 변경되었나보군요!