feat: add apply button for date range - data loads only on click
CI/CD / build-and-push (push) Successful in 1m25s
Details
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:
parent
71affe7d43
commit
ba52cb31c1
|
|
@ -23,8 +23,16 @@ export default function Home() {
|
||||||
const defaultRange = getDefaultRange();
|
const defaultRange = getDefaultRange();
|
||||||
const [startDate, setStartDate] = useState(defaultRange.start);
|
const [startDate, setStartDate] = useState(defaultRange.start);
|
||||||
const [endDate, setEndDate] = useState(defaultRange.end);
|
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 reportRef = useRef<HTMLDivElement>(null);
|
||||||
|
const isDirty = startDate !== appliedStart || endDate !== appliedEnd;
|
||||||
|
|
||||||
|
const applyRange = () => {
|
||||||
|
setAppliedStart(startDate);
|
||||||
|
setAppliedEnd(endDate);
|
||||||
|
};
|
||||||
|
|
||||||
const handleExportPdf = async () => {
|
const handleExportPdf = async () => {
|
||||||
if (!reportRef.current) return;
|
if (!reportRef.current) return;
|
||||||
|
|
@ -113,6 +121,17 @@ export default function Home() {
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
<ErrorBoundary fallback="SummaryCards 오류">
|
<ErrorBoundary fallback="SummaryCards 오류">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue