dashboard 형태의 UI 수정 및 고도화
This commit is contained in:
@@ -1,13 +1,30 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { navLinks } from '../../routes.jsx';
|
||||
import { getBlogPosts } from '../../data/blog';
|
||||
import { getTodos } from '../../api';
|
||||
import myPhoto from '../../assets/myPhoto.jpg';
|
||||
import './Home.css';
|
||||
|
||||
const SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000;
|
||||
|
||||
const Home = () => {
|
||||
const posts = getBlogPosts().slice(0, 3);
|
||||
const highlights = navLinks.filter((link) => link.id !== 'home');
|
||||
const [recentDev, setRecentDev] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
getTodos()
|
||||
.then((todos) => {
|
||||
if (!Array.isArray(todos)) return;
|
||||
const now = Date.now();
|
||||
const filtered = todos
|
||||
.filter((t) => t.status === 'done' && t.updated_at && (now - new Date(t.updated_at).getTime()) <= SEVEN_DAYS_MS)
|
||||
.slice(0, 5);
|
||||
setRecentDev(filtered);
|
||||
})
|
||||
.catch(() => { /* 조용히 실패 */ });
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="home">
|
||||
@@ -97,6 +114,36 @@ const Home = () => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="home-section">
|
||||
<div className="home-section__header">
|
||||
<h2>최근 개발</h2>
|
||||
<p>최근 7일 내 완료된 태스크를 보여줍니다.</p>
|
||||
</div>
|
||||
<div className="home-dev-log">
|
||||
{recentDev.length === 0 ? (
|
||||
<p className="home-dev-log__empty">완료된 태스크가 없습니다.</p>
|
||||
) : (
|
||||
recentDev.map((todo) => (
|
||||
<div key={todo.id} className="home-dev-log__item">
|
||||
<span className="home-dev-log__dot" />
|
||||
<div className="home-dev-log__content">
|
||||
<p className="home-dev-log__title">{todo.title}</p>
|
||||
{todo.description && (
|
||||
<p className="home-dev-log__desc">{todo.description}</p>
|
||||
)}
|
||||
</div>
|
||||
<span className="home-dev-log__date">
|
||||
{new Date(todo.updated_at).toLocaleDateString('ko-KR', { month: 'short', day: 'numeric' })}
|
||||
</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
<Link to="/todo" className="home-dev-log__link">
|
||||
Todo 보드 열기 →
|
||||
</Link>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="home-section">
|
||||
<div className="home-section__header">
|
||||
<h2>Profile</h2>
|
||||
|
||||
Reference in New Issue
Block a user