diff --git a/src/components/Dashboard/Modals/EditService/Tabs/IntegrationTab/Components/InputElements/IntegrationSelector.tsx b/src/components/Dashboard/Modals/EditService/Tabs/IntegrationTab/Components/InputElements/IntegrationSelector.tsx index 08b8a4ff1..bc83b42eb 100644 --- a/src/components/Dashboard/Modals/EditService/Tabs/IntegrationTab/Components/InputElements/IntegrationSelector.tsx +++ b/src/components/Dashboard/Modals/EditService/Tabs/IntegrationTab/Components/InputElements/IntegrationSelector.tsx @@ -3,7 +3,6 @@ import { Group, Select, SelectItem, Text } from '@mantine/core'; import { UseFormReturnType } from '@mantine/form'; import { useTranslation } from 'next-i18next'; import { forwardRef } from 'react'; -import { IntegrationsType } from '../../../../../../../../types/integration'; import { IntegrationField, integrationFieldDefinitions, @@ -54,12 +53,15 @@ export const IntegrationSelector = ({ form }: IntegrationSelectorProps) => { }, ].filter((x) => Object.keys(integrationFieldProperties).includes(x.value)); - const inputProps = form.getInputProps('integration.type'); - const getNewProperties = (value: string | null): ServiceIntegrationPropertyType[] => { if (!value) return []; + const integrationType = value as ServiceIntegrationType['type']; + if (integrationType === null) { + return []; + } + const requiredProperties = Object.entries(integrationFieldDefinitions).filter(([k, v]) => { - const val = integrationFieldProperties[value as ServiceIntegrationType['type']]; + const val = integrationFieldProperties[integrationType['type']]; return val.includes(k as IntegrationField); })!; return requiredProperties.map(([k, value]) => ({ @@ -70,36 +72,36 @@ export const IntegrationSelector = ({ form }: IntegrationSelectorProps) => { })); }; + const inputProps = form.getInputProps('integration.type'); + return ( - <> - x.value === form.values.integration?.type)?.image} + alt="test" + width={20} + height={20} + /> + ) + } + onChange={(value) => { + form.setFieldValue('integration.properties', getNewProperties(value)); + console.log(`changed to value ${value}`); + inputProps.onChange(value); + }} + {...inputProps} + /> ); }; diff --git a/src/types/service.ts b/src/types/service.ts index 13156ec00..e0313e5c3 100644 --- a/src/types/service.ts +++ b/src/types/service.ts @@ -16,7 +16,7 @@ export interface ServiceType extends TileBaseType { behaviour: ServiceBehaviourType; network: ServiceNetworkType; appearance: ServiceAppearanceType; - integration?: ServiceIntegrationType | null; + integration: ServiceIntegrationType; } export type ConfigServiceType = Omit & { @@ -51,7 +51,7 @@ export type IntegrationType = | 'nzbGet'; export type ServiceIntegrationType = { - type: IntegrationType; + type: IntegrationType | null; properties: ServiceIntegrationPropertyType[]; };