0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

feat(console): add support fields config to sie (#6792)

add support fields to sie page
This commit is contained in:
simeng-li 2024-11-12 10:51:00 +08:00 committed by GitHub
parent ae4b65bc26
commit 1c0b29fb13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 56 additions and 0 deletions

View file

@ -0,0 +1,46 @@
import { emailRegEx } from '@logto/core-kit';
import { useFormContext } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import Card from '@/ds-components/Card';
import FormField from '@/ds-components/FormField';
import TextInput from '@/ds-components/TextInput';
import { type SignInExperienceForm } from '@/pages/SignInExperience/types';
import { uriValidator } from '@/utils/validator';
import FormSectionTitle from '../../components/FormSectionTitle';
function SupportForm() {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const {
register,
formState: { errors },
control,
} = useFormContext<SignInExperienceForm>();
return (
<Card>
<FormSectionTitle title="content.support.title" />
<FormField title="sign_in_exp.content.support.support_email">
<TextInput
{...register('supportEmail', {
pattern: { value: emailRegEx, message: t('errors.email_pattern_error') },
})}
error={errors.supportEmail?.message}
placeholder={t('sign_in_exp.content.support.support_email_placeholder')}
/>
</FormField>
<FormField title="sign_in_exp.content.support.support_website">
<TextInput
{...register('supportWebsiteUrl', {
validate: (value) => !value || uriValidator(value) || t('errors.invalid_uri_format'),
})}
error={errors.supportWebsiteUrl?.message}
placeholder={t('sign_in_exp.content.support.support_website_placeholder')}
/>
</FormField>
</Card>
);
}
export default SupportForm;

View file

@ -1,8 +1,10 @@
import PageMeta from '@/components/PageMeta'; import PageMeta from '@/components/PageMeta';
import { isDevFeaturesEnabled } from '@/consts/env';
import SignInExperienceTabWrapper from '../components/SignInExperienceTabWrapper'; import SignInExperienceTabWrapper from '../components/SignInExperienceTabWrapper';
import LanguagesForm from './LanguagesForm'; import LanguagesForm from './LanguagesForm';
import SupportForm from './SupportForm';
import TermsForm from './TermsForm'; import TermsForm from './TermsForm';
type Props = { type Props = {
@ -14,6 +16,7 @@ function Content({ isActive }: Props) {
<SignInExperienceTabWrapper isActive={isActive}> <SignInExperienceTabWrapper isActive={isActive}>
{isActive && <PageMeta titleKey={['sign_in_exp.tabs.content', 'sign_in_exp.page_title']} />} {isActive && <PageMeta titleKey={['sign_in_exp.tabs.content', 'sign_in_exp.page_title']} />}
<TermsForm /> <TermsForm />
{isDevFeaturesEnabled && <SupportForm />}
<LanguagesForm isManageLanguageVisible /> <LanguagesForm isManageLanguageVisible />
</SignInExperienceTabWrapper> </SignInExperienceTabWrapper>
); );

View file

@ -24,6 +24,13 @@ const content = {
default_language_description_fixed: default_language_description_fixed:
'When auto-detect is off, the default language is the only language your software will show. Turn on auto-detect for language extension.', 'When auto-detect is off, the default language is the only language your software will show. Turn on auto-detect for language extension.',
}, },
support: {
title: 'SUPPORT',
support_email: 'Support email',
support_email_placeholder: 'support@email.com',
support_website: 'Support website',
support_website_placeholder: 'https://your.website/support',
},
manage_language: { manage_language: {
title: 'Manage language', title: 'Manage language',
subtitle: subtitle: