Initialise fileSystem reducer

pull/1140/head
ioedeveloper 4 years ago
parent aecbc8463d
commit b4a44693a7
  1. 42
      libs/remix-ui/file-explorer/src/lib/reducers/fileSystem.ts

@ -0,0 +1,42 @@
interface Action {
type: string;
payload: Record<string, string | number | boolean>;
}
export const initialState = {
files: [],
isRequesting: false,
isSuccessful: false,
hasError: null
}
export const reducer = (state = initialState, action: Action) => {
switch (action.type) {
case 'FETCH_DIRECTORY_REQUEST': {
return {
...state,
isRequesting: true,
isSuccessful: false,
hasError: null
}
}
case 'FETCH_DIRECTORY_SUCCESS': {
return {
files: [],
isRequesting: false,
isSuccessful: true,
hasError: null
}
}
case 'FETCH_DIRECTORY_ERROR': {
return {
...state,
isRequesting: false,
isSuccessful: false,
hasError: action.payload
}
}
default:
throw new Error()
}
}
Loading…
Cancel
Save