-
Notifications
You must be signed in to change notification settings - Fork 1
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 #182 from Moaguide-develop/feat/testpage
feat: 학습하기 페이지 리뉴얼 작업
- Loading branch information
Showing
27 changed files
with
1,058 additions
and
77 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@ | ||
import Navbar from '@/components/common/Navbar'; | ||
import LearningPageClient from '@/components/learning/LearningPageClient'; | ||
|
||
const LearningPage = async () => { | ||
|
||
const response = await fetch('http://43.200.90.72/contents/overview', { cache: 'no-store' }); | ||
|
||
if (!response.ok) { | ||
console.error('Failed to fetch Overview API'); | ||
return <div>데이터를 가져오지 못했습니다.</div>; | ||
} | ||
|
||
const initialData = await response.json(); | ||
|
||
return ( | ||
<div> | ||
<Navbar /> | ||
<LearningPageClient initialData={initialData} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LearningPage; |
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
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,88 @@ | ||
import Image from 'next/image'; | ||
import defaultImage from '../../../public/images/learning/learning_img.svg'; | ||
|
||
interface FilteredContentsProps { | ||
contents: any[]; | ||
total: number; | ||
page: number; | ||
size: number; | ||
onPageChange: (newPage: number) => void; | ||
} | ||
|
||
const FilteredContents = ({ | ||
contents, | ||
total, | ||
page, | ||
size, | ||
onPageChange, | ||
}: FilteredContentsProps) => { | ||
const totalPages = Math.ceil(total / size); | ||
|
||
const formatDate = (dateString: string) => { | ||
const date = new Date(dateString); | ||
return date.toISOString().split('T')[0]; | ||
}; | ||
|
||
return ( | ||
<div className='mt-10'> | ||
<div className="space-y-10"> | ||
{contents.length > 0 ? ( | ||
contents.map((item) => ( | ||
<div key={item.contentId} className="flex items-center gap-4"> | ||
<div className="w-64 h-40 flex-shrink-0 overflow-hidden rounded-md"> | ||
<Image | ||
src={item.img_link || defaultImage} | ||
alt={item.title} | ||
width={128} | ||
height={80} | ||
className="object-cover w-full h-full" | ||
/> | ||
</div> | ||
<div className="h-full flex-1"> | ||
<h3 className="text-lg font-bold text-gray-800 mb-4 line-clamp-1"> | ||
{item.title} | ||
</h3> | ||
<p className="text-sm text-gray-600 line-clamp-2"> | ||
{item.description} | ||
</p> | ||
<div className="justify-end text-xs text-gray-500 mt-4 flex items-center gap-4"> | ||
<span>{formatDate(item.date)}</span> | ||
<span>❤ {item.likes}</span> | ||
<span>👁 {item.views}</span> | ||
</div> | ||
</div> | ||
</div> | ||
)) | ||
) : ( | ||
<div className="text-center text-gray-500">데이터가 없습니다.</div> | ||
)} | ||
</div> | ||
|
||
{/* 페이지네이션 */} | ||
{totalPages > 1 && ( | ||
<div className="flex justify-center mt-8"> | ||
<ul className="flex items-center space-x-1"> | ||
{Array.from({ length: totalPages }, (_, i) => i + 1).map( | ||
(pageNum) => ( | ||
<li key={pageNum}> | ||
<button | ||
onClick={() => onPageChange(pageNum)} | ||
className={`w-8 h-8 flex items-center justify-center border rounded ${ | ||
page === pageNum | ||
? 'bg-purple-600 text-white' | ||
: 'bg-white text-gray-800 border-gray-300 hover:bg-gray-100' | ||
}`} | ||
> | ||
{pageNum} | ||
</button> | ||
</li> | ||
) | ||
)} | ||
</ul> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default FilteredContents; |
Oops, something went wrong.