From 23ae012cb2a118d93dc6c91f3519442d35a956d0 Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Tue, 17 Sep 2024 12:06:22 +0200 Subject: [PATCH] chore(eslint): fix errors --- src/app/layout.tsx | 6 +- src/utils/hooks/useConvertImage.tsx | 4 +- src/utils/hooks/useFetchPosts.ts | 1 + src/utils/renderSection.tsx | 2 - studio/components/AnchorSelect.tsx | 2 +- studio/components/CategorySelect.tsx | 85 +++++++++---------- .../components/SalariesTableEditor.tsx | 2 +- studio/components/slug/ReferenceSlugInput.tsx | 3 +- studio/lib/interfaces/languages.ts | 2 +- studio/lib/token.ts | 1 + studioShared/lib/token.ts | 1 + 11 files changed, 55 insertions(+), 54 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 18593e823..a6df87b4b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,11 +2,13 @@ import { Metadata } from "next"; import { Darker_Grotesque, Figtree } from "next/font/google"; import { draftMode } from "next/headers"; +import { generateMetadataFromSeo } from "src/utils/seo"; +import { DefaultLanguageObject } from "studio/lib/interfaces/languages"; import LiveVisualEditing from "studio/lib/loaders/AutomaticVisualEditing"; +import { DEFAULT_LANGUAGE_QUERY } from "studio/lib/queries/languages"; import { loadQuery } from "studio/lib/store"; + import "src/styles/global.css"; -import { generateMetadataFromSeo } from "src/utils/seo"; -import { DEFAULT_LANGUAGE_QUERY } from "studio/lib/queries/languages"; const darkerGrotesque = Darker_Grotesque({ subsets: ["latin"], diff --git a/src/utils/hooks/useConvertImage.tsx b/src/utils/hooks/useConvertImage.tsx index 2449a9d44..849a5b07e 100644 --- a/src/utils/hooks/useConvertImage.tsx +++ b/src/utils/hooks/useConvertImage.tsx @@ -1,12 +1,12 @@ import Image from "next/image"; import { useNextSanityImage } from "next-sanity-image"; - -// TODO: add support for sharedClient import { JSX } from "react"; import { client } from "studio/lib/client"; import { IImage } from "studio/lib/interfaces/media"; +// TODO: add support for sharedClient + const MockImage = ({ image }: { image: IImage }) => { if (!image.src) { return null; diff --git a/src/utils/hooks/useFetchPosts.ts b/src/utils/hooks/useFetchPosts.ts index 67054d0ad..fdbca6efb 100644 --- a/src/utils/hooks/useFetchPosts.ts +++ b/src/utils/hooks/useFetchPosts.ts @@ -60,6 +60,7 @@ export const useFetchPosts = ({ setPostsCount(count); } catch (error) { + console.log("Error when fetching posts:", error); setPosts((prevState) => ({ ...prevState, initialLoading: false, diff --git a/src/utils/renderSection.tsx b/src/utils/renderSection.tsx index 793212c72..7e97b016e 100644 --- a/src/utils/renderSection.tsx +++ b/src/utils/renderSection.tsx @@ -162,7 +162,6 @@ const renderContactFormSection = ( section: ContactFormSection, sectionIndex: number, isDraftMode: boolean, - initialData: QueryResponseInitial, ) => { return isDraftMode ?
: ; }; @@ -237,7 +236,6 @@ const SectionRenderer = ({ section as ContactFormSection, sectionIndex, isDraftMode, - initialData, ); default: return null; diff --git a/studio/components/AnchorSelect.tsx b/studio/components/AnchorSelect.tsx index 2eed950e7..1d68f3d97 100644 --- a/studio/components/AnchorSelect.tsx +++ b/studio/components/AnchorSelect.tsx @@ -53,7 +53,7 @@ const AnchorSelect = ({ value, onChange, path }: AnchorSelectProps) => { }); const formattedResponseToListItems = response.sections.map( - (section: AnchorItem, index: number) => { + (section: AnchorItem) => { const title = section.basicTitle || fromCamelCase(section._type); return { basicTitle: title, diff --git a/studio/components/CategorySelect.tsx b/studio/components/CategorySelect.tsx index 4cb42642a..2af1c92a6 100644 --- a/studio/components/CategorySelect.tsx +++ b/studio/components/CategorySelect.tsx @@ -1,5 +1,5 @@ import { Select } from "@sanity/ui"; -import React, { useEffect, useState } from "react"; +import React, { forwardRef, useEffect, useState } from "react"; import { PatchEvent, StringInputProps, set, useClient } from "sanity"; import { fetchWithToken } from "studio/lib/fetchWithToken"; @@ -9,49 +9,48 @@ interface Category { name: string; } -interface CategorySelectorProps extends StringInputProps {} - -const CategorySelector = React.forwardRef< - HTMLSelectElement, - CategorySelectorProps ->((props, ref) => { - const { value, onChange } = props; - const client = useClient(); - const [categories, setCategories] = useState([]); - - useEffect(() => { - async function fetchCategories() { - const result = await fetchWithToken( - `*[_type == "blog"][0].categories`, - ); - - setCategories(result || []); - } - fetchCategories(); - }, [client]); - - const handleChange = (event: React.ChangeEvent) => { - onChange(PatchEvent.from(set(event.target.value))); - }; - - return ( - + - ))} - - ); -}); + {categories.map((category) => ( + + ))} + + ); + }, +); CategorySelector.displayName = "CategorySelector"; diff --git a/studio/components/salariesInput/components/SalariesTableEditor.tsx b/studio/components/salariesInput/components/SalariesTableEditor.tsx index 22ff07434..7de3b9740 100644 --- a/studio/components/salariesInput/components/SalariesTableEditor.tsx +++ b/studio/components/salariesInput/components/SalariesTableEditor.tsx @@ -24,7 +24,7 @@ const SalariesTableEditor = ({ {Object.entries(salaries) .toSorted(([a], [b]) => Number(b) - Number(a)) - .map(([year, salary], index) => ( + .map(([year, salary]) => ( <>