-
Notifications
You must be signed in to change notification settings - Fork 1
Create dashboard page #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
33a62ad
2926f18
123a5f1
a14e329
d638654
5d4a05e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,11 +41,17 @@ function postBatch<Schema extends z.ZodTypeAny>( | |
| }) | ||
| } | ||
|
|
||
| export type SortDir = 'asc' | 'desc' | ||
|
|
||
| export interface ListOffersParams { | ||
| status?: OfferStatus | ||
| asset?: string | ||
| limit?: number | ||
| offset?: number | ||
| // Server-side sort. NOTE: backend does not honor these yet — sent as a | ||
| // forward-compatible convention; results are currently returned unsorted. | ||
| sortBy?: string | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be strict union type. Also if it's not ready on backend let's not front run these changes. Just hide the sort buttons for now with a todo. |
||
| sortDir?: SortDir | ||
| } | ||
|
|
||
| function toQueryParams(params: ListOffersParams): Record<string, string> { | ||
|
|
@@ -54,6 +60,8 @@ function toQueryParams(params: ListOffersParams): Record<string, string> { | |
| if (params.asset) queryParams.asset = params.asset | ||
| if (params.limit !== undefined) queryParams.limit = String(params.limit) | ||
| if (params.offset !== undefined) queryParams.offset = String(params.offset) | ||
| if (params.sortBy) queryParams.sort_by = params.sortBy | ||
| if (params.sortDir) queryParams.sort_dir = params.sortDir | ||
| return queryParams | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,73 @@ | ||
| import { useCallback } from 'react' | ||
| import { Link, Outlet } from 'react-router-dom' | ||
|
|
||
| import ArrowSquareOutIcon from '@/components/icons/ArrowSquareOutIcon' | ||
| import BellIcon from '@/components/icons/BellIcon' | ||
| import { UiButton } from '@/components/ui/UiButton' | ||
| import { WalletButton } from '@/components/WalletButton' | ||
| import { env } from '@/constants/env' | ||
| import { RoutePath } from '@/constants/routes' | ||
|
|
||
| const ABOUT_SIMPLICITY_URL = 'https://github.com/BlockstreamResearch/simplicity' | ||
|
|
||
| const NAV = [ | ||
| { to: RoutePath.Dashboard, label: 'Dashboard' }, | ||
| { to: RoutePath.Borrow, label: 'Borrow' }, | ||
| { to: RoutePath.Supply, label: 'Supply' }, | ||
| ...(env.DEV ? [{ to: RoutePath.DesignSystem, label: 'System' }] : []), | ||
| ...(env.DEV | ||
| ? [ | ||
| { to: RoutePath.DesignSystem, label: 'System' }, | ||
| { to: RoutePath.Demo, label: 'Demo' }, | ||
| ] | ||
| : []), | ||
| ] | ||
|
|
||
| export default function AppLayout() { | ||
| const openAbout = useCallback(() => { | ||
| window.open(ABOUT_SIMPLICITY_URL, '_blank', 'noopener,noreferrer') | ||
| }, []) | ||
|
Comment on lines
+26
to
+28
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use link with target blank |
||
|
|
||
| return ( | ||
| <main className='bg-background text-foreground min-h-screen'> | ||
| <div className='mx-auto flex w-full max-w-5xl flex-col gap-8 px-4 py-8'> | ||
| <header className='flex items-center justify-between'> | ||
| <h1 className='text-h2'>Lending</h1> | ||
| <nav className='flex flex-wrap items-center gap-6 text-sm font-medium'> | ||
| <main className='bg-surface text-foreground min-h-screen'> | ||
| <div className='mx-auto flex w-full max-w-[1280px] flex-col gap-8 px-4 pt-6 pb-12 sm:px-8 lg:gap-10 lg:px-20 lg:pt-10 lg:pb-20'> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class |
||
| <header className='flex flex-wrap items-center justify-between gap-4'> | ||
| <Link to={RoutePath.Dashboard} className='flex flex-col gap-1.5'> | ||
| <span className='text-3xl leading-none font-black tracking-tight uppercase sm:text-4xl lg:text-[43px] lg:leading-[40px]'> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let it be h1
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class |
||
| Lending | ||
| </span> | ||
| <span className='text-foreground text-xs font-medium tracking-[0.16em] uppercase'> | ||
| powered by Simplicity | ||
| </span> | ||
| </Link> | ||
|
|
||
| <div className='flex flex-wrap items-center gap-3'> | ||
| <UiButton variant='ghost' onPress={openAbout}> | ||
| About Simplicity | ||
| <ArrowSquareOutIcon className='size-4' /> | ||
| </UiButton> | ||
| {/* Notifications not wired yet — disabled placeholder. */} | ||
| <UiButton variant='primary' isIconOnly isDisabled aria-label='Notifications'> | ||
| <BellIcon className='size-5' /> | ||
| </UiButton> | ||
|
Comment on lines
+49
to
+51
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hide until available |
||
| <WalletButton /> | ||
| </div> | ||
| </header> | ||
|
|
||
| <Outlet /> | ||
|
|
||
| <footer className='text-muted flex flex-col gap-3 text-xs'> | ||
| <nav className='flex flex-wrap items-center gap-4 font-medium'> | ||
| {NAV.map(({ to, label }) => ( | ||
| <Link key={to} className='text-accent hover:underline' to={to}> | ||
| {label} | ||
| </Link> | ||
| ))} | ||
| </nav> | ||
| </header> | ||
|
|
||
| <Outlet /> | ||
|
|
||
| <footer className='text-muted text-xs'> | ||
| <p>Network: {env.VITE_NETWORK}</p> | ||
| <p>API URL: {env.VITE_API_URL}</p> | ||
| <p>Esplora Base URL: {env.VITE_ESPLORA_BASE_URL}</p> | ||
| <div> | ||
| <p>Network: {env.VITE_NETWORK}</p> | ||
| <p>API URL: {env.VITE_API_URL}</p> | ||
| <p>Esplora Base URL: {env.VITE_ESPLORA_BASE_URL}</p> | ||
| </div> | ||
| </footer> | ||
| </div> | ||
| </main> | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have an option to disable this button? What do you think? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { UiButton } from '@/components/ui/UiButton' | ||
| import { DEFAULT_WALLET_TYPE } from '@/lib/wallet-core/types' | ||
| import { useWallet } from '@/providers/wallet/useWallet' | ||
| import { truncateAddress } from '@/utils/format' | ||
|
|
||
| export function WalletButton() { | ||
| const { connectionStatus, receiveAddress, connect } = useWallet() | ||
|
|
||
| if (connectionStatus === 'ready' && receiveAddress) { | ||
| return <UiButton variant='secondary'>{truncateAddress(receiveAddress)}</UiButton> | ||
| } | ||
|
|
||
| return ( | ||
| <UiButton variant='primary' onPress={() => connect(DEFAULT_WALLET_TYPE)}> | ||
| Connect Wallet | ||
| </UiButton> | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import type { SVGProps } from 'react' | ||
|
|
||
| export default function ArrowSquareOutIcon(props: SVGProps<SVGSVGElement>) { | ||
| return ( | ||
| <svg | ||
| fill='none' | ||
| role='presentation' | ||
| focusable='false' | ||
| aria-hidden='true' | ||
| viewBox='0 0 24 24' | ||
| xmlns='http://www.w3.org/2000/svg' | ||
| {...props} | ||
| > | ||
| <path | ||
| d='M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5' | ||
| stroke='currentColor' | ||
| strokeWidth='1.75' | ||
| strokeLinecap='round' | ||
| strokeLinejoin='round' | ||
| /> | ||
| </svg> | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import type { SVGProps } from 'react' | ||
|
|
||
| export default function ArrowSquareUpIcon(props: SVGProps<SVGSVGElement>) { | ||
| return ( | ||
| <svg | ||
| fill='none' | ||
| role='presentation' | ||
| focusable='false' | ||
| aria-hidden='true' | ||
| viewBox='0 0 24 24' | ||
| xmlns='http://www.w3.org/2000/svg' | ||
| {...props} | ||
| > | ||
| <rect x='3' y='3' width='18' height='18' rx='3' stroke='currentColor' strokeWidth='1.75' /> | ||
| <path | ||
| d='M12 16V8m0 0-3 3m3-3 3 3' | ||
| stroke='currentColor' | ||
| strokeWidth='1.75' | ||
| strokeLinecap='round' | ||
| strokeLinejoin='round' | ||
| /> | ||
| </svg> | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import type { SVGProps } from 'react' | ||
|
|
||
| export default function ArrowsRotateIcon(props: SVGProps<SVGSVGElement>) { | ||
| return ( | ||
| <svg | ||
| fill='none' | ||
| role='presentation' | ||
| focusable='false' | ||
| aria-hidden='true' | ||
| viewBox='0 0 24 24' | ||
| xmlns='http://www.w3.org/2000/svg' | ||
| {...props} | ||
| > | ||
| <path | ||
| d='M20 4v6h-6M4 20v-6h6M4 10a8 8 0 0 1 14-3l2 3M20 14a8 8 0 0 1-14 3l-2-3' | ||
| stroke='currentColor' | ||
| strokeWidth='1.75' | ||
| strokeLinecap='round' | ||
| strokeLinejoin='round' | ||
| /> | ||
| </svg> | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import type { SVGProps } from 'react' | ||
|
|
||
| export default function BellIcon(props: SVGProps<SVGSVGElement>) { | ||
| return ( | ||
| <svg | ||
| fill='none' | ||
| role='presentation' | ||
| focusable='false' | ||
| aria-hidden='true' | ||
| viewBox='0 0 24 24' | ||
| xmlns='http://www.w3.org/2000/svg' | ||
| {...props} | ||
| > | ||
| <path | ||
| d='M6 9a6 6 0 1 1 12 0c0 4 1.5 5.5 2 6.5H4c.5-1 2-2.5 2-6.5ZM9.5 19a2.5 2.5 0 0 0 5 0' | ||
| stroke='currentColor' | ||
| strokeWidth='1.75' | ||
| strokeLinecap='round' | ||
| strokeLinejoin='round' | ||
| /> | ||
| </svg> | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import type { SVGProps } from 'react' | ||
|
|
||
| export default function ChevronDownIcon(props: SVGProps<SVGSVGElement>) { | ||
| return ( | ||
| <svg | ||
| fill='none' | ||
| role='presentation' | ||
| focusable='false' | ||
| aria-hidden='true' | ||
| viewBox='0 0 24 24' | ||
| xmlns='http://www.w3.org/2000/svg' | ||
| {...props} | ||
| > | ||
| <path | ||
| d='M6 9l6 6 6-6' | ||
| stroke='currentColor' | ||
| strokeWidth='1.75' | ||
| strokeLinecap='round' | ||
| strokeLinejoin='round' | ||
| /> | ||
| </svg> | ||
| ) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we really need to specify custom options here, let's create a common interface for extra query options, e.g.:
If not, then we just can use default options inside queries