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
function FindProxyForURL(url, host) { | |
alert(JSON.stringify({ url, host })); | |
if (url.includes('facebook.com')) { | |
return 'PROXY 127.0.0.1:4916;'; | |
} | |
return 'DIRECT'; | |
} |
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
useEffect(() => { | |
dispatch(fetchTodos()) | |
}, []) |
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
// Styles | |
const useStyles = makeStyles({ | |
... | |
}) |
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
import { applyMiddleware, combineReducers, createStore } from "redux" | |
import thunk from "redux-thunk" | |
import todo, { TodoAction } from "./todo" | |
// Action Types | |
export type Action = TodoAction | |
const reducer = combineReducers({ todo }) | |
export type State = ReturnType<typeof reducer> |
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
// State type | |
// this interface represents the schema for the Todo state | |
export interface TodoState { | |
fetchError?: any | |
createError?: any | |
completeError?: any | |
uncompleteError?: any | |
isFetchingTodos: boolean | |
isCreatingTodo: boolean | |
isCompletingTodo: boolean |
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
/** | |
* mark a todo as incomplete | |
*/ | |
export const uncompleteTodo = async (_id: string): Promise<TodoItem> => { | |
const todoCollection = await useCollection<TodoItem>("todo") | |
const { result } = await todoCollection.updateOne({ _id }, { | |
$set: { complete: false }, | |
}) | |
if (!result.ok) { | |
throw new Error("Could not uncomplete TodoItem") |
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
export const selectIncompleteTodos = (state: RootState): TodoItem[] => state.todo.todos.filter(item => !item.complete) ?? [] |
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
/** | |
* POST /:id/uncomplete | |
* mark an existing to-do item as incomplete | |
*/ | |
todoRouter.post("/:id/uncomplete", async (req: Request, res: Response) => { | |
const { id } = req.params | |
try { | |
const todo = await uncompleteTodo(id) | |
if (!todo) { | |
return res.status(404).json({ error: "Item not found" }) |
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
import { RouteProps } from "react-router-dom" | |
import HomePage from "./pages/HomePage" | |
import TodoPage from "./pages/TodoPage" | |
const routes: RouteProps[] = [ | |
{ path: "/", component: HomePage, exact: true }, | |
{ path: "/todo", component: TodoPage }, | |
] | |
export default routes |
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
// Reducer | |
const reducer = (state: TodoState = defaultState, action: TodoAction): TodoState => { | |
switch (action.type) { | |
... | |
case "TODO_UNCOMPLETED_STARTED": { | |
return { ...state, isUncompletingTodo: true } | |
} | |
case "TODO_UNCOMPLETED": { |
NewerOlder