-
Notifications
You must be signed in to change notification settings - Fork 17
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
1 parent
20f0e9f
commit a4b2652
Showing
7 changed files
with
82 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Banner, Text } from '@centrifuge/fabric' | ||
import * as React from 'react' | ||
import { useLoanChanges, usePoolChanges } from '../utils/usePools' | ||
import { RouterTextLink } from './TextLink' | ||
|
||
export type PoolChangesBannerProps = { | ||
poolId: string | ||
} | ||
const STORAGE_KEY = 'poolChangesBannerDismissedAt' | ||
|
||
export function PoolChangesBanner({ poolId }: PoolChangesBannerProps) { | ||
const changes = usePoolChanges(poolId) | ||
const loanChanges = useLoanChanges(poolId) | ||
const [isOpen, setIsOpen] = React.useState(false) | ||
|
||
React.useEffect(() => { | ||
const dismissedAt = new Date(localStorage.getItem(STORAGE_KEY) ?? 0) | ||
if ( | ||
(changes && new Date(changes.submittedAt) > dismissedAt) || | ||
(loanChanges?.length && new Date(loanChanges.at(-1)!.submittedAt) > dismissedAt) | ||
) { | ||
setIsOpen(true) | ||
} | ||
}, [changes, loanChanges]) | ||
|
||
function onClose() { | ||
localStorage.setItem(STORAGE_KEY, new Date(Date.now()).toISOString()) | ||
setIsOpen(false) | ||
} | ||
|
||
return ( | ||
<Banner | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
title={ | ||
<Text as="h3" color="textInverted" variant="heading5"> | ||
There are pending pool changes that can now be enabled{' '} | ||
<RouterTextLink to={`/issuer/${poolId}/configuration`}>here</RouterTextLink> | ||
</Text> | ||
} | ||
/> | ||
) | ||
} |
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
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