-
Notifications
You must be signed in to change notification settings - Fork 0
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
PADV-973 feat: add instructor modal #40
Conversation
describe('Add instructor modal', () => { | ||
test('Render add insctructor modal', async () => { | ||
const { getByText, getByPlaceholderText } = renderWithProviders( | ||
<AddInstructors isOpen close={() => { }} />, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<AddInstructors isOpen close={() => { }} />, | |
<AddInstructors isOpen close={() => {}} />, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
setIsNoUser(false); | ||
} | ||
dispatch(addInstructor(selectedInstitution.id, formJson.instructorEmail)); | ||
close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't add confirmations at the end? @AuraAlba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not part of the scope but I added the success message
</FormGroup> | ||
<div className="d-flex justify-content-end"> | ||
<ModalCloseButton className="btntpz btn-text btn-tertiary">Cancel</ModalCloseButton> | ||
<Button type="submit">Send invite</Button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Button type="submit">Send invite</Button> | |
<Button type="submit">Send invitation</Button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how is in the figma, should I change it?
|
||
expect(httpClientMock.post).toHaveBeenCalledTimes(1); | ||
expect(httpClientMock.post).toHaveBeenCalledWith( | ||
'http://localhost:18000/pearson_course_operation/api/v2/instructors/[email protected]&institution_id=1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line too long. @AuraAlba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -1,5 +1,5 @@ | |||
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; | |||
import { getInstructorData, handleInstructorsEnrollment } from 'features/Instructors/data/api'; | |||
import { getInstructorData, handleInstructorsEnrollment, handleNewInstructor } from 'features/Instructors/data/api'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line too long. @AuraAlba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
</FormGroup> | ||
<div className="d-flex justify-content-end"> | ||
<ModalCloseButton className="btntpz btn-text btn-tertiary">Cancel</ModalCloseButton> | ||
<Button type="submit">Send invite</Button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure if it would fit within the scope of this issue, but currently, the button remains enabled even if the required input field is empty. While I see that the input field has the 'required' attribute, I'm concerned that users could potentially bypass this by manipulating the HTML using browser dev tools. To strengthen the feature, would it be feasible to add client-side validation to ensure that the input field is filled before sending any requests? And of course the back can check if the email is being provided, if not throw and error, but my point of all of this is avoid just spamming the "send" button with a bunch of request.
What are your thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have problem with this, is not a complex implementation. I added
addInstructorRequest: (state) => { | ||
state.addInstructor.status = RequestStatus.LOADING; | ||
}, | ||
addInstructorSuccess: (state, { payload }) => { | ||
state.addInstructor.status = RequestStatus.SUCCESS; | ||
state.addInstructor.data = payload; | ||
}, | ||
addInstructorFailed: (state) => { | ||
state.addInstructor.status = RequestStatus.ERROR; | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this names, there aren't clear, maybe:
addInstructorRequest: (state) => { | |
state.addInstructor.status = RequestStatus.LOADING; | |
}, | |
addInstructorSuccess: (state, { payload }) => { | |
state.addInstructor.status = RequestStatus.SUCCESS; | |
state.addInstructor.data = payload; | |
}, | |
addInstructorFailed: (state) => { | |
state.addInstructor.status = RequestStatus.ERROR; | |
}, | |
}, | |
setInstructorLoading: (state) => { | |
state.addInstructor.status = RequestStatus.LOADING; | |
}, | |
setInstructorSuccessRequest: (state, { payload }) => { | |
state.addInstructor.status = RequestStatus.SUCCESS; | |
state.addInstructor.data = payload; | |
}, | |
setInstructorErrorRequest: (state) => { | |
state.addInstructor.status = RequestStatus.ERROR; | |
}, | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually when we defined a reducer is not a good practice write the name as a setter, I will find a name more descriptive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not modify this, for me it is quite clear to describe the actions that the reducer performs and adding the request word does not contribute to this description
@@ -44,37 +44,37 @@ function fetchCoursesData(id) { | |||
}; | |||
} | |||
|
|||
function fetchClassesData() { | |||
function assignInstructors(data, classId, institutionId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could be a good addition to use jsdocs for documentation purposes:
function assignInstructors(data, classId, institutionId) { | |
/** | |
* Assign instructors to a class. | |
* | |
* @param {Object} data - The data containing information about the instructors to be assigned. | |
* @param {string} classId - The ID of the class to which the instructors will be assigned. | |
* @param {string} institutionId - The ID of the institution associated with the class. | |
* @returns {Promise<void>} - A promise that resolves after dispatching appropriate actions. | |
*/ | |
function assignInstructors(data, classId, institutionId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
}; | ||
} | ||
|
||
function assignInstructors(data, classId, institutionId) { | ||
function addInstructor(institutionId, instructorEmail) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const stateInstructors = useSelector((state) => state.instructors.classes); | ||
import { addInstructor } from 'features/Instructors/data/thunks'; | ||
|
||
const AddInstructors = ({ isOpen, close }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think close
is not clear enough, maybe handleOnClose
or onClose
could be more descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -16,6 +17,7 @@ const InstructorsPage = () => { | |||
const selectedInstitution = useSelector((state) => state.main.selectedInstitution); | |||
const dispatch = useDispatch(); | |||
const [currentPage, setCurrentPage] = useState(initialPage); | |||
const [isOpen, open, close] = useToggle(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This names does not explain itself what's supposed to should do, maybe:
const [isOpen, open, close] = useToggle(false); | |
const [isOpen, openMolda, closeModal] = useToggle(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
24bf9a6
to
51b12e6
Compare
Ticket
https://agile-jira.pearson.com/browse/PADV-973
Description
Add instructor modal
Changes made
Update add instructor modal
Remove classes fetch used in the past component
Update tests
Screenshots
How to test
Clone the Institution Portal MFE
Run npm install.
Run npm run start
Go to http://localhost:1980/instructors