fix(post options): link sage warning to FAQ

This commit is contained in:
Tommaso Casaburi
2026-06-02 12:16:22 +07:00
parent 342a8f53a7
commit 75c805c822
13 changed files with 165 additions and 21 deletions
@@ -1,7 +1,8 @@
import { Fragment } from 'react';
import { HashLink } from 'react-router-hash-link';
import { Link } from 'react-router-dom';
import type { DirectoryCommunity } from '../../hooks/use-directories';
import type { PostOptionsValidationError } from '../../lib/utils/post-options-utils';
import { SAGE_FAQ_LINK_LABEL, SAGE_FAQ_PATH, SAGE_OPTION, type PostOptionsValidationError } from '../../lib/utils/post-options-utils';
interface PostOptionsErrorMessageProps {
directories?: DirectoryCommunity[];
@@ -33,10 +34,33 @@ const DirectoryLinks = ({ codes, directories }: { codes: string[]; directories:
</>
);
const UnsupportedOption = ({ option }: { option: string }) => (
<>
{option}
{option === SAGE_OPTION && (
<>
{' '}
[<HashLink to={SAGE_FAQ_PATH}>{SAGE_FAQ_LINK_LABEL}</HashLink>]
</>
)}
</>
);
const UnsupportedOptions = ({ options }: { options: string[] }) => (
<>
{options.map((option, index) => (
<Fragment key={`${option}-${index}`}>
{index === 0 ? '' : ', '}
<UnsupportedOption option={option} />
</Fragment>
))}
</>
);
const PostOptionsErrorMessage = ({ directories = EMPTY_DIRECTORIES, error }: PostOptionsErrorMessageProps) => {
return (
<>
Unsupported options: {error.unsupportedOptions.join(', ')}.
Unsupported options: <UnsupportedOptions options={error.unsupportedOptions} />.
{error.supportedDirectoryCodesByOption.map(({ option, directoryCodes }) => (
<Fragment key={option}>
{' '}