Skip to content

Commit

Permalink
chore: review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanya-atatakai committed Dec 18, 2024
1 parent f9d1d4f commit 61a68b0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import { useElectronApi } from '@/hooks/useElectronApi';
import { useSetup } from '@/hooks/useSetup';
import { useStakingProgram } from '@/hooks/useStakingProgram';

import { commonFieldProps, emailValidateMessages } from '../formUtils';
import { onDummyServiceCreation } from '../utils';
import { validateGeminiApiKey, validateTwitterCredentials } from './validation';
import {
validateGeminiApiKey,
validateTwitterCredentials,
} from '../validations';

const { Title, Text } = Typography;

Expand All @@ -24,13 +28,6 @@ type FieldValues = {
};
type ValidationStatus = 'valid' | 'invalid' | 'unknown';

const requiredRules = [{ required: true, message: 'Field is required' }];
const validateMessages = {
required: 'Field is required',
types: { email: 'Enter a valid email' },
};
const commonFieldProps = { rules: requiredRules, hasFeedback: true };

const XAccountCredentials = () => (
<Flex vertical>
<Divider style={{ margin: '16px 0' }} />
Expand Down Expand Up @@ -208,7 +205,7 @@ export const MemeooorrAgentForm = ({
name="setup-your-agent"
layout="vertical"
onFinish={onFinish}
validateMessages={validateMessages}
validateMessages={emailValidateMessages}
disabled={canSubmitForm}
>
<Form.Item
Expand Down Expand Up @@ -243,6 +240,7 @@ export const MemeooorrAgentForm = ({
<Form.Item
name="xEmail"
label="X email"
{...emailRequiredFieldProps}
rules={[{ required: true, type: 'email' }]}
hasFeedback
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SetupScreen } from '@/enums/SetupScreen';
import { useSetup } from '@/hooks/useSetup';
import { useStakingProgram } from '@/hooks/useStakingProgram';

import { commonFieldProps, validateMessages } from '../formUtils';
import { onDummyServiceCreation } from '../utils';

const { Text } = Typography;
Expand All @@ -18,10 +19,6 @@ type FieldValues = {
CoinGeckoApiKey: string;
};

const requiredRules = [{ required: true, message: 'Field is required' }];
const validateMessages = { required: 'Field is required' };
const commonFieldProps = { rules: requiredRules, hasFeedback: true };

type ModiusAgentFormProps = { serviceTemplate: ServiceTemplate };

export const ModiusAgentForm = ({ serviceTemplate }: ModiusAgentFormProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { SetupScreen } from '@/enums/SetupScreen';
import { useServices } from '@/hooks/useServices';

import { SetupCreateHeader } from '../Create/SetupCreateHeader';
import { MemeooorrAgentForm } from './MemeooorrAgentForm';
import { ModiusAgentForm } from './ModiusAgentForm';
import { MemeooorrAgentForm } from './MemeooorrAgentForm/MemeooorrAgentForm';
import { ModiusAgentForm } from './ModiusAgentForm/ModiusAgentForm';

const { Title, Text } = Typography;

Expand Down
8 changes: 8 additions & 0 deletions frontend/components/SetupPage/SetupYourAgent/formUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const requiredRules = [{ required: true, message: 'Field is required' }];
export const validateMessages = { required: 'Field is required' };
export const commonFieldProps = { rules: requiredRules, hasFeedback: true };

export const emailValidateMessages = {
required: 'Field is required',
types: { email: 'Enter a valid email' },
};

0 comments on commit 61a68b0

Please sign in to comment.