Base du projet 'application ticketing'

This commit is contained in:
2020-02-17 22:28:57 +01:00
parent 2a72ac97ac
commit afa734f96d
64 changed files with 1798 additions and 685 deletions

View File

View File

@ -1,35 +0,0 @@
import { LOGIN_SUCCESS, LOGIN_FAILURE } from '../actions/login';
import { FETCH_MESSAGES_SUCCESS } from '../actions/chat';
const defaultState = {
messagesByChannel: {},
}
export default function chatReducer(state = defaultState, action) {
switch (action.type) {
case FETCH_MESSAGES_SUCCESS:
return {
...state,
messagesByChannel: {
...state.messagesByChannel,
[action.channel]: [...action.data.Messages]
}
};
case 'CHANNEL_EVENT':
switch(action.event) {
case "message":
return {
...state,
messagesByChannel: {
...state.messagesByChannel,
[action.data.Channel]: [
...state.messagesByChannel[action.data.Channel],
action.data.Message
]
}
};
}
return state;
}
return state;
}

View File

@ -1,16 +0,0 @@
import { LOGIN_SUCCESS, LOGIN_FAILURE } from '../actions/login';
const defaultState = {
isLoggedIn: false,
username: null,
}
export default function loginReducer(state = defaultState, action) {
switch (action.type) {
case LOGIN_SUCCESS:
return { ...state, isLoggedIn: true, username: action.data.Username };
case LOGIN_FAILURE:
return { ...state, isLoggedIn: false, username: null };
}
return state;
}

View File

@ -1,31 +0,0 @@
import { ADD_PRODUCT, REMOVE_PRODUCT } from '../actions/products';
export const rootReducer = (state, action) => {
console.log(`Action: ${JSON.stringify(action)}`)
switch (action.type) {
case ADD_PRODUCT:
// L'action est de type ADD_PRODUCT
// On ajoute le produit dans la liste et
// on retourne un nouvel état modifié
return {
products: [...state.products, action.product]
}
case REMOVE_PRODUCT:
// L'action est de type REMOVE_PRODUCT
// On filtre la liste des produits et on
// retourne un nouvel état modifié
return {
products: state.products.filter(p => p.name !== action.productName)
}
}
// Si l'action n'est pas gérée, on retourne l'état
// sans le modifier
return state
}