Skip to content

Commit

Permalink
chore(eslint): fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiazom committed Sep 17, 2024
1 parent 8817d7c commit 23ae012
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 54 deletions.
6 changes: 4 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
4 changes: 2 additions & 2 deletions src/utils/hooks/useConvertImage.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/utils/hooks/useFetchPosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const useFetchPosts = ({

setPostsCount(count);
} catch (error) {
console.log("Error when fetching posts:", error);
setPosts((prevState) => ({
...prevState,
initialLoading: false,
Expand Down
2 changes: 0 additions & 2 deletions src/utils/renderSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ const renderContactFormSection = (
section: ContactFormSection,
sectionIndex: number,
isDraftMode: boolean,
initialData: QueryResponseInitial<PageBuilder>,
) => {
return isDraftMode ? <div></div> : <ContactForm data={section} />;
};
Expand Down Expand Up @@ -237,7 +236,6 @@ const SectionRenderer = ({
section as ContactFormSection,
sectionIndex,
isDraftMode,
initialData,
);
default:
return null;
Expand Down
2 changes: 1 addition & 1 deletion studio/components/AnchorSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
85 changes: 42 additions & 43 deletions studio/components/CategorySelect.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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<Category[]>([]);

useEffect(() => {
async function fetchCategories() {
const result = await fetchWithToken<Category[]>(
`*[_type == "blog"][0].categories`,
);

setCategories(result || []);
}
fetchCategories();
}, [client]);

const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
onChange(PatchEvent.from(set(event.target.value)));
};

return (
<Select
ref={ref}
value={value || ""}
onChange={handleChange}
placeholder="Select a category"
>
<option value="" disabled>
Select a category
</option>
{categories.map((category) => (
<option key={category.name} value={category.name}>
{category.name}
type CategorySelectorProps = StringInputProps;

const CategorySelector = forwardRef<HTMLSelectElement, CategorySelectorProps>(
(props, ref) => {
const { value, onChange } = props;
const client = useClient();
const [categories, setCategories] = useState<Category[]>([]);

useEffect(() => {
async function fetchCategories() {
const result = await fetchWithToken<Category[]>(
`*[_type == "blog"][0].categories`,
);

setCategories(result || []);
}
fetchCategories();
}, [client]);

const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
onChange(PatchEvent.from(set(event.target.value)));
};

return (
<Select
ref={ref}
value={value || ""}
onChange={handleChange}
placeholder="Select a category"
>
<option value="" disabled>
Select a category
</option>
))}
</Select>
);
});
{categories.map((category) => (
<option key={category.name} value={category.name}>
{category.name}
</option>
))}
</Select>
);
},
);

CategorySelector.displayName = "CategorySelector";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const SalariesTableEditor = ({
</div>
{Object.entries(salaries)
.toSorted(([a], [b]) => Number(b) - Number(a))
.map(([year, salary], index) => (
.map(([year, salary]) => (
<>
<div key={year} className={styles.tableCell}>
<label htmlFor={`salary-number-input-${year}`}>
Expand Down
3 changes: 1 addition & 2 deletions studio/components/slug/ReferenceSlugInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ interface ReferenceSlugInputProps {
}

const ReferenceSlugInput: React.FC<ReferenceSlugInputProps> = (props) => {
const { value, readOnly, schemaType, onChange, elementProps, document } =
props;
const { value, readOnly, onChange, elementProps, document } = props;
const [slug, setSlug] = useState<string | null>(value || null);
const client = useClient();

Expand Down
2 changes: 1 addition & 1 deletion studio/lib/interfaces/languages.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
interface DefaultLanguageObject {
export interface DefaultLanguageObject {
defaultLanguage: string;
}
1 change: 1 addition & 0 deletions studio/lib/token.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Server-Only Token Management

// eslint-disable-next-line import/no-unresolved
import "server-only";
import { experimental_taintUniqueValue } from "react";

Expand Down
1 change: 1 addition & 0 deletions studioShared/lib/token.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Server-Only Token Management

// eslint-disable-next-line import/no-unresolved
import "server-only";
import { experimental_taintUniqueValue } from "react";

Expand Down

0 comments on commit 23ae012

Please sign in to comment.