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 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
37 changes: 37 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

src/generated/
graphql.schema.json
13 changes: 13 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This example shows how to integrate the TypeScript type system into Next.js. Since TypeScript is supported out of the box with Next.js, all we have to do is to install TypeScript.

This example shows how to properly export and import typescript types without getting the

```js
Attempted import error: 'TypeA' is not exported from './package-1'.
```

error as raised in [vercel/next.js#7882](https://github.com/vercel/next.js/issues/7882).

## Useful links

[Add import type and export type support to TypeScript](https://github.com/babel/babel/pull/11171)
27 changes: 27 additions & 0 deletions client/codegen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
schema: [{ 'http://localhost:4000/graphql': {} }],
documents: ['./src/**/graphql/*.ts'],
overwrite: true,
generates: {
'./src/generated/index.tsx': {
plugins: [
'typescript',
'typescript-operations',
'typescript-react-apollo',
],
config: {
skipTypename: false,
withHooks: true,
withHOC: false,
withComponent: false,
apolloReactCommonImportFrom: '@apollo/client',
apolloReactComponentsImportFrom: '@apollo/client',
apolloReactHocImportFrom: '@apollo/client',
apolloReactHooksImportFrom: '@apollo/client',
},
},
'./graphql.schema.json': {
plugins: ['introspection'],
},
},
};
20 changes: 0 additions & 20 deletions client/components/SomeComponent/__test__/Index.test.tsx

This file was deleted.

This file was deleted.

27 changes: 0 additions & 27 deletions client/components/SomeComponent/index.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions client/components/index.ts

This file was deleted.

7 changes: 0 additions & 7 deletions client/interfaces/models.d.ts

This file was deleted.

55 changes: 0 additions & 55 deletions client/modules/home.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions client/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
41 changes: 41 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "chapter-client",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"gen": "graphql-codegen --config codegen.js"
},
"dependencies": {
"@apollo/client": "^3.1.1",
"@material-ui/core": "^4.5.2",
"@material-ui/icons": "^4.5.1",
"@types/react-redux": "^7.1.7",
"graphql": "^15.3.0",
"immer": "^3.2.0",
"next": "^9.5.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-hook-form": "^4.9.3",
"react-redux": "^7.1.0",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@graphql-codegen/cli": "1.17.7",
"@graphql-codegen/introspection": "1.17.7",
"@graphql-codegen/typescript": "1.17.7",
"@graphql-codegen/typescript-operations": "1.17.7",
"@graphql-codegen/typescript-react-apollo": "1.17.7",
"@types/node": "^12.12.21",
"@types/react": "^16.9.44",
"@types/react-dom": "^16.9.8",
"typescript": "^3.9.7",
"@graphql-codegen/typescript-graphql-files-modules": "1.17.7",
"@graphql-codegen/typescript-document-nodes": "1.17.7",
"@graphql-codegen/fragment-matcher": "1.17.7"
},
"license": "MIT"
}
File renamed without changes.
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
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
4 changes: 4 additions & 0 deletions client/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import AddSponsor from '../modules/dashboard/AddSponsor';
import ProgressCardContent from './ProgressCardContent';

export { AddSponsor, ProgressCardContent };
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ILocationModal } from 'client/store/types/locations';
import { ILocationModal } from '../modules/dashboard/Dashboard/Locations/node_modules/client/store/types/locations';

const getLocationString = (
location: ILocationModal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const sanitizeFormData = (data: Obj): Obj => {
}

return prev;
}, {});
}, {} as Obj);
};

export default sanitizeFormData;
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const AddSponsor: React.FC = () => {
// const eventId = useSelector(state => state.selectedChapter.eventId);
// const chapterId = useSelector(state => state.selectedChapter.id);

const onSubmit = async data => {
const onSubmit = async (data: any) => {
try {
// await dispatch(sponsorActions.submit(eventId, chapterId));
setResponseMsg(`${data.name} has been added as a ${data.type} sponsor.`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
IField,
IEventFormData,
} from './EventFormUtils';
import { IEventModal } from 'client/store/types/events';
import useFormStyles from '../shared/formStyles';
import { IEventModal } from '../../Events/components/node_modules/client/store/types/events';
import useFormStyles from '../shared/components/formStyles';

const formatValue = (field: IField, store?: IEventModal): any => {
const { key } = field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IVenueModal } from 'client/store/types/venues';
import { IEventModal } from 'client/store/types/events';
import { IEventModal } from '../../Events/components/node_modules/client/store/types/events';

export interface IField {
key: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import { Card, Typography } from '@material-ui/core';
import Link from 'next/link';

import { IEventModal } from 'client/store/types/events';
import { IEventModal } from '../../Events/components/node_modules/client/store/types/events';
import { ProgressCardContent } from 'client/components';
import Tags from './components/Tag';
import Actions from './components/Actions';
import Tags from '../../Events/components/Tag';
import Actions from '../../Events/components/Actions';

interface IEventItemProps {
event: IEventModal;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { useForm, Controller } from 'react-hook-form';
import { Button, TextField, FormControl } from '@material-ui/core';
import useFormStyles from '../shared/formStyles';
import useFormStyles from '../shared/components/formStyles';

const fields = ['country_code', 'city', 'region', 'postal_code', 'address'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { ILocationModal } from 'client/store/types/locations';
import getLocationString from 'client/helpers/getLocationString';
import { IVenueModal } from 'client/store/types/venues';
import useFormStyles from '../shared/formStyles';
import useFormStyles from '../shared/components/formStyles';

interface IData {
name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import Link from 'next/link';

import links from 'client/constants/DashboardLinks';
import { makeStyles } from '@material-ui/core';

import links from '../../../../constants/DashboardLinks';

const useStyles = makeStyles(() => ({
link: {
fontSize: '1rem',
Expand Down
Loading