Skip to content

Commit

Permalink
Create contractReducer.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 8, 2024
1 parent fc722d1 commit de84361
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const initialState = {
contracts: [],
contract: null,
error: null
};

export default function contractReducer(state = initialState, action) {
switch (action.type) {
case 'FETCH_CONTRACTS_SUCCESS':
return { ...state, contracts: action.contracts };
case 'FETCH_CONTRACTS_FAILURE':
return { ...state, error: action.error };
case 'FETCH_CONTRACT_SUCCESS':
return { ...state, contract: action.contract };
case 'FETCH_CONTRACT_FAILURE':
return { ...state, error: action.error };
case 'CREATE_CONTRACT_SUCCESS':
return { ...state, contract: action.contract };
case 'CREATE_CONTRACT_FAILURE':
return { ...state, error: action.error };
default:
return state;
}
}

0 comments on commit de84361

Please sign in to comment.