-
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-944 Add redux in students and courses pages #27
Conversation
numPages: 0, | ||
count: 0, | ||
}, | ||
courses: { |
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.
courses, classes and filters have the same initialState, is there some way to unify it? @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.
I created a constat and import it in the states with the same structure
src/features/Students/data/slice.js
Outdated
status: RequestStatus.LOADING, | ||
error: null, | ||
}, | ||
filters: {}, |
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.
Could you please move this to the end of the inititalState. @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
<StudentsTable data={data} count={data.length} columns={getColumns()} />, | ||
<Provider store={store}> | ||
<StudentsTable data={data} count={data.length} columns={getColumns()} /> | ||
</Provider>, | ||
); | ||
|
||
// Check if the table rows are present |
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.
Is this inline comment necessary? @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.
Not. I removed them
@@ -43,7 +43,9 @@ const InstructorsFilters = ({ resetPagination }) => { | |||
const formJson = Object.fromEntries(formData.entries()); | |||
dispatch(updateFilters(formJson)); | |||
try { | |||
dispatch(fetchInstructorsData(currentPage, formJson)); | |||
const initialPage = 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.
What do you think about having a module dedicated to constants? @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.
We already have a constants file, so I moved it there
|
||
const CoursesPage = () => { | ||
const stateInstitution = useSelector((state) => state.main.institution.data); | ||
const [state, dispatch] = useReducer(reducer, initialState); | ||
const stateCourses = useSelector((state) => state.courses); | ||
const dispatch = useDispatch(); | ||
const [currentPage, setCurrentPage] = useState(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.
const [currentPage, setCurrentPage] = useState(1); | |
const [currentPage, setCurrentPage] = useState(initialPage); |
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 CoursesFilters = ({ | ||
fetchData, resetPagination, dataCourses, setFilters, | ||
resetPagination, |
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.
resetPagination, | |
const CoursesFilters = ({ resetPagination }) => { |
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
dataCourses={dataCourses} | ||
/>, | ||
<Provider store={store}> | ||
<CoursesFilters |
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.
<CoursesFilters | |
<CoursesFilters resetPagination={resetPagination} /> |
dataCourses={dataCourses} | ||
/>, | ||
<Provider store={store}> | ||
<CoursesFilters |
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.
<CoursesFilters | |
<CoursesFilters resetPagination={resetPagination} /> |
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
Ticket
https://agile-jira.pearson.com/browse/PADV-944
Description
Manage unique state with redux to shared state between components
Changes made
Define redux actions and reducer for couses and students pages
Import redux store in other pages
Add and update tests
How to test
Clone the Institution Portal MFE
Run npm install.
Run npm run start
Go to http://localhost:1980/