Skip to content

Commit

Permalink
feat: add slot status to the slot page
Browse files Browse the repository at this point in the history
  • Loading branch information
VmMad committed Mar 1, 2024
1 parent e895097 commit e44d838
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/src/app/lib/enums/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./slot-status.enum";
5 changes: 5 additions & 0 deletions client/src/app/lib/enums/slot-status.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum SlotStatus {
Pending = "pending",
Confirmed = "confirmed",
Finalized = "finalized",
}
18 changes: 15 additions & 3 deletions client/src/app/routes/nova/SlotPage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import React from "react";
import useuseSlotDetails from "~/helpers/nova/hooks/useSlotDetails";
import useSlotDetails from "~/helpers/nova/hooks/useSlotDetails";
import PageDataRow, { IPageDataRow } from "~/app/components/nova/PageDataRow";
import Modal from "~/app/components/Modal";
import mainHeaderMessage from "~assets/modals/nova/slot/main-header.json";
import NotFound from "~/app/components/NotFound";
import { RouteComponentProps } from "react-router-dom";
import "./SlotPage.scss";
import { PillStatus } from "~/app/lib/ui/enums";
import StatusPill from "~/app/components/nova/StatusPill";
import { SlotStatus } from "~/app/lib/enums";

const SLOT_STATUS_TO_PILL_STATUS: Record<SlotStatus, PillStatus> = {
[SlotStatus.Pending]: PillStatus.Pending,
[SlotStatus.Confirmed]: PillStatus.Success,
[SlotStatus.Finalized]: PillStatus.Success,
};

export default function SlotPage({
match: {
Expand All @@ -15,8 +24,7 @@ export default function SlotPage({
network: string;
slotIndex: string;
}>): React.JSX.Element {
const { slotCommitment } = useuseSlotDetails(network, slotIndex);

const { slotCommitment } = useSlotDetails(network, slotIndex);
const parsedSlotIndex = parseSlotIndex(slotIndex);

const dataRows: IPageDataRow[] = [
Expand All @@ -30,6 +38,9 @@ export default function SlotPage({
},
];

const slotStatus: SlotStatus = slotCommitment ? SlotStatus.Finalized : SlotStatus.Pending;
const slotStatusPill = SLOT_STATUS_TO_PILL_STATUS[slotStatus];

function parseSlotIndex(slotIndex: string): number | undefined {
const slotIndexNum = parseInt(slotIndex, 10);
if (isNaN(slotIndexNum)) {
Expand All @@ -47,6 +58,7 @@ export default function SlotPage({
<h1>Slot</h1>
<Modal icon="info" data={mainHeaderMessage} />
</div>
<StatusPill label={slotStatus} status={slotStatusPill} />
</div>
{parsedSlotIndex ? (
<div className="section">
Expand Down

0 comments on commit e44d838

Please sign in to comment.