-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from jangyonghan/Next-장용한-sprint10
[장용한] Sprint10
- Loading branch information
Showing
21 changed files
with
438 additions
and
150 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
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; | ||
} | ||
}; |
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,10 @@ | ||
export interface Comment { | ||
updateAt?: string; | ||
createdAt: string; | ||
likeCount: number; | ||
image: string; | ||
content: string; | ||
title: string; | ||
nickname: string; | ||
id?: number; | ||
} |
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 was deleted.
Oops, something went wrong.
File renamed without changes.
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,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; |
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,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; | ||
} |
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,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; | ||
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]); | ||
|
||
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; |
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 |
---|---|---|
@@ -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); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.