-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
480 additions
and
20 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 |
---|---|---|
@@ -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 } |
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 |
---|---|---|
|
@@ -19,3 +19,4 @@ export type RouterType = { | |
export const routes: RouterType[] = [ | ||
{ link: 'home', name: 'Home', icon: House }, | ||
] | ||
|
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,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 GitHub Actions / build (18.x)
|
||
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> | ||
) | ||
} |
Oops, something went wrong.