Skip to content

Commit

Permalink
updated reducer files
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-jad-alhak committed Jan 26, 2025
1 parent 403c720 commit 4816871
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const ReactUseReducerHookBasic: React.FC<IReactUseReducerHookBasicProps> = (prop
const [state, dispatch] = React.useReducer(listReducer, initialState);

React.useEffect(() => {
console.log('ReactUseReducerHookBasic: useEffect');

if (!isConfigured) return;

const loadItems = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ export const ActionTypes = {
FETCH_START: 'FETCH_START',
FETCH_SUCCESS: 'FETCH_SUCCESS',
FETCH_ERROR: 'FETCH_ERROR',
WEB_PART_NOT_CONFIGURED: 'WEB_PART_NOT_CONFIGURED',
SET_CONFIGURED: 'SET_CONFIGURED'
} as const;

Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,6 @@ export const listReducer = (state: IListState, action: ListAction): IListState =
error: action.payload, // string
};

case ActionTypes.WEB_PART_NOT_CONFIGURED:
// Set loading to false and update the error message for configuration issues
return {
...state,
loading: false,
error: action.payload,
};

case ActionTypes.SET_CONFIGURED:
// Update the isConfigured state
return {
...state,
isConfigured: action.payload,
};

default:
// Log an error for unknown actions
Logger.write(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ export type ListAction =
| { type: typeof ActionTypes.FETCH_START }
| { type: typeof ActionTypes.FETCH_SUCCESS; payload: any[] }
| { type: typeof ActionTypes.FETCH_ERROR; payload: string }
| { type: typeof ActionTypes.WEB_PART_NOT_CONFIGURED; payload: string }
| { type: typeof ActionTypes.SET_CONFIGURED; payload: boolean };


0 comments on commit 4816871

Please sign in to comment.