Skip to content

Commit 8ec2cb8

Browse files
committed
Added Todo page.
1 parent d015d10 commit 8ec2cb8

33 files changed

+4040
-349
lines changed

codegen.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
schema: http://localhost:4000/graphql
2+
documents: null
3+
generates:
4+
./src/types/generatedTypes.ts:
5+
plugins:
6+
- typescript
7+
- typescript-operations
8+
config:
9+
namingConvention: keep
10+
skipTypename: true
11+
nonOptionalTypename: false
12+
maybeValue: T | null
13+
avoidOptionals:
14+
field: true
15+
inputValue: true
16+
object: true
17+
18+
require: ts-node/register

package-lock.json

Lines changed: 3810 additions & 240 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@
1414
"@types/react": "^17.0.0",
1515
"@types/react-dom": "^17.0.0",
1616
"graphql": "^15.4.0",
17+
"node-sass": "^4.14.1",
1718
"react": "^17.0.1",
1819
"react-dom": "^17.0.1",
1920
"react-router-dom": "^5.2.0",
2021
"react-scripts": "^4.0.1",
2122
"typescript": "^4.1.3"
2223
},
2324
"scripts": {
25+
"prestart": "npm run generate",
2426
"start": "react-scripts start",
2527
"build": "react-scripts build",
2628
"test": "react-scripts test",
29+
"generate": "graphql-codegen",
2730
"eject": "react-scripts eject"
2831
},
2932
"eslintConfig": {
@@ -42,6 +45,9 @@
4245
]
4346
},
4447
"devDependencies": {
48+
"@graphql-codegen/cli": "^1.20.0",
49+
"@graphql-codegen/typescript": "^1.20.0",
50+
"@graphql-codegen/typescript-operations": "^1.17.13",
4551
"@types/jest-axe": "^3.5.1",
4652
"@types/jest-image-snapshot": "^4.1.3",
4753
"@types/jsdom-screenshot": "^3.2.0",

src/App.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
import React from 'react';
22
import logo from './logo.svg';
3+
import {
4+
Link
5+
} from "react-router-dom";
6+
import { Can } from './rules/Can';
7+
import { Article } from "./rules/entities";
38
import './App.css';
9+
import { ExchangeRates } from './pages';
410

511
function App() {
12+
const article = new Article({ published: true });
13+
614
return (
715
<div className="App">
816
<header className="App-header">
917
<img src={logo} className="App-logo" alt="logo" />
10-
<p className="paragraph-cls">Lorem ipsum dolor sit amet consectetur adipisicing elit. Atque ex perferendis maxime voluptatem molestiae? Qui cupiditate asperiores ipsa nesciunt, iusto minima voluptatem alias sit porro sunt ad veritatis reiciendis? Deserunt.</p>
11-
<a
18+
19+
<p>
20+
Edit <code>src/App.tsx</code> and save to reload.
21+
</p><a
1222
className="App-link"
1323
href="https://reactjs.org"
1424
target="_blank"
1525
rel="noopener noreferrer"
1626
>
1727
Learn React
1828
</a>
29+
<Link to="/todos">Todos</Link>
30+
<Can I="read" a={article}>
31+
{() => <ExchangeRates />}
32+
</Can>
1933
</header>
34+
2035
</div>
2136
);
2237
}

src/components/Books/gql.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/components/ExchangeRates/gql.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/components/TodoItem/TodoItem.spec.tsx

Whitespace-only changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import { ToDo } from '../../types';
3+
4+
type TodoItemProps = {
5+
todo: ToDo;
6+
onChange: (todo: Pick<ToDo, 'id' | 'completed'>) => void
7+
};
8+
9+
export const TodoItem = ({ todo, onChange }: TodoItemProps): JSX.Element => {
10+
const { id, title, completed } = todo;
11+
12+
return (
13+
<>
14+
<div className="Todo__item">
15+
<label htmlFor={`${id}-checkbox`}>{title}</label>
16+
<input
17+
id={`${id}-checkbox`}
18+
type="checkbox"
19+
checked={completed || false}
20+
onChange={() => onChange({ id, completed: !completed })}
21+
/>
22+
</div>
23+
</>);
24+
}

src/components/TodoItem/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./TodoItem";

src/components/Todos/gql.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)