Skip to content

Commit d1c4388

Browse files
committed
export csv button
1 parent 15668f3 commit d1c4388

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

frontend/src/ts/components/pages/account/AccountPage.tsx

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ export function AccountPage(): JSXElement {
4646
const [isExporting, setIsExporting] = createSignal(false);
4747

4848
const resultsQuery = useResultsLiveQuery({ queryState, sorting, limit });
49+
const nonLimitResultsQuery = useResultsLiveQuery({
50+
queryState,
51+
sorting,
52+
limit: () => Infinity,
53+
});
4954

5055
return (
5156
<Show when={isAuthenticated() && isOpen()}>
@@ -87,27 +92,28 @@ export function AccountPage(): JSXElement {
8792
/>
8893
<TestStats queryState={queryState} />
8994

90-
<div class="grid grid-cols-3">
91-
<Button
92-
text="Export CSV"
93-
fa={{ icon: "fa-file-csv" }}
94-
class="col-start-3 w-full"
95-
disabled={isExporting()}
96-
onClick={() => {
97-
setIsExporting(true);
98-
showLoaderBar();
99-
const filteredResults = useResultsLiveQuery({
100-
queryState,
101-
sorting,
102-
limit: () => Infinity,
103-
});
104-
void downloadResultsCSV(filteredResults()).finally(() => {
105-
hideLoaderBar();
106-
setIsExporting(false);
107-
});
108-
}}
109-
/>
110-
</div>
95+
<AsyncContent collections={{ nonLimitResultsQuery }}>
96+
{({ nonLimitResultsQueryData }) => (
97+
<div class="grid grid-cols-3">
98+
<Button
99+
text="Export CSV"
100+
fa={{ icon: "fa-file-csv" }}
101+
class="col-start-3 w-full"
102+
disabled={isExporting()}
103+
onClick={() => {
104+
setIsExporting(true);
105+
showLoaderBar();
106+
void downloadResultsCSV(
107+
nonLimitResultsQueryData(),
108+
).finally(() => {
109+
hideLoaderBar();
110+
setIsExporting(false);
111+
});
112+
}}
113+
/>
114+
</div>
115+
)}
116+
</AsyncContent>
111117

112118
<Advertisement id="ad-account-2" visible="sellout" />
113119

0 commit comments

Comments
 (0)