-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding ApiRx for Tangle dApp for Real Time Data (#1788)
Co-authored-by: drewstone <[email protected]>
- Loading branch information
Showing
72 changed files
with
590 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export async function GET(request: Request) { | ||
export async function GET() { | ||
return new Response('Hello, from API!'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import type { IconBase } from '@webb-tools/icons/types'; | ||
import type React from 'react'; | ||
|
||
export type BreadcrumbType = { | ||
label: string; | ||
isLast: boolean; | ||
icon: JSX.Element; | ||
icon: React.ReactElement<IconBase>; | ||
href: string; | ||
className?: string; | ||
}; |
14 changes: 14 additions & 0 deletions
14
apps/tangle-dapp/components/HeaderChip/ChipValueClient.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use client'; | ||
|
||
import getRoundedDownNumberWith2Decimals from '../../utils/getRoundedDownNumberWith2Decimals'; | ||
import dataHooks from './dataHooks'; | ||
import { ChipType } from './types'; | ||
|
||
export default function ChipValueClient(props: { | ||
type: ChipType; | ||
value?: number; | ||
}) { | ||
const era = dataHooks[props.type](props.value); | ||
|
||
return <>{getRoundedDownNumberWith2Decimals(era)}</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import useEraCountSubscription from '../../data/HeaderChips/useEraCountSubscription'; | ||
import useSessionCountSubscription from '../../data/HeaderChips/useSessionCountSubscription'; | ||
|
||
const dataHooks = { | ||
ERA: useEraCountSubscription, | ||
Session: useSessionCountSubscription, | ||
} as const; | ||
|
||
export default dataHooks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/tangle-dapp/components/InfoIconWithTooltip/InfoIconWithTooltip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
apps/tangle-dapp/components/KeyMetricItem/KeyMetricItemValueClient.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use client'; | ||
|
||
import { Typography } from '@webb-tools/webb-ui-components/typography/Typography'; | ||
|
||
import type { MetricReturnType } from '../../types'; | ||
import getRoundedDownNumberWith2Decimals from '../../utils/getRoundedDownNumberWith2Decimals'; | ||
import dataHooks, { defaultHook } from './dataHooks'; | ||
import type { MetricItemProps } from './types'; | ||
|
||
function KeyMetricItemValueClient( | ||
props: Pick<MetricItemProps, 'prefix' | 'suffix' | 'title'> & MetricReturnType | ||
) { | ||
const { title, prefix, suffix, value1: value1_, value2: value2_ } = props; | ||
const dataHook = dataHooks[title] ?? defaultHook; | ||
const { value1, value2 } = dataHook({ value1: value1_, value2: value2_ }); | ||
|
||
return ( | ||
<div className="flex flex-col gap-1 sm:flex-row sm:items-center"> | ||
<div className="flex items-center gap-0.5"> | ||
<Typography | ||
variant="h4" | ||
fw="bold" | ||
className="text-mono-140 dark:text-mono-40" | ||
> | ||
{typeof value1 === 'number' && (prefix ?? '')} | ||
{getRoundedDownNumberWith2Decimals(value1)} | ||
{value2 && <> / {getRoundedDownNumberWith2Decimals(value2)}</>} | ||
</Typography> | ||
|
||
{typeof value1 === 'number' && suffix && ( | ||
<Typography | ||
variant="h4" | ||
fw="bold" | ||
className="text-mono-140 dark:text-mono-40" | ||
> | ||
{suffix} | ||
</Typography> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default KeyMetricItemValueClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { | ||
useActiveAndDelegationCountSubscription, | ||
useValidatorsCountSubscription, | ||
useWaitingCountSubscription, | ||
} from '../../data'; | ||
import type { MetricReturnType } from '../../types'; | ||
|
||
const dataHooks: { | ||
[key: string]: (defaultValue?: MetricReturnType) => MetricReturnType; | ||
} = { | ||
Validators: useValidatorsCountSubscription, | ||
Waiting: useWaitingCountSubscription, | ||
'Active/Delegation': useActiveAndDelegationCountSubscription, | ||
} as const; | ||
|
||
export default dataHooks; | ||
|
||
export const defaultHook = (defaultValue: MetricReturnType = {}) => | ||
defaultValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from './sideBar'; | ||
export * from './Breadcrumbs'; | ||
export * from './HeaderChip'; | ||
export * from './InfoIconWithTooltip'; | ||
export * from './KeyMetricItem'; | ||
export * from './sideBar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.