Skip to content

Commit

Permalink
chore: add loading data
Browse files Browse the repository at this point in the history
  • Loading branch information
pietro-maximoff committed Sep 28, 2023
1 parent a250afd commit 0699e69
Show file tree
Hide file tree
Showing 35 changed files with 46 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export const CloseWithDepositLoanFrame: FC<PropsWithChildren> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="close-with-deposits-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export const CloseWithSwapLoanFrame: FC<PropsWithChildren> = ({ children }) => {
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="close-with-swaps-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export const CollateralSurplusHistoryFrame: FC<PropsWithChildren> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="surplus-withdrawals-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const DepositCollateralLoanFrame: FC<PropsWithChildren> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="deposit-collaterals-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export const LiquidationLoanFrame: FC<PropsWithChildren> = ({ children }) => {
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="close-with-deposits-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export const NewLoanHistoryFrame: FC<PropsWithChildren> = ({ children }) => {
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="new-loans-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export const RolloverLoanHistoryFrame: FC<PropsWithChildren> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="rollover-loans-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ export const TransactionHistoryFrame: FC<PropsWithChildren> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={noDataLabel}
loadingData={t(translations.common.tables.loading)}
dataAttribute="transaction-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export const MyntConversionsHistoryFrame: React.FC<PropsWithChildren> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="mynt-conversions-history-table"
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const ZeroConversionsHistoryFrame: React.FC<PropsWithChildren> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="zero-conversions-history-table"
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const LendingHistoryFrame: FC<PropsWithChildren> = ({ children }) => {
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="earn-history-table"
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ export const StabilityPoolHistoryFrame: FC<PropsWithChildren> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={noDataLabel}
loadingData={t(translations.common.tables.loading)}
dataAttribute="stability-pool-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export const FundingHistoryFrame: FC = () => {
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="funding-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export const RedemptionsHistoryFrame: FC = () => {
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="redemption-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const RewardsEarnedHistory: FC<RewardHistoryProps> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="subsidy-history-reward-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export const StabilityPoolRewards: FC<RewardHistoryProps> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="reward-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export const StabilityPoolSubsidies: FC<RewardHistoryProps> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="subsidy-history-reward-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export const VestingRewards: FC<RewardHistoryProps> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="vesting-reward-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export const StakingDelegateChanges: FC<StakingHistoryProps> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="staking-delegate-change-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export const StakingExtendedDuration: FC<StakingHistoryProps> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="staking-extended-duration-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const StakingHistory: FC<StakingHistoryProps> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="staking-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const StakingWithdraws: FC<StakingHistoryProps> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="staking-withdrawns-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export const VestingDelegateChanges: FC<StakingHistoryProps> = ({
isLoading={loading}
className="bg-gray-80 text-gray-10 lg:px-6 lg:py-4"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="staking-delegate-change-history-table"
/>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const BorrowAssetsTable: FC = () => (
rowTitle={generateRowTitle}
className="text-gray-10 lg:px-6 lg:py-4 text-xs"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="borrow-assets-table"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const OpenLoansTable: FC<OpenLoansTableProps> = ({ loans, loading }) => (
rowTitle={generateRowTitle}
className="text-gray-10 lg:px-6 lg:py-4 text-xs"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
isLoading={loading}
dataAttribute="borrow-assets-table"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const LendFrame: FC = () => {
rowTitle={generateRowTitle}
className="text-gray-10 lg:px-6 lg:py-4 text-xs"
noData={t(translations.common.tables.noData)}
loadingData={t(translations.common.tables.loading)}
dataAttribute="lend-frame-table"
expandedContent={pool => <LendFrameDetails pool={pool} />}
expandedClassNames="border border-gray-70 border-t-0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export const StabilityPool: FC = () => {
: t(translations.rewardPage.stabilityPool.notConnected)}
</span>
}
loadingData={t(translations.common.tables.loading)}
rowTitle={row => (
<div className="flex flex-col items-start gap-1">
<Paragraph className="text-gray-40 font-medium">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const Staking: FC = () => {
: t(translations.rewardPage.stabilityPool.notConnected)}
</span>
}
loadingData={t(translations.common.tables.loading)}
rowTitle={row => (
<div className="flex flex-col items-start gap-1 font-medium">
<Paragraph className="text-gray-40">{row.type}</Paragraph>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const Vesting: FC = () => {
: t(translations.rewardPage.vesting.table.notConnected)}
</span>
}
loadingData={t(translations.common.tables.loading)}
isLoading={loading}
dataAttribute="funding-history-table"
rowTitle={generateRowTitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const StakesFrame: FC = () => {
: t(translations.stakePage.table.notConnected)}
</span>
}
loadingData={t(translations.common.tables.loading)}
dataAttribute="stakes-table"
/>
{account && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const VestingStakesFrame: FC = () => {
: t(translations.stakePage.table.notConnected)}
</span>
}
loadingData={t(translations.common.tables.loading)}
dataAttribute="vesting-stakes-table"
/>
{account && (
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"noDataToExport": "No data to export"
},
"noData": "No data available",
"noDataWithFilters": "No data with the current filters"
"noDataWithFilters": "No data with the current filters",
"loading": "Loading data..."
},
"max": "max",
"amount": "Amount",
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/2_molecules/Table/Table.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type TableProps<RowType extends RowObject> = {
rowKey?: (row: RowType) => number | string;
rowTitle?: (row: RowType) => ReactNode;
noData?: ReactNode;
loadingData?: ReactNode;
onRowClick?: (row: RowType) => void;
dataAttribute?: string;
isClickable?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const TableDesktop = <RowType extends RowObject>({
rows,
rowKey,
noData,
loadingData,
onRowClick,
dataAttribute,
isClickable,
Expand Down Expand Up @@ -143,19 +144,13 @@ export const TableDesktop = <RowType extends RowObject>({
))}
</tr>

{isLoading ? (
<tr className={rowStyles.row}>
<td className={styles.loading} colSpan={999}>
Loading data…
</td>
</tr>
) : (
<tr className={rowStyles.row}>
<td className={styles.noData} colSpan={999}>
{noData ? noData : 'No data'}
</td>
</tr>
)}
<tr className={rowStyles.row}>
<td className={styles.loading} colSpan={999}>
{isLoading
? loadingData || 'Loading data…'
: noData || 'No data'}
</td>
</tr>
</>
)}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const TableMobile = <RowType extends RowObject>({
onRowClick,
dataAttribute,
noData,
loadingData,
isLoading,
className,
expandedContent,
Expand All @@ -36,13 +37,9 @@ export const TableMobile = <RowType extends RowObject>({
))}

{(!rows || rows.length === 0) && (
<>
{isLoading ? (
<div className={styles.loading}>Loading data…</div>
) : (
<div className={styles.noData}>{noData ? noData : 'No data'}</div>
)}
</>
<div className={isLoading ? styles.loading : styles.noData}>
{isLoading ? loadingData || 'Loading data…' : noData || 'No data'}
</div>
)}
</div>
);

0 comments on commit 0699e69

Please sign in to comment.