This PR was created by [GitStart](https://gitstart.com/) to address the requirements from this ticket: [TWNTY-7535](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-7535). --- ### Description. Migrate link components to `twenty-ui` \ \ Fixes #7535 --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: gitstart-twenty <140154534+gitstart-twenty@users.noreply.github.com> Co-authored-by: Charles Bochet <charles@twenty.com>
32 lines
798 B
TypeScript
32 lines
798 B
TypeScript
import { useState } from 'react';
|
|
import { Toggle } from 'twenty-ui';
|
|
|
|
import { RemoteTableStatus } from '~/generated-metadata/graphql';
|
|
|
|
export const SettingsIntegrationRemoteTableSyncStatusToggle = ({
|
|
tableName,
|
|
tableStatus,
|
|
onSyncUpdate,
|
|
}: {
|
|
tableName: string;
|
|
tableStatus: RemoteTableStatus;
|
|
onSyncUpdate: (value: boolean, tableName: string) => Promise<void>;
|
|
}) => {
|
|
const [isToggleLoading, setIsToggleLoading] = useState(false);
|
|
|
|
const onChange = async (newValue: boolean) => {
|
|
if (isToggleLoading) return;
|
|
setIsToggleLoading(true);
|
|
await onSyncUpdate(newValue, tableName);
|
|
setIsToggleLoading(false);
|
|
};
|
|
|
|
return (
|
|
<Toggle
|
|
value={tableStatus === RemoteTableStatus.Synced}
|
|
disabled={isToggleLoading}
|
|
onChange={onChange}
|
|
/>
|
|
);
|
|
};
|