-
Notifications
You must be signed in to change notification settings - Fork 17
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
Pool Overview redesign #2435
Pool Overview redesign #2435
Conversation
PR deployed in Google Cloud |
PR deployed in Google Cloud |
66fc7a5
to
1181892
Compare
909545e
to
35bc8e6
Compare
c29f491
to
dbe5c48
Compare
90bc09f
to
4afb124
Compare
const data: ChartData[] = React.useMemo( | ||
() => | ||
truncatedPoolStates?.map((day) => { | ||
truncatedPoolStates?.map((day: any) => { |
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.
truncatedPoolStates?.map((day: any) => { | |
truncatedPoolStates?.map((day) => { |
better to make sure truncatedPoolStates
is typed rather than casting day as any
<Box width="8px" height="8px" borderRadius="50%" backgroundColor={color} marginRight="4px" /> | ||
) | ||
|
||
const navObj = { |
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.
const navObj = { | |
const navData = { |
for consistency though out
|
||
const graphData = selectedTabIndex === 0 ? tokenData : apyData | ||
|
||
const toggleRange = (e: any) => { |
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.
let's try and avoid anys please!
</Shelf> | ||
<Box display="flex" justifyContent="space-between" alignItems="center"> | ||
<Box display="flex" justifyContent="space-evenly"> | ||
{graphData.map((item: any, index: any) => { |
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.
here too!
type DailyPoolStateProps = { | ||
timestamp: string | ||
tranches: { [trancheId: string]: TrancheState } | ||
apy?: Perquintill | undefined | ||
} |
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.
rather build the type from the existing dailyPoolState using Pick
or Omit
so that we can more easily catch changes if they were to happen
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.
for TrancheState as well
const data = React.useMemo(() => { | ||
const tokenData = | ||
dailyPoolStates?.map((state) => { | ||
return { price: state.tranches[trancheId].price?.toFloat() || 0, day: new Date(state.timestamp) } | ||
dailyPoolStates?.map((state: DailyPoolStateProps) => { |
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.
dailyPoolStates?.map((state: DailyPoolStateProps) => { | |
dailyPoolStates?.map((state) => { |
again this type should be interfered if dailyPoolStates
is type properly
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.
now that its correctly inferred you can remove the DailyPoolStateProps
from this map
import { Spinner } from '../Spinner' | ||
import { Tooltips } from '../Tooltips' | ||
|
||
const StyledPillButton = styled(PillButton)` |
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.
seems this can be removed?
interface DailyTrancheState { | ||
yield30DaysAnnualized: Perquintill | ||
timestamp: string | ||
} | ||
|
||
function hasValuationMethod(pricing: any): pricing is { valuationMethod: string } { | ||
return pricing && typeof pricing.valuationMethod === 'string' | ||
type DailyTrancheStateArr = Record<string, DailyTrancheState[]> | ||
|
||
type Tranche = { | ||
currency: { | ||
name: string | ||
} | ||
id: string | ||
} |
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.
also here best to build the types from existing ones rather than redeclaring, recommend using Pick
or Omit
const fmk = useFormikContext<PoolMetadataInput>() | ||
const { values } = fmk | ||
|
||
console.log('FORM', values) |
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.
oops
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.
Very nice work @kattylucy!! Just a few more comments about the types and then I think we're good to go 🔥
] as const | ||
] | ||
|
||
function calculateTranchePrices(pool: any) { |
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.
would type this as Pool
. Will save you having to assign types in the subsequent maps
return { juniorTokenPrice, seniorTokenPrice } | ||
} | ||
|
||
function getYieldFieldForFilter(tranche: any, filter: string) { |
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.
this would be tranche: Pool['tranches'][0]
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.
Actually I think it has to be DailyTrancheState
const data: ChartData[] = React.useMemo( | ||
() => | ||
truncatedPoolStates?.map((day) => { | ||
truncatedPoolStates?.map((day: DailyPoolState) => { |
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.
better to have the types on truncatedPoolStates
instead of type casting in the map
const data = React.useMemo(() => { | ||
const tokenData = | ||
dailyPoolStates?.map((state) => { | ||
return { price: state.tranches[trancheId].price?.toFloat() || 0, day: new Date(state.timestamp) } | ||
dailyPoolStates?.map((state: DailyPoolStateProps) => { |
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.
now that its correctly inferred you can remove the DailyPoolStateProps
from this map
|
||
{!!values?.issuerCategories?.length && | ||
values.issuerCategories.map( | ||
(category: { type: string; value: string | number; customType?: string }, index: number) => { |
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.
another case where types should already be inferred from the formik values, so you shouldn't have to type them manually here. If the compiler is complaining you probably need to type the values from formik first!
65fd070
to
b636cf7
Compare
86f6fbb
to
178af27
Compare
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.
🔥 🔥 🔥
https://www.figma.com/design/ng7qdNcSCXSDA6ZUdWIs6u/Pool-Overview%2F-Pool-Detail?node-id=2802-6256&node-type=frame&t=HdoH2YlSaWxLKG0U-0
#2427