Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3-cleanup-namingconventions #711

Draft
wants to merge 9 commits into
base: v3
Choose a base branch
from
16 changes: 8 additions & 8 deletions src/app/(main)/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { getDraftModeInfo } from "src/utils/draftmode";
import SectionRenderer from "src/utils/renderSection";
import { fetchSeoData, generateMetadataFromSeo } from "src/utils/seo";
import { CompanyLocation } from "studio/lib/interfaces/companyDetails";
import { CompensationsPage } from "studio/lib/interfaces/compensations";
import { CompensationsDocument } from "studio/lib/interfaces/compensations";
import { BlogPage, PageBuilder, Post } from "studio/lib/interfaces/pages";
import { CustomerCasePage } from "studio/lib/interfaces/specialPages";
import { CustomerCaseDocument } from "studio/lib/interfaces/specialPages";
import { COMPANY_LOCATIONS_QUERY } from "studio/lib/queries/companyDetails";
import {
BLOG_PAGE_QUERY,
Expand Down Expand Up @@ -57,13 +57,13 @@ async function Page({ params }: Props) {
const [
initialPage,
initialBlogPage,
initialCompensationsPage,
initialCompensationsDocument,
initialLocationsData,
initialCustomerCases,
] = await Promise.all([
loadStudioQuery<PageBuilder>(SLUG_QUERY, { slug }, { perspective }),
loadStudioQuery<BlogPage>(BLOG_PAGE_QUERY, { slug }, { perspective }),
loadStudioQuery<CompensationsPage>(
loadStudioQuery<CompensationsDocument>(
COMPENSATIONS_PAGE_QUERY,
{ slug },
{ perspective },
Expand All @@ -73,7 +73,7 @@ async function Page({ params }: Props) {
{},
{ perspective },
),
loadStudioQuery<CustomerCasePage>(
loadStudioQuery<CustomerCaseDocument>(
CUSTOMER_CASES_PAGE_QUERY,
{ slug },
{ perspective },
Expand Down Expand Up @@ -123,15 +123,15 @@ async function Page({ params }: Props) {
);
}

if (initialCompensationsPage.data && initialLocationsData.data) {
if (initialCompensationsDocument.data && initialLocationsData.data) {
return isDraftMode ? (
<CompensationsPreview
initialCompensations={initialCompensationsPage}
initialCompensations={initialCompensationsDocument}
initialLocations={initialLocationsData}
/>
) : (
<Compensations
compensations={initialCompensationsPage.data}
compensations={initialCompensationsDocument.data}
locations={initialLocationsData.data}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions src/compensations/Compensations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "src/components/forms/radioButtonGroup/RadioButtonGroup";
import Text from "src/components/text/Text";
import { CompanyLocation } from "studio/lib/interfaces/companyDetails";
import { CompensationsPage } from "studio/lib/interfaces/compensations";
import { CompensationsDocument } from "studio/lib/interfaces/compensations";

import styles from "./compensations.module.css";
import BenefitsByLocation from "./components/benefitsByLocation/BenefitsByLocation";
Expand All @@ -24,7 +24,7 @@ import {
} from "./utils/salary";

interface CompensationsProps {
compensations: CompensationsPage;
compensations: CompensationsDocument;
locations: CompanyLocation[];
}

Expand Down
6 changes: 3 additions & 3 deletions src/compensations/CompensationsPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import { QueryResponseInitial, useQuery } from "@sanity/react-loader";
import { Suspense } from "react";

import { CompanyLocation } from "studio/lib/interfaces/companyDetails";
import { CompensationsPage } from "studio/lib/interfaces/compensations";
import { CompensationsDocument } from "studio/lib/interfaces/compensations";
import { COMPANY_LOCATIONS_QUERY } from "studio/lib/queries/companyDetails";
import { COMPENSATIONS_PAGE_QUERY } from "studio/lib/queries/specialPages";

import Compensations from "./Compensations";

interface CompensationsPreviewProps {
initialCompensations: QueryResponseInitial<CompensationsPage>;
initialCompensations: QueryResponseInitial<CompensationsDocument>;
initialLocations: QueryResponseInitial<CompanyLocation[]>;
}

const CompensationsPreview = ({
initialCompensations,
initialLocations,
}: CompensationsPreviewProps) => {
const { data: compensationsData } = useQuery<CompensationsPage>(
const { data: compensationsData } = useQuery<CompensationsDocument>(
COMPENSATIONS_PAGE_QUERY,
{ slug: initialCompensations.data.slug.current },
{ initial: initialCompensations },
Expand Down
4 changes: 2 additions & 2 deletions src/compensations/components/yearlyBonuses/YearlyBonuses.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Text from "src/components/text/Text";
import { BonusPage } from "studio/lib/interfaces/compensations";
import { BonusObject } from "studio/lib/interfaces/compensations";

import styles from "./yearlyBonuses.module.css";

interface YearlyBonusesProps {
bonuses: BonusPage[];
bonuses: BonusObject[];
}

const YearlyBonuses = ({ bonuses }: YearlyBonusesProps) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/navigation/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const mockNavigation: Navigation = {
footer: [
{
_key: "47456f5da563",
_type: "footerSection",
_type: "footer",
sectionTitle: "Social Media",
sectionType: SectionType.SocialMedia,
socialMediaLinks: {
Expand All @@ -68,7 +68,7 @@ export const mockNavigation: Navigation = {
},
{
_key: "c3d5803182fb",
_type: "footerSection",
_type: "footer",
sectionTitle: "Content",
sectionType: SectionType.Content,
linksAndContent: [
Expand Down
4 changes: 2 additions & 2 deletions src/components/sections/article/Article.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import CustomLink from "src/components/link/CustomLink";
import { RichText } from "src/components/richText/RichText";
import Text from "src/components/text/Text";
import { useConvertSanityImageToNextImage } from "src/utils/hooks/useConvertImage";
import { ArticleSection } from "studio/lib/interfaces/pages";
import { ArticleObject } from "studio/lib/interfaces/pages";

import styles from "./article.module.css";

interface ArticleProps {
article: ArticleSection;
article: ArticleObject;
}

const Article = ({ article }: ArticleProps) => {
Expand Down
8 changes: 4 additions & 4 deletions src/components/sections/article/ArticlePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useQuery } from "@sanity/react-loader";
import { Suspense } from "react";

import { PreviewProps } from "src/types/preview";
import { ArticleSection, PageBuilder } from "studio/lib/interfaces/pages";
import { ArticleObject, PageBuilder } from "studio/lib/interfaces/pages";
import { PAGE_QUERY } from "studio/lib/queries/page";

import Article from "./Article";
Expand All @@ -19,13 +19,13 @@ export default function ArticlePreview({
{ initial: initialData },
);

const articleSection = data.sections.find(
const article = data.sections.find(
(section, index) => section._type === "article" && index === sectionIndex,
) as ArticleSection;
) as ArticleObject;

return (
<Suspense>
<Article article={articleSection} />
<Article article={article} />
</Suspense>
);
}
17 changes: 7 additions & 10 deletions src/components/sections/article/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PortableTextBlock } from "sanity";

import placeholder from "src/stories/assets/image-placeholder.png";
import { LinkType } from "studio/lib/interfaces/navigation";
import { ArticleSection } from "studio/lib/interfaces/pages";
import { ArticleObject } from "studio/lib/interfaces/pages";
import { ImageAlignment } from "studio/schemas/fields/media";

const commonRichText: PortableTextBlock[] = [
Expand Down Expand Up @@ -43,11 +43,11 @@ const commonLink = {
},
};

const createArticleSection = (
const createArticle = (
imageAlignment: ImageAlignment,
includeLink: boolean,
tag?: string,
): ArticleSection => ({
): ArticleObject => ({
_key: "286f87152fce",
_type: "article",
basicTitle: "AI Carbon Accounting",
Expand All @@ -63,19 +63,16 @@ const createArticleSection = (
...(includeLink ? { link: commonLink } : {}),
});

export const extendedArticleLargeLeftMock = createArticleSection(
export const extendedArticleLargeLeftMock = createArticle(
ImageAlignment.Left,
true,
"Measure",
);
export const extendedArticleLargeRightMock = createArticleSection(
export const extendedArticleLargeRightMock = createArticle(
ImageAlignment.Right,
true,
"Measure",
);

export const articleLeftMock = createArticleSection(ImageAlignment.Left, false);
export const articleRightMock = createArticleSection(
ImageAlignment.Right,
false,
);
export const articleLeftMock = createArticle(ImageAlignment.Left, false);
export const articleRightMock = createArticle(ImageAlignment.Right, false);
4 changes: 2 additions & 2 deletions src/components/sections/callToAction/CallToAction.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import LinkButton from "src/components/linkButton/LinkButton";
import Text from "src/components/text/Text";
import { CallToActionSection } from "studio/lib/interfaces/pages";
import { CallToActionObject } from "studio/lib/interfaces/pages";

import styles from "./callToAction.module.css";

interface CallToActionProps {
callToAction: CallToActionSection;
callToAction: CallToActionObject;
}

const CallToAction = ({ callToAction }: CallToActionProps) => {
Expand Down
10 changes: 5 additions & 5 deletions src/components/sections/callToAction/CallToActionPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useQuery } from "@sanity/react-loader";
import { Suspense } from "react";

import { PreviewProps } from "src/types/preview";
import { CallToActionSection, PageBuilder } from "studio/lib/interfaces/pages";
import { CallToActionObject, PageBuilder } from "studio/lib/interfaces/pages";
import { PAGE_QUERY } from "studio/lib/queries/page";

import CallToAction from "./CallToAction";
Expand All @@ -19,19 +19,19 @@ export default function CallToActionPreview({
{ initial: initialData },
);

const callToActionSection = newData
const callToAction = newData
? (newData.sections.find(
(section, index) =>
section._type === "ctaSection" && index === sectionIndex,
) as CallToActionSection)
) as CallToActionObject)
: (initialData.data.sections.find(
(section, index) =>
section._type === "ctaSection" && index === sectionIndex,
) as CallToActionSection);
) as CallToActionObject);

return (
<Suspense>
<CallToAction callToAction={callToActionSection} />
<CallToAction callToAction={callToAction} />
</Suspense>
);
}
4 changes: 2 additions & 2 deletions src/components/sections/callout/Callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { PortableText, PortableTextReactComponents } from "@portabletext/react";

import CustomLink from "src/components/link/CustomLink";
import Text from "src/components/text/Text";
import { CalloutSection } from "studio/lib/interfaces/pages";
import { CalloutObject } from "studio/lib/interfaces/pages";

import styles from "./callout.module.css";

interface CalloutProps {
callout: CalloutSection;
callout: CalloutObject;
}

const myPortableTextComponents: Partial<PortableTextReactComponents> = {
Expand Down
10 changes: 5 additions & 5 deletions src/components/sections/callout/CalloutPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useQuery } from "@sanity/react-loader";
import { Suspense } from "react";

import { PreviewProps } from "src/types/preview";
import { CalloutSection, PageBuilder } from "studio/lib/interfaces/pages";
import { CalloutObject, PageBuilder } from "studio/lib/interfaces/pages";
import { PAGE_QUERY } from "studio/lib/queries/page";

import Callout from "./Callout";
Expand All @@ -19,19 +19,19 @@ export default function CalloutPreview({
{ initial: initialData },
);

const calloutSection = newData
const callout = newData
? (newData.sections.find(
(section, index) =>
section._type === "callout" && index === sectionIndex,
) as CalloutSection)
) as CalloutObject)
: (initialData.data.sections.find(
(section, index) =>
section._type === "callout" && index === sectionIndex,
) as CalloutSection);
) as CalloutObject);

return (
<Suspense>
<Callout callout={calloutSection} />
<Callout callout={callout} />
</Suspense>
);
}
6 changes: 3 additions & 3 deletions src/components/sections/hero/Hero.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, StoryObj } from "@storybook/react";

import { Hero } from "./Hero";
import { mockHeroSection } from "./mockData";
import { mockHero } from "./mockData";

const meta: Meta<typeof Hero> = {
title: "Components/Sections/Hero",
Expand All @@ -21,14 +21,14 @@ type Story = StoryObj<typeof Hero>;

export const Landing: Story = {
args: {
hero: mockHeroSection,
hero: mockHero,
isLanding: true,
},
};

export const Default: Story = {
args: {
hero: mockHeroSection,
hero: mockHero,
isLanding: false,
},
};
4 changes: 2 additions & 2 deletions src/components/sections/hero/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import LinkButton from "src/components/linkButton/LinkButton";
import Text from "src/components/text/Text";
import { ILink } from "studio/lib/interfaces/navigation";
import { HeroSection } from "studio/lib/interfaces/pages";
import { HeroObject } from "studio/lib/interfaces/pages";

import styles from "./hero.module.css";

interface HeroProps {
hero: HeroSection;
hero: HeroObject;
isLanding: boolean;
}

Expand Down
10 changes: 5 additions & 5 deletions src/components/sections/hero/HeroPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useQuery } from "@sanity/react-loader";
import { Suspense } from "react";

import { PreviewProps } from "src/types/preview";
import { HeroSection, PageBuilder } from "studio/lib/interfaces/pages";
import { HeroObject, PageBuilder } from "studio/lib/interfaces/pages";
import { PAGE_QUERY } from "studio/lib/queries/page";

import { Hero } from "./Hero";
Expand All @@ -24,17 +24,17 @@ export default function HeroPreview({
{ initial: initialData },
);

const heroSection = newData
const heroObject = newData
? (newData.sections.find(
(section, index) => section._type === "hero" && index === sectionIndex,
) as HeroSection)
) as HeroObject)
: (initialData.data.sections.find(
(section, index) => section._type === "hero" && index === sectionIndex,
) as HeroSection);
) as HeroObject);

return (
<Suspense>
<Hero hero={heroSection} isLanding={isLanding} />
<Hero hero={heroObject} isLanding={isLanding} />
</Suspense>
);
}
4 changes: 2 additions & 2 deletions src/components/sections/hero/mockData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LinkType } from "studio/lib/interfaces/navigation";
import { HeroSection } from "studio/lib/interfaces/pages";
import { HeroObject } from "studio/lib/interfaces/pages";

export const mockHeroSection: HeroSection = {
export const mockHero: HeroObject = {
_key: "",
_type: "hero",
basicTitle: "Effortless Climate Action",
Expand Down
Loading