-
Notifications
You must be signed in to change notification settings - Fork 35
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
[장용한] Sprint10 #297
The head ref may contain hidden characters: "Next-\uC7A5\uC6A9\uD55C-sprint10"
[장용한] Sprint10 #297
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import axios from "axios"; | ||
|
||
const API_URL = "https://panda-market-api.vercel.app"; | ||
|
||
export const postArticle = async (body: FormData) => { | ||
try { | ||
const response = await axios.post(API_URL, body); | ||
return response.data; | ||
} catch (error) { | ||
console.error("Error posting board:", error); | ||
throw error; | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface Comment { | ||
updateAt?: string; | ||
createdAt: string; | ||
likeCount: number; | ||
image: string; | ||
content: string; | ||
title: string; | ||
nickname: string; | ||
id?: number; | ||
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. 확인했을때 |
||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import style from "@/components/CommentCards.module.css"; | ||
import Best from "@/image/icons/ic_best.svg"; | ||
import Heart from "@/image/icons/ic_heart.svg"; | ||
import { Comment } from "@/api/types/comment"; | ||
import Link from "next/link"; | ||
|
||
interface CommentProps { | ||
comments: Comment[]; | ||
showBest?: boolean; | ||
} | ||
|
||
const CommentCards: React.FC<CommentProps> = ({ | ||
comments, | ||
showBest = false, | ||
}) => { | ||
return ( | ||
<> | ||
{comments.map((comments) => ( | ||
<Link href={`/boards/${comments.id}`}> | ||
<div key={comments.id} className={style.cardcontainer}> | ||
{showBest && <Best className={style.besticon} />} | ||
<div className={style.sectioncontent}> | ||
<p className={style.commentcontent}>{comments.content}</p> | ||
<img | ||
src={comments.image} | ||
alt={comments.title} | ||
className={style.commentimage} | ||
/> | ||
</div> | ||
<div className={style.commentmetacontainer}> | ||
<div className={style.commentmeta}> | ||
<span>{comments.nickname}</span> | ||
<Heart /> | ||
<span>{comments.likeCount}</span> | ||
</div> | ||
<p>{comments.createdAt}</p> | ||
</div> | ||
</div> | ||
</Link> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default CommentCards; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.fileInputcontainer { | ||
position: relative; | ||
} | ||
|
||
.button { | ||
position: absolute; | ||
background-color: transparent; | ||
border: none; | ||
left: 240px; | ||
top: 8px; | ||
cursor: pointer; | ||
} | ||
|
||
.inputImage { | ||
width: 282px; | ||
height: 282px; | ||
border-radius: 12px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { ChangeEvent, useEffect, useRef, useState } from "react"; | ||
import style from "./FileInput.module.css"; | ||
import Xbutton from "@/image/icons/ic_X.svg"; | ||
|
||
interface FileInputProps { | ||
id: string; | ||
name: string; | ||
value: File | null; | ||
onChange: (name: string, file: File | null) => void; | ||
} | ||
|
||
function FileInput({ name, value, onChange }: FileInputProps) { | ||
const [preview, setPreview] = useState<string>(); | ||
const inputRef = useRef<HTMLInputElement>(null); | ||
|
||
const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
const nextValue = | ||
e.target.files && e.target.files.length > 0 ? e.target.files[0] : null; | ||
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. 이런 부분을 ts-patterns와 같은 라이브러리를 사용해서 가독성을 높여보시는건 어떨까요? |
||
onChange(name, nextValue); | ||
}; | ||
|
||
const handleClearClick = () => { | ||
const inputNode = inputRef.current; | ||
if (!inputNode) return; | ||
|
||
inputNode.value = ""; | ||
onChange(name, null); | ||
}; | ||
|
||
useEffect(() => { | ||
if (!value) return; | ||
|
||
const nextPreview = URL.createObjectURL(value); | ||
setPreview(nextPreview); | ||
|
||
return () => { | ||
setPreview(undefined); | ||
URL.revokeObjectURL(nextPreview); | ||
}; | ||
}, [value]); | ||
Comment on lines
+30
to
+40
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. 그리고 언마운트시에 |
||
|
||
return ( | ||
<div className={style.fileInputcontainer}> | ||
<input | ||
id="imgFile" | ||
type="file" | ||
accept="image/png, image/jpeg" | ||
onChange={handleChange} | ||
ref={inputRef} | ||
/> | ||
{value && ( | ||
<> | ||
<button onClick={handleClearClick} className={style.button}> | ||
<Xbutton alt="취소버튼" /> | ||
</button> | ||
<img src={preview} alt="" className={style.inputImage} /> | ||
</> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default FileInput; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
.commentcontiner { | ||
margin-top: 40px; | ||
} | ||
|
||
.sronly { | ||
position: absolute; | ||
width: 1px; | ||
height: 1px; | ||
padding: 0; | ||
margin: -1px; | ||
overflow: hidden; | ||
clip-path: inset(50%); | ||
border: 0; | ||
clip: rect(0 0 0 0); | ||
} | ||
Comment on lines
+5
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. 지난번에 말한거 적용하셨네용 ~~~ 👍 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
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.
NEXT 환경변수를 이용해서 관리해보시면 좋을 것 같아요 !
보안상의 이점이 있답니다.