diff --git a/src/app/dashboard/[subdomain]/editor/portfolio-editor.tsx b/src/app/dashboard/[subdomain]/editor/portfolio-editor.tsx index d9f5a1d6..b95ede81 100644 --- a/src/app/dashboard/[subdomain]/editor/portfolio-editor.tsx +++ b/src/app/dashboard/[subdomain]/editor/portfolio-editor.tsx @@ -105,7 +105,7 @@ export default function PortfolioEditor() { const getValues = useGetState(values) const updateValue = useCallback( - (val: Partial) => { + (val: EditorValues) => { if (visibility !== PageVisibilityEnum.Draft) { setVisibility(PageVisibilityEnum.Modified) } @@ -301,7 +301,7 @@ export default function PortfolioEditor() { } const EditorExtraProperties = memo( - ({ updateValue }: { updateValue: (val: Partial) => void }) => { + ({ updateValue }: { updateValue: (val: EditorValues) => void }) => { const { t } = useTranslation("dashboard") return ( diff --git a/src/app/dashboard/[subdomain]/editor/post-editor.tsx b/src/app/dashboard/[subdomain]/editor/post-editor.tsx index 2c9f3cb0..3f3d10ba 100644 --- a/src/app/dashboard/[subdomain]/editor/post-editor.tsx +++ b/src/app/dashboard/[subdomain]/editor/post-editor.tsx @@ -134,7 +134,7 @@ export default function PostEditor() { const getDraftKey = useGetState(draftKey) const updateValue = useCallback( - (val: Partial) => { + (val: EditorValues) => { if (visibility !== PageVisibilityEnum.Draft) { setVisibility(PageVisibilityEnum.Modified) } @@ -190,7 +190,7 @@ export default function PostEditor() { if (check) { toast.error(check) } else { - const uniqueTags = Array.from(new Set(values.tags.split(","))).join(",") + const uniqueTags = Array.from(new Set(values.tags?.split(","))).join(",") const baseValues = { ...values, @@ -517,7 +517,7 @@ const EditorExtraProperties = memo( characterId, siteLink, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void type: NoteType defaultSlug: string characterId?: number diff --git a/src/app/dashboard/[subdomain]/editor/short-editor.tsx b/src/app/dashboard/[subdomain]/editor/short-editor.tsx index ab8d5a10..71939c99 100644 --- a/src/app/dashboard/[subdomain]/editor/short-editor.tsx +++ b/src/app/dashboard/[subdomain]/editor/short-editor.tsx @@ -103,7 +103,7 @@ export default function ShortEditor() { const getValues = useGetState(values) const updateValue = useCallback( - (val: Partial) => { + (val: EditorValues) => { if (visibility !== PageVisibilityEnum.Draft) { setVisibility(PageVisibilityEnum.Modified) } @@ -299,7 +299,7 @@ export default function ShortEditor() { } const EditorExtraProperties = memo( - ({ updateValue }: { updateValue: (val: Partial) => void }) => { + ({ updateValue }: { updateValue: (val: EditorValues) => void }) => { const { t } = useTranslation("dashboard") return ( diff --git a/src/components/dashboard/editor-properties/EditorAutofill.tsx b/src/components/dashboard/editor-properties/EditorAutofill.tsx index 3d9e60f7..d6108d83 100644 --- a/src/components/dashboard/editor-properties/EditorAutofill.tsx +++ b/src/components/dashboard/editor-properties/EditorAutofill.tsx @@ -8,7 +8,7 @@ import { EditorValues } from "~/lib/types" export default function EditorAutofill({ updateValue, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void }) { const { t } = useTranslation("dashboard") const externalUrl = useEditorState((state) => state.externalUrl) diff --git a/src/components/dashboard/editor-properties/EditorContent.tsx b/src/components/dashboard/editor-properties/EditorContent.tsx index 33a298de..7a687700 100644 --- a/src/components/dashboard/editor-properties/EditorContent.tsx +++ b/src/components/dashboard/editor-properties/EditorContent.tsx @@ -9,7 +9,7 @@ export default function EditorContent({ updateValue, prompt, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void prompt?: string }) { const { t } = useTranslation("dashboard") diff --git a/src/components/dashboard/editor-properties/EditorCover.tsx b/src/components/dashboard/editor-properties/EditorCover.tsx index 933e8ac8..86e4896e 100644 --- a/src/components/dashboard/editor-properties/EditorCover.tsx +++ b/src/components/dashboard/editor-properties/EditorCover.tsx @@ -8,7 +8,7 @@ export default function EditorCover({ updateValue, prompt, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void prompt?: string }) { const { t } = useTranslation("dashboard") diff --git a/src/components/dashboard/editor-properties/EditorDisableAISummary.tsx b/src/components/dashboard/editor-properties/EditorDisableAISummary.tsx index dc2c8bac..f06f8326 100644 --- a/src/components/dashboard/editor-properties/EditorDisableAISummary.tsx +++ b/src/components/dashboard/editor-properties/EditorDisableAISummary.tsx @@ -6,7 +6,7 @@ import { EditorValues } from "~/lib/types" export default function EditorDisableAISummary({ updateValue, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void }) { const { t } = useTranslation("dashboard") const value = useEditorState((state) => state.disableAISummary) @@ -16,7 +16,7 @@ export default function EditorDisableAISummary({ updateValue({ disableAISummary: state, diff --git a/src/components/dashboard/editor-properties/EditorExcerpt.tsx b/src/components/dashboard/editor-properties/EditorExcerpt.tsx index 84059cd9..44262c09 100644 --- a/src/components/dashboard/editor-properties/EditorExcerpt.tsx +++ b/src/components/dashboard/editor-properties/EditorExcerpt.tsx @@ -9,7 +9,7 @@ export default function EditorExcerpt({ updateValue, prompt, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void prompt?: string }) { const { t } = useTranslation("dashboard") diff --git a/src/components/dashboard/editor-properties/EditorExternalUrl.tsx b/src/components/dashboard/editor-properties/EditorExternalUrl.tsx index 9873700c..ceb67128 100644 --- a/src/components/dashboard/editor-properties/EditorExternalUrl.tsx +++ b/src/components/dashboard/editor-properties/EditorExternalUrl.tsx @@ -8,7 +8,7 @@ import { EditorValues } from "~/lib/types" export default function EditorExternalUrl({ updateValue, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void }) { const { t } = useTranslation("dashboard") const value = useEditorState((state) => state.externalUrl) diff --git a/src/components/dashboard/editor-properties/EditorImages.tsx b/src/components/dashboard/editor-properties/EditorImages.tsx index 74d58bb8..4181b14c 100644 --- a/src/components/dashboard/editor-properties/EditorImages.tsx +++ b/src/components/dashboard/editor-properties/EditorImages.tsx @@ -10,7 +10,7 @@ export default function EditorImages({ updateValue, prompt, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void prompt?: string }) { const { t } = useTranslation("dashboard") @@ -21,7 +21,7 @@ export default function EditorImages({
- {value.map((image, index) => ( + {value?.map((image, index) => ( { if (key) { const tmpValue = [ - ...value, + ...(value || []), { address: key.address, mime_type: key.mime_type, diff --git a/src/components/dashboard/editor-properties/EditorPublishAt.tsx b/src/components/dashboard/editor-properties/EditorPublishAt.tsx index 4cf5735d..9329fec7 100644 --- a/src/components/dashboard/editor-properties/EditorPublishAt.tsx +++ b/src/components/dashboard/editor-properties/EditorPublishAt.tsx @@ -8,7 +8,7 @@ export default function EditorPublishAt({ updateValue, prompt, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void prompt?: string }) { const { t } = useTranslation("dashboard") diff --git a/src/components/dashboard/editor-properties/EditorSlug.tsx b/src/components/dashboard/editor-properties/EditorSlug.tsx index 8e714ceb..ae0458cc 100644 --- a/src/components/dashboard/editor-properties/EditorSlug.tsx +++ b/src/components/dashboard/editor-properties/EditorSlug.tsx @@ -12,7 +12,7 @@ export default function EditorSlug({ type, siteLink, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void defaultValue?: string type: string siteLink?: string diff --git a/src/components/dashboard/editor-properties/EditorTags.tsx b/src/components/dashboard/editor-properties/EditorTags.tsx index cf27143c..e4199d14 100644 --- a/src/components/dashboard/editor-properties/EditorTags.tsx +++ b/src/components/dashboard/editor-properties/EditorTags.tsx @@ -9,7 +9,7 @@ export default function EditorTags({ updateValue, characterId, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void characterId?: number }) { const { t } = useTranslation("dashboard") diff --git a/src/components/dashboard/editor-properties/EditorTitle.tsx b/src/components/dashboard/editor-properties/EditorTitle.tsx index 6d736689..6e4a3df6 100644 --- a/src/components/dashboard/editor-properties/EditorTitle.tsx +++ b/src/components/dashboard/editor-properties/EditorTitle.tsx @@ -8,7 +8,7 @@ import { EditorValues } from "~/lib/types" export default function EditorTitle({ updateValue, }: { - updateValue: (val: Partial) => void + updateValue: (val: EditorValues) => void }) { const { t } = useTranslation("dashboard") const value = useEditorState((state) => state.title) diff --git a/src/components/ui/TagInput.tsx b/src/components/ui/TagInput.tsx index 3ac90964..e4f2022e 100644 --- a/src/components/ui/TagInput.tsx +++ b/src/components/ui/TagInput.tsx @@ -23,7 +23,7 @@ export function TagInput({ }: Props) { const [query, setQuery] = useState("") - const { editorTags, setValues } = useEditorState( + const { editorTags = [], setValues } = useEditorState( (state) => ({ editorTags: state.tags === "" ? [] : state.tags?.split(","), setValues: state.setValues, diff --git a/src/lib/types.ts b/src/lib/types.ts index 09df8325..28561a84 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -127,20 +127,20 @@ export type ColorScheme = "dark" | "light" export type NoteType = "post" | "page" | "portfolio" | "short" export type EditorValues = { - title: string - publishedAt: string - published: boolean - excerpt: string - slug: string - tags: string - content: string - cover: { + title?: string + publishedAt?: string + published?: boolean + excerpt?: string + slug?: string + tags?: string + content?: string + cover?: { address?: string mime_type?: string } - disableAISummary: boolean - externalUrl: string - images: { + disableAISummary?: boolean + externalUrl?: string + images?: { address?: string mime_type?: string }[]