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 f7aedfe commit 4319902
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
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/payloads/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
3 changes: 1 addition & 2 deletions studio/components/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
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
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 4319902

Please sign in to comment.