Skip to content

Commit

Permalink
feat: move type Language
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc committed Aug 22, 2023
1 parent 9433423 commit a965497
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
48 changes: 28 additions & 20 deletions src/app/(public)/about/work/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,30 @@ import Languages from '@/components/organisms/about-work/Languages';
import Publications from '@/components/organisms/about-work/Publications';
import WorkExperience from '@/components/organisms/about-work/WorkExperience';

import { jobsQuery, jobsQueryQL } from '@/queries/jobs';
import { languageQuery } from '@/queries/languages';
import { jobsQueryQL } from '@/queries/jobs';
import { languagesQueryQL } from '@/queries/languages';
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 { Icon } from '@/sanityTypes/Icon';
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 { Job } from '@/types/Job';
import { Language } from '@/types/Language';

export const metadata = {
title: 'About my Work | MartaCodes.it',
description: 'About page',
};

const getData = async () => {
const jobs: Job[] = await sanityClient.fetch(jobsQuery);

const languages: Language[] = await sanityClient.fetch(languageQuery);

const publications: Publication[] = await sanityClient.fetch(
publicationQuery
);
Expand All @@ -48,31 +44,43 @@ const getData = async () => {
const shortTexts: ShortText[] = await sanityClient.fetch(shortTextQuery);

return {
jobs,
languages,
publications,
schools,
shortTexts,
skills,
};
};

const queryData = async () => {
async function queryJobs() {
const { data } = await apolloClient.query({
query: jobsQueryQL,
});

const jobs: Job[] = flattenToArray<Job>(data.jobs);
return flattenToArray<Job>(data.jobs);
}

async function queryLanguages() {
const { data } = await apolloClient.query({
query: languagesQueryQL,
});

return flattenToArray<Language>(data.languages);
}

const queryData = async () => {
const jobs = await queryJobs();
const languages = await queryLanguages();

return {
jobs: jobs,
jobs,
languages,
};
};

const AboutPage = async () => {
const { languages, publications, schools, shortTexts, skills } =
await getData();
const { publications, schools, shortTexts, skills } = await getData();

const { jobs } = await queryData();
const { jobs, languages } = await queryData();

const softwareDevelopment: ShortText | undefined = shortTexts.find(
(item) => item.name === 'software-development'
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/about-work/Languages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Languages = ({ languages }: LanguageProps) => {
className='flex flex-row items-center rounded-md p-4 shadow-md dark:bg-slate-900 md:w-64'
>
<Image
src={language.flagUrl}
src={language.flag.url}
alt={language.name}
width={40}
height={40}
Expand Down
2 changes: 1 addition & 1 deletion src/queries/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const jobsQuery = groq`

export const jobsQueryQL = gql`
query {
jobs(locale: "en") {
jobs(locale: "en", sort: "startDate:desc") {
data {
id
attributes {
Expand Down
3 changes: 3 additions & 0 deletions src/queries/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ export const languagesQueryQL = gql`
query {
languages(locale: "en") {
data {
id
attributes {
name
level
flag {
data {
id
attributes {
name
url
alternativeText
}
Expand Down

0 comments on commit a965497

Please sign in to comment.