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 * as React from "react"; | |
import { render } from "react-dom"; | |
import App from "./App"; | |
import { init } from "./service"; | |
const rootElement = document.getElementById("root"); | |
render(<App />, rootElement); | |
init(); |
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 * as React from "react"; | |
import { useState } from "@iadvize-oss/store-react"; | |
import * as State from "./state"; | |
import { store } from "./store"; | |
import { createUserAndSave } from "./service"; | |
import Users from "./components/Users"; | |
import UserForm from "./components/UserForm"; |
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 * as User from "./state/user"; | |
import * as State from "./state"; | |
import { store } from "./store"; | |
export const createUserAndSave = ({ | |
firstName, | |
lastName, | |
picture | |
}: { |
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 * as Store from "@iadvize-oss/store"; | |
import * as State from "./state"; | |
export const store = Store.create<State.State>(() => State.initialState)(); |
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
const DEFAULT_USER_PICTURE = "https://i.pravatar.cc/300"; | |
export const id = (user: User): string => user.id; | |
export const displayName = (user: User): string => | |
`${user.firstName} ${user.lastName}`; | |
export const pictureOrDefault = (user: User): string => | |
user.picture || DEFAULT_USER_PICTURE; | |
export const createNew = ({ | |
firstName, |
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 decode = (apiPayload: unknown): Loaded | Failure => { | |
// parse payload | |
// remove admins | |
// if something goes wrong, return Failure | |
}; | |
export const users = (state: Loaded) => state.users; | |
export const addUser = (user: User.User) => ( | |
state: Loaded |
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 type User = { | |
id: string; | |
firstName: string; | |
lastName: string; | |
picture?: string; | |
}; |
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 * as NonEmptyArray from "fp-ts/lib/NonEmptyArray"; | |
import * as User from "./user"; | |
export type State = Loading | Failure | Loaded; | |
export const initialState: Loading = "Loading"; | |
type Loading = "Loading"; | |
type Failure = Error; |
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 React from "react"; | |
import { useDispatch, useSelector } from "react-redux"; | |
import { getUsers } from "./selectors"; | |
import { createUser } from "./actionCreators"; | |
import Users from "./components/Users"; | |
import UserForm from "./components/UserForm"; | |
export default function App() { |
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 getUsers = (state) => | |
state.users.map((user) => ({ | |
...user, | |
picture: user.picture || "https://i.pravatar.cc/300 " | |
})); |
NewerOlder