Add stripe connection option (#5372)
- Refactor creation and edition form so it handles stripe integration and not only postgres - Add a hook `useIsSettingsIntegrationEnabled` to avoid checking feature flags everywhere - Add zod schema for stripe <img width="250" alt="Capture d’écran 2024-05-13 à 12 41 52" src="https://github.com/twentyhq/twenty/assets/22936103/a77e7278-5d79-4f95-bddb-ae9ddd1426eb"> <img width="250" alt="Capture d’écran 2024-05-13 à 12 41 59" src="https://github.com/twentyhq/twenty/assets/22936103/d617dc6a-31a4-43c8-8192-dbfb7157de1c"> <img width="250" alt="Capture d’écran 2024-05-13 à 12 42 08" src="https://github.com/twentyhq/twenty/assets/22936103/c4e2d0e4-f826-436d-89be-4d1679a27861"> --------- Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
@ -3,7 +3,10 @@ import isEmpty from 'lodash.isempty';
|
||||
import pickBy from 'lodash.pickby';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { settingsIntegrationPostgreSQLConnectionFormSchema } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionForm';
|
||||
import {
|
||||
settingsIntegrationPostgreSQLConnectionFormSchema,
|
||||
settingsIntegrationStripeConnectionFormSchema,
|
||||
} from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionForm';
|
||||
import { RemoteServer } from '~/generated-metadata/graphql';
|
||||
|
||||
export const getEditionSchemaForForm = (databaseKey: string) => {
|
||||
@ -12,6 +15,8 @@ export const getEditionSchemaForForm = (databaseKey: string) => {
|
||||
return settingsIntegrationPostgreSQLConnectionFormSchema.extend({
|
||||
password: z.string().optional(),
|
||||
});
|
||||
case 'stripe':
|
||||
return settingsIntegrationStripeConnectionFormSchema;
|
||||
default:
|
||||
throw new Error(`No schema found for database key: ${databaseKey}`);
|
||||
}
|
||||
@ -34,6 +39,10 @@ export const getFormDefaultValuesFromConnection = ({
|
||||
schema: connection.schema || undefined,
|
||||
password: '',
|
||||
};
|
||||
case 'stripe':
|
||||
return {
|
||||
api_key: connection.foreignDataWrapperOptions.api_key,
|
||||
};
|
||||
default:
|
||||
throw new Error(
|
||||
`No default form values for database key: ${databaseKey}`,
|
||||
@ -71,6 +80,12 @@ export const formatValuesForUpdate = ({
|
||||
|
||||
return pickBy(formattedValues, (obj) => !isEmpty(obj));
|
||||
}
|
||||
case 'stripe':
|
||||
return {
|
||||
foreignDataWrapperOptions: {
|
||||
api_key: formValues.api_key,
|
||||
},
|
||||
};
|
||||
default:
|
||||
throw new Error(`Cannot format values for database key: ${databaseKey}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user