-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
김승석
authored and
김승석
committed
Dec 8, 2024
1 parent
1eb200c
commit 7ac5c0d
Showing
7 changed files
with
88 additions
and
96 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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.name_area {display : flex; align-items: center; margin-top: 24px;} | ||
.name_area .profile {width: 40px; height: 40px; border-radius: 50px; overflow: hidden;} | ||
.name_area .profile img {width: 100%; height: 100%; object-fit: cover;} | ||
.name_area .name {margin-left: 16px;} | ||
.name_area .name > p {font-size: 1.4rem; font-weight: 500; line-height: 1.7142; cursor: pointer;} | ||
.name_area .name > p:hover {text-decoration: underline;} | ||
.name_area .name > .date {color: #9CA3AF; font-size: 1.4rem; font-weight: 400; line-height: 1.7142;} |
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,21 @@ | ||
import profileIcon from "./../assets/icon_profile.png"; | ||
import useDate from "./../hooks/useDate"; | ||
import "./ProfileBox.css"; | ||
|
||
const ProfileBox = ({ img, name, date }) => { | ||
const formattedDate = useDate(date); | ||
|
||
return ( | ||
<div className="name_area"> | ||
<div className="profile"> | ||
<img src={img ? img : profileIcon} alt={name} onError={(e) => (e.target.src = profileIcon)} /> | ||
</div> | ||
<div className="name"> | ||
<p>{name}</p> | ||
<div className="date">{formattedDate}</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ProfileBox; |
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,25 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import axios from "axios"; | ||
const useApi = (url) => { | ||
const [data, setData] = useState(null); | ||
|
||
const [loading, setLoading] = useState(true); | ||
const [error, setError] = useState(null); | ||
useEffect(() => { | ||
const fetchProduct = async () => { | ||
try { | ||
const response = await axios.get(url); | ||
setData(response.data); | ||
} catch (error) { | ||
setError(error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
fetchProduct(); | ||
}, [url]); | ||
|
||
return { data, loading, error }; | ||
}; | ||
|
||
export default useApi; |
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,11 @@ | ||
const useDate = (dateSet) => { | ||
const dateString = dateSet; | ||
const date = new Date(dateString); | ||
const year = date.getFullYear(); | ||
const month = String(date.getMonth() + 1).padStart(2, "0"); | ||
const day = String(date.getDate()).padStart(2, "0"); | ||
const formattedDate = `${year}.${month}.${day}`; | ||
|
||
return formattedDate; | ||
}; | ||
export default useDate; |
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