diff --git a/frontend/specs/screens/home/reducers/homeReducer.spec.js b/frontend/specs/screens/home/reducers/homeReducer.spec.js
index 7eb9288..d042850 100644
--- a/frontend/specs/screens/home/reducers/homeReducer.spec.js
+++ b/frontend/specs/screens/home/reducers/homeReducer.spec.js
@@ -1,4 +1,4 @@
-import { actionCreators, onSuccessful } from '@/shared/base';
+import { actionTypes, onSuccessful } from '@/shared/base';
import { homeReducer } from '@/screens/home/reducers';
describe('home/reducers/homeReducer tests', () => {
@@ -19,7 +19,7 @@ describe('home/reducers/homeReducer tests', () => {
const initialState = { loading: true, reservations: [] };
const action = {
- type: onSuccessful(actionCreators.GET_RESERVATIONS),
+ type: onSuccessful(actionTypes.GET_RESERVATIONS),
response,
};
diff --git a/frontend/specs/screens/home/sagas/cancelReservation.spec.js b/frontend/specs/screens/home/sagas/cancelReservation.spec.js
index c084812..d09a28d 100644
--- a/frontend/specs/screens/home/sagas/cancelReservation.spec.js
+++ b/frontend/specs/screens/home/sagas/cancelReservation.spec.js
@@ -3,7 +3,7 @@ import { call } from 'redux-saga/effects';
import { throwError } from 'redux-saga-test-plan/providers';
import {
- actionCreators,
+ actionTypes,
onCancellation,
onFailure,
onSuccessful,
@@ -18,7 +18,7 @@ describe('cancelReservation Saga', () => {
let scenario;
const action = {
- type: actionCreators.DELETE_RESERVATION,
+ type: actionTypes.DELETE_RESERVATION,
reservationId: 999,
};
const expectedRequestParams = { reservationId: action.reservationId };
@@ -56,13 +56,13 @@ describe('cancelReservation Saga', () => {
[call(confirmation, action.reservationId), true],
])
.put({
- type: onSuccessful(actionCreators.DELETE_RESERVATION),
+ type: onSuccessful(actionTypes.DELETE_RESERVATION),
response: {
data: expectedApiResponse,
},
})
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType: 'success',
message: 'Reservation cancelled.',
})
@@ -73,7 +73,7 @@ describe('cancelReservation Saga', () => {
return scenario
.provide([[call(confirmation, action.reservationId), false]])
.put({
- type: onCancellation(actionCreators.REJECT_CONFIRMATION_MODAL),
+ type: onCancellation(actionTypes.REJECT_CONFIRMATION_MODAL),
})
.silentRun();
});
@@ -98,12 +98,12 @@ describe('cancelReservation Saga', () => {
],
])
.put({
- type: onFailure(actionCreators.DELETE_RESERVATION),
+ type: onFailure(actionTypes.DELETE_RESERVATION),
alertType: 'danger',
message: expectedErrMessage,
})
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType: 'danger',
message: expectedErrMessage,
})
@@ -122,12 +122,12 @@ describe('cancelReservation Saga', () => {
[call(confirmation, action.reservationId), true],
])
.put({
- type: onFailure(actionCreators.DELETE_RESERVATION),
+ type: onFailure(actionTypes.DELETE_RESERVATION),
alertType: 'danger',
message: expectedErrMessage,
})
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType: 'danger',
message: expectedErrMessage,
})
diff --git a/frontend/specs/screens/home/sagas/getAllReservations.spec.js b/frontend/specs/screens/home/sagas/getAllReservations.spec.js
index 5b588b3..1fb3c4e 100644
--- a/frontend/specs/screens/home/sagas/getAllReservations.spec.js
+++ b/frontend/specs/screens/home/sagas/getAllReservations.spec.js
@@ -2,7 +2,7 @@ import { expectSaga } from 'redux-saga-test-plan';
import { call } from 'redux-saga/effects';
import { throwError } from 'redux-saga-test-plan/providers';
-import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
+import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
import { fetchQuery, getExistingReservationsQuery } from '@/shared/graphql';
import getAllReservations from '@/screens/home/sagas/getAllReservations';
@@ -11,7 +11,7 @@ describe('getAllReservations Saga', () => {
let scenario;
const action = {
- type: actionCreators.GET_RESERVATIONS,
+ type: actionTypes.GET_RESERVATIONS,
};
const expectedRequestParams = {};
@@ -77,7 +77,7 @@ describe('getAllReservations Saga', () => {
message: expectedErrMessage,
})
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
@@ -101,7 +101,7 @@ describe('getAllReservations Saga', () => {
message: expectedErrMessage,
})
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
diff --git a/frontend/specs/screens/reservations/reducers/newReducer.spec.js b/frontend/specs/screens/reservations/reducers/newReducer.spec.js
index 1da73d2..ceb2a92 100644
--- a/frontend/specs/screens/reservations/reducers/newReducer.spec.js
+++ b/frontend/specs/screens/reservations/reducers/newReducer.spec.js
@@ -1,4 +1,4 @@
-import { actionCreators, onSuccessful } from '@/shared/base';
+import { actionTypes, onSuccessful } from '@/shared/base';
import { newReducer } from '@/screens/reservations/reducers';
@@ -17,7 +17,7 @@ describe('reservations/reducers/newReducer tests', () => {
const initialState = { loading: true, roomIds: [] };
const action = {
- type: onSuccessful(actionCreators.GET_ROOM_IDS),
+ type: onSuccessful(actionTypes.GET_ROOM_IDS),
response,
};
diff --git a/frontend/specs/screens/reservations/sagas/getAllRoomIds.spec.js b/frontend/specs/screens/reservations/sagas/getAllRoomIds.spec.js
index c70972b..a026b7c 100644
--- a/frontend/specs/screens/reservations/sagas/getAllRoomIds.spec.js
+++ b/frontend/specs/screens/reservations/sagas/getAllRoomIds.spec.js
@@ -2,7 +2,7 @@ import { expectSaga } from 'redux-saga-test-plan';
import { call } from 'redux-saga/effects';
import { throwError } from 'redux-saga-test-plan/providers';
-import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
+import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
import { fetchQuery, getRoomIdsQuery } from '@/shared/graphql';
import getAllRoomIds from '@/screens/reservations/sagas/getAllRoomIds';
@@ -10,7 +10,7 @@ import getAllRoomIds from '@/screens/reservations/sagas/getAllRoomIds';
describe('getAllRoomIds Saga', () => {
let scenario;
- const action = { type: actionCreators.GET_ROOM_IDS };
+ const action = { type: actionTypes.GET_ROOM_IDS };
const expectedRequestParams = {};
const mockRooms = [{ id: 'room1' }, { id: 'room2' }, { id: 'room3' }];
@@ -72,7 +72,7 @@ describe('getAllRoomIds Saga', () => {
message: expectedErrMessage,
})
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
@@ -98,7 +98,7 @@ describe('getAllRoomIds Saga', () => {
message: expectedErrMessage,
})
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
diff --git a/frontend/specs/screens/reservations/sagas/newReservation.spec.js b/frontend/specs/screens/reservations/sagas/newReservation.spec.js
index a1cc4fe..1ea7bed 100644
--- a/frontend/specs/screens/reservations/sagas/newReservation.spec.js
+++ b/frontend/specs/screens/reservations/sagas/newReservation.spec.js
@@ -2,7 +2,7 @@ import { expectSaga } from 'redux-saga-test-plan';
import { call } from 'redux-saga/effects';
import { throwError } from 'redux-saga-test-plan/providers';
-import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
+import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
import { fetchQuery, createReservationMutation } from '@/shared/graphql';
import newReservation from '@/screens/reservations/sagas/newReservation';
@@ -17,7 +17,7 @@ describe('newReservation Saga', () => {
};
const action = {
- type: actionCreators.CREATE_RESERVATION,
+ type: actionTypes.CREATE_RESERVATION,
...input,
};
@@ -50,12 +50,12 @@ describe('newReservation Saga', () => {
],
])
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType: 'success',
message: 'Reservation created.',
})
.put({
- type: onSuccessful(actionCreators.CREATE_RESERVATION),
+ type: onSuccessful(actionTypes.CREATE_RESERVATION),
response: {
data: mockResponse.data.createReservation.reservations,
},
@@ -83,12 +83,12 @@ describe('newReservation Saga', () => {
],
])
.put({
- type: onFailure(actionCreators.CREATE_RESERVATION),
+ type: onFailure(actionTypes.CREATE_RESERVATION),
alertType,
message: expectedErrMessage,
})
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
@@ -113,7 +113,7 @@ describe('newReservation Saga', () => {
message: expectedErrMessage,
})
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType,
message: expectedErrMessage,
})
diff --git a/frontend/specs/shared/base/baseApi.spec.js b/frontend/specs/shared/base/baseApi.spec.js
index 79c7122..4decf28 100644
--- a/frontend/specs/shared/base/baseApi.spec.js
+++ b/frontend/specs/shared/base/baseApi.spec.js
@@ -3,7 +3,7 @@ import { waitFor } from '@testing-library/react';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
-import { actionCreators, createBaseApi } from '@/shared/base';
+import { actionTypes, createBaseApi } from '@/shared/base';
describe('baseApi', () => {
const url = process.env.RESERVATION_API || '';
@@ -36,10 +36,10 @@ describe('baseApi', () => {
await baseApi.get('/test');
await waitFor(() => {
expect(mockStore.dispatch).toHaveBeenCalledWith({
- type: actionCreators.API_REQUEST,
+ type: actionTypes.API_REQUEST,
});
expect(mockStore.dispatch).toHaveBeenCalledWith({
- type: actionCreators.API_REQUEST_DONE,
+ type: actionTypes.API_REQUEST_DONE,
});
});
});
diff --git a/frontend/specs/shared/sagas/handleApiRequestError.spec.js b/frontend/specs/shared/sagas/handleApiRequestError.spec.js
index 316ab64..8fb395e 100644
--- a/frontend/specs/shared/sagas/handleApiRequestError.spec.js
+++ b/frontend/specs/shared/sagas/handleApiRequestError.spec.js
@@ -3,7 +3,7 @@ import { takeLatest } from 'redux-saga/effects';
import { default as sharedSagas } from '../../../src/shared/sagas';
import { handleApiRequestError } from '../../../src/shared/sagas/handleApiRequestError';
-import { actionCreators, } from '../../../src/shared/base';
+import { actionTypes, } from '../../../src/shared/base';
describe('handleApiRequestError Saga', () => {
it('should dispatch SET_ALERT action with error message', () => {
@@ -14,7 +14,7 @@ describe('handleApiRequestError Saga', () => {
return expectSaga(handleApiRequestError, { error })
.put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
message: `Oops! Something went wrong. ${error.name}: ${error.message}`,
alertType: 'danger',
})
@@ -29,7 +29,7 @@ describe('handleApiRequestError Saga', () => {
return expectSaga(sharedSagas)
.provide([
- [takeLatest(actionCreators.API_REQUEST_ERROR, handleApiRequestError), error],
+ [takeLatest(actionTypes.API_REQUEST_ERROR, handleApiRequestError), error],
])
.silentRun();
});
diff --git a/frontend/specs/shared/sagas/handleApiRequestUnauthorized.spec.js b/frontend/specs/shared/sagas/handleApiRequestUnauthorized.spec.js
index bb5ac8f..a85c458 100644
--- a/frontend/specs/shared/sagas/handleApiRequestUnauthorized.spec.js
+++ b/frontend/specs/shared/sagas/handleApiRequestUnauthorized.spec.js
@@ -3,19 +3,19 @@ import { takeLatest } from 'redux-saga/effects';
import { default as sharedSagas } from '../../../src/shared/sagas';
import { handleApiRequestUnauthorized } from '../../../src/shared/sagas/handleApiRequestUnauthorized';
-import { actionCreators } from '../../../src/shared/base';
+import { actionTypes } from '../../../src/shared/base';
describe('handleApiRequestUnauthorized Saga', () => {
it('should dispatch the LOGOUT action', () => {
return expectSaga(handleApiRequestUnauthorized)
- .put({ type: actionCreators.LOGOUT })
+ .put({ type: actionTypes.LOGOUT })
.run();
});
it('should be invoked by latest API_REQUEST_UNAUTHORIZED dispatch', () => {
return expectSaga(sharedSagas)
.provide([
- [takeLatest(actionCreators.API_REQUEST_UNAUTHORIZED, handleApiRequestUnauthorized)],
+ [takeLatest(actionTypes.API_REQUEST_UNAUTHORIZED, handleApiRequestUnauthorized)],
])
.silentRun();
});
diff --git a/frontend/specs/shared/sagas/logout.spec.js b/frontend/specs/shared/sagas/logout.spec.js
index 6cefcb2..c29d0a3 100644
--- a/frontend/specs/shared/sagas/logout.spec.js
+++ b/frontend/specs/shared/sagas/logout.spec.js
@@ -3,14 +3,14 @@ import { takeLatest } from 'redux-saga/effects';
import { default as sharedSagas } from '../../../src/shared/sagas';
import { logout } from '../../../src/shared/sagas/logout';
-import { actionCreators, } from '../../../src/shared/base';
+import { actionTypes, } from '../../../src/shared/base';
describe('logout Saga', () => {
it('should be invoked by latest LOGOUT dispatch', () => {
return expectSaga(sharedSagas)
.provide([
- [takeLatest(actionCreators.LOGOUT, logout),],
+ [takeLatest(actionTypes.LOGOUT, logout),],
])
.silentRun();
});
diff --git a/frontend/specs/shared/sharedReducer.spec.js b/frontend/specs/shared/sharedReducer.spec.js
index ff1e2a7..a06fd4c 100644
--- a/frontend/specs/shared/sharedReducer.spec.js
+++ b/frontend/specs/shared/sharedReducer.spec.js
@@ -1,5 +1,5 @@
import reducer, { initialState } from '@/shared/sharedReducer'; // Replace 'yourReducer' with the actual file path
-import { actionCreators } from '@/shared/base';
+import { actionTypes } from '@/shared/base';
describe('sharedReducer tests', () => {
beforeEach(() => {
@@ -7,7 +7,7 @@ describe('sharedReducer tests', () => {
});
it('should handle API_REQUEST action', () => {
- const action = { type: actionCreators.API_REQUEST };
+ const action = { type: actionTypes.API_REQUEST };
const newState = reducer(initialState, action);
expect(newState.requestInProgress).toBe(true);
@@ -15,7 +15,7 @@ describe('sharedReducer tests', () => {
});
it('should handle API_REQUEST_DONE action', () => {
- const action = { type: actionCreators.API_REQUEST_DONE };
+ const action = { type: actionTypes.API_REQUEST_DONE };
const newState = reducer(initialState, action);
@@ -25,7 +25,7 @@ describe('sharedReducer tests', () => {
it('should handle SET_ALERT action', () => {
const action = {
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
message: 'Sample alert message',
alertType: 'success',
};
@@ -38,7 +38,7 @@ describe('sharedReducer tests', () => {
it('should handle CLEAR_ALERT action', () => {
const action = {
- type: actionCreators.CLEAR_ALERT,
+ type: actionTypes.CLEAR_ALERT,
};
const stateWithAlert = {
@@ -55,7 +55,7 @@ describe('sharedReducer tests', () => {
it('should handle OPEN_CONFIRMATION_MODAL action', () => {
const action = {
- type: actionCreators.OPEN_CONFIRMATION_MODAL,
+ type: actionTypes.OPEN_CONFIRMATION_MODAL,
title: 'Confirmation Title',
message: 'Are you sure?',
text: 'Confirm',
@@ -82,7 +82,7 @@ describe('sharedReducer tests', () => {
it('should handle LOAD_COMPONENT action', () => {
const action = {
- type: actionCreators.LOAD_COMPONENT,
+ type: actionTypes.LOAD_COMPONENT,
};
const newState = reducer(initialState, action);
@@ -93,7 +93,7 @@ describe('sharedReducer tests', () => {
it('should handle COMPONENT_NOT_FOUND action', () => {
const action = {
- type: actionCreators.COMPONENT_NOT_FOUND,
+ type: actionTypes.COMPONENT_NOT_FOUND,
};
const newState = reducer(initialState, action);
diff --git a/frontend/src/configureStore.js b/frontend/src/configureStore.js
index aaac97e..97e55af 100644
--- a/frontend/src/configureStore.js
+++ b/frontend/src/configureStore.js
@@ -4,7 +4,7 @@ import { configureStore } from '@reduxjs/toolkit';
import { createReduxHistoryContext } from 'redux-first-history';
import { createBrowserHistory } from 'history';
-import { actionCreators } from '@/shared/base';
+import { actionTypes } from '@/shared/base';
import rootReducer from './rootReducer';
import rootSaga from './rootSaga';
@@ -20,7 +20,7 @@ const logger = createLogger({
collapsed: true,
predicate: (getState, action) =>
import.meta.env.VITE_NODE_ENV === 'development' &&
- ![actionCreators.API_REQUEST, actionCreators.API_REQUEST_DONE].includes(
+ ![actionTypes.API_REQUEST, actionTypes.API_REQUEST_DONE].includes(
action.type,
),
});
diff --git a/frontend/src/screens/home/index.jsx b/frontend/src/screens/home/index.jsx
index 220887b..6f9e7df 100644
--- a/frontend/src/screens/home/index.jsx
+++ b/frontend/src/screens/home/index.jsx
@@ -2,7 +2,7 @@ import React from 'react';
import { Col, Nav, Row, Tab } from 'react-bootstrap';
import { useSelector } from 'react-redux';
-import { actionCreators, connectComponent } from '@/shared/base';
+import { actionTypes, connectComponent } from '@/shared/base';
import { AlertModal, ConfirmationModal } from '@/shared/components';
import HomeTabs from './tabs';
@@ -81,32 +81,32 @@ const HomeComponent = ({
};
const screen = connectComponent(HomeComponent, {
- componentName: actionCreators.HOME_COMPONENT,
+ componentName: actionTypes.HOME_COMPONENT,
state: (state) => state?.site?.home?.reservations ?? [],
load: {
- reservations: () => ({ type: actionCreators.GET_RESERVATIONS }),
+ reservations: () => ({ type: actionTypes.GET_RESERVATIONS }),
},
- dispatch: (dispatch) => ({
- handleCloseAlert: () => dispatch({ type: actionCreators.CLEAR_ALERT }),
+ actionCreators: (dispatch) => ({
+ handleCloseAlert: () => dispatch({ type: actionTypes.CLEAR_ALERT }),
handleConfirmAction: () =>
- dispatch({ type: actionCreators.CONFIRM_CONFIRMATION_MODAL }),
+ dispatch({ type: actionTypes.CONFIRM_CONFIRMATION_MODAL }),
handleRejectAction: () =>
- dispatch({ type: actionCreators.REJECT_CONFIRMATION_MODAL }),
+ dispatch({ type: actionTypes.REJECT_CONFIRMATION_MODAL }),
cancelReservation: (id) =>
dispatch({
- type: actionCreators.DELETE_RESERVATION,
+ type: actionTypes.DELETE_RESERVATION,
reservationId: parseInt(id),
}),
editReservation: (id) =>
dispatch({
- type: actionCreators.EDIT_RESERVATION_COMPONENT,
+ type: actionTypes.EDIT_RESERVATION_COMPONENT,
reservationId: parseInt(id),
}),
newReservation: () => {
- dispatch({ type: actionCreators.NEW_RESERVATION_COMPONENT });
+ dispatch({ type: actionTypes.NEW_RESERVATION_COMPONENT });
},
showReservation: (id) =>
- dispatch({ type: actionCreators.SHOW_RESERVATION_COMPONENT, id }),
+ dispatch({ type: actionTypes.SHOW_RESERVATION_COMPONENT, id }),
}),
});
diff --git a/frontend/src/screens/home/reducers/home.js b/frontend/src/screens/home/reducers/home.js
index 94d1a66..7c0cca9 100644
--- a/frontend/src/screens/home/reducers/home.js
+++ b/frontend/src/screens/home/reducers/home.js
@@ -1,5 +1,5 @@
import {
- actionCreators,
+ actionTypes,
createComponentReducer,
onSuccessful,
} from '@/shared/base';
@@ -10,7 +10,7 @@ const initialState = {
};
const actionHandlers = {
- [onSuccessful(actionCreators.GET_RESERVATIONS)]: (state, action) => {
+ [onSuccessful(actionTypes.GET_RESERVATIONS)]: (state, action) => {
const reservations = action?.response?.data || [];
return {
...state,
@@ -18,7 +18,7 @@ const actionHandlers = {
loading: false,
};
},
- [onSuccessful(actionCreators.DELETE_RESERVATION)]: (state, action) => {
+ [onSuccessful(actionTypes.DELETE_RESERVATION)]: (state, action) => {
const reservations = action?.response?.data || [];
return {
...state,
@@ -29,7 +29,7 @@ const actionHandlers = {
};
const reducer = createComponentReducer(
- actionCreators.HOME_COMPONENT,
+ actionTypes.HOME_COMPONENT,
initialState,
actionHandlers,
);
diff --git a/frontend/src/screens/home/sagas/cancelReservation.js b/frontend/src/screens/home/sagas/cancelReservation.js
index 25dba49..c22b0e0 100644
--- a/frontend/src/screens/home/sagas/cancelReservation.js
+++ b/frontend/src/screens/home/sagas/cancelReservation.js
@@ -1,7 +1,7 @@
import { call, take, takeLatest, put, race } from 'redux-saga/effects';
import {
- actionCreators,
+ actionTypes,
onCancellation,
onFailure,
onSuccessful,
@@ -10,7 +10,7 @@ import { fetchQuery, deleteReservationMutation } from '@/shared/graphql';
export function* confirmation(reservationId) {
yield put({
- type: actionCreators.OPEN_CONFIRMATION_MODAL,
+ type: actionTypes.OPEN_CONFIRMATION_MODAL,
title: 'Are you sure you?',
message: `You will not be able to reverse cancellation (id: ${reservationId}).`,
cancellationText: 'Cancel',
@@ -18,8 +18,8 @@ export function* confirmation(reservationId) {
});
const { confirm } = yield race({
- confirm: take(actionCreators.CONFIRM_CONFIRMATION_MODAL),
- no: take(actionCreators.REJECT_CONFIRMATION_MODAL),
+ confirm: take(actionTypes.CONFIRM_CONFIRMATION_MODAL),
+ no: take(actionTypes.REJECT_CONFIRMATION_MODAL),
});
return confirm;
@@ -30,7 +30,7 @@ export function* cancelReservation({ reservationId }) {
const confirm = yield call(confirmation, reservationId);
if (!confirm) {
yield put({
- type: onCancellation(actionCreators.REJECT_CONFIRMATION_MODAL),
+ type: onCancellation(actionTypes.REJECT_CONFIRMATION_MODAL),
});
return;
} else {
@@ -50,12 +50,12 @@ export function* cancelReservation({ reservationId }) {
else {
const { reservations } = data?.deleteReservation || [];
yield put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType: 'success',
message: 'Reservation cancelled.',
});
yield put({
- type: onSuccessful(actionCreators.DELETE_RESERVATION),
+ type: onSuccessful(actionTypes.DELETE_RESERVATION),
response: {
data: reservations,
},
@@ -65,12 +65,12 @@ export function* cancelReservation({ reservationId }) {
} catch (ex) {
const message = `Could not delete reservation. ${ex}`;
yield put({
- type: onFailure(actionCreators.DELETE_RESERVATION),
+ type: onFailure(actionTypes.DELETE_RESERVATION),
alertType: 'danger',
message,
});
yield put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType: 'danger',
message,
});
@@ -78,7 +78,7 @@ export function* cancelReservation({ reservationId }) {
}
function* saga() {
- yield takeLatest(actionCreators.DELETE_RESERVATION, cancelReservation);
+ yield takeLatest(actionTypes.DELETE_RESERVATION, cancelReservation);
}
export default saga;
diff --git a/frontend/src/screens/home/sagas/getAllReservations.js b/frontend/src/screens/home/sagas/getAllReservations.js
index deeb2c0..c05eb6f 100644
--- a/frontend/src/screens/home/sagas/getAllReservations.js
+++ b/frontend/src/screens/home/sagas/getAllReservations.js
@@ -1,6 +1,6 @@
import { call, takeLatest, put } from 'redux-saga/effects';
-import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
+import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
import { fetchQuery, getExistingReservationsQuery } from '@/shared/graphql';
export function* getAllReservations() {
@@ -21,7 +21,7 @@ export function* getAllReservations() {
else {
const { reservations } = data?.getAllReservations || [];
yield put({
- type: onSuccessful(actionCreators.GET_RESERVATIONS),
+ type: onSuccessful(actionTypes.GET_RESERVATIONS),
response: {
data: reservations,
},
@@ -30,12 +30,12 @@ export function* getAllReservations() {
} catch (ex) {
const message = `Could not retrieve reservations. ${ex}`;
yield put({
- type: onFailure(actionCreators.GET_RESERVATIONS),
+ type: onFailure(actionTypes.GET_RESERVATIONS),
alertType: 'danger',
message,
});
yield put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType: 'danger',
message,
});
@@ -43,7 +43,7 @@ export function* getAllReservations() {
}
function* saga() {
- yield takeLatest(actionCreators.GET_RESERVATIONS, getAllReservations);
+ yield takeLatest(actionTypes.GET_RESERVATIONS, getAllReservations);
}
export default saga;
diff --git a/frontend/src/screens/reservations/new.jsx b/frontend/src/screens/reservations/new.jsx
index 533e4ce..03d0b9d 100644
--- a/frontend/src/screens/reservations/new.jsx
+++ b/frontend/src/screens/reservations/new.jsx
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { useSelector } from 'react-redux';
import { useNavigate } from 'react-router-dom';
-import { connectComponent, actionCreators } from '@/shared/base';
+import { connectComponent, actionTypes } from '@/shared/base';
import AlertModal from '@/shared/components/AlertModal';
const NewReservationComponent = ({
@@ -121,15 +121,15 @@ const NewReservationComponent = ({
};
const screen = connectComponent(NewReservationComponent, {
- componentName: actionCreators.NEW_RESERVATION_COMPONENT,
+ componentName: actionTypes.NEW_RESERVATION_COMPONENT,
state: (state) => state?.site?.newReservations?.roomIds,
load: {
- roomIds: () => ({ type: actionCreators.GET_ROOM_IDS }),
+ roomIds: () => ({ type: actionTypes.GET_ROOM_IDS }),
},
- dispatch: (dispatch) => ({
+ actionCreators: (dispatch) => ({
createReservation: (formData) =>
- dispatch({ type: actionCreators.CREATE_RESERVATION, ...formData }),
- handleCloseAlert: () => dispatch({ type: actionCreators.CLEAR_ALERT }),
+ dispatch({ type: actionTypes.CREATE_RESERVATION, ...formData }),
+ handleCloseAlert: () => dispatch({ type: actionTypes.CLEAR_ALERT }),
}),
});
diff --git a/frontend/src/screens/reservations/reducers/edit.js b/frontend/src/screens/reservations/reducers/edit.js
index dcc64ea..8f21f49 100644
--- a/frontend/src/screens/reservations/reducers/edit.js
+++ b/frontend/src/screens/reservations/reducers/edit.js
@@ -1,4 +1,4 @@
-import { actionCreators, createComponentReducer } from '@/shared/base';
+import { actionTypes, createComponentReducer } from '@/shared/base';
const initialState = {
loading: true,
@@ -7,7 +7,7 @@ const initialState = {
const actionHandlers = {};
const reducer = createComponentReducer(
- actionCreators.EDIT_RESERVATION_COMPONENT,
+ actionTypes.EDIT_RESERVATION_COMPONENT,
initialState,
actionHandlers,
);
diff --git a/frontend/src/screens/reservations/reducers/new.js b/frontend/src/screens/reservations/reducers/new.js
index 64811f8..98158cd 100644
--- a/frontend/src/screens/reservations/reducers/new.js
+++ b/frontend/src/screens/reservations/reducers/new.js
@@ -1,5 +1,5 @@
import {
- actionCreators,
+ actionTypes,
createComponentReducer,
onSuccessful,
} from '@/shared/base';
@@ -10,7 +10,7 @@ const initialState = {
};
const actionHandlers = {
- [onSuccessful(actionCreators.GET_ROOM_IDS)]: (state, action) => {
+ [onSuccessful(actionTypes.GET_ROOM_IDS)]: (state, action) => {
const roomIds = action?.response?.data || [];
return {
...state,
@@ -18,7 +18,7 @@ const actionHandlers = {
loading: false,
};
},
- [onSuccessful(actionCreators.CREATE_RESERVATION)]: (state, action) => {
+ [onSuccessful(actionTypes.CREATE_RESERVATION)]: (state, action) => {
const reservations = action?.response?.data || [];
return {
...state,
@@ -29,7 +29,7 @@ const actionHandlers = {
};
const reducer = createComponentReducer(
- actionCreators.NEW_RESERVATION_COMPONENT,
+ actionTypes.NEW_RESERVATION_COMPONENT,
initialState,
actionHandlers,
);
diff --git a/frontend/src/screens/reservations/reducers/show.js b/frontend/src/screens/reservations/reducers/show.js
index de917fe..c635f3f 100644
--- a/frontend/src/screens/reservations/reducers/show.js
+++ b/frontend/src/screens/reservations/reducers/show.js
@@ -1,4 +1,4 @@
-import { actionCreators, createComponentReducer } from '@/shared/base';
+import { actionTypes, createComponentReducer } from '@/shared/base';
const initialState = {
loading: true,
@@ -7,7 +7,7 @@ const initialState = {
const actionHandlers = {};
const reducer = createComponentReducer(
- actionCreators.SHOW_RESERVATION_COMPONENT,
+ actionTypes.SHOW_RESERVATION_COMPONENT,
initialState,
actionHandlers,
);
diff --git a/frontend/src/screens/reservations/sagas/getAllRoomIds.js b/frontend/src/screens/reservations/sagas/getAllRoomIds.js
index 87890bc..a77b8e5 100644
--- a/frontend/src/screens/reservations/sagas/getAllRoomIds.js
+++ b/frontend/src/screens/reservations/sagas/getAllRoomIds.js
@@ -1,6 +1,6 @@
import { call, takeLatest, put } from 'redux-saga/effects';
-import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
+import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
import { fetchQuery, getRoomIdsQuery } from '@/shared/graphql';
export function* getAllRoomIds() {
@@ -19,7 +19,7 @@ export function* getAllRoomIds() {
const roomIds = rooms?.map((room) => room.id);
yield put({
- type: onSuccessful(actionCreators.GET_ROOM_IDS),
+ type: onSuccessful(actionTypes.GET_ROOM_IDS),
response: {
data: roomIds,
},
@@ -28,12 +28,12 @@ export function* getAllRoomIds() {
} catch (ex) {
const message = `Could not retrieve room identifiers: ${ex}`;
yield put({
- type: onFailure(actionCreators.GET_ROOM_IDS),
+ type: onFailure(actionTypes.GET_ROOM_IDS),
alertType: 'danger',
message,
});
yield put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType: 'danger',
message,
});
@@ -41,7 +41,7 @@ export function* getAllRoomIds() {
}
function* saga() {
- yield takeLatest(actionCreators.GET_ROOM_IDS, getAllRoomIds);
+ yield takeLatest(actionTypes.GET_ROOM_IDS, getAllRoomIds);
}
export default saga;
diff --git a/frontend/src/screens/reservations/sagas/newReservation.js b/frontend/src/screens/reservations/sagas/newReservation.js
index 0ba08d3..6ff53d7 100644
--- a/frontend/src/screens/reservations/sagas/newReservation.js
+++ b/frontend/src/screens/reservations/sagas/newReservation.js
@@ -1,6 +1,6 @@
import { call, put, takeLatest } from 'redux-saga/effects';
-import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
+import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
import { fetchQuery, createReservationMutation } from '@/shared/graphql';
export function* newReservation({ room_id, checkin_date, checkout_date }) {
@@ -17,12 +17,12 @@ export function* newReservation({ room_id, checkin_date, checkout_date }) {
else {
const { reservations } = data?.createReservation || [];
yield put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType: 'success',
message: 'Reservation created.',
});
yield put({
- type: onSuccessful(actionCreators.CREATE_RESERVATION),
+ type: onSuccessful(actionTypes.CREATE_RESERVATION),
response: {
data: reservations,
},
@@ -31,12 +31,12 @@ export function* newReservation({ room_id, checkin_date, checkout_date }) {
} catch (ex) {
const message = `Could not create reservation. ${ex}`;
yield put({
- type: onFailure(actionCreators.CREATE_RESERVATION),
+ type: onFailure(actionTypes.CREATE_RESERVATION),
alertType: 'danger',
message,
});
yield put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
alertType: 'danger',
message,
});
@@ -44,7 +44,7 @@ export function* newReservation({ room_id, checkin_date, checkout_date }) {
}
export function* saga() {
- yield takeLatest(actionCreators.CREATE_RESERVATION, newReservation);
+ yield takeLatest(actionTypes.CREATE_RESERVATION, newReservation);
}
export default saga;
diff --git a/frontend/src/shared/base/actionCreators.js b/frontend/src/shared/base/actionTypes.js
similarity index 99%
rename from frontend/src/shared/base/actionCreators.js
rename to frontend/src/shared/base/actionTypes.js
index 7ea34c1..97c5fb9 100644
--- a/frontend/src/shared/base/actionCreators.js
+++ b/frontend/src/shared/base/actionTypes.js
@@ -1,4 +1,4 @@
-export const actionCreators = {
+export const actionTypes = {
// Component actions
LOAD_COMPONENT: 'shared/LOAD_COMPONENT',
COMPONENT_NOT_FOUND: 'shared/COMPONENT_NOT_FOUND',
diff --git a/frontend/src/shared/base/baseApi.js b/frontend/src/shared/base/baseApi.js
index dfa00d3..be0f256 100644
--- a/frontend/src/shared/base/baseApi.js
+++ b/frontend/src/shared/base/baseApi.js
@@ -1,6 +1,6 @@
import axios from 'axios';
-import { actionCreators } from '@/shared/base';
+import { actionTypes } from '@/shared/base';
let instance = null;
@@ -16,25 +16,25 @@ const createInstance = (url, token) => {
};
const handleRequest = (config, store) => {
- store.dispatch({ type: actionCreators.API_REQUEST });
+ store.dispatch({ type: actionTypes.API_REQUEST });
return config;
};
const handleRequestError = (error, store) => {
- store.dispatch({ type: actionCreators.API_REQUEST_ERROR, error });
+ store.dispatch({ type: actionTypes.API_REQUEST_ERROR, error });
return Promise.reject(error);
};
const handleResponse = (response, store) => {
- store.dispatch({ type: actionCreators.API_REQUEST_DONE });
+ store.dispatch({ type: actionTypes.API_REQUEST_DONE });
return response?.data || response;
};
const handleResponseError = (error, store) => {
const { message, name } = error;
- store.dispatch({ type: actionCreators.API_REQUEST_DONE });
+ store.dispatch({ type: actionTypes.API_REQUEST_DONE });
store.dispatch({
- type: actionCreators.API_REQUEST_ERROR,
+ type: actionTypes.API_REQUEST_ERROR,
error: { message, name },
});
return Promise.reject(error);
diff --git a/frontend/src/shared/base/connectComponent.jsx b/frontend/src/shared/base/connectComponent.jsx
index 0fdffba..e7fb0b7 100644
--- a/frontend/src/shared/base/connectComponent.jsx
+++ b/frontend/src/shared/base/connectComponent.jsx
@@ -6,7 +6,7 @@ import { useLoadComponent } from '@/shared/hooks';
/*
type Config = {
state: (state: any, ownProps: any) => object;
- dispatch?: (dispatch: Redux.Dispatch) => object;
+ actionCreators?: (dispatch: Redux.Dispatch) => object;
componentName: string;
load?: object;
};
@@ -35,7 +35,9 @@ export const connectComponent = (WrappedComponent, config) => {
};
};
const mapDispatchToProps = (dispatch) => {
- const dispatchFromConfig = config.dispatch ? config.dispatch(dispatch) : {};
+ const dispatchFromConfig = config.actionCreators
+ ? config.actionCreators(dispatch)
+ : {};
dispatchFromConfig.getDispatch = () => dispatch;
diff --git a/frontend/src/shared/base/index.js b/frontend/src/shared/base/index.js
index 0b11a66..f576ab2 100644
--- a/frontend/src/shared/base/index.js
+++ b/frontend/src/shared/base/index.js
@@ -1,4 +1,4 @@
-export { actionCreators } from './actionCreators';
+export { actionTypes } from './actionTypes';
export { connectComponent } from './connectComponent';
export { createBaseApi, getBaseApi } from './baseApi';
export { createComponentReducer } from './createComponentReducer';
diff --git a/frontend/src/shared/components/Loading.jsx b/frontend/src/shared/components/Loading.jsx
index 17d8c3d..e562fc7 100644
--- a/frontend/src/shared/components/Loading.jsx
+++ b/frontend/src/shared/components/Loading.jsx
@@ -2,7 +2,9 @@ import React from 'react';
import { Image } from 'react-bootstrap';
const Loading = ({ width = 99, height = 99 }) => {
- return ;
+ return (
+
+ );
};
export default Loading;
diff --git a/frontend/src/shared/sagas/handleApiRequestError.js b/frontend/src/shared/sagas/handleApiRequestError.js
index fd99c8b..99c55c9 100644
--- a/frontend/src/shared/sagas/handleApiRequestError.js
+++ b/frontend/src/shared/sagas/handleApiRequestError.js
@@ -1,17 +1,17 @@
import { put, takeLatest } from 'redux-saga/effects';
-import { actionCreators } from '../base';
+import { actionTypes } from '../base';
export function* handleApiRequestError({ error }) {
yield put({
- type: actionCreators.SET_ALERT,
+ type: actionTypes.SET_ALERT,
message: `Oops! Something went wrong. ${error?.name}: ${error?.message}`,
alertType: 'danger',
});
}
function* saga() {
- yield takeLatest(actionCreators.API_REQUEST_ERROR, handleApiRequestError);
+ yield takeLatest(actionTypes.API_REQUEST_ERROR, handleApiRequestError);
}
export default saga;
diff --git a/frontend/src/shared/sagas/handleApiRequestUnauthorized.js b/frontend/src/shared/sagas/handleApiRequestUnauthorized.js
index 28fc225..1033252 100644
--- a/frontend/src/shared/sagas/handleApiRequestUnauthorized.js
+++ b/frontend/src/shared/sagas/handleApiRequestUnauthorized.js
@@ -1,14 +1,14 @@
import { put, takeLatest } from 'redux-saga/effects';
-import { actionCreators } from '../base';
+import { actionTypes } from '../base';
export function* handleApiRequestUnauthorized() {
- yield put({ type: actionCreators.LOGOUT });
+ yield put({ type: actionTypes.LOGOUT });
}
function* handleApiRequestUnauthorizedSaga() {
yield takeLatest(
- actionCreators.API_REQUEST_UNAUTHORIZED,
+ actionTypes.API_REQUEST_UNAUTHORIZED,
handleApiRequestUnauthorized,
);
}
diff --git a/frontend/src/shared/sagas/loadComponent.js b/frontend/src/shared/sagas/loadComponent.js
index 39c71b7..7efef9a 100644
--- a/frontend/src/shared/sagas/loadComponent.js
+++ b/frontend/src/shared/sagas/loadComponent.js
@@ -1,6 +1,6 @@
import { put, takeLatest } from 'redux-saga/effects';
-import { actionCreators } from '../base';
+import { actionTypes } from '../base';
export function* loadComponent({ componentName }) {
yield put({
@@ -9,7 +9,7 @@ export function* loadComponent({ componentName }) {
}
function* saga() {
- yield takeLatest(actionCreators.LOAD_COMPONENT, loadComponent);
+ yield takeLatest(actionTypes.LOAD_COMPONENT, loadComponent);
}
export default saga;
diff --git a/frontend/src/shared/sagas/logout.js b/frontend/src/shared/sagas/logout.js
index 3ca2e07..5795fad 100644
--- a/frontend/src/shared/sagas/logout.js
+++ b/frontend/src/shared/sagas/logout.js
@@ -1,13 +1,13 @@
import { put, takeLatest } from 'redux-saga/effects';
-import { actionCreators } from '@/shared/base';
+import { actionTypes } from '@/shared/base';
export function* logout() {
- yield put({ type: actionCreators.CLEAR_USER_DATA });
+ yield put({ type: actionTypes.CLEAR_USER_DATA });
}
function* saga() {
- yield takeLatest(actionCreators.LOGOUT, logout);
+ yield takeLatest(actionTypes.LOGOUT, logout);
}
export default saga;
diff --git a/frontend/src/shared/sagas/unloadComponent.js b/frontend/src/shared/sagas/unloadComponent.js
index 84c3c08..e82c2ea 100644
--- a/frontend/src/shared/sagas/unloadComponent.js
+++ b/frontend/src/shared/sagas/unloadComponent.js
@@ -1,6 +1,6 @@
import { put, takeLatest } from 'redux-saga/effects';
-import { actionCreators } from '../base';
+import { actionTypes } from '../base';
export function* unloadComponent({ componentName }) {
yield put({
@@ -9,7 +9,7 @@ export function* unloadComponent({ componentName }) {
}
function* saga() {
- yield takeLatest(actionCreators.UNLOAD_COMPONENT, unloadComponent);
+ yield takeLatest(actionTypes.UNLOAD_COMPONENT, unloadComponent);
}
export default saga;
diff --git a/frontend/src/shared/sharedReducer.js b/frontend/src/shared/sharedReducer.js
index e1f06e2..88e9454 100644
--- a/frontend/src/shared/sharedReducer.js
+++ b/frontend/src/shared/sharedReducer.js
@@ -1,4 +1,4 @@
-import { actionCreators, onSuccessful } from './base';
+import { actionTypes, onSuccessful } from './base';
export const initialState = {
requestInProgress: false,
@@ -19,7 +19,7 @@ export const initialState = {
export default (state = initialState, action) => {
switch (action.type) {
// api requests
- case actionCreators.API_REQUEST:
+ case actionTypes.API_REQUEST:
const incCount = state.count + 1;
return {
@@ -27,8 +27,8 @@ export default (state = initialState, action) => {
count: incCount,
requestInProgress: incCount > 0,
};
- case actionCreators.API_REQUEST_DONE:
- case actionCreators.API_REQUEST_ERROR:
+ case actionTypes.API_REQUEST_DONE:
+ case actionTypes.API_REQUEST_ERROR:
const decCount = state.count - 1;
return {
@@ -38,20 +38,20 @@ export default (state = initialState, action) => {
};
// alerts
- case actionCreators.SET_ALERT:
+ case actionTypes.SET_ALERT:
return {
...state,
alertMessage: action.message,
alertType: action.alertType,
};
- case actionCreators.CLEAR_ALERT:
+ case actionTypes.CLEAR_ALERT:
return {
...state,
alertMessage: null,
alertType: null,
};
// confirmation
- case actionCreators.OPEN_CONFIRMATION_MODAL:
+ case actionTypes.OPEN_CONFIRMATION_MODAL:
return {
...state,
confirmationModalIsOpen: true,
@@ -61,9 +61,9 @@ export default (state = initialState, action) => {
confirmationModalCancellationText: action.cancellationText,
confirmationModalButtonStyle: action.buttonStyle,
};
- case actionCreators.CLOSE_CONFIRMATION_MODAL:
- case actionCreators.CONFIRM_CONFIRMATION_MODAL:
- case actionCreators.REJECT_CONFIRMATION_MODAL:
+ case actionTypes.CLOSE_CONFIRMATION_MODAL:
+ case actionTypes.CONFIRM_CONFIRMATION_MODAL:
+ case actionTypes.REJECT_CONFIRMATION_MODAL:
return {
...state,
confirmationModalIsOpen: false,
@@ -75,19 +75,19 @@ export default (state = initialState, action) => {
};
// common component actions
- case actionCreators.LOAD_COMPONENT:
+ case actionTypes.LOAD_COMPONENT:
return {
...state,
componentLoading: true,
componentNotFound: false,
};
- case actionCreators.COMPONENT_NOT_FOUND:
+ case actionTypes.COMPONENT_NOT_FOUND:
return {
...state,
componentLoading: false,
componentNotFound: true,
};
- case onSuccessful(actionCreators.LOAD_COMPONENT):
+ case onSuccessful(actionTypes.LOAD_COMPONENT):
return {
...state,
componentLoading: false,