From c4afcc18c82ac56bdf7ec1d710baca57efaf8b03 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Thu, 22 Oct 2020 15:24:00 +0200 Subject: [PATCH] introduce containers and core folders --- .eslintrc.js | 15 ++++++++------- src/Router.tsx | 2 +- src/components/Home.tsx | 8 -------- src/components/TodoList.tsx | 20 ++++++++++++++++++++ src/containers/Home.tsx | 9 +++++++++ src/core/models/todo.ts | 5 +++++ src/core/services/todo.ts | 17 +++++++++++++++++ 7 files changed, 60 insertions(+), 16 deletions(-) delete mode 100644 src/components/Home.tsx create mode 100644 src/components/TodoList.tsx create mode 100644 src/containers/Home.tsx create mode 100644 src/core/models/todo.ts create mode 100644 src/core/services/todo.ts diff --git a/.eslintrc.js b/.eslintrc.js index 1bfa3ae..0ed2355 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,23 +1,24 @@ module.exports = { - parser: "@typescript-eslint/parser", // Specifies the ESLint parser + parser: '@typescript-eslint/parser', // Specifies the ESLint parser parserOptions: { ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features - sourceType: "module", // Allows for the use of imports + sourceType: 'module', // Allows for the use of imports ecmaFeatures: { jsx: true // Allows for the parsing of JSX } }, settings: { react: { - version: "detect" // Tells eslint-plugin-react to automatically detect the version of React to use + version: 'detect' // Tells eslint-plugin-react to automatically detect the version of React to use } }, extends: [ - "plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react - "plugin:@typescript-eslint/recommended" // Uses the recommended rules from @typescript-eslint/eslint-plugin + 'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react + 'plugin:@typescript-eslint/recommended' // Uses the recommended rules from @typescript-eslint/eslint-plugin ], rules: { + 'react/prop-types': 0 // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs // e.g. "@typescript-eslint/explicit-function-return-type": "off", - }, -}; \ No newline at end of file + } +}; diff --git a/src/Router.tsx b/src/Router.tsx index 3b2cdc6..4c7afee 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -1,8 +1,8 @@ import React, { FC } from 'react'; import { Route, Switch } from 'react-router-dom'; -import { Home } from './components/Home'; import { About } from './components/About'; +import { Home } from './containers/Home'; const Router: FC = () => ( diff --git a/src/components/Home.tsx b/src/components/Home.tsx deleted file mode 100644 index 4e1dda8..0000000 --- a/src/components/Home.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React, { FC } from 'react'; - -export const Home: FC = () => ( -
-

Hello

-

Hi there!

-
-); diff --git a/src/components/TodoList.tsx b/src/components/TodoList.tsx new file mode 100644 index 0000000..541f2fe --- /dev/null +++ b/src/components/TodoList.tsx @@ -0,0 +1,20 @@ +import React, { FC } from 'react'; +import Todo from '../core/models/todo'; + +interface Props { + todos: Todo[]; +} + +export const TodoList: FC = ({ todos }) => ( +
+

Your tasks

+

Hi there!

+
    + {todos.map((todo) => ( +
  • + {todo.title}, status: {todo.isDone ? 'Done' : 'In Progress'} +
  • + ))} +
+
+); diff --git a/src/containers/Home.tsx b/src/containers/Home.tsx new file mode 100644 index 0000000..1db81b4 --- /dev/null +++ b/src/containers/Home.tsx @@ -0,0 +1,9 @@ +import React, { FC } from 'react'; + +import { listTodos } from '../core/services/todo'; +import { TodoList } from '../components/TodoList'; + +export const Home: FC = () => { + const todos = listTodos(); + return ; +}; diff --git a/src/core/models/todo.ts b/src/core/models/todo.ts new file mode 100644 index 0000000..227207a --- /dev/null +++ b/src/core/models/todo.ts @@ -0,0 +1,5 @@ +export default interface Todo { + id: string; + title: string; + isDone: boolean; +} diff --git a/src/core/services/todo.ts b/src/core/services/todo.ts new file mode 100644 index 0000000..53e0994 --- /dev/null +++ b/src/core/services/todo.ts @@ -0,0 +1,17 @@ +import Todo from '../models/todo'; + +export const listTodos = (): Todo[] => { + console.log('create list'); + return [ + { + id: '1', + title: 'test', + isDone: false + }, + { + id: '2', + title: 'second', + isDone: true + } + ]; +};