codex/pagination-loading-indicator #20

Merged
ksv741 merged 6 commits from codex/pagination-loading-indicator into main 2026-06-18 07:29:36 +03:00
Showing only changes of commit cb90f3c1c0 - Show all commits

View File

@ -95,6 +95,7 @@ const pagButtonDisabledStyle = {
export function BrokerOperationsTable({ export function BrokerOperationsTable({
isLoading, isLoading,
isFetching,
page, page,
pageNumber, pageNumber,
canGoBack, canGoBack,
@ -103,6 +104,7 @@ export function BrokerOperationsTable({
onNext, onNext,
}: { }: {
isLoading: boolean; isLoading: boolean;
isFetching: boolean;
page: BrokerOperationsPage | undefined; page: BrokerOperationsPage | undefined;
pageNumber: number; pageNumber: number;
canGoBack: boolean; canGoBack: boolean;
@ -128,10 +130,17 @@ export function BrokerOperationsTable({
<button <button
type="button" type="button"
onClick={onPrevious} onClick={onPrevious}
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={{
@ -147,10 +156,17 @@ export function BrokerOperationsTable({
<button <button
type="button" type="button"
onClick={onNext} onClick={onNext}
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>
</div> </div>
@ -180,9 +196,10 @@ export function BrokerOperationsTable({
/> />
</table> </table>
</div> </div>
) : operations.length === 0 ? ( ) : operations.length === 0 && !isFetching ? (
<p style={{ color: 'var(--color-text-secondary)' }}>Операций за выбранный период нет</p> <p style={{ color: 'var(--color-text-secondary)' }}>Операций за выбранный период нет</p>
) : ( ) : (
<div className="table-container">
<div style={{ overflowX: 'auto', background: 'var(--color-surface)' }}> <div style={{ overflowX: 'auto', background: 'var(--color-surface)' }}>
<table style={tableStyle}> <table style={tableStyle}>
<thead> <thead>
@ -204,7 +221,6 @@ export function BrokerOperationsTable({
<tbody> <tbody>
{operations.map((operation) => { {operations.map((operation) => {
const impact = getBrokerOperationImpact(operation); const impact = getBrokerOperationImpact(operation);
return ( return (
<tr key={operation.cursor || operation.id}> <tr key={operation.cursor || operation.id}>
<td style={tdStyle}>{formatDate(operation.date)}</td> <td style={tdStyle}>{formatDate(operation.date)}</td>
@ -226,6 +242,15 @@ export function BrokerOperationsTable({
</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>
); );