From 61a68b006de2bffcfa97b7fcd860ba03f822277e Mon Sep 17 00:00:00 2001 From: Atatakai Date: Wed, 18 Dec 2024 23:16:53 +0400 Subject: [PATCH] chore: review fixes --- .../{index.tsx => MemeooorrAgentForm.tsx} | 16 +++++++--------- .../{index.tsx => ModiusAgentForm.tsx} | 5 +---- .../SetupPage/SetupYourAgent/SetupYourAgent.tsx | 4 ++-- .../SetupPage/SetupYourAgent/formUtils.ts | 8 ++++++++ .../validation.ts => validations.ts} | 0 5 files changed, 18 insertions(+), 15 deletions(-) rename frontend/components/SetupPage/SetupYourAgent/MemeooorrAgentForm/{index.tsx => MemeooorrAgentForm.tsx} (95%) rename frontend/components/SetupPage/SetupYourAgent/ModiusAgentForm/{index.tsx => ModiusAgentForm.tsx} (95%) create mode 100644 frontend/components/SetupPage/SetupYourAgent/formUtils.ts rename frontend/components/SetupPage/SetupYourAgent/{MemeooorrAgentForm/validation.ts => validations.ts} (100%) diff --git a/frontend/components/SetupPage/SetupYourAgent/MemeooorrAgentForm/index.tsx b/frontend/components/SetupPage/SetupYourAgent/MemeooorrAgentForm/MemeooorrAgentForm.tsx similarity index 95% rename from frontend/components/SetupPage/SetupYourAgent/MemeooorrAgentForm/index.tsx rename to frontend/components/SetupPage/SetupYourAgent/MemeooorrAgentForm/MemeooorrAgentForm.tsx index de6f52b6..00d0785e 100644 --- a/frontend/components/SetupPage/SetupYourAgent/MemeooorrAgentForm/index.tsx +++ b/frontend/components/SetupPage/SetupYourAgent/MemeooorrAgentForm/MemeooorrAgentForm.tsx @@ -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; @@ -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 = () => ( @@ -208,7 +205,7 @@ export const MemeooorrAgentForm = ({ name="setup-your-agent" layout="vertical" onFinish={onFinish} - validateMessages={validateMessages} + validateMessages={emailValidateMessages} disabled={canSubmitForm} > diff --git a/frontend/components/SetupPage/SetupYourAgent/ModiusAgentForm/index.tsx b/frontend/components/SetupPage/SetupYourAgent/ModiusAgentForm/ModiusAgentForm.tsx similarity index 95% rename from frontend/components/SetupPage/SetupYourAgent/ModiusAgentForm/index.tsx rename to frontend/components/SetupPage/SetupYourAgent/ModiusAgentForm/ModiusAgentForm.tsx index 814d6d49..621d5214 100644 --- a/frontend/components/SetupPage/SetupYourAgent/ModiusAgentForm/index.tsx +++ b/frontend/components/SetupPage/SetupYourAgent/ModiusAgentForm/ModiusAgentForm.tsx @@ -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; @@ -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) => { diff --git a/frontend/components/SetupPage/SetupYourAgent/SetupYourAgent.tsx b/frontend/components/SetupPage/SetupYourAgent/SetupYourAgent.tsx index 85bb7f4b..788e03dd 100644 --- a/frontend/components/SetupPage/SetupYourAgent/SetupYourAgent.tsx +++ b/frontend/components/SetupPage/SetupYourAgent/SetupYourAgent.tsx @@ -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; diff --git a/frontend/components/SetupPage/SetupYourAgent/formUtils.ts b/frontend/components/SetupPage/SetupYourAgent/formUtils.ts new file mode 100644 index 00000000..02123763 --- /dev/null +++ b/frontend/components/SetupPage/SetupYourAgent/formUtils.ts @@ -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' }, +}; diff --git a/frontend/components/SetupPage/SetupYourAgent/MemeooorrAgentForm/validation.ts b/frontend/components/SetupPage/SetupYourAgent/validations.ts similarity index 100% rename from frontend/components/SetupPage/SetupYourAgent/MemeooorrAgentForm/validation.ts rename to frontend/components/SetupPage/SetupYourAgent/validations.ts