import styled from '@emotion/styled'; import { useLingui } from '@lingui/react/macro'; import { Control, Controller } from 'react-hook-form'; import { Select } from '@/ui/input/components/Select'; import { TextInput } from '@/ui/input/components/TextInput'; import { ConnectionFormData } from '@/settings/accounts/hooks/useImapSmtpCaldavConnectionForm'; import { H2Title } from 'twenty-ui/display'; import { Section } from 'twenty-ui/layout'; import { MOBILE_VIEWPORT } from 'twenty-ui/theme'; const StyledFormContainer = styled.div` display: flex; flex-direction: column; gap: ${({ theme }) => theme.spacing(6)}; `; const StyledConnectionSection = styled.div` display: flex; flex-direction: column; gap: ${({ theme }) => theme.spacing(2)}; `; const StyledSectionHeader = styled.div` margin-bottom: ${({ theme }) => theme.spacing(2)}; `; const StyledSectionTitle = styled.h3` color: ${({ theme }) => theme.font.color.primary}; font-size: ${({ theme }) => theme.font.size.md}; font-weight: ${({ theme }) => theme.font.weight.medium}; margin: 0; margin-bottom: ${({ theme }) => theme.spacing(1)}; `; const StyledSectionDescription = styled.p` color: ${({ theme }) => theme.font.color.tertiary}; font-size: ${({ theme }) => theme.font.size.sm}; margin: 0; `; const StyledFieldRow = styled.div` display: flex; gap: ${({ theme }) => theme.spacing(3)}; @media (max-width: ${MOBILE_VIEWPORT}px) { flex-direction: column; } `; const StyledFieldGroup = styled.div` flex: 1; & > * { width: 100%; } `; type SettingsAccountsConnectionFormProps = { control: Control; isEditing: boolean; }; export const SettingsAccountsConnectionForm = ({ control, isEditing, }: SettingsAccountsConnectionFormProps) => { const { t } = useLingui(); const getTitle = () => { return isEditing ? t`Edit Email Account` : t`New Email Account`; }; const getDescription = () => { if (isEditing) { return t`Update your email account configuration. Configure any combination of IMAP, SMTP, and CalDAV as needed.`; } return t`You can set up any combination of IMAP (receiving emails), SMTP (sending emails), and CalDAV (calendar sync).`; }; const handlePortChange = (value: string) => Number(value); return (
( )} /> {t`IMAP Configuration`} {t`Configure IMAP settings to receive and sync your emails.`}
{t`Leave blank if you don't need to import emails.`}
( )} /> ( )} /> ( field.onChange(handlePortChange(value)) } error={fieldState.error?.message} /> )} /> ( )} />
{t`CalDAV Configuration`} {t`Configure CalDAV settings to sync your calendar events.`}
{t`Leave blank if you don't need calendar sync.`}
( )} /> ( )} /> ( field.onChange(handlePortChange(value)) } error={fieldState.error?.message} /> )} /> (