26 lines
642 B
TypeScript
26 lines
642 B
TypeScript
import { createReducer } from '@reduxjs/toolkit';
|
|
import { submitReview } from './thunk';
|
|
|
|
export interface OrderDetailsState {
|
|
loading: boolean;
|
|
error: string | null;
|
|
}
|
|
|
|
const initialState: OrderDetailsState = {
|
|
loading: false,
|
|
error: null,
|
|
};
|
|
|
|
export const orderDetailsReducer = createReducer(initialState, builder => {
|
|
builder.addCase(submitReview.pending, state => {
|
|
state.loading = true;
|
|
});
|
|
builder.addCase(submitReview.fulfilled, state => {
|
|
state.loading = false;
|
|
});
|
|
builder.addCase(submitReview.rejected, (state, action) => {
|
|
state.loading = false;
|
|
state.error = action.payload as string;
|
|
});
|
|
});
|