Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit e614d3f

Browse files
authored
Merge branch 'master' into restrictions
2 parents 254cf6b + b8d742c commit e614d3f

File tree

23 files changed

+590
-144
lines changed

23 files changed

+590
-144
lines changed

src/features/Home/Benefits/Benefits.module.scss

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
width: 100%;
1313
flex-wrap: nowrap;
1414
margin-bottom: rem(6.4);
15-
gap: rem(3);
15+
gap: rem(20);
1616
display: flex;
17-
justify-content: space-evenly;
17+
justify-content: center;
1818
padding: 0 rem(1);
1919

2020
@media screen and (max-width: 992px) {
2121
margin-top: rem(3);
22+
gap: rem(8.8);
2223
}
2324

2425
@media screen and (max-width: 425px) {
2526
flex-direction: column;
27+
gap: rem(3);
2628
}
2729
}
2830

@@ -39,10 +41,6 @@
3941
margin: rem(1.6) 0;
4042
}
4143

42-
img {
43-
margin-bottom: rem(4);
44-
}
45-
4644
@media screen and (max-width: 992px) {
4745
flex-wrap: wrap;
4846
width: 90%;

src/features/Home/Benefits/Benefits.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const Benefits = () => {
5252
<article className={styles.InformationContainer}>
5353
<ImageContainer image='personalisation' alt='personalisation' />
5454
<section className={styles.InformationContent}>
55-
<h1>Personalize your trading</h1>
55+
<h1>Personalise your trading</h1>
5656
<Text type='subtitle-2' as='p'>
5757
Personalize your trading apps to match your needs. Create charts and views the way you
5858
like them. Develop your trading app using any common programming language and extend

src/features/Home/Benefits/__tests__/Benefits.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Benefits', () => {
2323
expect(execution).toBeInTheDocument();
2424
});
2525
it('should render personalize your trading information', () => {
26-
const title = screen.getByText(/Personalize your trading$/i);
26+
const title = screen.getByText(/Personalise your trading$/i);
2727
const information = screen.getByText(/create charts and views/i);
2828

2929
expect(title).toBeInTheDocument();

src/features/Home/GetStarted/GetStarted.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const GetStarted = () => {
2929
<Text type='subtitle-1' bold className={`${styles.dark} ${styles.header}`} as='h2'>
3030
1. Learn about our API
3131
</Text>
32-
<p>Understand basic concepts and terminologies.</p>
32+
<p>Understand basic concepts and terminologies</p>
3333
</section>
3434
<figure className={styles.arrowIcon}>
3535
<img src='img/home-arrow.svg' />
@@ -47,7 +47,7 @@ export const GetStarted = () => {
4747
<Text type='subtitle-1' bold className={`${styles.dark} ${styles.header}`} as='h2'>
4848
2. Sign up
4949
</Text>
50-
<p>Create a free Deriv account to access our API.</p>
50+
<p>Create a free Deriv account to access our API</p>
5151
</section>
5252
<figure className={styles.arrowIcon}>
5353
<img src='img/home-arrow.svg' />
@@ -64,7 +64,7 @@ export const GetStarted = () => {
6464
<Text type='subtitle-1' bold className={`${styles.dark} ${styles.header}`} as='h2'>
6565
3. Register your app
6666
</Text>
67-
<p>Fill out the registration form to start using Deriv API.</p>
67+
<p>Fill out the registration form to start using Deriv API</p>
6868
</section>
6969
<figure className={styles.arrowIcon}>
7070
<img src='img/home-arrow.svg' />

src/features/Home/HeroHeader/HeroHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const HeroHeader = () => {
66
return (
77
<header className={styles.HeroImageStyle} data-testid='hero-header'>
88
<div className={styles.HeroContainerStyle}>
9-
<Text type='heading-1' as={'h1'} bold className={styles.heading} aria-level={2}>
9+
<Text type='hero' as={'h1'} bold className={styles.heading} aria-level={2}>
1010
Deriv API
1111
</Text>
1212
<Text

src/features/Home/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Benefits } from './Benefits/Benefits';
44
import { ClientLibraries } from './ClientLibraries/ClientLibraries';
55
import { HeroHeader } from './HeroHeader/HeroHeader';
66
import { WaysToEarn } from './WaysToEarn/WaysToEarn';
7-
import { Carousel } from './Carousel/Carousel';
7+
// import { Carousel } from './Carousel/Carousel';
88
import Footer from '@site/src/components/Footer';
99
import styles from './styles.module.scss';
1010
import { GetStarted } from './GetStarted/GetStarted';
@@ -18,7 +18,8 @@ export default function HomepageFeatures() {
1818
<WaysToEarn />
1919
<GetStarted />
2020
<ApiFeatures />
21-
<Carousel />
21+
{/* Carousel requires new quote's before it should be enabled again */}
22+
{/* <Carousel /> */}
2223
<Footer />
2324
</main>
2425
);

src/features/dashboard/components/ApiTokenForm/CreateTokenField/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Text, Button } from '@deriv/ui';
33
import styles from '../api-token.form.module.scss';
44
import useApiToken from '@site/src/hooks/useApiToken';
55
import { FieldErrorsImpl, UseFormRegisterReturn } from 'react-hook-form';
6+
import TokenCreationDialogSuccess from '../../Dialogs/TokenCreationDialogSuccess';
67

78
type TCreateTokenField = {
89
register: UseFormRegisterReturn;
@@ -19,6 +20,8 @@ type TCreateTokenField = {
1920
form_is_cleared: boolean;
2021
setFormIsCleared: Dispatch<SetStateAction<boolean>>;
2122
setHideRestriction: Dispatch<SetStateAction<boolean>>;
23+
is_toggle: boolean;
24+
setToggleModal: Dispatch<SetStateAction<boolean>>;
2225
};
2326

2427
const CreateTokenField = ({
@@ -27,6 +30,8 @@ const CreateTokenField = ({
2730
form_is_cleared,
2831
setFormIsCleared,
2932
setHideRestriction,
33+
is_toggle,
34+
setToggleModal,
3035
}: TCreateTokenField) => {
3136
const { tokens } = useApiToken();
3237
const [input_value, setInputValue] = useState('');
@@ -79,6 +84,7 @@ const CreateTokenField = ({
7984
<Button disabled={disable_button} type='submit'>
8085
Create
8186
</Button>
87+
{is_toggle && <TokenCreationDialogSuccess setToggleModal={setToggleModal} />}
8288
</div>
8389
{errors && errors.name && (
8490
<Text as='span' type='paragraph-1' className='error-message'>

src/features/dashboard/components/ApiTokenForm/__tests__/api-token.form.test.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const scopes = [
7676
label: 'Admin',
7777
},
7878
];
79+
const preventDefault = jest.fn();
7980

8081
describe('Home Page', () => {
8182
beforeEach(() => {
@@ -156,4 +157,29 @@ describe('Home Page', () => {
156157

157158
expect(mockCreateToken).not.toHaveBeenCalled();
158159
});
160+
161+
it('Should open success dialog when token is created ', async () => {
162+
const nameInput = screen.getByRole('textbox');
163+
164+
await userEvent.type(nameInput, 'test create token');
165+
166+
const submitButton = screen.getByRole('button', { name: /Create/i });
167+
await userEvent.click(submitButton);
168+
169+
const modal = await screen.getByText('Your API token is ready to be used.');
170+
expect(modal).toBeVisible();
171+
});
172+
173+
it('Should have create button disabled in case of empty input or error message', async () => {
174+
const submitButton = screen.getByRole('button', { name: /Create/i });
175+
expect(submitButton).toBeDisabled();
176+
177+
const nameInput = screen.getByRole('textbox');
178+
179+
await userEvent.type(nameInput, 'token-text');
180+
expect(submitButton).toBeDisabled();
181+
182+
await userEvent.clear(nameInput);
183+
expect(submitButton).toBeDisabled();
184+
});
159185
});

src/features/dashboard/components/ApiTokenForm/api-token.form.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const ApiTokenForm = (props: HTMLAttributes<HTMLFormElement>) => {
8282
const { createToken, isCreatingToken } = useCreateToken();
8383
const [hiderestrictions, setHideRestrictions] = useState(false);
8484
const [form_is_cleared, setFormIsCleared] = useState(false);
85+
const [is_toggle, setToggleModal] = useState(false);
8586

8687
const {
8788
handleSubmit,
@@ -106,6 +107,7 @@ const ApiTokenForm = (props: HTMLAttributes<HTMLFormElement>) => {
106107
});
107108
createToken(name, selectedTokenScope);
108109
setFormIsCleared(true);
110+
setToggleModal((prev) => !prev);
109111
reset();
110112
},
111113
[createToken, reset],
@@ -163,6 +165,8 @@ const ApiTokenForm = (props: HTMLAttributes<HTMLFormElement>) => {
163165
form_is_cleared={form_is_cleared}
164166
setFormIsCleared={setFormIsCleared}
165167
setHideRestriction={setHideRestrictions}
168+
is_toggle={is_toggle}
169+
setToggleModal={setToggleModal}
166170
/>
167171
{!hiderestrictions && <TokenNameRestrictions />}
168172
<div className={styles.step_title}>

0 commit comments

Comments
 (0)