Merge pull request #15 from nightbug-xx/mcr5z4-codex/친구정보-출력-문제-수정

Add friend dashboard page
This commit is contained in:
nightbug-xx 2025-06-11 11:00:21 +09:00 committed by GitHub
commit 9d6bef7c64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,17 +13,17 @@ import { useNavigate, useParams } from 'react-router-dom'
import api from '../lib/api'
interface Character {
character_id: number
character_name: string
id: number
name: string
server: string
}
interface Homework {
homework_id: number
id: number
title: string
reset_type: string
clear_count: number
complete_cnt: number
complete_cnt?: number
}
export default function FriendCharacterDashboard() {
@ -41,8 +41,8 @@ export default function FriendCharacterDashboard() {
const hwResults = await Promise.all(
res.data.map((char: Character) =>
api
.get(`/friends/${friend_id}/characters/${char.character_id}/homeworks`)
.then(r => ({ id: char.character_id, data: r.data }))
.get(`/friends/${friend_id}/characters/${char.id}/homeworks`)
.then(r => ({ id: char.id, data: r.data }))
)
)
const map: Record<number, Homework[]> = {}
@ -67,15 +67,15 @@ export default function FriendCharacterDashboard() {
</Typography>
<Grid container spacing={2}>
{characters.map(char => (
<Grid item xs={12} sm={6} md={4} key={char.character_id} {...({} as any)}>
<Grid item xs={12} sm={6} md={4} key={char.id} {...({} as any)}>
<Card>
<CardContent>
<Typography variant="h6" gutterBottom>
{char.server} : {char.character_name}
{char.server} : {char.name}
</Typography>
<Stack spacing={1}>
{(homeworks[char.character_id] || []).map(hw => (
<Box key={hw.homework_id}>
{(homeworks[char.id] || []).map(hw => (
<Box key={hw.id}>
<Typography variant="subtitle2" gutterBottom>
{hw.title} ({hw.clear_count})
</Typography>
@ -83,7 +83,7 @@ export default function FriendCharacterDashboard() {
{Array.from({ length: hw.clear_count }).map((_, idx) => (
<Checkbox
key={idx}
checked={idx < hw.complete_cnt}
checked={idx < (hw.complete_cnt ?? 0)}
disabled
size="small"
/>