-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
87 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,26 @@ | ||
/* eslint-disable max-len */ | ||
import React from 'react'; | ||
import 'bulma/css/bulma.css'; | ||
import '@fortawesome/fontawesome-free/css/all.css'; | ||
import { Loader, TodoFilter, TodoList, TodoModal } from './components'; | ||
|
||
import { TodoList } from './components/TodoList'; | ||
import { TodoFilter } from './components/TodoFilter'; | ||
import { TodoModal } from './components/TodoModal'; | ||
import { Loader } from './components/Loader'; | ||
export const App = () => ( | ||
<> | ||
<div className="section"> | ||
<div className="container"> | ||
<div className="box"> | ||
<h1 className="title">Todos:</h1> | ||
|
||
export const App: React.FC = () => { | ||
return ( | ||
<> | ||
<div className="section"> | ||
<div className="container"> | ||
<div className="box"> | ||
<h1 className="title">Todos:</h1> | ||
|
||
<div className="block"> | ||
<TodoFilter /> | ||
</div> | ||
<div className="block"> | ||
<TodoFilter /> | ||
</div> | ||
|
||
<div className="block"> | ||
<Loader /> | ||
<TodoList /> | ||
</div> | ||
<div className="block"> | ||
<Loader /> | ||
<TodoList /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<TodoModal /> | ||
</> | ||
); | ||
}; | ||
<TodoModal /> | ||
</> | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
import { createStore, applyMiddleware, combineReducers } from 'redux'; | ||
import { composeWithDevTools } from 'redux-devtools-extension'; | ||
import thunk from 'redux-thunk'; | ||
import { combineSlices, configureStore } from '@reduxjs/toolkit'; | ||
|
||
import currentTodoReducer from '../features/currentTodo'; | ||
import filterReducer from '../features/filter'; | ||
import todosReducer from '../features/todos'; | ||
const rootReducer = combineSlices(); | ||
|
||
const rootReducer = combineReducers({ | ||
currentTodo: currentTodoReducer, | ||
filter: filterReducer, | ||
todos: todosReducer, | ||
export const store = configureStore({ | ||
reducer: rootReducer, | ||
}); | ||
|
||
// The `store` is passed to the Provider in `/src/index.tsx` | ||
export const store = createStore( | ||
rootReducer, | ||
composeWithDevTools(applyMiddleware(thunk)), | ||
); | ||
|
||
export type RootState = ReturnType<typeof store.getState>; | ||
export type RootState = ReturnType<typeof rootReducer>; | ||
export type AppDispatch = typeof store.dispatch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './Loader'; | ||
export * from './TodoList'; | ||
export * from './TodoFilter'; | ||
export * from './TodoModal'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,10 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
import { Todo } from '../types/Todo'; | ||
|
||
// we use string literal as a type to avoid mistype in future | ||
type RemoveTodoAction = { type: 'currentTodo/REMOVE' }; | ||
const initialState = null as Todo | null; | ||
|
||
// payload is a typical name for an action data | ||
type SetTodoAction = { | ||
type: 'currentTodo/SET'; | ||
payload: Todo; | ||
}; | ||
|
||
// Action creator return type protect us from a mistype | ||
const removeTodo = (): RemoveTodoAction => ({ type: 'currentTodo/REMOVE' }); | ||
|
||
const setTodo = (todo: Todo): SetTodoAction => ({ | ||
type: 'currentTodo/SET', | ||
payload: todo, | ||
export const currentTodoSlice = createSlice({ | ||
name: 'currentTodo', | ||
initialState, | ||
reducers: {}, | ||
}); | ||
|
||
// These actions will be used in the application | ||
export const actions = { setTodo, removeTodo }; | ||
|
||
type State = Todo | null; | ||
type Action = SetTodoAction | RemoveTodoAction; | ||
|
||
const currentTodoReducer = (state: State = null, action: Action): State => { | ||
switch (action.type) { | ||
// Implement all actions here | ||
|
||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default currentTodoReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
export const actions = { | ||
/* put action creators here */ | ||
}; | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
|
||
const filterReducer = () => { | ||
return { | ||
query: '', | ||
status: 'all', | ||
}; | ||
const initialState = { | ||
query: '', | ||
status: 'all', | ||
}; | ||
|
||
export default filterReducer; | ||
export const filterSlice = createSlice({ | ||
name: 'filter', | ||
initialState, | ||
reducers: {}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
import { Todo } from '../types/Todo'; | ||
|
||
export const actions = {}; | ||
|
||
const todosReducer = (): Todo[] => { | ||
return []; | ||
}; | ||
|
||
export default todosReducer; | ||
export const todosSlice = createSlice({ | ||
name: 'todos', | ||
initialState: [] as Todo[], | ||
reducers: {}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters