Skip to content

Commit

Permalink
feat: move types to Sanity folder
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc committed Aug 22, 2023
1 parent 6833778 commit 9433423
Show file tree
Hide file tree
Showing 45 changed files with 103 additions and 87 deletions.
4 changes: 2 additions & 2 deletions apollo/apollo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const apolloClient = new ApolloClient({
cache: new InMemoryCache(),
defaultOptions: {
watchQuery: {
fetchPolicy: 'network-only',
fetchPolicy: 'no-cache',
errorPolicy: 'ignore',
},
query: {
fetchPolicy: 'network-only',
fetchPolicy: 'no-cache',
errorPolicy: 'all',
},
},
Expand Down
11 changes: 5 additions & 6 deletions src/app/(public)/about/free-time/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ import {
} from '@/queries/random-facts';
import { tvSeriesQuery } from '@/queries/tv-series';
import { videoGamesQuery } from '@/queries/video-games';
import { Book } from '@/sanityTypes/Book';
import { Podcast } from '@/sanityTypes/Podcast';
import { RandomFact } from '@/sanityTypes/RandomFact';
import { TvShow } from '@/sanityTypes/TvSeries';
import { VideoGame } from '@/sanityTypes/VideoGame';

import { sanityClient } from '../../../../../sanity/lib/client';

import { Book } from '@/types/Book';
import { Podcast } from '@/types/Podcast';
import { RandomFact } from '@/types/RandomFact';
import { TvShow } from '@/types/TvSeries';
import { VideoGame } from '@/types/VideoGame';

export const metadata = {
title: 'About my Free Time | MartaCodes.it',
description: 'About page',
Expand Down
15 changes: 7 additions & 8 deletions src/app/(public)/about/work/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ import { publicationQuery } from '@/queries/publications';
import { schoolsQuery } from '@/queries/schools';
import { shortTextQuery } from '@/queries/short-texts';
import { skillQuery } from '@/queries/skills';
import { Icon } from '@/SanityTypes/Icon';
import { Language } from '@/SanityTypes/Language';
import { Publication } from '@/SanityTypes/Publication';
import { School } from '@/SanityTypes/School';
import { ShortText } from '@/SanityTypes/ShortText';
import { Skill } from '@/SanityTypes/Skill';

import apolloClient from '../../../../../apollo/apollo-client';
import { sanityClient } from '../../../../../sanity/lib/client';

import { Icon } from '@/types/Icon';
import { Job } from '@/types/Job';
import { Job2 } from '@/types/Job2';
import { Language } from '@/types/Language';
import { Publication } from '@/types/Publication';
import { School } from '@/types/School';
import { ShortText } from '@/types/ShortText';
import { Skill } from '@/types/Skill';

export const metadata = {
title: 'About my Work | MartaCodes.it',
Expand Down Expand Up @@ -63,7 +62,7 @@ const queryData = async () => {
query: jobsQueryQL,
});

const jobs: Job2[] = flattenToArray<Job2>(data.jobs);
const jobs: Job[] = flattenToArray<Job>(data.jobs);
return {
jobs: jobs,
};
Expand Down
3 changes: 1 addition & 2 deletions src/app/(public)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import Summary from '@/components/organisms/home/Summary';
import Seo from '@/components/Seo';

import { codeSnippetsQuery } from '@/queries/codeSnippets';
import { CodeSnippet } from '@/sanityTypes/CodeSnippet';

import { sanityClient } from '../../../sanity/lib/client';

import { CodeSnippet } from '@/types/CodeSnippet';

const getData = async () => {
// const homeData: HomeContent[] = await sanityClient.fetch(homeContentQuery);
const codeSnippets: CodeSnippet[] = await sanityClient.fetch(
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/RandomFacts/GeneralView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useState } from 'react';

import Button from '@/components/buttons/Button';

import { RandomFact } from '@/types/RandomFact';
import { RandomFact } from '@/sanityTypes/RandomFact';

export interface GeneralViewProps {
randomFacts: RandomFact[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/RandomFacts/Quiz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { saveToLocalStorage } from '@/lib/helper';
import Button from '@/components/buttons/Button';
import { localStorageKey } from '@/components/organisms/about-free-time/RandomFacts';

import { RandomFact } from '@/types/RandomFact';
import { RandomFact } from '@/sanityTypes/RandomFact';

export interface QuizOption {
headline: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import GeneralView, {
} from '@/components/molecules/RandomFacts/GeneralView';

import { trueRandomFactsQuery } from '@/queries/random-facts';
import { RandomFact } from '@/sanityTypes/RandomFact';

import { sanityClient } from '../../../../../sanity/lib/client';

import { RandomFact } from '@/types/RandomFact';

const meta: Meta<typeof GeneralView> = {
title: 'Components/Random Facts/General View',
component: GeneralView,
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-free-time/Books.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Image from 'next/image';
import * as React from 'react';

import { Book } from '@/types/Book';
import { Book } from '@/sanityTypes/Book';

export interface BookProps {
books: Book[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-free-time/Podcasts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Image from 'next/image';
import * as React from 'react';

import { Podcast } from '@/types/Podcast';
import { Podcast } from '@/sanityTypes/Podcast';

export interface PodcastProps {
podcasts: Podcast[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-free-time/TvSeries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Image from 'next/image';
import * as React from 'react';

import { TvShow } from '@/types/TvSeries';
import { TvShow } from '@/sanityTypes/TvSeries';

export interface TvSeriesProps {
tvSeries: TvShow[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-free-time/VideoGames.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Image from 'next/image';
import * as React from 'react';

import { VideoGame } from '@/types/VideoGame';
import { VideoGame } from '@/sanityTypes/VideoGame';

export interface VideoGameProps {
videoGames: VideoGame[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-work/Education.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PortableText } from '@portabletext/react';
import Image from 'next/image';
import * as React from 'react';

import { School } from '@/types/School';
import { School } from '@/sanityTypes/School';

export interface EducationProps {
schools: School[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-work/Publications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AiOutlineFilePdf } from 'react-icons/ai';

import UnstyledLink from '@/components/links/UnstyledLink';

import { Publication } from '@/types/Publication';
import { Publication } from '@/sanityTypes/Publication';

export interface PublicationProps {
publications: Publication[];
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/about-work/WorkExperience.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { useTheme } from 'next-themes';
import * as React from 'react';
import ReactMarkdown from 'react-markdown';

import { Job2 } from '@/types/Job2';
import { Job } from '@/types/Job';

export interface WorkExperienceProps {
jobs: Job2[];
jobs: Job[];
}

const WorkExperience = ({ jobs }: WorkExperienceProps) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/home/Code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'react-syntax-highlighter/dist/cjs/styles/hljs';
import Typed, { TypedOptions } from 'typed.js';

import { CodeSnippet } from '@/types/CodeSnippet';
import { CodeSnippet } from '@/sanityTypes/CodeSnippet';

export interface CodeSnippetsProps {
codeSnippets: CodeSnippet[];
Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/code-snippets.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { NextApiRequest, NextApiResponse } from 'next';

import { codeSnippetsQuery } from '@/queries/codeSnippets';
import { CodeSnippet } from '@/sanityTypes/CodeSnippet';

import { sanityClient } from '../../../sanity/lib/client';

import { CodeSnippet } from '@/types/CodeSnippet';

const codeSnippetsApi = async (req: NextApiRequest, res: NextApiResponse) => {
const codeSnippets: CodeSnippet[] = await sanityClient.fetch(
codeSnippetsQuery
Expand Down
9 changes: 4 additions & 5 deletions src/pages/api/hobbies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { booksQuery } from '@/queries/books';
import { podcastsQuery } from '@/queries/podcasts';
import { tvSeriesQuery } from '@/queries/tv-series';
import { videoGamesQuery } from '@/queries/video-games';
import { Book } from '@/sanityTypes/Book';
import { Podcast } from '@/sanityTypes/Podcast';
import { TvShow } from '@/sanityTypes/TvSeries';
import { VideoGame } from '@/sanityTypes/VideoGame';

import { sanityClient } from '../../../sanity/lib/client';

import { Book } from '@/types/Book';
import { Podcast } from '@/types/Podcast';
import { TvShow } from '@/types/TvSeries';
import { VideoGame } from '@/types/VideoGame';

const hobbiesApi = async (req: NextApiRequest, res: NextApiResponse) => {
const books: Book[] = await sanityClient.fetch(booksQuery);

Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/home.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { NextApiRequest, NextApiResponse } from 'next';

import { homeContentQuery } from '@/queries/homeContent';
import { HomeContent } from '@/sanityTypes/HomeContent';

import { sanityClient } from '../../../sanity/lib/client';

import { HomeContent } from '@/types/HomeContent';

const homeApi = async (req: NextApiRequest, res: NextApiResponse) => {
const homeContent: HomeContent = await sanityClient.fetch(homeContentQuery);

Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/jobs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { NextApiRequest, NextApiResponse } from 'next';

import { jobsQuery } from '@/queries/jobs';
import { Job } from '@/sanityTypes/Job';

import { sanityClient } from '../../../sanity/lib/client';

import { Job } from '@/types/Job';

const jobsApi = async (req: NextApiRequest, res: NextApiResponse) => {
const jobs: Job[] = await sanityClient.fetch(jobsQuery);

Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/publications.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { NextApiRequest, NextApiResponse } from 'next';

import { publicationQuery } from '@/queries/publications';
import { Publication } from '@/sanityTypes/Publication';

import { sanityClient } from '../../../sanity/lib/client';

import { Publication } from '@/types/Publication';

const publicationsApi = async (req: NextApiRequest, res: NextApiResponse) => {
const publications: Publication[] = await sanityClient.fetch(
publicationQuery
Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/random-facts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import {
falseRandomFactsQuery,
selectedTrueRandomFactsQuery,
} from '@/queries/random-facts';
import { RandomFact } from '@/sanityTypes/RandomFact';

import { sanityClient } from '../../../sanity/lib/client';

import { RandomFact } from '@/types/RandomFact';

const randomFactsApi = async (req: NextApiRequest, res: NextApiResponse) => {
const trueFacts: RandomFact[] = await sanityClient.fetch(
selectedTrueRandomFactsQuery
Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/schools.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { NextApiRequest, NextApiResponse } from 'next';

import { schoolsQuery } from '@/queries/schools';
import { School } from '@/sanityTypes/School';

import { sanityClient } from '../../../sanity/lib/client';

import { School } from '@/types/School';

const schoolsApi = async (req: NextApiRequest, res: NextApiResponse) => {
const schools: School[] = await sanityClient.fetch(schoolsQuery);

Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/short-texts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { NextApiRequest, NextApiResponse } from 'next';

import { shortTextQuery } from '@/queries/short-texts';
import { ShortText } from '@/sanityTypes/ShortText';

import { sanityClient } from '../../../sanity/lib/client';

import { ShortText } from '@/types/ShortText';

const shortTextsApi = async (req: NextApiRequest, res: NextApiResponse) => {
const shortTexts: ShortText[] = await sanityClient.fetch(shortTextQuery);

Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/skills.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { NextApiRequest, NextApiResponse } from 'next';

import { skillQuery } from '@/queries/skills';
import { Skill } from '@/sanityTypes/Skill';

import { sanityClient } from '../../../sanity/lib/client';

import { Skill } from '@/types/Skill';

const skillsApi = async (req: NextApiRequest, res: NextApiResponse) => {
const skills: Skill[] = await sanityClient.fetch(skillQuery);

Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/true-random-facts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { NextApiRequest, NextApiResponse } from 'next';

import { selectedTrueRandomFactsQuery } from '@/queries/random-facts';
import { RandomFact } from '@/sanityTypes/RandomFact';

import { sanityClient } from '../../../sanity/lib/client';

import { RandomFact } from '@/types/RandomFact';

const trueFactsApi = async (req: NextApiRequest, res: NextApiResponse) => {
const trueFacts: RandomFact[] = await sanityClient.fetch(
selectedTrueRandomFactsQuery
Expand Down
22 changes: 22 additions & 0 deletions src/queries/languages.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { gql } from '@apollo/client';
import { groq } from 'next-sanity';

export const languageQuery = groq`
Expand All @@ -7,3 +8,24 @@ export const languageQuery = groq`
level,
"flagUrl": flag.asset->url
}`;

export const languagesQueryQL = gql`
query {
languages(locale: "en") {
data {
attributes {
name
level
flag {
data {
attributes {
url
alternativeText
}
}
}
}
}
}
}
`;
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/sanityTypes/Icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface Icon {
_id: string;
title: string;
url: string;
}
17 changes: 17 additions & 0 deletions src/sanityTypes/Job.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { TypedObject } from '@portabletext/types';

export interface Job {
_id: string;
name: string;
company: string;
iconUrl: string;
location: string;
jobTitle: string;
startDate: string;
endDate: string;
isCurrentJob: boolean;
description: TypedObject;
mainColor: string;
darkColor: string;
technologies: string[];
}
6 changes: 6 additions & 0 deletions src/sanityTypes/Language.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface Language {
id: number;
name: string;
level: string;
flagUrl: string;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/types/Skill.ts → src/sanityTypes/Skill.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TypedObject } from '@portabletext/types';

import { Icon } from '@/types/Icon';
import { Icon } from '@/sanityTypes/Icon';

export interface Skill {
name: string;
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 9433423

Please sign in to comment.