diff --git a/src/components/AccountSwitcher/index.tsx b/src/components/AccountSwitcher/index.tsx
index 2bd13964f..15bf12315 100644
--- a/src/components/AccountSwitcher/index.tsx
+++ b/src/components/AccountSwitcher/index.tsx
@@ -7,7 +7,11 @@ import useAccountSelector from '@site/src/hooks/useAccountSelector';
import CurrencyIcon from '../CurrencyIcon';
import styles from './account_switcher.module.scss';
-const AccountSwitcher = () => {
+interface AccountSwitcherProps {
+ onChange: (accountName: string) => void;
+}
+
+const AccountSwitcher = ({ onChange }: AccountSwitcherProps) => {
const { onSelectAccount } = useAccountSelector();
const [isToggleDropdown, setToggleDropdown] = useState(false);
const { loginAccounts, currentLoginAccount } = useAuthContext();
@@ -16,7 +20,12 @@ const AccountSwitcher = () => {
const options = loginAccounts.map((accountItem) => ({
text: (
-
onSelectAccount(accountItem.name)}>
+
{
+ onSelectAccount(accountItem.name);
+ }}
+ >
{accountItem.name}
@@ -35,7 +44,10 @@ const AccountSwitcher = () => {
placeholder={currentLoginAccount.name}
variant='outline'
className={`${isToggleDropdown ? styles.active : styles.inactive}`}
- onSelectOption={() => setToggleDropdown((prev) => !prev)}
+ onSelectOption={() => {
+ onChange?.(currentLoginAccount.name);
+ setToggleDropdown((prev) => !prev);
+ }}
/>
);
diff --git a/src/components/CustomCheckbox/index.tsx b/src/components/CustomCheckbox/index.tsx
index fc71f1d0e..8e3aad7ff 100644
--- a/src/components/CustomCheckbox/index.tsx
+++ b/src/components/CustomCheckbox/index.tsx
@@ -5,12 +5,10 @@ import styles from './custom_checkbox.module.scss';
type TCustomCheckbox = {
name: string;
id: string;
- register: UseFormRegisterReturn & {
- onChange?: (e: React.ChangeEvent
) => void;
- };
+ register: UseFormRegisterReturn;
children: ReactElement;
- checked?: boolean;
onChange?: (e: React.ChangeEvent) => void;
+ checked?: boolean;
};
const CustomCheckbox = ({ name, id, register, children, onChange, checked }: TCustomCheckbox) => {
@@ -22,8 +20,8 @@ const CustomCheckbox = ({ name, id, register, children, onChange, checked }: TCu
id={id}
type='checkbox'
{...register}
+ onChangeCapture={onChange}
checked={checked}
- onChange={onChange}
/>
diff --git a/src/features/dashboard/components/ApiTokenCard/index.tsx b/src/features/dashboard/components/ApiTokenCard/index.tsx
index ed81a15e6..d64b22435 100644
--- a/src/features/dashboard/components/ApiTokenCard/index.tsx
+++ b/src/features/dashboard/components/ApiTokenCard/index.tsx
@@ -15,25 +15,33 @@ interface IApiTokenCardProps {
description: string;
}
-const ApiTokenCard = ({ register, name, label, description }: IApiTokenCardProps) => {
+const ApiTokenCard = ({ register, name, label, description, ...rest }: IApiTokenCardProps) => {
const [isAdminChecked, setIsAdminChecked] = useState(false);
const [isAdminPopupVisible, setIsAdminPopupVisible] = useState(false);
const { deviceType } = useDeviceType();
- const handleAdminScopeChange = (e?: React.ChangeEvent
, chk?: boolean) => {
- if (e) {
- const isChecked = e.target.checked;
- setIsAdminChecked(isChecked);
- setIsAdminPopupVisible(isChecked);
- } else if (chk) {
- setIsAdminPopupVisible(false);
+ const handleAdminScopeChange = (e: React.ChangeEvent) => {
+ const isChecked = e.target.checked;
+
+ if (isChecked) {
setIsAdminChecked(true);
+ setIsAdminPopupVisible(true);
} else {
- setIsAdminPopupVisible(false);
+ setIsAdminChecked(false);
setIsAdminChecked(false);
}
};
+ const handleModalPrimaryButton = () => {
+ setIsAdminChecked(true);
+ setIsAdminPopupVisible(false);
+ };
+
+ const handleModalSecondaryButton = () => {
+ setIsAdminChecked(false);
+ setIsAdminPopupVisible(false);
+ };
+
const adminSection = useMemo(() => {
if (name !== 'admin') return null;
return (
@@ -48,8 +56,8 @@ const ApiTokenCard = ({ register, name, label, description }: IApiTokenCardProps
isOpened={isAdminPopupVisible}
primaryButtonLabel='Enable admin access'
secondaryButtonLabel='Cancel'
- primaryButtonCallback={() => handleAdminScopeChange(undefined, true)}
- secondaryButtonCallback={() => handleAdminScopeChange(undefined, false)}
+ primaryButtonCallback={handleModalPrimaryButton}
+ secondaryButtonCallback={handleModalSecondaryButton}
isMobile={deviceType !== 'desktop'}
showSecondaryButton
shouldCloseOnSecondaryButtonClick
@@ -73,14 +81,12 @@ const ApiTokenCard = ({ register, name, label, description }: IApiTokenCardProps
}, [name, isAdminPopupVisible, deviceType]);
return (
-
+
- {tokens?.length ? renderTable() : null}
- {isLoadingTokens && }
+ {loading ? (
+
+ ) : isLoadingTokens ? (
+
+ ) : tokens?.length ? (
+ renderTable()
+ ) : null}
);
};
diff --git a/src/features/dashboard/components/Dialogs/TokenCreationDialogSuccess/index.tsx b/src/features/dashboard/components/Dialogs/TokenCreationDialogSuccess/index.tsx
index 457e059fd..b4fe1c045 100644
--- a/src/features/dashboard/components/Dialogs/TokenCreationDialogSuccess/index.tsx
+++ b/src/features/dashboard/components/Dialogs/TokenCreationDialogSuccess/index.tsx
@@ -43,7 +43,7 @@ export const TokenCreationDialogSuccess = ({
showHandleBar
disableCloseOnOverlay
isMobile={deviceType !== 'desktop'}
- primaryButtonLabel='Ok'
+ primaryButtonLabel='OK'
primaryButtonCallback={handleToggle}
>
) => {
[createToken, reset],
);
- const onCardClick = useCallback(
- (name: TApiTokenFormItemsNames) => {
- const values = getValues();
- setValue(name, !values[name]);
- },
- [getValues, setValue],
- );
-
useEffect(() => {
errors.name?.message ? setHideRestrictions(true) : setHideRestrictions(false);
}, [errors.name?.message]);
@@ -148,9 +140,6 @@ const TokenRegister = (props: HTMLAttributes) => {
name={item.name}
label={item.label}
description={item.description}
- onClick={() => {
- onCardClick(item.name);
- }}
register={register}
/>
))}
diff --git a/src/features/dashboard/components/TokenRegister/token-register.scss b/src/features/dashboard/components/TokenRegister/token-register.scss
index 9bd492590..082754292 100644
--- a/src/features/dashboard/components/TokenRegister/token-register.scss
+++ b/src/features/dashboard/components/TokenRegister/token-register.scss
@@ -19,7 +19,6 @@
.formContent {
@extend .align-center;
padding: 0 16px;
- gap: 24px;
width: 100%;
max-width: 608px;
}
@@ -33,6 +32,7 @@
.token_register__heading {
text-align: center;
+ margin-bottom: 1.5rem;
}
.token_register__account__switcher {
@@ -47,6 +47,7 @@
gap: 16px;
width: 100%;
z-index: 10;
+ margin-bottom: 1.5rem;
}
.token_register__scopes,
.token_register__name {
@@ -102,7 +103,7 @@
display: grid;
grid-template-columns: 0.5fr 0.5fr;
grid-gap: 1.6rem;
- margin-bottom: 2rem;
+ margin: 1.5rem 0;
@media screen and (max-width: 765px) {
grid-template-columns: 1fr;
}
diff --git a/src/styles/index.scss b/src/styles/index.scss
index ab863a1c8..c7a863802 100644
--- a/src/styles/index.scss
+++ b/src/styles/index.scss
@@ -114,6 +114,7 @@ h4 {
margin-left: rem(1.5);
font-size: var(--fontSizes-2xs) !important;
display: inline-block;
+ align-self: flex-start;
}
.error-border {