From 431990201ab45b54f09db84a32b0556c7b6de749 Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Tue, 17 Sep 2024 10:47:52 +0200 Subject: [PATCH] chore(eslint): fix errors --- src/app/layout.tsx | 2 +- 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 +++++++++---------- studio/components/ReferenceSlugInput.tsx | 3 +- .../components/SalariesTableEditor.tsx | 2 +- studio/lib/token.ts | 1 + studioShared/lib/token.ts | 1 + 10 files changed, 51 insertions(+), 52 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index b640959c8..95d5f3b41 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,12 +2,12 @@ import { Metadata } from "next"; import { Darker_Grotesque, Figtree } from "next/font/google"; import { draftMode } from "next/headers"; +import { generateMetadataFromSeo } from "src/utils/seo"; import LiveVisualEditing from "studio/lib/loaders/AutomaticVisualEditing"; import { CompanyInfo } from "studio/lib/payloads/companyDetails"; import { COMPANY_INFO_QUERY } from "studio/lib/queries/companyDetails"; import { loadQuery } from "studio/lib/store"; import "src/styles/global.css"; -import { generateMetadataFromSeo } from "src/utils/seo"; const darkerGrotesque = Darker_Grotesque({ subsets: ["latin"], diff --git a/src/utils/hooks/useConvertImage.tsx b/src/utils/hooks/useConvertImage.tsx index 4420eb350..b26257890 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/payloads/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 00e9815f0..e0c95c0e1 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 5025a4eed..413cf31e5 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/ReferenceSlugInput.tsx b/studio/components/ReferenceSlugInput.tsx index a1afd1829..d37adb775 100644 --- a/studio/components/ReferenceSlugInput.tsx +++ b/studio/components/ReferenceSlugInput.tsx @@ -29,8 +29,7 @@ interface ReferenceSlugInputProps { } const ReferenceSlugInput: React.FC = (props) => { - const { value, readOnly, schemaType, onChange, elementProps, document } = - props; + const { value, readOnly, onChange, elementProps, document } = props; const [slug, setSlug] = useState(value || null); const client = useClient(); 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]) => ( <>