Skip to content

Commit 5ca771c

Browse files
committed
feat: make changes in Register module and update README.md
1 parent bb8b67a commit 5ca771c

File tree

10 files changed

+65
-19
lines changed

10 files changed

+65
-19
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
<p align="center"> This repository is frontend part of Truthy CMS written in ReactJS & Redux-Saga. For Backend API please visit https://github.com/gobeam/truthy. Ant design (https://ant.design/) is used as an UI library. This project includes User Management, Role Management, Permission Management, Email Module, Account Settings, OTP, RBAC support, Localization, and many more. Hope you like it.<br>
99
If you love it don't forget to share your experience. If you want to contribute to the Truthy CMS in any way like API, Frontend, Design, Logo you're more than welcome to do so. Our plan is to make this no. 1 CMS maintained by open-source community.
10+
11+
View Live <a href="http://157.245.148.131:3000">here</a>
1012
</p>
1113

1214
<p align="center">
@@ -43,6 +45,7 @@ If you love it don't forget to share your experience. If you want to contribute
4345
- [File Structure](#file-structure)
4446
- [Application Security](#application-security)
4547
- [Contributing](#contributing)
48+
- [Sponsors](#sponsors)
4649
- [License](#license)
4750
- [Acknowledgement](#acknowledgement)
4851

@@ -199,6 +202,12 @@ User Will have 2FA authentication option available to be turned on or off. For 2
199202

200203
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
201204
Please make sure to update tests as appropriate. - see `CONTRIBUTING.md` for details.
205+
**If you want to be featured in contributors list on our home page please add PR on https://github.com/gobeam/truthy-contributors to provide your details.**
206+
207+
---
208+
209+
## Sponsors
210+
- [Ekbana Solutions Pvt. Ltd](https://ekbana.com/)
202211

203212
---
204213

app/containers/App/saga.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
REFRESH_TOKEN,
2121
} from 'containers/App/constants';
2222
import { makeOtpValueSelector } from 'containers/App/selectors';
23-
import { call, put, select, takeLatest } from 'redux-saga/effects';
23+
import { call, put, select, takeLatest, takeEvery } from 'redux-saga/effects';
2424
import ApiEndpoint, { BASE_URL } from 'utils/api';
2525
import { GET, POST } from 'utils/constants';
2626
import request from 'utils/request';
@@ -111,8 +111,8 @@ export function* handleAuthenticateOtp() {
111111
}
112112

113113
export default function* appPageSaga() {
114-
yield takeLatest(LOGOUT, handleLogout);
114+
yield takeEvery(LOGOUT, handleLogout);
115115
yield takeLatest(GET_PROFILE_REQUEST, handleProfile);
116116
yield takeLatest(REFRESH_TOKEN, handleRefreshToken);
117-
yield takeLatest(AUTHENTICATE_OTP, handleAuthenticateOtp);
117+
yield takeEvery(AUTHENTICATE_OTP, handleAuthenticateOtp);
118118
}

app/containers/LoginPage/saga.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { call, put, select, takeLatest } from 'redux-saga/effects';
1+
import { call, put, select, takeEvery } from 'redux-saga/effects';
22
import ApiEndpoint from 'utils/api';
33
import request from 'utils/request';
44
// import messages from 'containers/LoginPage/messages';
@@ -39,5 +39,5 @@ export function* attemptLogin() {
3939
}
4040

4141
export default function* loginPageSaga() {
42-
yield takeLatest(LOGIN_PROCESS, attemptLogin);
42+
yield takeEvery(LOGIN_PROCESS, attemptLogin);
4343
}

app/containers/RegisterPage/actions.js

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
REGISTER_PROCESS,
1212
REGISTER_SUCCESS,
1313
SET_FORM_VALUES,
14+
CLEAR_FORM_VALUES,
1415
} from 'containers/RegisterPage/constants';
1516

1617
export function setFormValuesAction(formValues) {
@@ -20,6 +21,13 @@ export function setFormValuesAction(formValues) {
2021
};
2122
}
2223

24+
export function clearFormAction(clearFormValue) {
25+
return {
26+
type: CLEAR_FORM_VALUES,
27+
clearFormValue,
28+
};
29+
}
30+
2331
export function asyncStartAction() {
2432
return {
2533
type: ASYNC_START,

app/containers/RegisterPage/constants.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
* RegisterPage constants
44
*
55
*/
6-
export const REGISTER_SUCCESS = 'containers/RegisterPage/REGISTER_SUCCESS';
7-
export const REGISTER_PROCESS = 'containers/RegisterPage/REGISTER_PROCESS';
8-
export const ADD_VALIDATION_ERROR =
9-
'containers/RegisterPage/ADD_VALIDATION_ERROR';
10-
export const ASYNC_START = 'containers/RegisterPage/ASYNC_START';
11-
export const ASYNC_END = 'containers/RegisterPage/ASYNC_END';
12-
export const SET_FORM_VALUES = 'containers/RegisterPage/SET_FORM_VALUES';
6+
const DOMAIN = 'containers/RegisterPage/';
7+
8+
export const REGISTER_SUCCESS = `${DOMAIN}REGISTER_SUCCESS`;
9+
export const REGISTER_PROCESS = `${DOMAIN}REGISTER_PROCESS`;
10+
export const ADD_VALIDATION_ERROR = `${DOMAIN}ADD_VALIDATION_ERROR`;
11+
export const ASYNC_START = `${DOMAIN}ASYNC_START`;
12+
export const ASYNC_END = `${DOMAIN}ASYNC_END`;
13+
export const SET_FORM_VALUES = `${DOMAIN}SET_FORM_VALUES`;
14+
export const CLEAR_FORM_VALUES = `${DOMAIN}CLEAR_FORM_VALUES`;

app/containers/RegisterPage/reducer.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
*
55
*/
66
import produce from 'immer';
7-
import { ASYNC_END, ASYNC_START } from 'containers/LoginPage/constants';
87
import {
98
ADD_VALIDATION_ERROR,
109
REGISTER_SUCCESS,
1110
SET_FORM_VALUES,
11+
ASYNC_END,
12+
ASYNC_START,
13+
CLEAR_FORM_VALUES,
1214
} from 'containers/RegisterPage/constants';
1315

1416
const EmptyFields = {
@@ -26,6 +28,7 @@ export const initialState = {
2628
errors: [],
2729
error: '',
2830
isLoading: false,
31+
clearFormValue: false,
2932
};
3033

3134
/* eslint-disable default-case, no-param-reassign */
@@ -44,6 +47,9 @@ const loginPageReducer = produce((draft, action) => {
4447
case ASYNC_END:
4548
draft.isLoading = false;
4649
break;
50+
case CLEAR_FORM_VALUES:
51+
draft.clearFormValue = action.clearFormValue;
52+
break;
4753
case REGISTER_SUCCESS:
4854
draft.isLoading = false;
4955
break;

app/containers/RegisterPage/registerForm.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import { createStructuredSelector } from 'reselect';
1010
import {
1111
enterRegisterAction,
1212
setFormValuesAction,
13+
clearFormAction,
1314
} from 'containers/RegisterPage/actions';
1415
import {
1516
makeErrorSelector,
1617
makeInitialValuesSelector,
1718
makeIsLoadingSelector,
19+
makeClearFormValueSelector,
1820
} from 'containers/RegisterPage/selectors';
1921
import messages from 'containers/RegisterPage/messages';
2022
import { FormattedMessage, injectIntl } from 'react-intl';
@@ -35,7 +37,8 @@ const { Title } = Typography;
3537
const stateSelector = createStructuredSelector({
3638
initialValues: makeInitialValuesSelector(),
3739
errors: makeErrorSelector(),
38-
isLoading: makeIsLoadingSelector(),
40+
clearFormValue: makeIsLoadingSelector(),
41+
isLoading: makeClearFormValueSelector(),
3942
});
4043

4144
const formItemLayout = {
@@ -63,10 +66,11 @@ const selectLayout = {
6366
},
6467
};
6568

66-
const RegisterForm = (props) => {
69+
function RegisterForm(props) {
6770
const { intl } = props;
6871
const dispatch = useDispatch();
69-
const { errors, isLoading, initialValues } = useSelector(stateSelector);
72+
const { errors, isLoading, initialValues, clearFormValue } =
73+
useSelector(stateSelector);
7074
const [form] = Form.useForm();
7175
const [password, setPassword] = useState('');
7276

@@ -89,6 +93,13 @@ const RegisterForm = (props) => {
8993
return Promise.resolve();
9094
};
9195

96+
useEffect(() => {
97+
if (clearFormValue) {
98+
form.resetFields();
99+
dispatch(clearFormAction(false));
100+
}
101+
}, [clearFormValue]);
102+
92103
useEffect(() => {
93104
if (errors?.length) {
94105
form.setFields(errors);
@@ -220,7 +231,7 @@ const RegisterForm = (props) => {
220231
</div>
221232
</FormWrapper>
222233
);
223-
};
234+
}
224235

225236
RegisterForm.propTypes = {
226237
intl: PropTypes.object,

app/containers/RegisterPage/saga.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { REGISTER_PROCESS } from 'containers/RegisterPage/constants';
22
import { call, put, select, takeLatest } from 'redux-saga/effects';
33
import {
44
asyncEndAction,
5+
asyncStartAction,
56
enterValidationErrorAction,
67
} from 'containers/RegisterPage/actions';
78
import { makeFormValuesSelector } from 'containers/RegisterPage/selectors';
@@ -12,14 +13,16 @@ import { showAlert, showFormattedAlert } from 'common/saga';
1213
import { POST } from 'utils/constants';
1314

1415
export function* handleRegister() {
16+
yield put(asyncStartAction());
1517
const formValues = yield select(makeFormValuesSelector());
1618
const requestUrl = ApiEndpoint.getRegisterPath();
19+
delete formValues.confirmPassword;
20+
delete formValues.accept;
1721
const requestPayload = ApiEndpoint.makeApiPayload(
1822
requestUrl,
1923
POST,
2024
formValues,
2125
);
22-
2326
try {
2427
const response = yield call(request, requestPayload);
2528
if (response && response.error) {

app/containers/RegisterPage/selectors.js

+7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ const makeErrorSelector = () =>
2626
const makeIsLoadingSelector = () =>
2727
createSelector(selectRegisterPageDomain, (substate) => substate.isLoading);
2828

29+
const makeClearFormValueSelector = () =>
30+
createSelector(
31+
selectRegisterPageDomain,
32+
(substate) => substate.clearFormValue,
33+
);
34+
2935
export {
36+
makeClearFormValueSelector,
3037
makeFormValuesSelector,
3138
makeErrorSelector,
3239
makeIsLoadingSelector,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "truthy-react-cms",
33
"description": "Truthy CMS starter template for React",
4-
"version": "0.2.0",
4+
"version": "0.3.0",
55
"license": "MIT",
66
"author": "gobeam <[email protected]>",
77
"keywords": [

0 commit comments

Comments
 (0)