Skip to content

Commit

Permalink
feat: add switch description and label
Browse files Browse the repository at this point in the history
  • Loading branch information
jainpawan21 committed Jan 3, 2024
1 parent 99a6222 commit 39daca9
Showing 1 changed file with 39 additions and 26 deletions.
65 changes: 39 additions & 26 deletions apps/web/src/pages/integrations/components/IntegrationInput.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import { useMantineTheme } from '@mantine/core';
import styled from '@emotion/styled';
import { CredentialsKeyEnum, IConfigCredentials, secureCredentials } from '@novu/shared';

import { Input, PasswordInput, Switch, Textarea, Text, Tooltip, Select } from '@novu/design-system';
import { Input, PasswordInput, Switch, Textarea, Tooltip, Select } from '@novu/design-system';
import { IntegrationSecretTextarea } from './IntegrationSecretTextarea';

const SwitchWrapper = styled.div`
display: flex;
align-items: center;
`;

> .mantine-Text-root {
margin-right: auto;
}
const SwitchDescription = styled.div`
color: ${({ theme }) => `${theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[6]}`};
font-size: 14px !important;
font-weight: 400;
margin-top: '0px';
margin-bottom: '10px';
line-height: '17px';
`;

const SwitchLabel = styled.div`
color: ${({ theme }) => `${theme.colorScheme === 'dark' ? theme.white : theme.colors.gray[8]}`};
font-size: 14px !important;
font-weight: 700;
margin: 5px auto 5px 0px;
line-height: 17px;
`;

export function IntegrationInput({
Expand All @@ -27,8 +38,6 @@ export function IntegrationInput({
register?: any;
ignoreTls?: boolean;
}) {
const theme = useMantineTheme();

if (isNeededToHide(credential.key)) {
if (credential.type === 'text') {
return <IntegrationSecretTextarea credential={credential} errors={errors} field={field} register={register} />;
Expand Down Expand Up @@ -90,7 +99,6 @@ export function IntegrationInput({
label={field.value ? 'Active' : 'Disabled'}
required={credential.required}
placeholder={credential.displayName}
description={credential.description ?? ''}
data-test-id={credential.key}
error={errors[credential.key]?.message}
{...register?.(credential.key)}
Expand All @@ -115,28 +123,33 @@ export function IntegrationInput({
}

return (
<SwitchWrapper>
{credential.displayName && <Text>{credential.displayName}</Text>}
{switchComponent}
</SwitchWrapper>
<>
<SwitchWrapper>
{credential.displayName && <SwitchLabel>{credential.displayName}</SwitchLabel>}
{switchComponent}
</SwitchWrapper>
{credential.description && <SwitchDescription>{credential.description}</SwitchDescription>}
</>
);
}

if (credential.type === 'boolean') {
return (
<SwitchWrapper>
{credential.displayName && <Text>{credential.displayName}</Text>}
<Switch
required={credential.required}
placeholder={credential.displayName}
description={credential.description ?? ''}
data-test-id={credential.key}
error={errors[credential.key]?.message}
{...register?.(credential.key)}
checked={field.value}
onChange={field.onChange}
/>
</SwitchWrapper>
<>
<SwitchWrapper>
{credential.displayName && <SwitchLabel>{credential.displayName}</SwitchLabel>}
<Switch
required={credential.required}
placeholder={credential.displayName}
data-test-id={credential.key}
error={errors[credential.key]?.message}
{...register?.(credential.key)}
checked={field.value}
onChange={field.onChange}
/>
</SwitchWrapper>
{credential.description && <SwitchDescription>{credential.description}</SwitchDescription>}
</>
);
}

Expand Down

0 comments on commit 39daca9

Please sign in to comment.