forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UPM] Sergei / UPM - 1209 / Notification and Banner for Senegal busin…
…ess closure (deriv-com#16349) * feat: make sketch of banner * fix: unit tests for traders hub * feat: done with senegal banner and notification * feat: create trading-disabled-modal and write unit tests * feat: add purchase handler * refactor: remove comments * feat: write unit tests for business-closure-banner * feat: add message to lock deposit * feat: get back changes in client store * feat: add pathname check for cashier deposit
- Loading branch information
1 parent
2fb91cb
commit 3a4c990
Showing
23 changed files
with
379 additions
and
4 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...src/components/banners/business-closure-banner/__tests__/business-closure-banner.spec.tsx
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,33 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { StoreProvider, mockStore } from '@deriv/stores'; | ||
import BusinessClosureBanner from '../business-closure-banner'; | ||
|
||
describe('<BusinessClosureBanner />', () => { | ||
const mockDefault = mockStore({ client: { is_account_to_be_closed_by_residence: false } }); | ||
|
||
const wrapper = (mock: ReturnType<typeof mockStore> = mockDefault) => { | ||
const Component = ({ children }: { children: JSX.Element }) => ( | ||
<StoreProvider store={mock}>{children}</StoreProvider> | ||
); | ||
return Component; | ||
}; | ||
|
||
it('should render nothing by default', () => { | ||
render(<BusinessClosureBanner />, { | ||
wrapper: wrapper(), | ||
}); | ||
|
||
expect(screen.queryByText(/Due to business changes/)).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render banner content if is_account_to_be_closed_by_residence === true ', () => { | ||
const mock = mockStore({ client: { is_account_to_be_closed_by_residence: true } }); | ||
|
||
render(<BusinessClosureBanner />, { | ||
wrapper: wrapper(mock), | ||
}); | ||
|
||
expect(screen.queryByText(/Due to business changes/)).toBeInTheDocument(); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
...ages/appstore/src/components/banners/business-closure-banner/business-closure-banner.scss
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,14 @@ | ||
.business-closure-banner { | ||
padding-inline: 1.6rem; | ||
// One more solution just change the color and make it without opacity instead of height calc (background-color: #fff4e4;) | ||
|
||
@include desktop-screen { | ||
position: sticky; | ||
top: 0; | ||
z-index: 2; | ||
|
||
& + div { | ||
height: calc(100vh - $HEADER_HEIGHT - $FOOTER_HEIGHT - 3.4rem); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/appstore/src/components/banners/business-closure-banner/business-closure-banner.tsx
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,29 @@ | ||
import React from 'react'; | ||
import { InlineMessage, Text } from '@deriv-com/ui'; | ||
import { observer, useStore } from '@deriv/stores'; | ||
import { Localize } from '@deriv/translations'; | ||
import { formatDate } from '@deriv/shared'; | ||
import './business-closure-banner.scss'; | ||
|
||
const BusinessClosureBanner = observer(() => { | ||
const { client } = useStore(); | ||
const { is_account_to_be_closed_by_residence, account_time_of_closure } = client; | ||
|
||
if (!is_account_to_be_closed_by_residence) return null; | ||
|
||
return ( | ||
<InlineMessage type='filled' variant='warning' className='business-closure-banner'> | ||
<Text size='xs'> | ||
<Localize | ||
i18n_default_text='Due to business changes, client accounts in Senegal are to be closed. Deposits and trading are disabled. | ||
Withdraw your funds by {{date}}.' | ||
values={{ | ||
date: formatDate(account_time_of_closure, 'DD MMM YYYY'), | ||
}} | ||
/> | ||
</Text> | ||
</InlineMessage> | ||
); | ||
}); | ||
|
||
export default BusinessClosureBanner; |
3 changes: 3 additions & 0 deletions
3
packages/appstore/src/components/banners/business-closure-banner/index.ts
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,3 @@ | ||
import BusinessClosureBanner from './business-closure-banner'; | ||
|
||
export default BusinessClosureBanner; |
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
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
23 changes: 23 additions & 0 deletions
23
...ngDisabledByResidenceModal/__tests__/trading-disabled-by-residence-modal-content.spec.tsx
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,23 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { StoreProvider, mockStore } from '@deriv/stores'; | ||
import { TradingDisabledByResidenceModalContent } from '../trading-disabled-by-residence-modal-content'; | ||
|
||
describe('<TradingDisabledByResidenceModalContent />', () => { | ||
const mockDefault = mockStore({}); | ||
|
||
const wrapper = (mock: ReturnType<typeof mockStore> = mockDefault) => { | ||
const Component = ({ children }: { children: JSX.Element }) => ( | ||
<StoreProvider store={mock}>{children}</StoreProvider> | ||
); | ||
return Component; | ||
}; | ||
|
||
it('should render modal content with correct title', () => { | ||
render(<TradingDisabledByResidenceModalContent />, { | ||
wrapper: wrapper(), | ||
}); | ||
|
||
expect(screen.getByText(/Trading disabled/)).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.