Skip to content

Commit

Permalink
V3 - Rename payload folder to interfaces and deleted unused redirect …
Browse files Browse the repository at this point in the history
…button (#656)

* Deleted custom button from toolline in Sanity studio as we dont't need it / use it anymore

* created slug folder, and move relevant files to this folder

* rename payloads folder to interfaces and updated all imports

* Update README.md

Co-authored-by: Mathias Oterhals Myklebust <[email protected]>

---------

Co-authored-by: Mathias Oterhals Myklebust <[email protected]>
  • Loading branch information
anemne and mathiazom authored Sep 17, 2024
1 parent 741aa87 commit 67361c0
Show file tree
Hide file tree
Showing 93 changed files with 224 additions and 394 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ To maintain consistency and efficiency, follow these steps when working on the p
2. Adding New UI with Content:

- Define the Sanity schema for new content types.
- Implement the corresponding interface and payload structure in src/lib/payloads.
- Implement the corresponding interface and payload structure in src/lib/interfaces.
- Fetch the necessary data and create the UI component.
- Document and test the UI component in Storybook, using mock data for isolated development.

Expand Down
341 changes: 123 additions & 218 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"react": "^18",
"react-dom": "^18",
"react-focus-on": "^3.9.3",
"sanity": "^3.50.0"
"sanity": "^3.57.3"
},
"devDependencies": {
"@storybook/addon-a11y": "^8.2.9",
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/[slug]/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PostPage from "src/post/PostPage";
import PostPagePreview from "src/post/PostPagePreview";
import { getDraftModeInfo } from "src/utils/draftmode";
import { fetchPostSeoData, generateMetadataFromSeo } from "src/utils/seo";
import { BlogPage, Post } from "studio/lib/payloads/pages";
import { BlogPage, Post } from "studio/lib/interfaces/pages";
import {
BLOG_PAGE_QUERY,
MORE_POST_PREVIEW,
Expand Down
6 changes: 3 additions & 3 deletions src/app/(main)/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import Compensations from "src/compensations/Compensations";
import { getDraftModeInfo } from "src/utils/draftmode";
import SectionRenderer from "src/utils/renderSection";
import { fetchSeoData, generateMetadataFromSeo } from "src/utils/seo";
import { BlogPage, PageBuilder, Post } from "studio/lib/payloads/pages";
import { CompensationsPage } from "studio/lib/payloads/compensations";
import { BlogPage, PageBuilder, Post } from "studio/lib/interfaces/pages";
import { CompensationsPage } from "studio/lib/interfaces/compensations";
import {
BLOG_PAGE_QUERY,
POSTS_QUERY,
Expand All @@ -18,7 +18,7 @@ import { loadQuery } from "studio/lib/store";
import CompensationsPreview from "src/compensations/CompensationsPreview";
import { homeLink } from "../../../blog/components/utils/linkTypes";
import CustomErrorMessage from "../../../blog/components/customErrorMessage/CustomErrorMessage";
import { CompanyLocation } from "studio/lib/payloads/companyDetails";
import { CompanyLocation } from "studio/lib/interfaces/companyDetails";
import { COMPANY_LOCATIONS_QUERY } from "studio/lib/queries/companyDetails";

export const dynamic = "force-dynamic";
Expand Down
10 changes: 5 additions & 5 deletions src/app/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import Footer from "src/components/navigation/footer/Footer";
import { NAV_QUERY } from "studio/lib/queries/navigation";
import { COMPANY_INFO_QUERY } from "studio/lib/queries/companyDetails";
import { Header } from "src/components/navigation/header/Header";
import { Navigation } from "studio/lib/payloads/navigation";
import { CompanyInfo } from "studio/lib/payloads/companyDetails";
import { Navigation } from "studio/lib/interfaces/navigation";
import { CompanyInfo } from "studio/lib/interfaces/companyDetails";
import { loadQuery } from "studio/lib/store";
import HeaderPreview from "src/components/navigation/header/HeaderPreview";
import FooterPreview from "src/components/navigation/footer/FooterPreview";
import { SOMEPROFILES_QUERY } from "studio/lib/queries/socialMediaProfiles";
import { SocialMediaProfiles } from "studio/lib/payloads/socialMedia";
import { SocialMediaProfiles } from "studio/lib/interfaces/socialMedia";
import { getDraftModeInfo } from "src/utils/draftmode";
import SkipToMain from "src/components/skipToMain/SkipToMain";
import { LEGAL_DOCUMENTS_QUERY } from "studio/lib/queries/legalDocuments";
import { LegalDocument } from "studio/lib/payloads/legalDocuments";
import { LegalDocument } from "studio/lib/interfaces/legalDocuments";
import styles from "./layout.module.css";
import { BRAND_ASSETS_QUERY } from "../../../studio/lib/queries/brandAssets";
import { BrandAssets } from "../../../studio/lib/payloads/brandAssets";
import { BrandAssets } from "../../../studio/lib/interfaces/brandAssets";

const hasValidData = (data: any) => data && Object.keys(data).length > 0;

Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/legal/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Legal from "src/blog/components/legal/Legal";
import LegalPreview from "src/blog/components/legal/LegalPreview";
import { getDraftModeInfo } from "src/utils/draftmode";
import { LegalDocument } from "studio/lib/payloads/legalDocuments";
import { LegalDocument } from "studio/lib/interfaces/legalDocuments";
import { LEGAL_DOCUMENT_SLUG_QUERY } from "studio/lib/queries/legalDocuments";
import { loadQuery } from "studio/lib/store";

Expand Down
4 changes: 2 additions & 2 deletions src/app/(main)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { getDraftModeInfo } from "src/utils/draftmode";
import { LANDING_QUERY } from "studio/lib/queries/navigation";
import { PAGE_QUERY, SEO_PAGE_QUERY } from "studio/lib/queries/pages";
import { PageBuilder } from "studio/lib/payloads/pages";
import { PageBuilder } from "studio/lib/interfaces/pages";
import SectionRenderer from "src/utils/renderSection";
import { loadQuery } from "studio/lib/store";
import { Metadata } from "next";
import { fetchSeoData, generateMetadataFromSeo } from "src/utils/seo";
import InformationSection from "src/blog/components/informationSection/InformationSection";
import { LinkType } from "studio/lib/payloads/navigation";
import { LinkType } from "studio/lib/interfaces/navigation";

export async function generateMetadata(): Promise<Metadata> {
const { data: landingId } = await loadQuery<string>(LANDING_QUERY);
Expand Down
2 changes: 1 addition & 1 deletion src/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MetadataRoute } from "next";
import { client } from "../../studio/lib/client";
import { Slug } from "../../studio/lib/payloads/global";
import { Slug } from "../../studio/lib/interfaces/global";
import { token } from "../../studio/lib/token";

interface SitemapDocument {
Expand Down
2 changes: 1 addition & 1 deletion src/blog/Blog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useCallback } from "react";
import useTabs from "src/utils/hooks/useTabs";
import { BlogPage, Post } from "studio/lib/payloads/pages";
import { BlogPage, Post } from "studio/lib/interfaces/pages";
import styles from "./blog.module.css";
import { useFetchPosts } from "src/utils/hooks/useFetchPosts";
import BlogHero from "./components/hero/BlogHero";
Expand Down
2 changes: 1 addition & 1 deletion src/blog/BlogPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
import { QueryResponseInitial, useQuery } from "@sanity/react-loader";
import { BlogPage, Post } from "studio/lib/payloads/pages";
import { BlogPage, Post } from "studio/lib/interfaces/pages";
import { BLOG_PAGE_QUERY } from "studio/lib/queries/pages";
import { Suspense } from "react";
import { Blog } from "./Blog";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Button from "src/components/buttons/Button";
import LinkButton from "src/components/linkButton/LinkButton";
import Text from "src/components/text/Text";
import { ILink } from "studio/lib/payloads/navigation";
import { ILink } from "studio/lib/interfaces/navigation";
import styles from "./customErrorMessage.module.css";

interface CustomErrorMessageProps {
Expand Down
2 changes: 1 addition & 1 deletion src/blog/components/hero/BlogHero.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Text from "src/components/text/Text";
import styles from "./blogHero.module.css";
import { Category } from "studio/lib/payloads/pages";
import { Category } from "studio/lib/interfaces/pages";
import { LegacyRef } from "react";

const BlogHero = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import LinkButton from "src/components/linkButton/LinkButton";
import Text from "src/components/text/Text";
import { ILink } from "studio/lib/payloads/navigation";
import { ILink } from "studio/lib/interfaces/navigation";
import styles from "./informationSection.module.css";
import React from "react";

Expand Down
2 changes: 1 addition & 1 deletion src/blog/components/legal/Legal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Text from "src/components/text/Text";
import styles from "./legal.module.css";
import { LegalDocument } from "studio/lib/payloads/legalDocuments";
import { LegalDocument } from "studio/lib/interfaces/legalDocuments";
import { RichText, PortableTextBlock } from "src/components/richText/RichText";
import Link from "next/link";

Expand Down
2 changes: 1 addition & 1 deletion src/blog/components/legal/LegalPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { QueryResponseInitial, useQuery } from "@sanity/react-loader";
import { NAV_QUERY } from "studio/lib/queries/navigation";
import { LegalDocument } from "studio/lib/payloads/legalDocuments";
import { LegalDocument } from "studio/lib/interfaces/legalDocuments";
import Legal from "./Legal";

export default function LegalPreview({
Expand Down
2 changes: 1 addition & 1 deletion src/blog/components/postCard/PostCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import Text from "src/components/text/Text";
import { useConvertSanityImageToNextImage } from "src/utils/hooks/useConvertImage";
import { Post } from "studio/lib/payloads/pages";
import { Post } from "studio/lib/interfaces/pages";
import styles from "./postCard.module.css";

export const PostCard = ({
Expand Down
4 changes: 2 additions & 2 deletions src/blog/components/postPreview/PostPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use client";
import { RichText, PortableTextBlock } from "src/components/richText/RichText";
import Text from "src/components/text/Text";
import { Post } from "studio/lib/payloads/pages";
import { Post } from "studio/lib/interfaces/pages";
import styles from "./postPreview.module.css";
import CustomLink from "src/components/link/CustomLink";
import { LinkType } from "studio/lib/payloads/navigation";
import { LinkType } from "studio/lib/interfaces/navigation";
import { useConvertSanityImageToNextImage } from "src/utils/hooks/useConvertImage";

export interface PostPreviewProps {
Expand Down
2 changes: 1 addition & 1 deletion src/blog/components/postPreviewGrid/PostPreviewGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState, useCallback } from "react";
import Text from "src/components/text/Text";
import { Post } from "studio/lib/payloads/pages";
import { Post } from "studio/lib/interfaces/pages";
import styles from "./postPreviewGrid.module.css";
import Button from "src/components/buttons/Button";
import { PostCard } from "../postCard/PostCard";
Expand Down
2 changes: 1 addition & 1 deletion src/blog/components/utils/linkTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LinkType } from "studio/lib/payloads/navigation";
import { LinkType } from "studio/lib/interfaces/navigation";

export const homeLink = {
_key: "return-home",
Expand Down
4 changes: 2 additions & 2 deletions src/compensations/Compensations.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import styles from "./compensations.module.css";
import Text from "src/components/text/Text";
import { CompensationsPage } from "studio/lib/payloads/compensations";
import { CompensationsPage } from "studio/lib/interfaces/compensations";
import SalaryCalculator, {
Degree,
} from "./components/salaryCalculator/SalaryCalculator";
Expand All @@ -13,7 +13,7 @@ import {
minSalariesExaminationYear,
salariesFromLocation,
} from "./utils/salary";
import { CompanyLocation } from "studio/lib/payloads/companyDetails";
import { CompanyLocation } from "studio/lib/interfaces/companyDetails";
import {
IOption,
RadioButtonGroup,
Expand Down
4 changes: 2 additions & 2 deletions src/compensations/CompensationsPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { Suspense } from "react";
import Compensations from "./Compensations";
import { QueryResponseInitial, useQuery } from "@sanity/react-loader";
import { CompensationsPage } from "studio/lib/payloads/compensations";
import { CompanyLocation } from "studio/lib/payloads/companyDetails";
import { CompensationsPage } from "studio/lib/interfaces/compensations";
import { CompanyLocation } from "studio/lib/interfaces/companyDetails";
import { COMPANY_LOCATIONS_QUERY } from "studio/lib/queries/companyDetails";
import { COMPENSATIONS_PAGE_QUERY } from "studio/lib/queries/pages";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Text from "src/components/text/Text";
import { RichText } from "src/components/richText/RichText";
import styles from "./benefitsByLocation.module.css";
import { Benefit } from "studio/lib/payloads/compensations";
import { Benefit } from "studio/lib/interfaces/compensations";

interface BenefitsByLocationProps {
benefits: Benefit[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BonusPage } from "studio/lib/payloads/compensations";
import { BonusPage } from "studio/lib/interfaces/compensations";
import Text from "../../../components/text/Text";
import styles from "./yearlyBonuses.module.css";

Expand Down
2 changes: 1 addition & 1 deletion src/compensations/utils/salary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
isSalariesType,
Salaries,
} from "studio/components/salariesInput/utils/parseSalaries";
import { SalariesByLocation } from "../../../studio/lib/payloads/compensations";
import { SalariesByLocation } from "../../../studio/lib/interfaces/compensations";
import { Result, ResultError, ResultOk } from "../../../studio/utils/result";

export function calculateSalary(
Expand Down
2 changes: 1 addition & 1 deletion src/components/link/CustomLink.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";
import CustomLink from "./CustomLink";
import { LinkType } from "studio/lib/payloads/navigation";
import { LinkType } from "studio/lib/interfaces/navigation";

const meta: Meta<typeof CustomLink> = {
title: "Components/Links/CustomLink",
Expand Down
2 changes: 1 addition & 1 deletion src/components/link/CustomLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import styles from "./link.module.css";
import Link from "next/link";
import { ILink } from "studio/lib/payloads/navigation";
import { ILink } from "studio/lib/interfaces/navigation";
import { getHref } from "src/utils/get";

type ComponentLinkType = "link" | "headerLink" | "footerLink";
Expand Down
2 changes: 1 addition & 1 deletion src/components/link/SoMeLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import styles from "./link.module.css";
import Link from "next/link";
import { SocialMediaLink } from "studio/lib/payloads/socialMedia";
import { SocialMediaLink } from "studio/lib/interfaces/socialMedia";

interface ISoMeLink {
link: SocialMediaLink;
Expand Down
2 changes: 1 addition & 1 deletion src/components/linkButton/LinkButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";
import LinkButton from "./LinkButton";
import { LinkType } from "studio/lib/payloads/navigation";
import { LinkType } from "studio/lib/interfaces/navigation";

const meta: Meta<typeof LinkButton> = {
title: "Components/Links/LinkButton",
Expand Down
2 changes: 1 addition & 1 deletion src/components/linkButton/LinkButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import styles from "./linkButton.module.css";
import { ILink } from "studio/lib/payloads/navigation";
import { ILink } from "studio/lib/interfaces/navigation";
import { getHref } from "src/utils/get";

type LinkButtonType = "primary" | "secondary";
Expand Down
10 changes: 5 additions & 5 deletions src/components/navigation/footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"use client";

import { ILink, LinkType, Navigation } from "studio/lib/payloads/navigation";
import { CompanyInfo } from "studio/lib/payloads/companyDetails";
import { ILink, LinkType, Navigation } from "studio/lib/interfaces/navigation";
import { CompanyInfo } from "studio/lib/interfaces/companyDetails";
import { useConvertSanityImageToNextImage } from "src/utils/hooks/useConvertImage";
import styles from "./footer.module.css";
import CustomLink from "../../link/CustomLink";
import {
SocialMediaLink,
SocialMediaProfiles,
} from "studio/lib/payloads/socialMedia";
} from "studio/lib/interfaces/socialMedia";
import SoMeLink from "src/components/link/SoMeLink";
import { ReactNode } from "react";
import Text from "src/components/text/Text";
import { LegalDocument } from "studio/lib/payloads/legalDocuments";
import { BrandAssets } from "studio/lib/payloads/brandAssets";
import { LegalDocument } from "studio/lib/interfaces/legalDocuments";
import { BrandAssets } from "studio/lib/interfaces/brandAssets";

export interface IFooter {
navigationData: Navigation;
Expand Down
8 changes: 4 additions & 4 deletions src/components/navigation/footer/FooterPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use client";
import { QueryResponseInitial, useQuery } from "@sanity/react-loader";
import { NAV_QUERY } from "studio/lib/queries/navigation";
import { Navigation } from "studio/lib/payloads/navigation";
import { CompanyInfo } from "studio/lib/payloads/companyDetails";
import { Navigation } from "studio/lib/interfaces/navigation";
import { CompanyInfo } from "studio/lib/interfaces/companyDetails";
import { COMPANY_INFO_QUERY } from "studio/lib/queries/companyDetails";
import Footer from "./Footer";
import { SocialMediaProfiles } from "studio/lib/payloads/socialMedia";
import { SocialMediaProfiles } from "studio/lib/interfaces/socialMedia";
import { SOMEPROFILES_QUERY } from "studio/lib/queries/socialMediaProfiles";
import { BrandAssets } from "studio/lib/payloads/brandAssets";
import { BrandAssets } from "studio/lib/interfaces/brandAssets";
import { BRAND_ASSETS_QUERY } from "studio/lib/queries/brandAssets";

function useInitialData<T>(
Expand Down
4 changes: 2 additions & 2 deletions src/components/navigation/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useState, useEffect } from "react";
import { FocusOn } from "react-focus-on";
import { ILink, Navigation } from "studio/lib/payloads/navigation";
import { ILink, Navigation } from "studio/lib/interfaces/navigation";
import styles from "./header.module.css";
import { useConvertSanityImageToNextImage } from "src/utils/hooks/useConvertImage";
import { linkID } from "studio/schemas/objects/link";
Expand All @@ -12,7 +12,7 @@ import LinkButton from "src/components/linkButton/LinkButton";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { getHref } from "src/utils/get";
import { BrandAssets } from "../../../../studio/lib/payloads/brandAssets";
import { BrandAssets } from "../../../../studio/lib/interfaces/brandAssets";

export interface IHeader {
data: Navigation;
Expand Down
4 changes: 2 additions & 2 deletions src/components/navigation/header/HeaderPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";
import { QueryResponseInitial, useQuery } from "@sanity/react-loader";
import { NAV_QUERY } from "studio/lib/queries/navigation";
import { Navigation } from "studio/lib/payloads/navigation";
import { Navigation } from "studio/lib/interfaces/navigation";
import { Header } from "./Header";
import { BrandAssets } from "../../../../studio/lib/payloads/brandAssets";
import { BrandAssets } from "../../../../studio/lib/interfaces/brandAssets";
import { BRAND_ASSETS_QUERY } from "../../../../studio/lib/queries/brandAssets";

export default function HeaderPreview({
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 @@ -2,12 +2,12 @@ import {
Navigation,
LinkType,
SectionType,
} from "studio/lib/payloads/navigation";
} from "studio/lib/interfaces/navigation";
import { callToActionFieldID } from "studio/schemas/fields/callToActionFields";
import { linkID } from "studio/schemas/objects/link";
import primaryLogoFile from "../../stories/assets/energiai-primary-logo.svg";
import secondaryLogoFile from "../../stories/assets/energiai-secondary-logo.svg";
import { SocialMediaProfiles } from "studio/lib/payloads/socialMedia";
import { SocialMediaProfiles } from "studio/lib/interfaces/socialMedia";

// Mock Navigation Data
export const mockNavigation: Navigation = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/sections/article/Article.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { RichText } from "src/components/richText/RichText";
import Text from "src/components/text/Text";
import { ArticleSection } from "studio/lib/payloads/pages";
import { ArticleSection } from "studio/lib/interfaces/pages";
import styles from "./article.module.css";
import { useConvertSanityImageToNextImage } from "src/utils/hooks/useConvertImage";
import CustomLink from "src/components/link/CustomLink";
Expand Down
Loading

0 comments on commit 67361c0

Please sign in to comment.