Home Reference Source Test Repository

Function

Static Public Summary
public

Generate an user log in component

public

Generate a form

public

Generate a link to change filter value

public

Temporary home page

public

Main wrapper

public

Generate site navigation

public

Error 404 fallback page

public

Todo(props: Object): ReactDOM

Generate a clickable todo item with a label and an delete button

public

Generate the whole todo application

public

Generate a list of todo filter links

public

Generate a footer for the todo list

public

Generate a form to submit a new todo

public

Generate a list of todos

public

User(props: userObj): ReactDOM

Generate user item with a picture and a link to the profile

public

Generate a header to display list title and button to launch user query

public

Generate a visual error when request fails

public

Generate a header to display list title and button to launch user query

public

Generate a list of users

public

addTodo(label: string): Object

action to add a todo

public

authReducer(state: Object, action: Object): Object

reducer for auth actions

public

action to clear completed todos

public

fetchUsers(since: number, perPage: number): Object

action to fetch user

public

Epic observer that query user API when triggered

public

fetchUsersError(error: *): Object

action to provide users error logs to state

public

action to provide users data to the state

public

filter a list of given todos

public

logIn(login: string, password: string): Object

action to log user in

public

logInEpic(action$: Object): Object

Epic observer that query auth API when triggered

public

action to notify user log in failure

public

action to notify user log in success

public

action to log user out

public

action to remove a todo

public

action to set a filter

public

reducer for filter actions

public

reducer for todo actions

public

action to toggle a todo

public

usersReducer(state: Object, action: Object): Object

reducer for users actions

Static Public

public AuthApp(props: Object): ReactDOM source

Generate an user log in component

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.onLoginFormSubmit function
  • nullable: false

the function to perform when the auth form is submitted, here logIn

Return:

ReactDOM

generate <section class="authApp"/> markup

Test:

public AuthForm(props: Object): ReactDOM source

Generate a form

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.onSubmit function
  • nullable: false

the function to perform when the form is submitted, here logIn

Return:

ReactDOM

generate <form class="authForm"/> markup

Test:

Generate a link to change filter value

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.active boolean
  • nullable: false

whether the link is already active or not

props.filter string
  • nullable: false

constant representing the filter value

props.onClick function(filter: string)
  • nullable: false

function to perform when link is clicked, here setTodoFilter

Return:

ReactDOM

generate <a class="filterList_item"> markup

Test:

public HomePage(): ReactDOM source

Temporary home page

Return:

ReactDOM

generate <div class="homePage"/> markup

public MainApp(props: Object): ReactDOM source

Main wrapper

Params:

NameTypeAttributeDescription
props Object

react props object

props.children ReactDOM

all components called from router

Return:

ReactDOM

generate <div class="notFound"/> markup

public Menu(): ReactDOM source

Generate site navigation

Return:

ReactDOM

generate <nav class="appMenu"/> markup

public NotFound(): ReactDOM source

Error 404 fallback page

Return:

ReactDOM

generate <div class="notFound"/> markup

public Todo(props: Object): ReactDOM source

Generate a clickable todo item with a label and an delete button

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.completed boolean
  • nullable: false

whether the todo is completed or not

props.label string
  • nullable: false

the todo label

props.onClick function
  • nullable: false

the function to perform when the todo label is clicked, here toggleTodo

props.onButtonClick function
  • nullable: false

the function to perform when the todo button is clicked, here removeTodo

Return:

ReactDOM

generate <li class="todoList_item"/> markup

Test:

public TodoApp(props: Object): ReactDOM source

Generate the whole todo application

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.todos Array<todoObj>
  • nullable: false

list of all available todos

props.filter string
  • nullable: false

current active filter

props.filterList Array<string>
  • nullable: false

list of all todo filters

props.onTodoFormSubmit function
  • nullable: false

function to perform when the todo form is submitted

props.onTodoClick function
  • nullable: false

function to perform when the todo label is clicked

props.onTodoButtonClick function
  • nullable: false

function to perform when the todo button is clicked

props.onTodoClearClick function
  • nullable: false

function to perform when the clear button is clicked

props.onLinkClick function
  • nullable: false

function to perform when a filter link is clicked

Return:

ReactDOM

generate <section class="todoApp" /> markup

Test:

import {TodoFilterLinks} from 'redux/app/modules/todos/TodoApp.component.js'

Generate a list of todo filter links

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.filterList Array<string>
  • nullable: false

list of all available filters

props.currentFilter string
  • nullable: false

constant representing the currently active filter in the list

props.onLinkClick function()
  • nullable: false

function to perform when a filter link is clicked

Return:

ReactDOM

generate <div class="filterList" /> markup

Test:

public TodoFooter(props: Object): ReactDOM source

Generate a footer for the todo list

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.todos Array<todoObj>
  • nullable: false

list of all todos

props.onTodoClearClick function()
  • nullable: false

function to perform when the clear button is clicked

Return:

ReactDOM

generate <p class="todoFooter" /> markup

Test:

public TodoForm(props: Object): ReactDOM source

Generate a form to submit a new todo

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.onTodoFormSubmit function(label: string)
  • nullable: false

function to perform on form submit

Return:

ReactDOM

generate <form class="todoForm"/> markup

Test:

public TodoList(props: Object): ReactDOM source

Generate a list of todos

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.filteredTodos Array<todoObj>
  • nullable: false

pre-filtered list of todos depending on the actual selected filter

props.onTodoClick function(id: number)
  • nullable: false

function to perform when a todo label is clicked, here toggleTodo

props.onTodoButtonClick function(id: number)
  • nullable: false

function to perform when a todo button is clicked, here removeTodo

Return:

ReactDOM

generate <ul class="todoList"/> markup

Test:

public User(props: userObj): ReactDOM source

Generate user item with a picture and a link to the profile

Params:

NameTypeAttributeDescription
props userObj
  • nullable: false

user object

Return:

ReactDOM

generate <li class="userList_item"/> markup

Test:

public UserApp(props: Object): ReactDOM source

Generate a header to display list title and button to launch user query

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.users Array<userObj>
  • nullable: false

list of user object

props.error Object
  • nullable: false

error object to display

props.error.message string
  • nullable: false

error message

props.onRefreshButtonClick Object
  • nullable: false

function to run when refresh button is clicked

Return:

ReactDOM

generate <section class="userApp"/> markup

Test:

public UserError(props: Object): ReactDOM source

Generate a visual error when request fails

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.error Object
  • nullable: false

error object to display

props.error.message string
  • nullable: false

error message

Return:

ReactDOM

generate <p class="userError"/> markup

Test:

public UserHeader(props: Object): ReactDOM source

Generate a header to display list title and button to launch user query

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.onClick Object
  • nullable: false

function to run when refresh button is clicked

Return:

ReactDOM

generate <div class="userHeader"/> markup

Test:

public UserList(props: Object): ReactDOM source

Generate a list of users

Params:

NameTypeAttributeDescription
props Object
  • nullable: false

react props object

props.users Array<userObj>
  • nullable: false

list of user object

Return:

ReactDOM

generate <ul class="userList"/> markup

Test:

public addTodo(label: string): Object source

action to add a todo

Params:

NameTypeAttributeDescription
label string
  • nullable: false

Return:

Object

Return Properties:

NameTypeAttributeDescription
type string

action type

label string

label of the todo to create

Test:

public authReducer(state: Object, action: Object): Object source

reducer for auth actions

Params:

NameTypeAttributeDescription
state Object

current state value

state.isFetching boolean

whether auth process is pending or not

state.isAuthenticated boolean

whether user is authenticated or not

state.user Object

user data

state.error Object

error data

action Object

action to perform on the state

action.type string

describe the action type

Return:

Object

Return Properties:

NameTypeAttributeDescription
state.isFetching boolean

whether auth process is pending or not

state.isAuthenticated boolean

whether user is authenticated or not

state.user Object

user data

state.error Object

error data

Test:

public clearTodo(): Object source

action to clear completed todos

Return:

Object

Return Properties:

NameTypeAttributeDescription
type string

action type

Test:

public fetchUsers(since: number, perPage: number): Object source

action to fetch user

Params:

NameTypeAttributeDescription
since number
  • optional
  • default: RANDOM
  • nullable: true

id from where to get users, default is a random number

perPage number
  • optional
  • default: 10
  • nullable: true

number of user to get, default is 10

Return:

Object

Return Properties:

NameTypeAttributeDescription
type string

action type

since number

id from where to get users

perPage number

number of user to get

Test:

public fetchUsersEpic(action$: Object): Array<userObj> | Object source

Epic observer that query user API when triggered

Params:

NameTypeAttributeDescription
action$ Object

action object that trigger the user API request

action$.type string

action type

Return:

Array<userObj> | Object

public fetchUsersError(error: *): Object source

action to provide users error logs to state

Params:

NameTypeAttributeDescription
error *

error from failed API request

Return:

Object

Return Properties:

NameTypeAttributeDescription
action type

type

error Object

error from failed API request

Test:

public fetchUsersSuccess(data: Array<userObj>): Object source

import {fetchUsersSuccess} from 'redux/app/modules/users/reducers/users.reducer.js'

action to provide users data to the state

Params:

NameTypeAttributeDescription
data Array<userObj>

user list from API

Return:

Object

Return Properties:

NameTypeAttributeDescription
action type

type

data Array<userObj>

user list from API

Test:

public getFilteredTodos(todos: Array<todoObj>, filter: string): Array<todoObj> source

filter a list of given todos

Params:

NameTypeAttributeDescription
todos Array<todoObj>

list of todos to filter

filter string

filter value

Return:

Array<todoObj>

a list of filtered todos

public logIn(login: string, password: string): Object source

action to log user in

Params:

NameTypeAttributeDescription
login string
  • nullable: false

user login

password string
  • nullable: false

user password

Return:

Object

Return Properties:

NameTypeAttributeDescription
type string

action type

login string

user login

password string

user password

Test:

public logInEpic(action$: Object): Object source

Epic observer that query auth API when triggered

Params:

NameTypeAttributeDescription
action$ Object

action object that trigger the auth API request

action$.type string

action type

Return:

Object

public logInFailure(error: Object): Object source

action to notify user log in failure

Params:

NameTypeAttributeDescription
error Object
  • nullable: false

error object related to the failure

Return:

Object

Return Properties:

NameTypeAttributeDescription
type string

action type

error string

error data

Test:

public logInSuccess(user: Object): Object source

action to notify user log in success

Params:

NameTypeAttributeDescription
user Object
  • nullable: false

data to associate to the current user

Return:

Object

Return Properties:

NameTypeAttributeDescription
type string

action type

user string

user data

Test:

public logOut(): Object source

action to log user out

Return:

Object

Return Properties:

NameTypeAttributeDescription
type string

action type

Test:

public removeTodo(id: number): Object source

action to remove a todo

Params:

NameTypeAttributeDescription
id number
  • nullable: false

Return:

Object

Return Properties:

NameTypeAttributeDescription
type string

action type

id number

id of the todo to remove

Test:

public setTodoFilter(filter: string): Object source

action to set a filter

Params:

NameTypeAttributeDescription
filter string

label of the filter to set

Return:

Object

Return Properties:

NameTypeAttributeDescription
type string

action type

filter string

label of the filter to set

Test:

public todoFiltersReducer(state: string, action: string): string source

reducer for filter actions

Params:

NameTypeAttributeDescription
state string

current state value

action string

action to perform on the state

action.type string

describe the action type

Return:

string

new state value after performing the action

Test:

public todosReducer(state: Array<todoObj>, action: Object): Array<todoObj> source

reducer for todo actions

Params:

NameTypeAttributeDescription
state Array<todoObj>
  • optional
  • default: []

current state value

action Object

action to perform on the state

action.type string

action type constant

action.label string

todo label

action.id number

todo id

Return:

Array<todoObj>

new state value after performing action

Test:

public toggleTodo(id: number): Object source

action to toggle a todo

Params:

NameTypeAttributeDescription
id number
  • nullable: false

Return:

Object

Return Properties:

NameTypeAttributeDescription
type string

action type

id number

id of the todo to toggle

Test:

public usersReducer(state: Object, action: Object): Object source

reducer for users actions

Params:

NameTypeAttributeDescription
state Object

current state value

state.requestState string

user request state

state.data Array<userObj>

data gotten from user request

state.error Object
  • nullable: true

error object from failed user request

state.error.message string

error object if an error occurred

action Object

action to perform on the state

action.type string

describe the action type

Return:

Object

Return Properties:

NameTypeAttributeDescription
state.requestState string

user request state

state.data Array<userObj>

data gotten from user request

state.error Object
  • nullable: true

error object from failed user request

Test: