Skip to content

Commit 67f3f6e

Browse files
authored
Merge pull request #18 from WillSams/refactor/rename-actionTypes-to-actionCreators
Refactor - Re-name "actionTypes" to "actionCreators"
2 parents a5b01bb + 45291e8 commit 67f3f6e

33 files changed

+137
-142
lines changed

frontend/.eslintrc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"plugin:eslint-comments/recommended",
55
"plugin:react/jsx-runtime"
66
],
7-
"plugins": [ "eslint-comments", "react", "react-refresh" ],
7+
"plugins": [ "eslint-comments", "react" ],
88
"root": true,
99
"env": { "browser": true, "es2020": true },
1010
"parserOptions": {
@@ -17,10 +17,6 @@
1717
"react/jsx-uses-react": "error",
1818
"react/jsx-uses-vars": "error",
1919
"react/jsx-no-target-blank": "off",
20-
"react-refresh/only-export-components": [
21-
"warn",
22-
{ "allowConstantExport": true },
23-
],
2420
"explicit-function-return-type": "off",
2521
"strict-boolean-expressions": "off",
2622
"no-floating-promises": "off",

frontend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"eslint": "^8.23.0",
4646
"eslint-plugin-eslint-comments": "^3.2.0",
4747
"eslint-plugin-react": "^7.33.2",
48-
"eslint-plugin-react-refresh": "^0.4.5",
4948
"identity-obj-proxy": "^3.0.0",
5049
"jest": "^29.7.0",
5150
"jest-environment-jsdom": "^29.7.0",

frontend/specs/screens/home/reducers/homeReducer.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { actionTypes, onSuccessful } from '@/shared/base';
1+
import { actionCreators, onSuccessful } from '@/shared/base';
22
import { homeReducer } from '@/screens/home/reducers';
33

44
describe('home/reducers/homeReducer tests', () => {
@@ -19,7 +19,7 @@ describe('home/reducers/homeReducer tests', () => {
1919
const initialState = { loading: true, reservations: [] };
2020

2121
const action = {
22-
type: onSuccessful(actionTypes.GET_RESERVATIONS),
22+
type: onSuccessful(actionCreators.GET_RESERVATIONS),
2323
response,
2424
};
2525

frontend/specs/screens/home/sagas/cancelReservation.spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { call } from 'redux-saga/effects';
33
import { throwError } from 'redux-saga-test-plan/providers';
44

55
import {
6-
actionTypes,
6+
actionCreators,
77
onCancellation,
88
onFailure,
99
onSuccessful,
@@ -18,7 +18,7 @@ describe('cancelReservation Saga', () => {
1818
let scenario;
1919

2020
const action = {
21-
type: actionTypes.DELETE_RESERVATION,
21+
type: actionCreators.DELETE_RESERVATION,
2222
reservationId: 999,
2323
};
2424
const expectedRequestParams = { reservationId: action.reservationId };
@@ -56,13 +56,13 @@ describe('cancelReservation Saga', () => {
5656
[call(confirmation, action.reservationId), true],
5757
])
5858
.put({
59-
type: onSuccessful(actionTypes.DELETE_RESERVATION),
59+
type: onSuccessful(actionCreators.DELETE_RESERVATION),
6060
response: {
6161
data: expectedApiResponse,
6262
},
6363
})
6464
.put({
65-
type: actionTypes.SET_ALERT,
65+
type: actionCreators.SET_ALERT,
6666
alertType: 'success',
6767
message: 'Reservation cancelled.',
6868
})
@@ -73,7 +73,7 @@ describe('cancelReservation Saga', () => {
7373
return scenario
7474
.provide([[call(confirmation, action.reservationId), false]])
7575
.put({
76-
type: onCancellation(actionTypes.REJECT_CONFIRMATION_MODAL),
76+
type: onCancellation(actionCreators.REJECT_CONFIRMATION_MODAL),
7777
})
7878
.silentRun();
7979
});
@@ -98,12 +98,12 @@ describe('cancelReservation Saga', () => {
9898
],
9999
])
100100
.put({
101-
type: onFailure(actionTypes.DELETE_RESERVATION),
101+
type: onFailure(actionCreators.DELETE_RESERVATION),
102102
alertType: 'danger',
103103
message: expectedErrMessage,
104104
})
105105
.put({
106-
type: actionTypes.SET_ALERT,
106+
type: actionCreators.SET_ALERT,
107107
alertType: 'danger',
108108
message: expectedErrMessage,
109109
})
@@ -122,12 +122,12 @@ describe('cancelReservation Saga', () => {
122122
[call(confirmation, action.reservationId), true],
123123
])
124124
.put({
125-
type: onFailure(actionTypes.DELETE_RESERVATION),
125+
type: onFailure(actionCreators.DELETE_RESERVATION),
126126
alertType: 'danger',
127127
message: expectedErrMessage,
128128
})
129129
.put({
130-
type: actionTypes.SET_ALERT,
130+
type: actionCreators.SET_ALERT,
131131
alertType: 'danger',
132132
message: expectedErrMessage,
133133
})

frontend/specs/screens/home/sagas/getAllReservations.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expectSaga } from 'redux-saga-test-plan';
22
import { call } from 'redux-saga/effects';
33
import { throwError } from 'redux-saga-test-plan/providers';
44

5-
import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
5+
import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
66
import { fetchQuery, getExistingReservationsQuery } from '@/shared/graphql';
77

88
import getAllReservations from '@/screens/home/sagas/getAllReservations';
@@ -11,7 +11,7 @@ describe('getAllReservations Saga', () => {
1111
let scenario;
1212

1313
const action = {
14-
type: actionTypes.GET_RESERVATIONS,
14+
type: actionCreators.GET_RESERVATIONS,
1515
};
1616
const expectedRequestParams = {};
1717

@@ -77,7 +77,7 @@ describe('getAllReservations Saga', () => {
7777
message: expectedErrMessage,
7878
})
7979
.put({
80-
type: actionTypes.SET_ALERT,
80+
type: actionCreators.SET_ALERT,
8181
alertType,
8282
message: expectedErrMessage,
8383
})
@@ -101,7 +101,7 @@ describe('getAllReservations Saga', () => {
101101
message: expectedErrMessage,
102102
})
103103
.put({
104-
type: actionTypes.SET_ALERT,
104+
type: actionCreators.SET_ALERT,
105105
alertType,
106106
message: expectedErrMessage,
107107
})

frontend/specs/screens/reservations/reducers/newReducer.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { actionTypes, onSuccessful } from '@/shared/base';
1+
import { actionCreators, onSuccessful } from '@/shared/base';
22

33
import { newReducer } from '@/screens/reservations/reducers';
44

@@ -17,7 +17,7 @@ describe('reservations/reducers/newReducer tests', () => {
1717
const initialState = { loading: true, roomIds: [] };
1818

1919
const action = {
20-
type: onSuccessful(actionTypes.GET_ROOM_IDS),
20+
type: onSuccessful(actionCreators.GET_ROOM_IDS),
2121
response,
2222
};
2323

frontend/specs/screens/reservations/sagas/getAllRoomIds.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { expectSaga } from 'redux-saga-test-plan';
22
import { call } from 'redux-saga/effects';
33
import { throwError } from 'redux-saga-test-plan/providers';
44

5-
import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
5+
import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
66
import { fetchQuery, getRoomIdsQuery } from '@/shared/graphql';
77

88
import getAllRoomIds from '@/screens/reservations/sagas/getAllRoomIds';
99

1010
describe('getAllRoomIds Saga', () => {
1111
let scenario;
1212

13-
const action = { type: actionTypes.GET_ROOM_IDS };
13+
const action = { type: actionCreators.GET_ROOM_IDS };
1414
const expectedRequestParams = {};
1515
const mockRooms = [{ id: 'room1' }, { id: 'room2' }, { id: 'room3' }];
1616

@@ -72,7 +72,7 @@ describe('getAllRoomIds Saga', () => {
7272
message: expectedErrMessage,
7373
})
7474
.put({
75-
type: actionTypes.SET_ALERT,
75+
type: actionCreators.SET_ALERT,
7676
alertType,
7777
message: expectedErrMessage,
7878
})
@@ -98,7 +98,7 @@ describe('getAllRoomIds Saga', () => {
9898
message: expectedErrMessage,
9999
})
100100
.put({
101-
type: actionTypes.SET_ALERT,
101+
type: actionCreators.SET_ALERT,
102102
alertType,
103103
message: expectedErrMessage,
104104
})

frontend/specs/screens/reservations/sagas/newReservation.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expectSaga } from 'redux-saga-test-plan';
22
import { call } from 'redux-saga/effects';
33
import { throwError } from 'redux-saga-test-plan/providers';
44

5-
import { actionTypes, onFailure, onSuccessful } from '@/shared/base';
5+
import { actionCreators, onFailure, onSuccessful } from '@/shared/base';
66
import { fetchQuery, createReservationMutation } from '@/shared/graphql';
77

88
import newReservation from '@/screens/reservations/sagas/newReservation';
@@ -17,7 +17,7 @@ describe('newReservation Saga', () => {
1717
};
1818

1919
const action = {
20-
type: actionTypes.CREATE_RESERVATION,
20+
type: actionCreators.CREATE_RESERVATION,
2121
...input,
2222
};
2323

@@ -50,12 +50,12 @@ describe('newReservation Saga', () => {
5050
],
5151
])
5252
.put({
53-
type: actionTypes.SET_ALERT,
53+
type: actionCreators.SET_ALERT,
5454
alertType: 'success',
5555
message: 'Reservation created.',
5656
})
5757
.put({
58-
type: onSuccessful(actionTypes.CREATE_RESERVATION),
58+
type: onSuccessful(actionCreators.CREATE_RESERVATION),
5959
response: {
6060
data: mockResponse.data.createReservation.reservations,
6161
},
@@ -83,12 +83,12 @@ describe('newReservation Saga', () => {
8383
],
8484
])
8585
.put({
86-
type: onFailure(actionTypes.CREATE_RESERVATION),
86+
type: onFailure(actionCreators.CREATE_RESERVATION),
8787
alertType,
8888
message: expectedErrMessage,
8989
})
9090
.put({
91-
type: actionTypes.SET_ALERT,
91+
type: actionCreators.SET_ALERT,
9292
alertType,
9393
message: expectedErrMessage,
9494
})
@@ -113,7 +113,7 @@ describe('newReservation Saga', () => {
113113
message: expectedErrMessage,
114114
})
115115
.put({
116-
type: actionTypes.SET_ALERT,
116+
type: actionCreators.SET_ALERT,
117117
alertType,
118118
message: expectedErrMessage,
119119
})

frontend/specs/shared/base/baseApi.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { waitFor } from '@testing-library/react';
33
import axios from 'axios';
44
import MockAdapter from 'axios-mock-adapter';
55

6-
import { actionTypes, createBaseApi } from '@/shared/base';
6+
import { actionCreators, createBaseApi } from '@/shared/base';
77

88
describe('baseApi', () => {
99
const url = process.env.RESERVATION_API || '';
@@ -36,10 +36,10 @@ describe('baseApi', () => {
3636
await baseApi.get('/test');
3737
await waitFor(() => {
3838
expect(mockStore.dispatch).toHaveBeenCalledWith({
39-
type: actionTypes.API_REQUEST,
39+
type: actionCreators.API_REQUEST,
4040
});
4141
expect(mockStore.dispatch).toHaveBeenCalledWith({
42-
type: actionTypes.API_REQUEST_DONE,
42+
type: actionCreators.API_REQUEST_DONE,
4343
});
4444
});
4545
});

frontend/specs/shared/sagas/handleApiRequestError.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { takeLatest } from 'redux-saga/effects';
33

44
import { default as sharedSagas } from '../../../src/shared/sagas';
55
import { handleApiRequestError } from '../../../src/shared/sagas/handleApiRequestError';
6-
import { actionTypes, } from '../../../src/shared/base';
6+
import { actionCreators, } from '../../../src/shared/base';
77

88
describe('handleApiRequestError Saga', () => {
99
it('should dispatch SET_ALERT action with error message', () => {
@@ -14,7 +14,7 @@ describe('handleApiRequestError Saga', () => {
1414

1515
return expectSaga(handleApiRequestError, { error })
1616
.put({
17-
type: actionTypes.SET_ALERT,
17+
type: actionCreators.SET_ALERT,
1818
message: `Oops! Something went wrong. ${error.name}: ${error.message}`,
1919
alertType: 'danger',
2020
})
@@ -29,7 +29,7 @@ describe('handleApiRequestError Saga', () => {
2929

3030
return expectSaga(sharedSagas)
3131
.provide([
32-
[takeLatest(actionTypes.API_REQUEST_ERROR, handleApiRequestError), error],
32+
[takeLatest(actionCreators.API_REQUEST_ERROR, handleApiRequestError), error],
3333
])
3434
.silentRun();
3535
});

0 commit comments

Comments
 (0)