Skip to content

Commit

Permalink
feat: Adding LogsSideDrawer and handling row click
Browse files Browse the repository at this point in the history
  • Loading branch information
RabeeAbuBaker committed Oct 11, 2023
1 parent 1bed456 commit bad347c
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { Divider } from "@mantine/core"
import { Card, Drawer, Group, Stack, Text } from "@pokt-foundation/pocket-blocks"
import React from "react"
import { TitledCard } from "~/components/TitledCard"
import { Logs } from "~/models/dwh/sdk"
import { dayjs } from "~/utils/dayjs"

type LogsSideDrawerProps = {
logsItem?: Logs
onSideDrawerClose: () => void
}

const LogsSideDrawer = ({ logsItem, onSideDrawerClose }: LogsSideDrawerProps) => {
console.log({ logsItem })
const cardItems = [
{
label: "Date",
value: dayjs(logsItem?.ts).format("D MMMM, YYYY"),
},
{
label: "Time",
value: dayjs(logsItem?.ts).format("h:mm A"),
},
{
label: "Application ID",
value: logsItem?.portalApplicationId,
},
{
label: "Chain ID",
value: logsItem?.chainId,
},
{
label: "Supported method",
value: logsItem?.chainMethod,
},
{
label: "Error type",
value: logsItem?.errorType,
},
{
label: "Error name",
value: logsItem?.errorName,
},
]

return (
<Drawer
opened={!!logsItem}
overlayColor="#000000"
overlayOpacity={0.5}
padding="sm"
position="right"
size={800}
onClose={onSideDrawerClose}
>
<Stack>
<TitledCard header={() => <Text weight={600}>Summary</Text>}>
<Card.Section p="md">
<Stack spacing={12}>
{cardItems.map(({ label, value }, index) => (
<React.Fragment key={`${label}-${index}`}>
<Group position="apart" px={12}>
<Text>{label}</Text> <Text>{value}</Text>
</Group>
{index !== cardItems.length - 1 && <Divider />}
</React.Fragment>
))}
</Stack>
</Card.Section>
</TitledCard>

<TitledCard header={() => <Text weight={600}>Message</Text>}>
<Card.Section p="md">
<Text>{logsItem?.errorMessage}</Text>
</Card.Section>
</TitledCard>
</Stack>
</Drawer>
)
}

export default LogsSideDrawer
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import LogsSideDrawer from "./LogsSideDrawer"
export * from "./LogsSideDrawer"
export default LogsSideDrawer
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from "react"
import { DataTable } from "~/components/DataTable"
import { Logs } from "~/models/dwh/sdk"
import LogsSideDrawer from "~/routes/account.$accountId.$appId.logs/components/LogsSideDrawer"
import { dayjs } from "~/utils/dayjs"

type LogsTableProps = {
Expand All @@ -13,6 +14,10 @@ const LogsTable = ({ logs, searchTerm }: LogsTableProps) => {

return (
<>
<LogsSideDrawer
logsItem={selectedLogsItem}
onSideDrawerClose={() => setSelectedLogsItem(undefined)}
/>
<DataTable
columns={["Timestamp", "Method", "Chain ID", "Error type", "Error name"]}
data={logs.map((log) => {
Expand Down

0 comments on commit bad347c

Please sign in to comment.