diff --git a/src/components/Editor/TopicSelect/TopicSelect.tsx b/src/components/Editor/TopicSelect/TopicSelect.tsx index b84984aa..ebab3d12 100644 --- a/src/components/Editor/TopicSelect/TopicSelect.tsx +++ b/src/components/Editor/TopicSelect/TopicSelect.tsx @@ -7,6 +7,7 @@ import styles from './TopicSelect.module.scss' import { clsx } from 'clsx' import { createSignal } from 'solid-js' import { slugify } from '../../../utils/slugify' +import { clone } from '../../../utils/clone' type TopicSelectProps = { topics: Topic[] @@ -64,10 +65,13 @@ export const TopicSelect = (props: TopicSelectProps) => { ) } + const initialValue = clone(props.selectedTopics) + return (
*/} -У каждого соавтора можно добавить роль
*/} diff --git a/src/context/editor.tsx b/src/context/editor.tsx index 9f5a3a04..d47877ad 100644 --- a/src/context/editor.tsx +++ b/src/context/editor.tsx @@ -1,7 +1,7 @@ import type { JSX } from 'solid-js' import { Accessor, createContext, createSignal, useContext } from 'solid-js' import { createStore, SetStoreFunction } from 'solid-js/store' -import { Topic } from '../graphql/types.gen' +import { Topic, TopicInput } from '../graphql/types.gen' import { apiClient } from '../utils/apiClient' import { useLocalize } from './localize' import { useSnackbar } from './snackbar' @@ -48,6 +48,14 @@ export function useEditorContext() { return useContext(EditorContext) } +const topic2topicInput = (topic: Topic): TopicInput => { + return { + id: topic.id, + slug: topic.slug, + title: topic.title + } +} + export const EditorProvider = (props: { children: JSX.Element }) => { const { t } = useLocalize() @@ -93,10 +101,10 @@ export const EditorProvider = (props: { children: JSX.Element }) => { shoutId: form.shoutId, shoutInput: { body: form.body, - topics: form.selectedTopics, + topics: form.selectedTopics.map((topic) => topic2topicInput(topic)), // authors?: InputMaybe