diff --git a/src/App.css b/src/App.css index 40a5043..2bcf9c7 100644 --- a/src/App.css +++ b/src/App.css @@ -1,3 +1,9 @@ +@import url('https://fonts.googleapis.com/css2?family=42dot+Sans:wght@300..800&family=Gowun+Batang&display=swap'); + +body { + font-family: "42dot Sans", sans-serif; +} + #root { margin: 0 auto; padding: 2rem; diff --git a/src/index.css b/src/index.css index 1da9c62..c6dd210 100644 --- a/src/index.css +++ b/src/index.css @@ -1,9 +1,11 @@ +@import url('https://fonts.googleapis.com/css2?family=42dot+Sans:wght@300..800&family=Gowun+Batang&display=swap'); + @tailwind base; @tailwind components; @tailwind utilities; :root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; + font-family: "42dot Sans", Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; line-height: 1.5; font-weight: 400; diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index 4070c7c..12f38c9 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -23,6 +23,7 @@ const Home = () => { const [userInfo, setUserInfo] = useState({}); const [userLoading, setUserLoading] = useState(true); const [userError, setUserError] = useState(null); + const [prevTier, setPrevTier] = useState(null); const [loading, setLoading] = useState(true); const [user, setUser] = useState(null); @@ -38,6 +39,15 @@ const Home = () => { const navigate = useNavigate(); const [client, setClient] = useState(null); // WebSocket 클라이언트 상태 + // 티어 아이콘 매핑 + const tierEmojis = { + NONE: "❌미획득", + SEED: "🫘씨앗", + SPROUT: "🌱새싹", + FLOWER: "🌺꽃", + FRUIT: "🍎열매", + TREE: "🌳나무", + }; // 사용자 정보 불러오기 useEffect(() => { @@ -56,6 +66,33 @@ const Home = () => { fetchUserInfo(); }, []); +// 업적 기록을 가져오기 +const fetchTierInfo = async () => { + try { + const response = await fetch("/api/user/tierinfo"); + const data = await response.json(); + + // "2025년 겨울 시즌" 데이터 필터링 + const winterTier = data.find(item => item.year === "2025" && item.season === "winter"); + + if (winterTier) { + console.log("겨울 시즌 티어:", winterTier.tier); + setPrevTier(winterTier.tier); // 상태로 저장하여 UI에 반영 + } else { + console.log("겨울 시즌 데이터 없음"); + setPrevTier("미획득"); + } + } catch (error) { + console.error("Tier 정보를 가져오는 중 오류 발생:", error); + } +}; + +// useEffect를 사용하여 API 호출 +useEffect(() => { + fetchTierInfo(); +}, []); + + const toggleModal = async () => { // 읽은 알림들을 필터링하여 제거 setNotifications(prev => prev.filter(noti => !noti.read)); @@ -366,8 +403,6 @@ useEffect(() => { - -

내 커밋 기록

{/* 커밋 통계 - 테이블과 너비 동일하게 */} @@ -420,7 +455,7 @@ useEffect(() => { - + @@ -429,19 +464,56 @@ useEffect(() => { - {Object.entries(seasonData).map(([season, data], index) => { - if (!data) return null; + {seasonData.spring && ( + + + + + + + + + )} + +
시즌현재 시즌 (봄) 총 커밋 공개 커밋 비공개 커밋
+
+ {getSeasonIcon("spring")} + 봄 시즌 +
+
+ {seasonData.spring.totalCommitContributions + seasonData.spring.restrictedContributionsCount} + + {seasonData.spring.totalCommitContributions} + + {seasonData.spring.restrictedContributionsCount} + + 0 ? 'current-streak-badge' : 'zero-value'}`}> + {seasonData.spring.currentStreakDays}일 + + + 0 ? 'max-streak-badge' : 'zero-value'}`}> + {seasonData.spring.maxStreakDays}일 + +
- const totalSeasonContributions = data.totalCommitContributions + data.restrictedContributionsCount; - let rowClass = ''; + {/* 지난 시즌 테이블 */} + + + + + + + + + + + + + {["summer", "fall", "winter"].map((season) => { + if (!seasonData[season]) return null; - switch (season) { - case 'spring': rowClass = 'row-spring'; break; - case 'summer': rowClass = 'row-summer'; break; - case 'fall': rowClass = 'row-fall'; break; - case 'winter': rowClass = 'row-winter'; break; - default: rowClass = ''; - } + const totalSeasonContributions = seasonData[season].totalCommitContributions + seasonData[season].restrictedContributionsCount; + let rowClass = `row-${season}`; return ( @@ -455,19 +527,24 @@ useEffect(() => { {totalSeasonContributions} @@ -475,6 +552,7 @@ useEffect(() => { })}
지난 시즌총 커밋공개 커밋비공개 커밋획득 티어최장 연속
- {data.totalCommitContributions} + {seasonData[season].totalCommitContributions} - {data.restrictedContributionsCount} + {seasonData[season].restrictedContributionsCount} - 0 ? 'current-streak-badge' : 'zero-value'}`}> - {data.currentStreakDays}일 - + {season === "winter" ? ( + + {tierEmojis[prevTier] || tierEmojis['NONE']} + + ) : ( + + {tierEmojis['NONE']} + )} - 0 ? 'max-streak-badge' : 'zero-value'}`}> - {data.maxStreakDays}일 + 0 ? 'max-streak-badge' : 'zero-value'}`}> + {seasonData[season].maxStreakDays}일
+ diff --git a/src/pages/Profile.jsx b/src/pages/Profile.jsx index ec201b5..4ed162f 100644 --- a/src/pages/Profile.jsx +++ b/src/pages/Profile.jsx @@ -11,15 +11,17 @@ const Profile = ({ userInfo }) => { const [isRefreshing, setIsRefreshing] = useState(false); const refreshTimerRef = useRef(null); - const maxExp = userInfo.petGrow === "EGG" ? 150 : userInfo.petGrow === "HATCH" ? 300 : 300; + //FIXME: 테스트를 위해 수치 줄임. 차후 150/300으로 변경 필요. + const maxExp = userInfo.petGrow === "EGG" ? 20 : userInfo.petGrow === "HATCH" ? 40 : 40; // 티어 아이콘 매핑 const tierEmojis = { - SEED: "🫘", - SPROUT: "🌱", - FLOWER: "🌺", - FRUIT: "🍎", - TREE: "🌳", + NONE: "❌미획득", + SEED: "🫘씨앗", + SPROUT: "🌱새싹", + FLOWER: "🌺꽃", + FRUIT: "🍎열매", + TREE: "🌳나무", }; // 펫 성장 단계 한글화 @@ -170,7 +172,7 @@ useEffect(() => {
User Avatar
- z{userInfo.username || "사용자"} + {userInfo.nickname || userInfo.username}({userInfo.username || "사용자"}) {/* 유저 세부 정보 */} @@ -193,7 +195,7 @@ useEffect(() => { 🏆 티어: - {tierEmojis[userInfo.tier] || ""} {userInfo.tier || "없음"} + {tierEmojis[userInfo.tier] || ""}