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

Commit 645764d

Browse files
Hubert KosterHubert Koster
authored andcommitted
chore: fixing merge conflict
1 parent a6284be commit 645764d

File tree

4 files changed

+59
-4
lines changed

4 files changed

+59
-4
lines changed

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ const CreateTokenField = ({
4545
return token_names;
4646
}, [tokens]);
4747

48-
const token_name_exists = getTokenNames.includes(input_value.toLowerCase());
48+
const tokens_limit_reached = tokens.length === 30 && Object.keys(errors).length === 0;
49+
const token_name_exists =
50+
getTokenNames.includes(input_value.toLowerCase()) && Object.keys(errors).length === 0;
51+
const has_no_errors = Object.values(errors).length === 0;
4952
const disable_button = token_name_exists || Object.keys(errors).length > 0 || input_value === '';
5053
const error_border_active = token_name_exists || errors.name;
5154

@@ -67,11 +70,14 @@ const CreateTokenField = ({
6770
type='text'
6871
name='name'
6972
{...register}
70-
placeholder='Token name'
73+
placeholder=' '
7174
/>
7275
<Button disabled={disable_button} type='submit'>
7376
Create
7477
</Button>
78+
<label className={styles.tokenInputLabel}>
79+
Token name (you&apos;ve created <b>{tokens.length}</b> out of 30 tokens)
80+
</label>
7581
</div>
7682
{errors && errors.name && (
7783
<Text as='span' type='paragraph-1' className='error-message'>
@@ -83,6 +89,34 @@ const CreateTokenField = ({
8389
<p>That name is taken. Choose another.</p>
8490
</div>
8591
)}
92+
{tokens_limit_reached && input_value !== '' && (
93+
<div className='error-message'>
94+
<p>You&apos;ve reached 30 tokens creation limit.</p>
95+
</div>
96+
)}
97+
{has_no_errors && (
98+
<div className={styles.helperText}>
99+
<ul>
100+
<li>
101+
<span>Only alphanumeric characters with spaces and underscores are allowed.</span>
102+
</li>
103+
<li>
104+
<span>The name must be between 2 to 32 characters.</span>
105+
</li>
106+
<li>
107+
<span>Duplicate token names aren&apos;t allowed.</span>
108+
</li>
109+
<li>
110+
<span>
111+
The name cannot contain &ldquo;Binary&rdquo;, &ldquo;Deriv&rdquo;, or similar words.
112+
</span>
113+
</li>
114+
<li>
115+
<span>You can create up to 30 tokens for this account.</span>
116+
</li>
117+
</ul>
118+
</div>
119+
)}
86120
</React.Fragment>
87121
);
88122
};

src/features/dashboard/components/ApiTokenForm/api-token.form.module.scss

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ form {
5151
.customTextInput {
5252
align-items: center;
5353
border: 1px solid var(--colors-greyLight400);
54-
border-radius: 4px;
54+
border-radius: rem(1.6);
5555
display: flex;
5656
position: relative;
5757
box-sizing: border-box;
@@ -66,6 +66,8 @@ form {
6666
border-top-left-radius: 0;
6767
border-bottom-left-radius: 0;
6868
height: rem(3);
69+
border-top-right-radius: rem(1.6);
70+
border-bottom-right-radius: rem(1.6);
6971
}
7072
label {
7173
position: absolute;
@@ -92,16 +94,22 @@ form {
9294
background-color: var(--ifm-color-emphasis-0);
9395
padding: 0 rem(0.4);
9496
transform: translateY(rem(-2)) scale(0.75);
97+
&.tokenInputLabel {
98+
color: var(--smoke);
99+
}
95100
}
96101
&:focus {
97102
outline-color: unset;
98103
outline: unset;
99-
border-radius: rem(0.3);
104+
border-radius: rem(1.6);
100105
& ~ label {
101106
color: var(--colors-blue400);
102107
background-color: var(--ifm-color-emphasis-0);
103108
padding: 0 rem(0.4);
104109
transform: translateY(rem(-2)) scale(0.75);
110+
&.tokenInputLabel {
111+
color: var(--smoke);
112+
}
105113
}
106114
}
107115
&::placeholder {
@@ -121,7 +129,14 @@ form {
121129
}
122130

123131
.helperText {
132+
line-height: 2.2;
124133
font-size: rem(1.4);
125134
padding-left: rem(1);
126135
color: var(--colors-greyLight600);
136+
li {
137+
font-size: rem(1);
138+
span {
139+
font-size: rem(1.4);
140+
}
141+
}
127142
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import useCreateToken from '@site/src/features/dashboard/hooks/useCreateToken';
99
import * as yup from 'yup';
1010
import styles from './api-token.form.module.scss';
1111
import CreateTokenField from './CreateTokenField';
12+
import useApiToken from '@site/src/hooks/useApiToken';
1213

1314
const schema = yup
1415
.object({
@@ -80,6 +81,7 @@ const scopes: TScope[] = [
8081
const ApiTokenForm = (props: HTMLAttributes<HTMLFormElement>) => {
8182
const { createToken, isCreatingToken } = useCreateToken();
8283
const [form_is_cleared, setFormIsCleared] = useState(false);
84+
const { tokens } = useApiToken();
8385

8486
const {
8587
handleSubmit,

src/styles/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
--schema-array: #ff8fc8;
3535
--schema-number: #acb2ff;
3636
--schema-integer: #f8c272;
37+
--smoke: #414652;
3738
}
3839

3940
/* For readability concerns, you should choose a lighter palette in dark mode. */
@@ -97,6 +98,9 @@ h6 {
9798
&:focus {
9899
outline: var(--colors-coral500) !important;
99100
}
101+
label {
102+
color: var(--colors-coral500) !important;
103+
}
100104
}
101105

102106
/* reset */

0 commit comments

Comments
 (0)