Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 0 additions & 6 deletions .env.example

This file was deleted.

27 changes: 26 additions & 1 deletion graphql/cms/homepage.generated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const defaultOptions = {} as const;
export type HomePageQueryVariables = Types.Exact<{ [key: string]: never; }>;


export type HomePageQuery = { __typename?: 'Query', homePage?: { __typename?: 'HomePageEntityResponse', data?: { __typename?: 'HomePageEntity', attributes?: { __typename?: 'HomePage', sections?: Array<{ __typename?: 'ComponentCommonCarousel', id: string } | { __typename?: 'ComponentCommonHeader', id: string } | { __typename?: 'ComponentCommonTwoColumnBlock', id: string } | { __typename?: 'Error' } | null> | null } | null } | null } | null };
export type HomePageQuery = { __typename?: 'Query', homePage?: { __typename?: 'HomePageEntityResponse', data?: { __typename?: 'HomePageEntity', attributes?: { __typename?: 'HomePage', sections?: Array<{ __typename?: 'ComponentCommonCarousel', id: string, Item?: Array<{ __typename?: 'ComponentCommonTwoColumnBlock', TitleText?: string | null, Image?: { __typename?: 'UploadFileEntityResponse', data?: { __typename?: 'UploadFileEntity', attributes?: { __typename?: 'UploadFile', url: string, alternativeText?: string | null } | null } | null } | null } | null> | null } | { __typename?: 'ComponentCommonHeader', id: string, Text?: string | null } | { __typename?: 'ComponentCommonTwoColumnBlock', id: string, TitleText?: string | null, Description?: string | null, ButtonText?: string | null, ButtonUrl?: string | null, ImagePosition?: Types.Enum_Componentcommontwocolumnblock_Imageposition | null, Image?: { __typename?: 'UploadFileEntityResponse', data?: { __typename?: 'UploadFileEntity', attributes?: { __typename?: 'UploadFile', url: string, alternativeText?: string | null } | null } | null } | null } | { __typename?: 'Error' } | null> | null } | null } | null } | null };


export const HomePageDocument = gql`
Expand All @@ -17,12 +17,37 @@ export const HomePageDocument = gql`
sections {
... on ComponentCommonHeader {
id
Text
}
... on ComponentCommonCarousel {
id
Item {
TitleText
Image {
data {
attributes {
url
alternativeText
}
}
}
}
}
... on ComponentCommonTwoColumnBlock {
id
TitleText
Description
ButtonText
ButtonUrl
ImagePosition
Image {
data {
attributes {
url
alternativeText
}
}
}
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions graphql/cms/homepage.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,40 @@ query HomePage {
sections {
... on ComponentCommonHeader {
id
Text
# TODO: Complete this query
}
... on ComponentCommonCarousel {
id
Item {
TitleText
Image {
data {
attributes {
url
alternativeText
}
}
}
}
# TODO: Complete this query
}
... on ComponentCommonTwoColumnBlock {
id
# TODO: Complete this query
TitleText
Description
ButtonText
ButtonUrl
ImagePosition
Image {
data {
attributes {
url
alternativeText
}
}
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"next": "12.1.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-slick": "^0.29.0",
"slick-carousel": "^1.8.1",
"yup": "^0.32.11"
},
"devDependencies": {
Expand Down
114 changes: 97 additions & 17 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
// @ts-nocheck
// import { NextLink } from "components/common/NextLink";
import { Box, Container, Typography } from "@mui/material";
import { useMemo } from 'react'
import type { GetStaticProps, NextPage } from "next";
import Head from "next/head";
import Image from 'next/image';
import {
HomePageDocument,
HomePageQuery,
useHomePageQuery,
} from "graphql/cms/homepage.generated";

import {
APOLLO_STRAPI_STATE_PROP_NAME,
initializeStrapiApollo,
} from "lib/apollo/cms-client";
import type { GetStaticProps, NextPage } from "next";
import Head from "next/head";
import { Box, Button, CircularProgress, Container, Typography } from "@mui/material";
import Slider from "react-slick";
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";



const Home: NextPage = () => {
const { data } = useHomePageQuery();

const { data, loading } = useHomePageQuery();

const hostUrl = useMemo(() => {
return process.env.STRAPI_CMS_URL
}, [])

const pageData = useMemo(() => {
return data?.homePage?.data?.attributes?.sections
}, [data?.homePage?.data?.attributes?.sections])

const settings = useMemo(() => {
return {
infinite: true,
speed: 500,
slidesToShow: 6,
slidesToScroll: 1,
swipeToSlide: true,
}
}, [])

return (
<>
Expand All @@ -23,20 +49,74 @@ const Home: NextPage = () => {
<meta name="description" content="Manage your expenses" />
<link rel="icon" href="/favicon.ico" />
</Head>
<Container>
<Box my={2}>
<Typography variant="h4">Welcome to JOMI Code Challenge</Typography>
<Typography>
Please follow the instructions on
<a href="https://github.com/jomijournal/jomi-cms-challenge-backend">
https://github.com/jomijournal/jomi-cms-challenge-backend
</a>{" "}
to complete the challenge
</Typography>
{loading ?
<Box sx={{ height: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center' }} >
<CircularProgress />
</Box>
:
<>
<Container>
<Box my={2}>
<Typography sx={{ textAlign: 'center', mt: 3, fontSize: 32 }}>{pageData?.[0].Text}</Typography>
<Box mt={8} sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Box >

<Image alt={pageData?.[1].Image?.data?.attributes?.alternativeText} width={500}
height={200}
src={`${hostUrl}${pageData?.[1].Image?.data?.attributes?.url}`} />
</Box>
<Box ml={5} sx={{ width: '50%' }}>
<Typography sx={{ fontSize: 26, fontWeight: 500 }}>{pageData?.[1]?.TitleText}</Typography>
<Typography sx={{ width: 400 }} mt={1} mb={3}>{pageData?.[1]?.Description}</Typography>
<Button variant="outlined">{pageData?.[1]?.ButtonText}</Button>
</Box>
</Box>
<Box mt={8} sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>

<Box >
<Typography sx={{ fontSize: 26, fontWeight: 500 }}>{pageData?.[2]?.TitleText}</Typography>
<Typography sx={{ width: 400 }} mt={1} mb={3}>{pageData?.[2]?.Description}</Typography>
<Button variant="outlined">{pageData?.[2]?.ButtonText}</Button>
</Box>
<Box ml={5} sx={{ width: '50%' }}>
<Image alt={pageData?.[2].Image?.data?.attributes?.alternativeText} width={500}
height={200}
src={`${hostUrl}${pageData?.[2].Image?.data?.attributes?.url}`} />
</Box>
</Box>

{/* <Typography variant="h4">Welcome to JOMI Code Challenge</Typography>
<Typography>
Please follow the instructions on
<a href="https://github.com/jomijournal/jomi-cms-challenge-backend">
https://github.com/jomijournal/jomi-cms-challenge-backend
</a>{" "}
to complete the challenge
</Typography> */}
</Box>

{/* <Box>TODO: Render components from useHomePageQury here </Box> */}
</Container>
<Box sx={{ backgroundColor: '#000000', height: 300, display: "flex", alignItems: 'center' }} mt={8}>
<Container>
<Slider {...settings}>
{pageData?.[3].Item.map((el, index) => (
<Box ml={1} key={index} >
<Image alt={el?.Image?.data?.attributes?.alternativeText} width={100}
height={100}
src={`${hostUrl}${el?.Image?.data?.attributes?.url}`} />
</Box>

))}



</Slider>
</Container>
</Box >
</>
}

<Box>{/* TODO: Render components from useHomePageQury here */}</Box>
</Container>
</>
);
};
Expand Down
43 changes: 43 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,11 @@ chokidar@^3.5.2:
optionalDependencies:
fsevents "~2.3.2"

classnames@^2.2.5:
version "2.3.2"
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.3.2.tgz#351d813bf0137fcc6a76a16b88208d2560a0d924"
integrity sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==

cli-cursor@^2.0.0, cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
Expand Down Expand Up @@ -3053,6 +3058,11 @@ end-of-stream@^1.1.0:
dependencies:
once "^1.4.0"

enquire.js@^2.1.6:
version "2.1.6"
resolved "https://registry.yarnpkg.com/enquire.js/-/enquire.js-2.1.6.tgz#3e8780c9b8b835084c3f60e166dbc3c2a3c89814"
integrity sha512-/KujNpO+PT63F7Hlpu4h3pE3TokKRHN26JYmQpPyjkRD/N57R7bPDNojMXdi7uveAKjYB7yQnartCxZnFWr0Xw==

entities@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55"
Expand Down Expand Up @@ -4163,6 +4173,13 @@ json-to-pretty-yaml@^1.2.2:
remedial "^1.0.7"
remove-trailing-spaces "^1.0.6"

json2mq@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/json2mq/-/json2mq-0.2.0.tgz#b637bd3ba9eabe122c83e9720483aeb10d2c904a"
integrity sha512-SzoRg7ux5DWTII9J2qkrZrqV1gt+rTaoufMxEzXbS26Uid0NwaJd123HcoB80TgubEppxxIGdNxCx50fEoEWQA==
dependencies:
string-convert "^0.2.0"

json5@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe"
Expand Down Expand Up @@ -5043,6 +5060,17 @@ react-is@^17.0.2:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==

react-slick@^0.29.0:
version "0.29.0"
resolved "https://registry.yarnpkg.com/react-slick/-/react-slick-0.29.0.tgz#0bed5ea42bf75a23d40c0259b828ed27627b51bb"
integrity sha512-TGdOKE+ZkJHHeC4aaoH85m8RnFyWqdqRfAGkhd6dirmATXMZWAxOpTLmw2Ll/jPTQ3eEG7ercFr/sbzdeYCJXA==
dependencies:
classnames "^2.2.5"
enquire.js "^2.1.6"
json2mq "^0.2.0"
lodash.debounce "^4.0.8"
resize-observer-polyfill "^1.5.0"

react-transition-group@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.2.tgz#8b59a56f09ced7b55cbd53c36768b922890d5470"
Expand Down Expand Up @@ -5214,6 +5242,11 @@ require-main-filename@^2.0.0:
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==

resize-observer-polyfill@^1.5.0:
version "1.5.1"
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==

resolve-from@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
Expand Down Expand Up @@ -5417,6 +5450,11 @@ slice-ansi@0.0.4:
resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35"
integrity sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=

slick-carousel@^1.8.1:
version "1.8.1"
resolved "https://registry.yarnpkg.com/slick-carousel/-/slick-carousel-1.8.1.tgz#a4bfb29014887bb66ce528b90bd0cda262cc8f8d"
integrity sha512-XB9Ftrf2EEKfzoQXt3Nitrt/IPbT+f1fgqBdoxO3W/+JYvtEOW6EgxnWfr9GH6nmULv7Y2tPmEX3koxThVmebA==

snake-case@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c"
Expand Down Expand Up @@ -5460,6 +5498,11 @@ stable@^0.1.8:
resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf"
integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==

string-convert@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/string-convert/-/string-convert-0.2.1.tgz#6982cc3049fbb4cd85f8b24568b9d9bf39eeff97"
integrity sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==

string-env-interpolation@1.0.1, string-env-interpolation@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/string-env-interpolation/-/string-env-interpolation-1.0.1.tgz#ad4397ae4ac53fe6c91d1402ad6f6a52862c7152"
Expand Down