feat: add loading overlay and spinner to PositionGroupTable
This commit is contained in:
parent
510ee91fab
commit
90e9c468de
@ -100,7 +100,7 @@ function PositionGroupTable({
|
|||||||
const [cursor, setCursor] = useState<string | undefined>(undefined);
|
const [cursor, setCursor] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
const query = group.type ? { type: group.type, limit: 10, cursor } : { limit: 100, cursor };
|
const query = group.type ? { type: group.type, limit: 10, cursor } : { limit: 100, cursor };
|
||||||
const { data: page, isLoading } = useBrokerPositions(accountId, query);
|
const { data: page, isLoading, isFetching } = useBrokerPositions(accountId, query);
|
||||||
|
|
||||||
const rawPositions = page?.items ?? [];
|
const rawPositions = page?.items ?? [];
|
||||||
const positions = group.type
|
const positions = group.type
|
||||||
@ -148,10 +148,17 @@ function PositionGroupTable({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={handlePrevious}
|
onClick={handlePrevious}
|
||||||
disabled={!canGoBack}
|
disabled={!canGoBack || isFetching}
|
||||||
style={canGoBack ? pagButtonStyle : pagButtonDisabledStyle}
|
style={canGoBack && !isFetching ? pagButtonStyle : pagButtonDisabledStyle}
|
||||||
>
|
>
|
||||||
←
|
{isFetching ? (
|
||||||
|
<span
|
||||||
|
className="loading-spinner"
|
||||||
|
style={{ width: 14, height: 14, display: 'block' }}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
'←'
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
@ -167,10 +174,17 @@ function PositionGroupTable({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={handleNext}
|
onClick={handleNext}
|
||||||
disabled={!canGoForward}
|
disabled={!canGoForward || isFetching}
|
||||||
style={canGoForward ? pagButtonStyle : pagButtonDisabledStyle}
|
style={canGoForward && !isFetching ? pagButtonStyle : pagButtonDisabledStyle}
|
||||||
>
|
>
|
||||||
→
|
{isFetching ? (
|
||||||
|
<span
|
||||||
|
className="loading-spinner"
|
||||||
|
style={{ width: 14, height: 14, display: 'block' }}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
'→'
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -213,6 +227,7 @@ function PositionGroupTable({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{!isLoading && positions.length > 0 && (
|
{!isLoading && positions.length > 0 && (
|
||||||
|
<div className="table-container">
|
||||||
<div style={{ overflowX: 'auto', background: 'var(--color-surface)' }}>
|
<div style={{ overflowX: 'auto', background: 'var(--color-surface)' }}>
|
||||||
<table aria-label={`Брокерские позиции: ${group.title}`} style={tableStyle}>
|
<table aria-label={`Брокерские позиции: ${group.title}`} style={tableStyle}>
|
||||||
<thead>
|
<thead>
|
||||||
@ -266,6 +281,15 @@ function PositionGroupTable({
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{isFetching && (
|
||||||
|
<div className="table-loading-overlay">
|
||||||
|
<div className="loading-spinner" />
|
||||||
|
<span style={{ fontSize: 13, color: 'var(--color-text-secondary)' }}>
|
||||||
|
Загрузка страницы {pageNumber}…
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user