codex/pagination-loading-indicator #20
@ -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,51 +196,60 @@ 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 style={{ overflowX: 'auto', background: 'var(--color-surface)' }}>
|
<div className="table-container">
|
||||||
<table style={tableStyle}>
|
<div style={{ overflowX: 'auto', background: 'var(--color-surface)' }}>
|
||||||
<thead>
|
<table style={tableStyle}>
|
||||||
<tr>
|
<thead>
|
||||||
<th align="left" style={thStyle}>
|
<tr>
|
||||||
Дата
|
<th align="left" style={thStyle}>
|
||||||
</th>
|
Дата
|
||||||
<th align="left" style={thStyle}>
|
</th>
|
||||||
Тип
|
<th align="left" style={thStyle}>
|
||||||
</th>
|
Тип
|
||||||
<th align="left" style={thStyle}>
|
</th>
|
||||||
Инструмент
|
<th align="left" style={thStyle}>
|
||||||
</th>
|
Инструмент
|
||||||
<th align="right" style={thStyle}>
|
</th>
|
||||||
Сумма
|
<th align="right" style={thStyle}>
|
||||||
</th>
|
Сумма
|
||||||
</tr>
|
</th>
|
||||||
</thead>
|
</tr>
|
||||||
<tbody>
|
</thead>
|
||||||
{operations.map((operation) => {
|
<tbody>
|
||||||
const impact = getBrokerOperationImpact(operation);
|
{operations.map((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>
|
||||||
<td style={tdStyle}>
|
<td style={tdStyle}>
|
||||||
<span>{getBrokerOperationTypeLabel(operation)}</span>
|
<span>{getBrokerOperationTypeLabel(operation)}</span>
|
||||||
</td>
|
</td>
|
||||||
<td style={tdStyle}>
|
<td style={tdStyle}>
|
||||||
<OperationInstrument operation={operation} />
|
<OperationInstrument operation={operation} />
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
align="right"
|
align="right"
|
||||||
style={{ ...tdStyle, color: moneyColor(impact), fontWeight: 700 }}
|
style={{ ...tdStyle, color: moneyColor(impact), fontWeight: 700 }}
|
||||||
>
|
>
|
||||||
{formatMoney(operation.payment)}
|
{formatMoney(operation.payment)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
{isFetching && (
|
||||||
|
<div className="table-loading-overlay">
|
||||||
|
<div className="loading-spinner" />
|
||||||
|
<span style={{ fontSize: 13, color: 'var(--color-text-secondary)' }}>
|
||||||
|
Загрузка страницы {pageNumber}…
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user