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

PADV-944 Add redux in students and courses pages #27

Merged
merged 2 commits into from
Jan 5, 2024
Merged

Conversation

AuraAlba
Copy link
Contributor

@AuraAlba AuraAlba commented Jan 4, 2024

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/

@AuraAlba AuraAlba requested a review from anfbermudezme January 4, 2024 21:40
numPages: 0,
count: 0,
},
courses: {
Copy link
Contributor

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

Copy link
Contributor Author

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

status: RequestStatus.LOADING,
error: null,
},
filters: {},
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor Author

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);
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
const [currentPage, setCurrentPage] = useState(1);
const [currentPage, setCurrentPage] = useState(initialPage);

Copy link
Contributor Author

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,
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
resetPagination,
const CoursesFilters = ({ resetPagination }) => {

Copy link
Contributor Author

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
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
<CoursesFilters
<CoursesFilters resetPagination={resetPagination} />

dataCourses={dataCourses}
/>,
<Provider store={store}>
<CoursesFilters
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
<CoursesFilters
<CoursesFilters resetPagination={resetPagination} />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@AuraAlba AuraAlba merged commit 4bb4079 into master Jan 5, 2024
2 checks passed
@AuraAlba AuraAlba deleted the vue/PADV-944 branch January 5, 2024 18:41
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.

2 participants