Merge pull request #15 from nightbug-xx/mcr5z4-codex/친구정보-출력-문제-수정
Add friend dashboard page
This commit is contained in:
commit
9d6bef7c64
@ -13,17 +13,17 @@ import { useNavigate, useParams } from 'react-router-dom'
|
|||||||
import api from '../lib/api'
|
import api from '../lib/api'
|
||||||
|
|
||||||
interface Character {
|
interface Character {
|
||||||
character_id: number
|
id: number
|
||||||
character_name: string
|
name: string
|
||||||
server: string
|
server: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Homework {
|
interface Homework {
|
||||||
homework_id: number
|
id: number
|
||||||
title: string
|
title: string
|
||||||
reset_type: string
|
reset_type: string
|
||||||
clear_count: number
|
clear_count: number
|
||||||
complete_cnt: number
|
complete_cnt?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function FriendCharacterDashboard() {
|
export default function FriendCharacterDashboard() {
|
||||||
@ -41,8 +41,8 @@ export default function FriendCharacterDashboard() {
|
|||||||
const hwResults = await Promise.all(
|
const hwResults = await Promise.all(
|
||||||
res.data.map((char: Character) =>
|
res.data.map((char: Character) =>
|
||||||
api
|
api
|
||||||
.get(`/friends/${friend_id}/characters/${char.character_id}/homeworks`)
|
.get(`/friends/${friend_id}/characters/${char.id}/homeworks`)
|
||||||
.then(r => ({ id: char.character_id, data: r.data }))
|
.then(r => ({ id: char.id, data: r.data }))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
const map: Record<number, Homework[]> = {}
|
const map: Record<number, Homework[]> = {}
|
||||||
@ -67,15 +67,15 @@ export default function FriendCharacterDashboard() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
{characters.map(char => (
|
{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>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Typography variant="h6" gutterBottom>
|
<Typography variant="h6" gutterBottom>
|
||||||
{char.server} : {char.character_name}
|
{char.server} : {char.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Stack spacing={1}>
|
<Stack spacing={1}>
|
||||||
{(homeworks[char.character_id] || []).map(hw => (
|
{(homeworks[char.id] || []).map(hw => (
|
||||||
<Box key={hw.homework_id}>
|
<Box key={hw.id}>
|
||||||
<Typography variant="subtitle2" gutterBottom>
|
<Typography variant="subtitle2" gutterBottom>
|
||||||
{hw.title} ({hw.clear_count}회)
|
{hw.title} ({hw.clear_count}회)
|
||||||
</Typography>
|
</Typography>
|
||||||
@ -83,7 +83,7 @@ export default function FriendCharacterDashboard() {
|
|||||||
{Array.from({ length: hw.clear_count }).map((_, idx) => (
|
{Array.from({ length: hw.clear_count }).map((_, idx) => (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
key={idx}
|
key={idx}
|
||||||
checked={idx < hw.complete_cnt}
|
checked={idx < (hw.complete_cnt ?? 0)}
|
||||||
disabled
|
disabled
|
||||||
size="small"
|
size="small"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user