Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Initial setup apollo on client #393

Merged
merged 16 commits into from
Aug 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Refactor some stuff to get it running
  • Loading branch information
Zeko369 committed Aug 2, 2020
commit 9e9555b9560f200bec753a5302b8219945e1ddce
4 changes: 2 additions & 2 deletions client/components/PageLayout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import Link from 'next/link';
import { makeStyles, Grid } from '@material-ui/core';

import { headerLinks } from 'client/constants/Header';
import { headerLinks } from '../../constants/Header';

const useStyles = makeStyles({
link: {
Expand All @@ -14,7 +14,7 @@ const useStyles = makeStyles({
},
});

const Header = ({ classes }) => {
const Header: React.FC<{ classes: Record<string, any> }> = ({ classes }) => {
const styles = useStyles();

return (
Expand Down
2 changes: 1 addition & 1 deletion client/components/PageLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import Header from './Header';
import usePageLayoutStyles from './pageLayout.styles';

const PageLayout = ({ children }) => {
const PageLayout: React.FC = ({ children }) => {
const classes = usePageLayoutStyles();
return (
<>
Expand Down
58 changes: 28 additions & 30 deletions client/modules/home.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
import React, { useEffect } from 'react';
import React from 'react';
import Link from 'next/link';
import { Card, Typography, Grid } from '@material-ui/core';
import { useSelector } from 'react-redux';
import { SomeComponent, ProgressCardContent } from 'client/components';
import { AppStoreState } from 'client/store/reducers';
import { chapterActions } from 'client/store/actions';
import useThunkDispatch from 'client/hooks/useThunkDispatch';
// import { useSelector } from 'react-redux';
import { SomeComponent, ProgressCardContent } from '../components';
// import { AppStoreState } from '../store/reducers';
// import { chapterActions } from '../store/actions';
// import useThunkDispatch from '../hooks/useThunkDispatch';

const Home: React.FC = () => {
const { error, loading, name, description } = useSelector(
(state: AppStoreState) => ({
error: state.chapter.error,
loading: state.chapter.loading,
name: state.chapter.name,
description: state.chapter.description,
}),
);
const dispatch = useThunkDispatch();
// const { error, loading, name, description } = useSelector(
// (state: AppStoreState) => ({
// error: state.chapter.error,
// loading: state.chapter.loading,
// name: state.chapter.name,
// description: state.chapter.description,
// }),
// );
// const dispatch = useThunkDispatch();

useEffect(() => {
dispatch(chapterActions.fetchChapter('1'));
}, []);
// useEffect(() => {
// dispatch(chapterActions.fetchChapter('1'));
// }, []);

return (
<>
<SomeComponent />
<Grid container spacing={2}>
<Grid item xs={10}>
{!error && (
<Card>
<ProgressCardContent loading={loading}>
<Typography gutterBottom variant="h5" component="h2">
{name}
</Typography>
<Typography variant="body2" color="textSecondary" component="p">
{description}
</Typography>
</ProgressCardContent>
</Card>
)}
<Card>
<ProgressCardContent loading={false}>
<Typography gutterBottom variant="h5" component="h2">
Hello
</Typography>
<Typography variant="body2" color="textSecondary" component="p">
World
</Typography>
</ProgressCardContent>
</Card>
</Grid>
</Grid>
<Link href="/add-sponsor">
Expand Down
6 changes: 3 additions & 3 deletions client/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import thunk from 'redux-thunk';
import { ThemeProvider as MaterialUIThemeProvider } from '@material-ui/core/styles';
import CssBaseline from '@material-ui/core/CssBaseline';

import theme from 'styles/theme';
import { rootReducer } from 'client/store/reducers';
import PageLayout from 'client/components/PageLayout';
import theme from '../styles/theme';
import { rootReducer } from '../store/reducers';
import PageLayout from '../components/PageLayout';

const composeEnhancers =
(typeof window !== 'undefined' &&
Expand Down
7 changes: 4 additions & 3 deletions client/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import * as React from 'react';
import { ServerStyleSheets } from '@material-ui/core/styles';
import Document, { Head, Main, NextScript } from 'next/document';

import theme from 'styles/theme';
import theme from '../styles/theme';

export default class MyDocument extends Document {
static async getInitialProps(ctx) {
static async getInitialProps(ctx: any) {
const materialUISheet = new ServerStyleSheets();
const originalRenderPage = ctx.renderPage;

try {
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: App => props =>
enhanceApp: (App: any) => (props: any) =>
materialUISheet.collect(<App {...props} />),
});

Expand Down
11 changes: 2 additions & 9 deletions client/pages/add-sponsor.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import * as React from 'react';
import { AddSponsor } from 'client/components';
import { AddSponsor } from '../components';

const AddSponsorPage = () => {
return (
<>
<AddSponsor />
{
// TODO: page designs and styling
}
</>
);
return <AddSponsor />;
};

export default AddSponsorPage;
2 changes: 1 addition & 1 deletion client/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Home from 'client/modules/home';
import Home from '../modules/home';

export default Home;
File renamed without changes.