Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement registration happy path #6

Closed
wants to merge 2 commits into from

Conversation

syedsajjadkazmii
Copy link
Contributor

Description

This PR implements a happy path for user registration in the authn component's register form.
It uses redux-saga and redux toolkit for implementing API fetching and side effects.

JIRA

VAN-1885

How Has This Been Tested?

Locally

Screenshots/sandbox (optional):

Screen.Recording.2024-04-03.at.4.15.05.PM.mov

Merge Checklist

  • If your update includes visual changes, have they been reviewed by a designer? Send them a link to the Sandbox, if applicable.
  • Is there adequate test coverage for your changes?

Comment on lines +44 to +49
'no-param-reassign': ['error', {
props: true,
ignorePropertyModificationsFor: [
'state',
],
}],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since RTK provides the facility to directly mutate the state object in slice, the ESLint gives error ESLint: Assignment to property of function parameter 'state'.(no-param-reassign). To suppress that error, we are ignoring assignment to state variable.

Comment on lines 19 to 28
const AuthnComponent = ({ open, setOpen }) => (
<AppProvider store={configureStore()}>
<BaseContainer open={open} setOpen={setOpen}>
<LoginForm />
</BaseContainer>
<BaseContainer open={open} setOpen={setOpen} footerText={messages.footerText}>
<RegisterForm />
</BaseContainer>
</AppProvider>
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason for this change:

useIntl() can only be used if the component is wrapped by AppProvider.

Since AuthnComponent has to be provided with store, we wrapped the content of AuthnComponent with AppProvider. And as AppProvider is now wrapped inside AuthnComponent, we could not use useIntl() here. outside of it.

@syedsajjadkazmii syedsajjadkazmii force-pushed the sajjad/VAN-1885-api-fetching branch from ee56122 to b098088 Compare April 3, 2024 11:30
@syedsajjadkazmii syedsajjadkazmii force-pushed the sajjad/VAN-1885-api-fetching branch from b098088 to 6609703 Compare April 3, 2024 11:35
"redux-logger": "3.0.6",
"redux-mock-store": "1.5.4",
"redux-saga": "1.3.0",
"redux-thunk": "2.4.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need redux-thunk?

const loggerMiddleware = createLogger({
collapsed: true,
});
return composeWithDevTools(applyMiddleware(thunkMiddleware, sagaMiddleware, loggerMiddleware));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using thunkMiddleware? just for devtools and if yes do we need to configure devtools?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, i dont have a solid reason for this. I just copied the existing configurations from frontend-app-authn. We can surely discuss what was the purpose of thunkMiddleware in frontend-app-authn and decide if we want to keep this or not. Currently I am not aware of why it was added in frontend-app-authn

* @param {object} registrationInformation - The registration information to be sent to the server.
* @returns {object} An object containing the redirect URL, success status, and authenticated user details.
*/
export default async function registerRequest(registrationInformation) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export default async function registerRequest(registrationInformation) {
export default async function registerRequest(payload) {

Comment on lines +15 to +18
import EmailField from '../fields/email-field';
import MarketingEmailOptOutCheckbox from '../fields/marketing-email-opt-out-field';
import NameField from '../fields/name-field';
import PasswordField from '../fields/password-field';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to segregate our code or are we increasing the code complexity by doing it? I mean now we are writing edX specific code and there would not be any use case like where we are making complex configurable forms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a modular approach. Currently, we have limited functionality of fields but we will be implementing validations and other use-cases as well. So it would make sense to have separate components for fields instead of writing everything in the registration component.

@attiyaIshaque attiyaIshaque force-pushed the attiya/VAN-1815-registration-form branch 3 times, most recently from 5c6c003 to 0f6b354 Compare April 4, 2024 08:31
Base automatically changed from attiya/VAN-1815-registration-form to master April 4, 2024 08:52
@syedsajjadkazmii syedsajjadkazmii deleted the sajjad/VAN-1885-api-fetching branch April 4, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants