Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions services/console/src/views/project/ProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SwitchField from '../../ui/form/SwitchField'
import Heading from '../../ui/Heading'
import { LocaleTextField } from '../settings/Locales'
import { useTranslation } from 'react-i18next'
import { UseFormReturn } from 'react-hook-form'

// eslint-disable-next-line @typescript-eslint/no-namespace
export declare namespace Intl {
Expand Down Expand Up @@ -46,6 +47,9 @@ export default function ProjectForm({ project, onSave }: ProjectFormProps) {
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
locale,
}

const editing = project

return (
<FormWrapper<Project>
defaultValues={defaults}
Expand All @@ -58,7 +62,7 @@ export default function ProjectForm({ project, onSave }: ProjectFormProps) {
: await api.projects.create(params)
onSave?.(project)
}}
submitLabel={project ? t('save_settings') : t('create_project')}
submitLabel={editing ? t('save_settings') : t('create_project')}
>
{
form => (
Expand All @@ -79,30 +83,38 @@ export default function ProjectForm({ project, onSave }: ProjectFormProps) {
label={t('timezone')}
required
/>
<Heading size="h4" title={t('message_settings')} />
<TextInput.Field
form={form}
name="text_opt_out_message"
label={t('sms_opt_out_message')}
subtitle={t('sms_opt_out_message_subtitle')} />
<TextInput.Field
form={form}
name="text_help_message"
label={t('sms_help_message')}
subtitle={t('sms_help_message_subtitle')} />
<SwitchField
form={form}
name="link_wrap_email"
label={t('link_wrapping_email')}
subtitle={t('link_wrapping_email_subtitle')} />
<SwitchField
form={form}
name="link_wrap_push"
label={t('link_wrapping_push')}
subtitle={t('link_wrapping_push_subtitle')} />
{editing && <ProjectSettings form={form} />}
</>
)
}
</FormWrapper>
)
}

function ProjectSettings({ form }: { form: UseFormReturn<Project> }) {
const { t } = useTranslation()

return <>
<Heading size="h4" title={t('message_settings')} />
<TextInput.Field
form={form}
name="text_opt_out_message"
label={t('sms_opt_out_message')}
subtitle={t('sms_opt_out_message_subtitle')} />
<TextInput.Field
form={form}
name="text_help_message"
label={t('sms_help_message')}
subtitle={t('sms_help_message_subtitle')} />
<SwitchField
form={form}
name="link_wrap_email"
label={t('link_wrapping_email')}
subtitle={t('link_wrapping_email_subtitle')} />
<SwitchField
form={form}
name="link_wrap_push"
label={t('link_wrapping_push')}
subtitle={t('link_wrapping_push_subtitle')} />
</>
}