Skip to content

Commit

Permalink
Merge pull request RoboSats#1570 from RoboSats/add-skeleton-while-loa…
Browse files Browse the repository at this point in the history
…ding-limits

Add skeleton while loading limits
  • Loading branch information
KoalaSat authored Oct 20, 2024
2 parents 72cd7a8 + 60f2d17 commit 1f2d01b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion frontend/src/basic/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const Routes: React.FC = () => {

return (
<DomRoutes>
{['/garage/:token?', '/', ''].map((path, index) => {
{['/garage/:token?', '/garage', '/', ''].map((path, index) => {
return (
<Route
path={path}
Expand Down
11 changes: 8 additions & 3 deletions frontend/src/components/BookTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
IconButton,
Tooltip,
styled,
Skeleton,
} from '@mui/material';
import {
DataGrid,
Expand Down Expand Up @@ -427,8 +428,8 @@ const BookTable = ({
const currencyCode = String(currencyDict[params.row.currency.toString()]);
const coordinator = federation.getCoordinator(params.row.coordinatorShortAlias);
const premium = parseFloat(params.row.premium);
const price =
(coordinator.limits[params.row.currency.toString()]?.price ?? 1) * (1 + premium / 100);
const limitPrice = coordinator.limits[params.row.currency.toString()]?.price;
const price = (limitPrice ?? 1) * (1 + premium / 100);

return (
<div
Expand All @@ -437,7 +438,11 @@ const BookTable = ({
onOrderClicked(params.row.id, params.row.coordinatorShortAlias);
}}
>
{`${pn(Math.round(price))} ${currencyCode}/BTC`}
{limitPrice ? (
`${pn(Math.round(price))} ${currencyCode}/BTC`
) : (
<Skeleton variant='rectangular' width={200} height={20} style={{ marginTop: 15 }} />
)}
</div>
);
},
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/Charts/DepthChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const DepthChart: React.FC<DepthChartProps> = ({
useEffect(() => {
if (Object.values(federation.book).length > 0) {
const enriched = Object.values(federation.book).map((order) => {
if (order.coordinatorShortAlias != null && order.currency) {
if (order && order.coordinatorShortAlias != null && order.currency) {
const limits = federation.getCoordinator(order.coordinatorShortAlias).limits;

const originalPrice =
Expand Down Expand Up @@ -127,12 +127,12 @@ const DepthChart: React.FC<DepthChartProps> = ({
? enrichedOrders.sort(
(order1, order2) => (order1?.base_price ?? 0) - (order2?.base_price ?? 0),
)
: enrichedOrders.sort((order1, order2) => order1.premium - order2.premium);
: enrichedOrders.sort((order1, order2) => order1?.premium - order2?.premium);

const sortedBuyOrders: PublicOrder[] = sortedOrders
.filter((order) => order.type === 0)
.filter((order) => order?.type === 0)
.reverse();
const sortedSellOrders: PublicOrder[] = sortedOrders.filter((order) => order.type === 1);
const sortedSellOrders: PublicOrder[] = sortedOrders.filter((order) => order?.type === 1);

const buySerie: Datum[] = generateSerie(sortedBuyOrders);
const sellSerie: Datum[] = generateSerie(sortedSellOrders);
Expand Down

0 comments on commit 1f2d01b

Please sign in to comment.