From 0ed5f8c1021918b1cb00b81b3d1d89e38e82a0d0 Mon Sep 17 00:00:00 2001 From: Ane Date: Wed, 25 Sep 2024 10:44:51 +0200 Subject: [PATCH] testimonalsSection --> testimonalsObject --- .../imageSection/ImageSectionComponentPreview.tsx | 4 ++-- src/components/sections/testimonials/Testimonials.tsx | 4 ++-- .../sections/testimonials/TestimonialsPreview.tsx | 10 +++++----- src/components/sections/testimonials/mockData.ts | 4 ++-- src/utils/renderSection.tsx | 10 +++++----- studio/lib/interfaces/pages.ts | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/components/sections/imageSection/ImageSectionComponentPreview.tsx b/src/components/sections/imageSection/ImageSectionComponentPreview.tsx index d12b4cb5..3147971c 100644 --- a/src/components/sections/imageSection/ImageSectionComponentPreview.tsx +++ b/src/components/sections/imageSection/ImageSectionComponentPreview.tsx @@ -18,7 +18,7 @@ export default function ImageSectionComponentPreview({ { initial: initialData }, ); - const testimonialsSection = newData + const testimonials = newData ? (newData.sections.find( (section, index) => section._type === "imageSection" && index === sectionIndex, @@ -30,7 +30,7 @@ export default function ImageSectionComponentPreview({ return ( - + ); } diff --git a/src/components/sections/testimonials/Testimonials.tsx b/src/components/sections/testimonials/Testimonials.tsx index 7fca3403..a5ebbfa5 100644 --- a/src/components/sections/testimonials/Testimonials.tsx +++ b/src/components/sections/testimonials/Testimonials.tsx @@ -2,13 +2,13 @@ import { RichText } from "src/components/richText/RichText"; import Text from "src/components/text/Text"; import useTabs from "src/utils/hooks/useTabs"; -import { TestimonialsSection } from "studio/lib/interfaces/pages"; +import { TestimonialsObject } from "studio/lib/interfaces/pages"; import { RenderImage } from "./RenderAvatar"; import styles from "./testimonials.module.css"; interface TestimonialsProps { - testimonials: TestimonialsSection; + testimonials: TestimonialsObject; } export const Testimonials = ({ testimonials }: TestimonialsProps) => { diff --git a/src/components/sections/testimonials/TestimonialsPreview.tsx b/src/components/sections/testimonials/TestimonialsPreview.tsx index 17f65f22..81b0d18c 100644 --- a/src/components/sections/testimonials/TestimonialsPreview.tsx +++ b/src/components/sections/testimonials/TestimonialsPreview.tsx @@ -4,7 +4,7 @@ import { useQuery } from "@sanity/react-loader"; import { Suspense } from "react"; import { PreviewProps } from "src/types/preview"; -import { PageBuilder, TestimonialsSection } from "studio/lib/interfaces/pages"; +import { PageBuilder, TestimonialsObject } from "studio/lib/interfaces/pages"; import { PAGE_QUERY } from "studio/lib/queries/page"; import { Testimonials } from "./Testimonials"; @@ -19,19 +19,19 @@ export default function TestimonialsPreview({ { initial: initialData }, ); - const testimonialsSection = newData + const testimonials = newData ? (newData.sections.find( (section, index) => section._type === "testimonials" && index === sectionIndex, - ) as TestimonialsSection) + ) as TestimonialsObject) : (initialData.data.sections.find( (section, index) => section._type === "testimonials" && index === sectionIndex, - ) as TestimonialsSection); + ) as TestimonialsObject); return ( - + ); } diff --git a/src/components/sections/testimonials/mockData.ts b/src/components/sections/testimonials/mockData.ts index 4cda0bac..ea5e0893 100644 --- a/src/components/sections/testimonials/mockData.ts +++ b/src/components/sections/testimonials/mockData.ts @@ -1,9 +1,9 @@ import alex from "src/stories/assets/alex.jpg"; import mika from "src/stories/assets/mika.jpg"; import vince from "src/stories/assets/vince.jpg"; -import { TestimonialsSection } from "studio/lib/interfaces/pages"; +import { TestimonialsObject } from "studio/lib/interfaces/pages"; -export const testimonialsMockData: TestimonialsSection = { +export const testimonialsMockData: TestimonialsObject = { _type: "testimonials", _key: "b69121269c53", basicTitle: "Take it from our customers", diff --git a/src/utils/renderSection.tsx b/src/utils/renderSection.tsx index 1566232d..c028052b 100644 --- a/src/utils/renderSection.tsx +++ b/src/utils/renderSection.tsx @@ -29,7 +29,7 @@ import { LogoSaladObject, PageBuilder, Section, - TestimonialsSection, + TestimonialsObject, } from "studio/lib/interfaces/pages"; interface SectionRendererProps { @@ -113,8 +113,8 @@ const renderCallToAction = ( ); }; -const renderTestimonialsSection = ( - section: TestimonialsSection, +const renderTestimonials = ( + section: TestimonialsObject, sectionIndex: number, isDraftMode: boolean, initialData: QueryResponseInitial, @@ -211,8 +211,8 @@ const SectionRenderer = ({ initialData, ); case "testimonials": - return renderTestimonialsSection( - section as TestimonialsSection, + return renderTestimonials( + section as TestimonialsObject, sectionIndex, isDraftMode, initialData, diff --git a/studio/lib/interfaces/pages.ts b/studio/lib/interfaces/pages.ts index d01f58ae..bb9ebbec 100644 --- a/studio/lib/interfaces/pages.ts +++ b/studio/lib/interfaces/pages.ts @@ -44,7 +44,7 @@ export interface CallToActionObject { callToActions?: ILink[]; } -export interface TestimonialsSection { +export interface TestimonialsObject { _key: string; _type: string; basicTitle?: string;