Skip to content

Commit

Permalink
Store controls in state
Browse files Browse the repository at this point in the history
  • Loading branch information
donnapep committed Nov 6, 2024
1 parent c3dd120 commit 8b198bf
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions assets/admin/students/student-action-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ export const StudentActionMenu = ( {
studentName,
studentDisplayName,
} ) => {
const [ action, setAction ] = useState( '' );
const [ isModalOpen, setModalOpen ] = useState( false );
const closeModal = ( needsReload ) => {
if ( needsReload ) {
window.location.reload();
}
setModalOpen( false );
};

const defaultControls = [
{
title: __( 'Add to Course', 'sensei-lms' ),
Expand All @@ -57,6 +48,17 @@ export const StudentActionMenu = ( {
},
];

const [ action, setAction ] = useState( '' );
const [ controls, setControls ] = useState( defaultControls );
const [ isModalOpen, setModalOpen ] = useState( false );

const closeModal = ( needsReload ) => {
if ( needsReload ) {
window.location.reload();
}
setModalOpen( false );
};

/**
* Filters controls for the single student action menu.
*
Expand All @@ -68,7 +70,7 @@ export const StudentActionMenu = ( {
*
* @return {Array} Filtered controls.
*/
const controls = applyFilters(
applyFilters(
'senseiStudentActionMenuControls',
defaultControls,
setAction,
Expand Down

0 comments on commit 8b198bf

Please sign in to comment.