2026-05-24 23:22:18 +09:00
|
|
|
import { Card, List, NavBar, Space, Tag } from 'antd-mobile';
|
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
|
import { useAuthStore } from '@/stores/authStore';
|
2026-05-24 23:32:19 +09:00
|
|
|
import { notificationApi } from '@/api/notification';
|
2026-05-24 23:22:18 +09:00
|
|
|
|
|
|
|
|
export default function Home() {
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const profile = useAuthStore((s) => s.profile);
|
|
|
|
|
const clear = useAuthStore((s) => s.clear);
|
|
|
|
|
|
2026-05-24 23:32:19 +09:00
|
|
|
const summary = useQuery({
|
|
|
|
|
queryKey: ['mobile.me.summary'],
|
|
|
|
|
queryFn: () => notificationApi.summary(),
|
|
|
|
|
staleTime: 10_000,
|
2026-05-24 23:22:18 +09:00
|
|
|
});
|
|
|
|
|
|
2026-05-24 23:32:19 +09:00
|
|
|
const s = summary.data;
|
|
|
|
|
const loading = summary.isLoading;
|
|
|
|
|
|
2026-05-24 23:22:18 +09:00
|
|
|
return (
|
|
|
|
|
<div className="page">
|
|
|
|
|
<NavBar back={null} right={<a onClick={() => { clear(); navigate('/login'); }} style={{ fontSize: 14 }}>로그아웃</a>}>
|
|
|
|
|
홈
|
|
|
|
|
</NavBar>
|
|
|
|
|
<div style={{ padding: 16 }}>
|
|
|
|
|
<Card>
|
|
|
|
|
<div style={{ fontSize: 18, fontWeight: 700 }}>
|
|
|
|
|
{profile?.userName ?? profile?.loginId ?? '사용자'} 님
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{ color: '#888', fontSize: 13, marginTop: 4 }}>
|
|
|
|
|
{profile?.agentName ? `${profile.agentName} · ${profile.orgName ?? ''}` : '설계사 정보 없음'}
|
|
|
|
|
</div>
|
2026-05-24 23:32:19 +09:00
|
|
|
{profile?.roleCodes && profile.roleCodes.length > 0 && (
|
2026-05-24 23:22:18 +09:00
|
|
|
<div style={{ marginTop: 8 }}>
|
|
|
|
|
<Space wrap>
|
|
|
|
|
{profile.roleCodes.map((r) => <Tag key={r} color="primary">{r}</Tag>)}
|
|
|
|
|
</Space>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
<div style={{ marginTop: 16 }}>
|
|
|
|
|
<List header="요약">
|
|
|
|
|
<List.Item
|
2026-05-24 23:32:19 +09:00
|
|
|
extra={loading ? '...' : `총 ${s?.statementCount ?? 0}건`}
|
2026-05-24 23:22:18 +09:00
|
|
|
onClick={() => navigate('/statement')}
|
|
|
|
|
clickable
|
|
|
|
|
>
|
|
|
|
|
정산 명세서
|
|
|
|
|
</List.Item>
|
|
|
|
|
<List.Item
|
2026-05-24 23:32:19 +09:00
|
|
|
extra={loading ? '...' : `총 ${s?.withdrawRequestCount ?? 0}건`}
|
2026-05-24 23:22:18 +09:00
|
|
|
onClick={() => navigate('/withdraw')}
|
|
|
|
|
clickable
|
|
|
|
|
>
|
|
|
|
|
출금 신청
|
|
|
|
|
</List.Item>
|
|
|
|
|
<List.Item
|
2026-05-24 23:32:19 +09:00
|
|
|
extra={
|
|
|
|
|
loading
|
|
|
|
|
? '...'
|
|
|
|
|
: (s?.unreadNotificationCount ?? 0) > 0
|
|
|
|
|
? <Tag color="danger">{s?.unreadNotificationCount}건 안 읽음</Tag>
|
|
|
|
|
: '모두 확인'
|
|
|
|
|
}
|
2026-05-24 23:22:18 +09:00
|
|
|
onClick={() => navigate('/notice')}
|
|
|
|
|
clickable
|
|
|
|
|
>
|
2026-05-24 23:32:19 +09:00
|
|
|
알림 / 공지
|
2026-05-24 23:22:18 +09:00
|
|
|
</List.Item>
|
|
|
|
|
</List>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-05-24 23:32:19 +09:00
|
|
|
{s && !s.agentId && (
|
2026-05-24 23:22:18 +09:00
|
|
|
<div style={{ marginTop: 24, fontSize: 12, color: '#f96', textAlign: 'center' }}>
|
2026-05-24 23:32:19 +09:00
|
|
|
본 계정에 연결된 설계사(agent)가 없습니다. 명세서·출금 조회가 제한됩니다.
|
2026-05-24 23:22:18 +09:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|