import { styled } from '@linaria/react'; import { useContext, type ReactNode } from 'react'; import { H2Title } from 'twenty-ui/typography'; import { Toggle } from 'twenty-ui/input'; import { Section } from 'twenty-ui/layout'; import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants'; const StyledHeader = styled.div` align-items: center; display: flex; gap: ${themeCssVariables.spacing[3]}; justify-content: space-between; margin-bottom: ${themeCssVariables.spacing[4]}; `; type SettingsLogicFunctionTriggerSectionProps = { title: string; description: string; enabled: boolean; onEnabledChange: (enabled: boolean) => void; readonly: boolean; children?: ReactNode; }; // Common scaffolding for the four trigger toggles on a logic function. Hides // the section entirely when an installed app function doesn't use this trigger // (read-only + disabled = nothing to show). export const SettingsLogicFunctionTriggerSection = ({ title, description, enabled, onEnabledChange, readonly, children, }: SettingsLogicFunctionTriggerSectionProps) => { const { theme } = useContext(ThemeContext); if (readonly && !enabled) { return null; } return (
{!readonly && ( )} {enabled && children}
); };