fix: types error

This commit is contained in:
DIYgod 2023-08-26 01:23:16 +01:00
parent 9276cded12
commit 03b65b07c6
No known key found for this signature in database
16 changed files with 33 additions and 33 deletions

View File

@ -105,7 +105,7 @@ export default function PortfolioEditor() {
const getValues = useGetState(values)
const updateValue = useCallback(
(val: Partial<EditorValues>) => {
(val: EditorValues) => {
if (visibility !== PageVisibilityEnum.Draft) {
setVisibility(PageVisibilityEnum.Modified)
}
@ -301,7 +301,7 @@ export default function PortfolioEditor() {
}
const EditorExtraProperties = memo(
({ updateValue }: { updateValue: (val: Partial<EditorValues>) => void }) => {
({ updateValue }: { updateValue: (val: EditorValues) => void }) => {
const { t } = useTranslation("dashboard")
return (

View File

@ -134,7 +134,7 @@ export default function PostEditor() {
const getDraftKey = useGetState(draftKey)
const updateValue = useCallback(
(val: Partial<EditorValues>) => {
(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<EditorValues>) => void
updateValue: (val: EditorValues) => void
type: NoteType
defaultSlug: string
characterId?: number

View File

@ -103,7 +103,7 @@ export default function ShortEditor() {
const getValues = useGetState(values)
const updateValue = useCallback(
(val: Partial<EditorValues>) => {
(val: EditorValues) => {
if (visibility !== PageVisibilityEnum.Draft) {
setVisibility(PageVisibilityEnum.Modified)
}
@ -299,7 +299,7 @@ export default function ShortEditor() {
}
const EditorExtraProperties = memo(
({ updateValue }: { updateValue: (val: Partial<EditorValues>) => void }) => {
({ updateValue }: { updateValue: (val: EditorValues) => void }) => {
const { t } = useTranslation("dashboard")
return (

View File

@ -8,7 +8,7 @@ import { EditorValues } from "~/lib/types"
export default function EditorAutofill({
updateValue,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
}) {
const { t } = useTranslation("dashboard")
const externalUrl = useEditorState((state) => state.externalUrl)

View File

@ -9,7 +9,7 @@ export default function EditorContent({
updateValue,
prompt,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
prompt?: string
}) {
const { t } = useTranslation("dashboard")

View File

@ -8,7 +8,7 @@ export default function EditorCover({
updateValue,
prompt,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
prompt?: string
}) {
const { t } = useTranslation("dashboard")

View File

@ -6,7 +6,7 @@ import { EditorValues } from "~/lib/types"
export default function EditorDisableAISummary({
updateValue,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
}) {
const { t } = useTranslation("dashboard")
const value = useEditorState((state) => state.disableAISummary)
@ -16,7 +16,7 @@ export default function EditorDisableAISummary({
<label className="form-label">{t("Disable AI-generated summary")}</label>
<Switch
label=""
checked={value}
checked={value || false}
setChecked={(state) =>
updateValue({
disableAISummary: state,

View File

@ -9,7 +9,7 @@ export default function EditorExcerpt({
updateValue,
prompt,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
prompt?: string
}) {
const { t } = useTranslation("dashboard")

View File

@ -8,7 +8,7 @@ import { EditorValues } from "~/lib/types"
export default function EditorExternalUrl({
updateValue,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
}) {
const { t } = useTranslation("dashboard")
const value = useEditorState((state) => state.externalUrl)

View File

@ -10,7 +10,7 @@ export default function EditorImages({
updateValue,
prompt,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
prompt?: string
}) {
const { t } = useTranslation("dashboard")
@ -21,7 +21,7 @@ export default function EditorImages({
<div>
<FieldLabel label={t("Images")} />
<div className="grid grid-cols-4 gap-2">
{value.map((image, index) => (
{value?.map((image, index) => (
<ImageUploader
key={image.address}
className="aspect-video rounded-lg"
@ -51,7 +51,7 @@ export default function EditorImages({
uploadEnd={(key) => {
if (key) {
const tmpValue = [
...value,
...(value || []),
{
address: key.address,
mime_type: key.mime_type,

View File

@ -8,7 +8,7 @@ export default function EditorPublishAt({
updateValue,
prompt,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
prompt?: string
}) {
const { t } = useTranslation("dashboard")

View File

@ -12,7 +12,7 @@ export default function EditorSlug({
type,
siteLink,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
defaultValue?: string
type: string
siteLink?: string

View File

@ -9,7 +9,7 @@ export default function EditorTags({
updateValue,
characterId,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
characterId?: number
}) {
const { t } = useTranslation("dashboard")

View File

@ -8,7 +8,7 @@ import { EditorValues } from "~/lib/types"
export default function EditorTitle({
updateValue,
}: {
updateValue: (val: Partial<EditorValues>) => void
updateValue: (val: EditorValues) => void
}) {
const { t } = useTranslation("dashboard")
const value = useEditorState((state) => state.title)

View File

@ -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,

View File

@ -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
}[]