Skip to content

Commit

Permalink
first draft of the delegatee list
Browse files Browse the repository at this point in the history
  • Loading branch information
wirednkod committed Aug 20, 2024
1 parent 43370e4 commit 53e1d06
Show file tree
Hide file tree
Showing 6 changed files with 480 additions and 20 deletions.
25 changes: 14 additions & 11 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import 'dot-connect/font.css'
import { config } from './walletConfigs'
import { ReDotProvider, ReDotChainProvider } from '@reactive-dot/react'
import { Suspense } from 'react'
import { AccountContextProvider } from './contexts/AccountsContext'
import { AccountContextProvider } from '@/contexts/AccountsContext'
import { DelegateeContextProvider } from '@/contexts/DelegateesContext'

const App = () => {
const [settings] = useLocalStorage('fellowship-settings', {
Expand All @@ -23,17 +24,19 @@ const App = () => {
<ReDotProvider config={config}>
<ReDotChainProvider chainId="polkadot">
<Suspense>
<AccountContextProvider>
<TooltipProvider>
<div className="flex min-h-screen w-full flex-col bg-muted/40">
<Navigation />
<div className="flex flex-col sm:gap-4 sm:py-4 sm:pl-14">
<Header />
<Content />
<DelegateeContextProvider>
<AccountContextProvider>
<TooltipProvider>
<div className="flex min-h-screen w-full flex-col bg-muted/40">
<Navigation />
<div className="flex flex-col sm:gap-4 sm:py-4 sm:pl-14">
<Header />
<Content />
</div>
</div>
</div>
</TooltipProvider>
</AccountContextProvider>
</TooltipProvider>
</AccountContextProvider>
</DelegateeContextProvider>
</Suspense>
</ReDotChainProvider>
</ReDotProvider>
Expand Down
3 changes: 2 additions & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const DappName = 'Polkadot DelegIt Dashboard'
const PolkadotUrl = 'https://delegit-xyz.github.io/dashboard'

const GithubOwner = 'delegit-xyz'
// const GithubApiUrl = `https://api.github.com/repos/${GithubOwner}/${GithubRfc}`
export const DelegeeList =
'https://raw.githubusercontent.com/novasamatech/opengov-delegate-registry/master/registry/polkadot.json'

const SideMenuMaximisedWidth = 185
const SideMenuMinimisedWidth = 75
Expand Down
50 changes: 50 additions & 0 deletions src/contexts/DelegateesContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* eslint-disable react-refresh/only-export-components */
import { createContext, useContext, useEffect, useState } from 'react'
import delegateesList from '@/polkadot.json'

type DelegateesContextProps = {
children: React.ReactNode | React.ReactNode[]
}

type DelegateeProps = {
address: string
name: string
image: string
shortDescription: string
longDescription: string
isOrganization: boolean
}

export interface IDelegateesContext {
delegetees: DelegateeProps[]
}

const DelegateesContext = createContext<IDelegateesContext | undefined>(
undefined,
)

const DelegateeContextProvider = ({ children }: DelegateesContextProps) => {
const [delegetees, setDelegatees] = useState<DelegateeProps[]>([])

useEffect(() => {
setDelegatees(delegateesList as DelegateeProps[])
}, [])

return (
<DelegateesContext.Provider value={{ delegetees }}>
{children}
</DelegateesContext.Provider>
)
}

const useDelegatees = () => {
const context = useContext(DelegateesContext)
if (context === undefined) {
throw new Error(
'useDelegatees must be used within a DelegateesContextProvider',
)
}
return context
}

export { DelegateeContextProvider, useDelegatees }
1 change: 1 addition & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export type RouterType = {
export const routes: RouterType[] = [
{ link: 'home', name: 'Home', icon: House },
]

28 changes: 20 additions & 8 deletions src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
import { Button } from '@/components/ui/button'
import { Card } from '@/components/ui/card'
import { useDelegatees } from '@/contexts/DelegateesContext'

const openInNewTab = (url: string | URL | undefined) => {

Check failure on line 4 in src/pages/Home/index.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

'openInNewTab' is declared but its value is never read.

Check failure on line 4 in src/pages/Home/index.tsx

View workflow job for this annotation

GitHub Actions / build (20.x)

'openInNewTab' is declared but its value is never read.
window.open(url, '_blank', 'noopener,noreferrer')
}

export const Home = () => {
const { delegetees } = useDelegatees()

console.log(delegetees)
return (
<main className="grid flex-1 items-start gap-4 p-4 sm:mx-[5%] xl:mx-[20%] mx-0 sm:px-6 sm:py-0 md:gap-8">
<h1 className="font-unbounded text-primary flex-1 shrink-0 whitespace-nowrap text-xl font-semibold tracking-tight sm:grow-0">
Title
Delegetees
</h1>
<div className="pageTop">
<p>text</p>
<Button className="mt-6" onClick={() => openInNewTab('')}>
ClickButton
</Button>
{delegetees?.map((d) => (
<Card className="border-2 flex flex-col p-2 mb-5">
<div className="flex columns-3">
<div className="p-2 w-[10%]">
<img className="rounded-3xl" width="100" src={d.image} />
</div>
<div className="p-2 w-[85%]">
<div className="font-bold">{d.name}</div>
<div className="">{d.shortDescription}</div>
</div>
</div>
<div className="w-full">Other info</div>
</Card>
))}
</div>

<div style={{ paddingTop: '2rem' }}></div>
</main>
)
}
Loading

0 comments on commit 53e1d06

Please sign in to comment.