Skip to content

Commit

Permalink
feat(lo): add revert type notification
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv committed Jan 15, 2024
1 parent a8dfff1 commit d9adc64
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { CheckCircle } from 'components/Icons'
import DeltaTokenAmount from 'components/WalletPopup/Transactions/DeltaTokenAmount'
import { LimitOrderStatus } from 'components/swapv2/LimitOrder/type'
import { APP_PATHS } from 'constants/index'
import { NETWORKS_INFO } from 'constants/networks'
import useTheme from 'hooks/useTheme'

function InboxItemBridge({
Expand All @@ -44,19 +45,22 @@ function InboxItemBridge({
takingAmountRate,
chainId: rawChainId,
} = templateBody?.order || {}
const isReorg = templateBody.isReorg

const isFilled = status === LimitOrderStatus.FILLED
const isPartialFilled = status === LimitOrderStatus.PARTIALLY_FILLED
const chainId = rawChainId && rawChainId !== '{{.chainId}}' ? (Number(rawChainId) as ChainId) : undefined
const statusMessage = isFilled
const statusMessage = isReorg
? t`Reverted`
: isFilled
? t`100% Filled`
: isPartialFilled
? t`${filledPercent} Filled ${increasedFilledPercent}`
: `${filledPercent}% Filled | Expired`

const navigate = useNavigate()
const onClick = () => {
navigate(APP_PATHS.LIMIT)
navigate(`${APP_PATHS.LIMIT}/${NETWORKS_INFO[+templateBody.order.chainId as ChainId]?.route}`)
onRead(announcement, statusMessage)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AnnouncementTemplateLimitOrder } from 'components/Announcement/type'
import Logo from 'components/Logo'
import { LimitOrderStatus } from 'components/swapv2/LimitOrder/type'
import { APP_PATHS } from 'constants/index'
import { NETWORKS_INFO } from 'constants/networks'
import useTheme from 'hooks/useTheme'
import { formatTime } from 'utils/time'

Expand Down Expand Up @@ -36,12 +37,17 @@ export default function AnnouncementItem({
chainId: rawChainId,
takerAssetLogoURL,
} = templateBody?.order || {}
const isReorg = templateBody.isReorg
const isFilled = status === LimitOrderStatus.FILLED
const isPartialFilled = status === LimitOrderStatus.PARTIALLY_FILLED
const chainId = rawChainId && rawChainId !== '{{.chainId}}' ? (Number(rawChainId) as ChainId) : undefined
const theme = useTheme()

const statusMessage = isFilled ? (
const statusMessage = isReorg ? (
<Text as="span" color={theme.red}>
reverted ({filledPercent} filled)
</Text>
) : isFilled ? (
<Text as="span" color={theme.primary}>
successfully filled
</Text>
Expand All @@ -57,7 +63,7 @@ export default function AnnouncementItem({

const navigate = useNavigate()
return (
<Wrapper onClick={() => navigate(APP_PATHS.LIMIT)}>
<Wrapper onClick={() => navigate(`${APP_PATHS.LIMIT}/${NETWORKS_INFO[chainId || ChainId.MAINNET].route}`)}>
<Flex justifyContent="space-between" width="100%">
<Title>
<InboxIcon type={templateType} chainId={chainId} />
Expand Down
1 change: 1 addition & 0 deletions src/components/Announcement/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type PoolPositionAnnouncement = {
export type AnnouncementTemplateLimitOrder = {
order: LimitOrderAnnouncement
popupType: PopupType
isReorg: boolean
}
export type AnnouncementTemplateCrossChain = { transaction: CrossChainTransfer; popupType: PopupType }
export type AnnouncementTemplateBridge = { transaction: MultichainTransfer; popupType: PopupType }
Expand Down
1 change: 0 additions & 1 deletion src/pages/NotificationCenter/PrivateAnnouncement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default function GeneralAnnouncement({ type }: { type?: PrivateAnnounceme
isLoading: isLoadingAll,
} = useGetPrivateAnnouncementsQuery({ page, pageSize: ITEMS_PER_PAGE }, { skip: !!templateIds })

console.log(type, respNotificationByType, dataAllNotification)
const [ackAnnouncement] = useAckPrivateAnnouncementsByIdsMutation()
const [clearAllAnnouncement] = useClearAllPrivateAnnouncementByIdMutation()

Expand Down

0 comments on commit d9adc64

Please sign in to comment.