Skip to content

Commit 4118815

Browse files
authored
Small UI fixes (#2674)
1 parent 6871acb commit 4118815

7 files changed

Lines changed: 61 additions & 14 deletions

File tree

centrifuge-app/src/components/Dashboard/Account/AssetsSection.tsx

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,14 @@ export default function AssetsSection({ pool }: { pool: Pool }) {
105105
}
106106
)
107107

108-
let [liquidityAdminAccount] = useSuitableAccounts({ poolId: pool.id, poolRole: ['LiquidityAdmin'] })
109108
const [update, setUpdate] = useState(false)
110109
const isTinlakePool = pool.id.startsWith('0x')
110+
const [liquidityAdminAccount] = useSuitableAccounts({ poolId: pool.id, poolRole: ['LiquidityAdmin'] })
111+
const [account] = useSuitableAccounts({
112+
poolId: pool.id,
113+
proxyType: ['Borrow', 'Invest'],
114+
poolRole: ['LiquidityAdmin', 'PoolAdmin'],
115+
})
111116

112117
// Needs to update when selecting a new pool
113118
useEffect(() => {
@@ -155,6 +160,39 @@ export default function AssetsSection({ pool }: { pool: Pool }) {
155160
return acc
156161
}, {}) || {}
157162

163+
const { execute: closeEpochTx, isLoading: loadingClose } = useCentrifugeTransaction(
164+
'Start order execution',
165+
(cent) => (args: [poolId: string, collect: boolean], options) =>
166+
cent.pools.closeEpoch([args[0], false], { batch: true }).pipe(
167+
switchMap((closeTx) => {
168+
const tx = api.tx.utility.batchAll(
169+
[
170+
...closeTx.method.args[0],
171+
orders?.length
172+
? api.tx.utility.batch(
173+
orders
174+
.slice(0, MAX_COLLECT)
175+
.map((order) =>
176+
api.tx.investments[order.type === 'invest' ? 'collectInvestmentsFor' : 'collectRedemptionsFor'](
177+
order.accountId,
178+
[pool.id, order.trancheId]
179+
)
180+
)
181+
)
182+
: null,
183+
].filter(Boolean)
184+
)
185+
return cent.wrapSignAndSend(api, tx, options)
186+
})
187+
),
188+
{
189+
onSuccess: () => {
190+
setUpdate(false)
191+
queryClient.invalidateQueries(['loans', pool.id])
192+
},
193+
}
194+
)
195+
158196
const { execute, isLoading: isUpdating } = useCentrifugeTransaction(
159197
'Update NAV',
160198
(cent) => (args: [values: TransactionLoanData[]], options) => {
@@ -305,8 +343,10 @@ export default function AssetsSection({ pool }: { pool: Pool }) {
305343
},
306344
{
307345
onSuccess: () => {
308-
setUpdate(false)
309-
queryClient.invalidateQueries(['loans', pool.id])
346+
closeEpochTx([pool.id, ordersFullyExecutable], {
347+
account,
348+
forceProxyType: ['Borrow', 'Invest'],
349+
})
310350
},
311351
}
312352
)
@@ -500,7 +540,7 @@ export default function AssetsSection({ pool }: { pool: Pool }) {
500540
<Button
501541
small
502542
style={{ width: '170px' }}
503-
disabled={!form.dirty || isUpdating}
543+
disabled={!form.dirty || isUpdating || loadingClose}
504544
onClick={() => form.submitForm()}
505545
>
506546
Update NAV

centrifuge-app/src/components/LayoutBase/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { WalletMenu } from '@centrifuge/centrifuge-react'
22
import { Box, Drawer, IconButton, IconHamburger, IconX } from '@centrifuge/fabric'
33
import { useEffect, useState } from 'react'
44
import { Outlet, useLocation } from 'react-router'
5-
import styled from 'styled-components'
5+
import styled, { useTheme } from 'styled-components'
66
import { useIsAboveBreakpoint } from '../../utils/useIsAboveBreakpoint'
77
import { Footer } from '../Footer'
88
import { LogoLink } from '../LogoLink-deprecated'
@@ -68,6 +68,7 @@ const MobileMenuContent = () => (
6868
)
6969

7070
export const LayoutBase = () => {
71+
const theme = useTheme()
7172
const location = useLocation()
7273
const isDesktop = useIsAboveBreakpoint('L')
7374
const isMedium = useIsAboveBreakpoint('M')
@@ -82,7 +83,7 @@ export const LayoutBase = () => {
8283
return (
8384
<>
8485
{isDesktop && (
85-
<Box position="fixed" top="1rem" right="1rem" zIndex={1200} width={220} mt={2} marginRight={1}>
86+
<Box position="fixed" top="1rem" right="1rem" zIndex={theme.zIndices.header} mt={2} marginRight={1}>
8687
<WalletMenu />
8788
</Box>
8889
)}

centrifuge-app/src/components/PoolCard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const StyledCard = styled(Card)`
2323
max-width: 100%;
2424
padding: 12px;
2525
border: 1px solid ${({ theme }) => theme.colors.borderPrimary};
26-
height: 350px;
26+
min-height: 350px;
2727
2828
&:hover {
2929
border: 1px solid ${({ theme }) => theme.colors.textPrimary};

centrifuge-app/src/components/PoolList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function PoolList() {
7878
<Stack>
7979
<Stack>
8080
<Box overflow="auto">
81-
<Grid columns={[1, 2, 2, 3]} as="ul" role="list" gap={3}>
81+
<Grid columns={[1, 1, 2, 2, 3]} as="ul" role="list" gap={3}>
8282
{metadataIsLoading
8383
? Array(6)
8484
.fill(true)

centrifuge-js/src/modules/pools.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
isValidDate,
4141
} from '../utils'
4242
import { CurrencyBalance, Perquintill, Price, Rate, TokenBalance } from '../utils/BN'
43+
import { parseDate } from '../utils/Date'
4344
import { Dec } from '../utils/Decimal'
4445

4546
const PerquintillBN = new BN(10).pow(new BN(18))
@@ -1603,12 +1604,12 @@ export function getPoolsModule(inst: Centrifuge) {
16031604
tranches: {},
16041605
}
16051606
permissions.trancheInvestor.info
1606-
.filter((info: any) => info.permissionedTill * 1000 > Date.now())
1607+
.filter((info: any) => parseDate(info.permissionedTill) > new Date())
16071608
.forEach((info: any) => {
1608-
roles.tranches[info.trancheId] = {
1609-
permissionedTill: new Date(info.permissionedTill * 1000).toISOString(),
1609+
return (roles.tranches[info.trancheId] = {
1610+
permissionedTill: parseDate(info.permissionedTill).toISOString(),
16101611
isFrozen: info.isFrozen,
1611-
}
1612+
})
16121613
})
16131614

16141615
setPoolRoles(account, poolId, roles)
@@ -1681,10 +1682,10 @@ export function getPoolsModule(inst: Centrifuge) {
16811682
tranches: {},
16821683
}
16831684
permissions.trancheInvestor.info
1684-
.filter((info: any) => info.permissionedTill * 1000 > Date.now())
1685+
.filter((info: any) => parseDate(info.permissionedTill) > new Date())
16851686
.forEach((info: any) => {
16861687
roles[account].tranches[info.trancheId] = {
1687-
permissionedTill: new Date(info.permissionedTill * 1000).toISOString(),
1688+
permissionedTill: parseDate(info.permissionedTill).toISOString(),
16881689
isFrozen: info.isFrozen,
16891690
}
16901691
})

centrifuge-js/src/utils/Date.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export function parseDate(date: number) {
2+
const isDateInSeconds = date.toString().length <= 10
3+
return isDateInSeconds ? new Date(date * 1000) : new Date(date)
4+
}

fabric/src/components/Button/WalletButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const StyledButton = styled.button`
3030
border-radius: 4px;
3131
white-space: nowrap;
3232
border: 3px solid transparent;
33+
width: 220px;
3334
`
3435

3536
const IdenticonWrapper = styled(Flex)({

0 commit comments

Comments
 (0)