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

Strapi #11

Merged
merged 34 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
514e990
feat: basic test with Apollo Client
martapanc Aug 15, 2023
8c96162
feat: add ReactMarkdown; wip strapi GraphQL response tests
martapanc Aug 17, 2023
33087f5
feat: add graphqlUtils and config.yml
martapanc Aug 17, 2023
6833778
feat: replace Job with Job2
martapanc Aug 21, 2023
9433423
feat: move types to Sanity folder
martapanc Aug 22, 2023
a965497
feat: move type Language
martapanc Aug 22, 2023
32503e4
feat: move type School
martapanc Aug 22, 2023
2a63819
feat: fix format to return number
martapanc Aug 22, 2023
c7a88bf
feat: move type Publication
martapanc Aug 22, 2023
328547e
feat: move type Skill
martapanc Aug 22, 2023
8317109
fix: change Icon type
martapanc Aug 22, 2023
f1a4c59
fix: change Icon type
martapanc Aug 22, 2023
eec597a
feat: replace ShortText with Single type Intro
martapanc Aug 22, 2023
ef1254c
fix: refactor
martapanc Aug 22, 2023
a58ab34
feat: move types Book and Podcast
martapanc Aug 23, 2023
9d9e0c3
feat: move types TvShow and VideoGame
martapanc Aug 23, 2023
ee6c622
fix: update query links in hobbiesApi
martapanc Aug 23, 2023
15e27d2
fix: update TvShow type in pages.tsx
martapanc Aug 23, 2023
6ecec28
feat: move type RandomFact
martapanc Aug 23, 2023
edb0458
chore: remove true-random-facts api endpoint
martapanc Aug 23, 2023
28e1007
fix: update TvShow type in pages.tsx
martapanc Aug 23, 2023
14dc331
fix: change explanation from TypedObject to string
martapanc Aug 23, 2023
47a92e3
fix: check for undefined answer.explanation
martapanc Aug 23, 2023
b07c634
fix: fix eneralView SB story
martapanc Aug 23, 2023
680f814
fix: fix SB story
martapanc Aug 23, 2023
bc31209
fix: fix hobbies api
martapanc Aug 23, 2023
722a93a
fix: move randomFact description and explanation to string
martapanc Aug 23, 2023
f376fe2
chore: upgrade StoryBook
martapanc Aug 24, 2023
7b3a838
feat: move type CodeSnippet
martapanc Aug 24, 2023
385ba58
feat: install and configure react-i18next
martapanc Aug 24, 2023
f5d2251
fix: fix Button.tsx
martapanc Aug 24, 2023
49dc895
feat: localise headings
martapanc Aug 24, 2023
a31fda4
feat: add menu translations
martapanc Aug 25, 2023
8daee3b
feat: use translations in header and footer
martapanc Aug 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apollo/apollo-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ApolloClient, InMemoryCache } from '@apollo/client';

const apolloClient = new ApolloClient({
uri: process.env.GRAPHQL_URL,
cache: new InMemoryCache(),
defaultOptions: {
watchQuery: {
fetchPolicy: 'no-cache',
errorPolicy: 'ignore',
},
query: {
fetchPolicy: 'no-cache',
errorPolicy: 'all',
},
},
});

export default apolloClient;
1 change: 1 addition & 0 deletions graphql.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
schema: https://martacodes-it-strapi.up.railway.app/graphql
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const nextConfig = {
// },

images: {
domains: ['cdn.sanity.io'],
domains: ['cdn.sanity.io', 'res.cloudinary.com'],
remotePatterns: [
{
protocol: 'https',
Expand Down
27 changes: 17 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "next dev --port 3001",
"build": "next build",
"start": "next start",
"lint": "next lint",
Expand All @@ -23,6 +23,7 @@
"sanity:prod": "sanity build && sanity start"
},
"dependencies": {
"@apollo/client": "^3.8.1",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/material": "^5.13.5",
Expand All @@ -40,34 +41,40 @@
"clsx": "^1.2.1",
"focus-trap-react": "^10.1.4",
"framer-motion": "^10.12.18",
"graphql": "^16.8.0",
"i18next": "^23.4.5",
"inquirer-fuzzy-path": "^2.3.0",
"next": "^13.4.9",
"next-cloudinary": "^4.18.0",
"next-sanity": "5.1.0",
"next-themes": "^0.2.1",
"plop": "^3.1.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-headroom": "^3.2.1",
"react-i18next": "^13.2.0",
"react-icons": "^4.10.1",
"react-markdown": "^8.0.7",
"react-syntax-highlighter": "^15.5.0",
"react-tippy": "^1.4.0",
"sanity": "^3.0.0",
"sanity-plugin-internationalized-array": "^1.7.0",
"sanity-plugin-media": "^2.2.1",
"strapi-flatten-graphql": "^0.1.0",
"styled-components": "^5.2.0",
"tailwind-merge": "^1.12.0",
"typed.js": "^2.0.16"
},
"devDependencies": {
"@commitlint/cli": "^16.3.0",
"@commitlint/config-conventional": "^16.2.4",
"@storybook/addon-essentials": "^7.1.1",
"@storybook/addon-interactions": "^7.1.1",
"@storybook/addon-links": "^7.1.1",
"@storybook/blocks": "^7.1.1",
"@storybook/nextjs": "^7.1.1",
"@storybook/react": "^7.1.1",
"@storybook/testing-library": "^0.0.14-next.2",
"@storybook/addon-essentials": "^7.3.2",
"@storybook/addon-interactions": "^7.3.2",
"@storybook/addon-links": "^7.3.2",
"@storybook/blocks": "^7.3.2",
"@storybook/nextjs": "^7.3.2",
"@storybook/react": "^7.3.2",
"@storybook/testing-library": "^0.2.0",
"@svgr/webpack": "^6.5.1",
"@tailwindcss/forms": "^0.5.3",
"@testing-library/jest-dom": "^5.16.5",
Expand All @@ -82,7 +89,7 @@
"eslint-config-next": "^13.4.4",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-storybook": "^0.6.12",
"eslint-plugin-storybook": "^0.6.13",
"eslint-plugin-unused-imports": "^2.0.0",
"husky": "^7.0.4",
"jest": "^27.5.1",
Expand All @@ -92,7 +99,7 @@
"postcss": "^8.4.23",
"prettier": "^2.8.8",
"prettier-plugin-tailwindcss": "^0.1.13",
"storybook": "^7.0.20",
"storybook": "^7.3.2",
"tailwindcss": "^3.3.2",
"typescript": "^4.9.5"
},
Expand Down
87 changes: 62 additions & 25 deletions src/app/(public)/about/free-time/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DocumentNode } from 'graphql/language';
import * as React from 'react';

import { flattenToArray } from '@/lib/graphqlUtils';
import { shuffleArray } from '@/lib/helper';

import { QuizData, QuizOption } from '@/components/molecules/RandomFacts/Quiz';
Expand All @@ -10,58 +12,92 @@ import RandomFacts from '@/components/organisms/about-free-time/RandomFacts';
import TvSeries from '@/components/organisms/about-free-time/TvSeries';
import VideoGames from '@/components/organisms/about-free-time/VideoGames';

import { booksQuery } from '@/queries/books';
import { podcastsQuery } from '@/queries/podcasts';
import { booksQueryQL } from '@/queries/books';
import { podcastsQueryQL } from '@/queries/podcasts';
import {
falseRandomFactsQuery,
selectedTrueRandomFactsQuery,
trueRandomFactsQuery,
falseRandomFactsQueryQL,
selectedTrueRandomFactsQueryQL,
trueRandomFactsQueryQL,
} from '@/queries/random-facts';
import { tvSeriesQuery } from '@/queries/tv-series';
import { videoGamesQuery } from '@/queries/video-games';
import { tvShowsQueryQL } from '@/queries/tv-shows';
import { videoGamesQueryQL } from '@/queries/video-games';

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

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

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

const getData = async () => {
const books: Book[] = await sanityClient.fetch(booksQuery);
async function queryBooks() {
const { data } = await apolloClient.query({ query: booksQueryQL });

return flattenToArray<Book>(data.books);
}

async function queryPodcasts() {
const { data } = await apolloClient.query({ query: podcastsQueryQL });

return flattenToArray<Podcast>(data.podcasts);
}

async function queryTvShows() {
const { data } = await apolloClient.query({ query: tvShowsQueryQL });

const podcasts: Podcast[] = await sanityClient.fetch(podcastsQuery);
return flattenToArray<TvShow>(data.tvShows);
}

const tvSeries: TvShow[] = await sanityClient.fetch(tvSeriesQuery);
async function queryVideoGames() {
const { data } = await apolloClient.query({ query: videoGamesQueryQL });

const videoGames: VideoGame[] = await sanityClient.fetch(videoGamesQuery);
return flattenToArray<VideoGame>(data.videoGames);
}

async function queryRandomFacts(query: DocumentNode) {
const { data } = await apolloClient.query({ query });

return flattenToArray<RandomFact>(data.randomFacts);
}

const getData = async () => {
const randomFacts: QuizData = await loadRandomFactsForQuiz();

return {
randomFacts,
};
};

const queryData = async () => {
const books = await queryBooks();
const podcasts = await queryPodcasts();
const tvShows = await queryTvShows();
const videoGames = await queryVideoGames();

return {
books,
podcasts,
tvSeries,
tvShows,
videoGames,
randomFacts,
};
};

const loadRandomFactsForQuiz = async () => {
const falseFacts: RandomFact[] = await sanityClient.fetch(
falseRandomFactsQuery
const falseFacts: RandomFact[] = await queryRandomFacts(
falseRandomFactsQueryQL
);
const selectedTrueFacts: RandomFact[] = await sanityClient.fetch(
selectedTrueRandomFactsQuery

const selectedTrueFacts: RandomFact[] = await queryRandomFacts(
selectedTrueRandomFactsQueryQL
);
const trueFacts: RandomFact[] = await sanityClient.fetch(
trueRandomFactsQuery

const trueFacts: RandomFact[] = await queryRandomFacts(
trueRandomFactsQueryQL
);

const oneFalseFact: RandomFact = shuffleArray(falseFacts)[0];
Expand Down Expand Up @@ -104,8 +140,9 @@ const loadRandomFactsForQuiz = async () => {
};

const AboutFreeTimePage = async () => {
const { books, podcasts, tvSeries, videoGames, randomFacts } =
await getData();
const { randomFacts } = await getData();

const { books, podcasts, tvShows, videoGames } = await queryData();

return (
<main className='min-h-main'>
Expand All @@ -128,7 +165,7 @@ const AboutFreeTimePage = async () => {

<VideoGames videoGames={videoGames} />

<TvSeries tvSeries={tvSeries} />
<TvSeries tvShows={tvShows} />

<Music />

Expand Down
Loading
Loading