feat: add apply button for date range - data loads only on click
CI/CD / build-and-push (push) Successful in 1m25s Details

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Cloud User 2026-03-17 11:32:36 +09:00
parent 71affe7d43
commit ba52cb31c1
1 changed files with 20 additions and 1 deletions

View File

@ -23,8 +23,16 @@ export default function Home() {
const defaultRange = getDefaultRange();
const [startDate, setStartDate] = useState(defaultRange.start);
const [endDate, setEndDate] = useState(defaultRange.end);
const { data, isLoading, error } = useReport(startDate, endDate);
const [appliedStart, setAppliedStart] = useState(defaultRange.start);
const [appliedEnd, setAppliedEnd] = useState(defaultRange.end);
const { data, isLoading, error } = useReport(appliedStart, appliedEnd);
const reportRef = useRef<HTMLDivElement>(null);
const isDirty = startDate !== appliedStart || endDate !== appliedEnd;
const applyRange = () => {
setAppliedStart(startDate);
setAppliedEnd(endDate);
};
const handleExportPdf = async () => {
if (!reportRef.current) return;
@ -113,6 +121,17 @@ export default function Home() {
</button>
))}
</div>
<button
onClick={applyRange}
disabled={!isDirty}
className={`px-4 py-1.5 text-sm rounded font-medium ${
isDirty
? 'bg-blue-600 text-white hover:bg-blue-700'
: 'bg-gray-200 text-gray-400 cursor-not-allowed'
}`}
>
</button>
</div>
<ErrorBoundary fallback="SummaryCards 오류">