Skip to content

Commit

Permalink
feat(sanctions): persist sanctions banner durring the new api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
milan-bc committed Jun 8, 2022
1 parent 5060a0f commit c2bf955
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Expand Up @@ -16,3 +16,5 @@ export const getDefaultBeneficiary = (currency: WalletCurrencyType, state: RootS
export const getRecentSwapTxs = (state: RootState) => state.custodial.recentSwapTxs
export const getProductEligibilityForUser = (state: RootState) =>
state.custodial.productEligibilityForUser

export const getUserHadNotifications = (state: RootState) => state.custodial.userHadNotifications
Expand Up @@ -9,7 +9,8 @@ import { CustodialState, ProductEligibilityForUser } from './types'
const initialState: CustodialState = {
beneficiaries: Remote.NotAsked,
productEligibilityForUser: Remote.NotAsked,
recentSwapTxs: Remote.NotAsked
recentSwapTxs: Remote.NotAsked,
userHadNotifications: false
}

const custodialSlice = createSlice({
Expand Down Expand Up @@ -44,6 +45,11 @@ const custodialSlice = createSlice({
action: PayloadAction<ProductEligibilityForUser>
) => {
state.productEligibilityForUser = Remote.Success(action.payload)
if (action.payload.notifications.length > 0) {
state.userHadNotifications = true
} else if (state.userHadNotifications) {
state.userHadNotifications = false
}
},

// Swap Tx
Expand Down
Expand Up @@ -90,4 +90,5 @@ export type CustodialState = {
beneficiaries: RemoteDataType<string, BeneficiariesType>
productEligibilityForUser: RemoteDataType<string, ProductEligibilityForUser>
recentSwapTxs: RemoteDataType<string, SwapOrderType[]>
userHadNotifications: boolean
}
Expand Up @@ -72,13 +72,14 @@ export const getData = (state: RootState): { bannerToShow: BannerType } => {
announcementState
)

const userHadNotifications = selectors.custodial.getUserHadNotifications(state)
const products = selectors.custodial.getProductEligibilityForUser(state).getOrElse({
notifications: []
} as ProductEligibilityForUser)

const sanctionsAnnouncement = getSanctionsAnnouncement()
const showSanctionsBanner = showBanner(
products?.notifications?.length > 0,
products?.notifications?.length > 0 || userHadNotifications,
sanctionsAnnouncement,
announcementState
)
Expand Down

0 comments on commit c2bf955

Please sign in to comment.