Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Trompette committed Apr 9, 2024
1 parent 204fd5b commit f9c319e
Showing 1 changed file with 50 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { useEffect } from 'react';
import { FormProvider, useForm } from 'react-hook-form';
import { useNavigate, useParams } from 'react-router-dom';
import { zodResolver } from '@hookform/resolvers/zod';
import { IconSettings } from 'twenty-ui';

import { useDeleteOneDatabaseConnection } from '@/databases/hooks/useDeleteOneDatabaseConnection';
import { useGetDatabaseConnection } from '@/databases/hooks/useGetDatabaseConnection';
import { useGetDatabaseConnectionTables } from '@/databases/hooks/useGetDatabaseConnectionTables';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { SettingsIntegrationDatabaseTablesListCard } from '@/settings/integrations/components/SettingsIntegrationDatabaseTablesListCard';
import {
SettingsIntegrationDatabaseTablesListCard,
SettingsIntegrationsDatabaseTablesFormValues,
settingsIntegrationsDatabaseTablesSchema,
} from '@/settings/integrations/components/SettingsIntegrationDatabaseTablesListCard';
import { useSettingsIntegrationCategories } from '@/settings/integrations/hooks/useSettingsIntegrationCategories';
import { getConnectionDbName } from '@/settings/integrations/utils/getConnectionDbName';
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
Expand Down Expand Up @@ -73,6 +79,11 @@ export const SettingsIntegrationDatabaseConnection = () => {
skip: !isIntegrationAvailable || !connection,
});

const formConfig = useForm<SettingsIntegrationsDatabaseTablesFormValues>({
mode: 'onTouched',
resolver: zodResolver(settingsIntegrationsDatabaseTablesSchema),
});

if (!isIntegrationAvailable || !connection) return null;

const settingsIntegrationsPagePath = getSettingsPagePath(
Expand All @@ -82,41 +93,44 @@ export const SettingsIntegrationDatabaseConnection = () => {
const connectionName = getConnectionDbName({ integration, connection });

return (
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
<SettingsPageContainer>
<Breadcrumb
links={[
{
children: 'Integrations',
href: settingsIntegrationsPagePath,
},
{
children: integration.text,
href: `${settingsIntegrationsPagePath}/${databaseKey}`,
},
{ children: connectionName },
]}
/>
<Section>
<H2Title title="About" description="About this remote object" />
<SettingsIntegrationDatabaseConnectionSummaryCard
databaseLogoUrl={integration.from.image}
connectionId={connectionId}
connectionName={connectionName}
onRemove={deleteConnection}
/>
</Section>
<Section>
<H2Title
title="Tables"
description="Select the tables that should be tracked"
/>
<SettingsIntegrationDatabaseTablesListCard
connectionId={connectionId}
tables={tables}
// eslint-disable-next-line react/jsx-props-no-spreading
<FormProvider {...formConfig}>
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
<SettingsPageContainer>
<Breadcrumb
links={[
{
children: 'Integrations',
href: settingsIntegrationsPagePath,
},
{
children: integration.text,
href: `${settingsIntegrationsPagePath}/${databaseKey}`,
},
{ children: connectionName },
]}
/>
</Section>
</SettingsPageContainer>
</SubMenuTopBarContainer>
<Section>
<H2Title title="About" description="About this remote object" />
<SettingsIntegrationDatabaseConnectionSummaryCard
databaseLogoUrl={integration.from.image}
connectionId={connectionId}
connectionName={connectionName}
onRemove={deleteConnection}
/>
</Section>
<Section>
<H2Title
title="Tables"
description="Select the tables that should be tracked"
/>
<SettingsIntegrationDatabaseTablesListCard
connectionId={connectionId}
tables={tables}
/>
</Section>
</SettingsPageContainer>
</SubMenuTopBarContainer>
</FormProvider>
);
};

0 comments on commit f9c319e

Please sign in to comment.