Skip to content

Commit

Permalink
fix initialization warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rushtong committed Jan 16, 2024
1 parent 3ffe3e6 commit b04b175
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
43 changes: 21 additions & 22 deletions src/components/manage_dac_table/ManageDacTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,28 +154,6 @@ export const ManageDacTable = function ManageDacTable(props) {
setSelectedDatasets
} = props;

useEffect(() => {
recalculateVisibleTable({
tableSize,
pageCount,
filteredList: processDacRowData({
dacs,
viewDatasets,
viewMembers,
editDac,
deleteDac,
userRole,
columns
}),
currentPage,
setPageCount: (c) => setPageCount(c),
setCurrentPage: (p) => setCurrentPage(p),
setVisibleList: (l) => setVisibleDacs(l),
sort
});
}, [dacs, tableSize, pageCount, userRole, currentPage, sort, deleteDac, editDac, viewDatasets, viewMembers]);


const editDac = useCallback((selectedDac) => {
setShowDacModal(true);
setSelectedDac(selectedDac);
Expand All @@ -201,6 +179,27 @@ export const ManageDacTable = function ManageDacTable(props) {
setSelectedDatasets(approvedDatasets);
}, [setShowDatasetsModal, setSelectedDac, setSelectedDatasets]);

useEffect(() => {
recalculateVisibleTable({
tableSize,
pageCount,
filteredList: processDacRowData({
dacs,
viewDatasets,
viewMembers,
editDac,
deleteDac,
userRole,
columns
}),
currentPage,
setPageCount: (c) => setPageCount(c),
setCurrentPage: (p) => setCurrentPage(p),
setVisibleList: (l) => setVisibleDacs(l),
sort
});
}, [dacs, tableSize, pageCount, userRole, currentPage, sort, deleteDac, editDac, viewDatasets, viewMembers]);

const changeTableSize = useCallback((value) => {
if (value > 0 && !isNaN(parseInt(value))) {
setTableSize(value);
Expand Down
28 changes: 14 additions & 14 deletions src/pages/manage_dac/ManageDac.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ export const ManageDac = function ManageDac() {
const [selectedDatasets, setSelectedDatasets] = useState([]);


const reloadUserRole = useCallback(async () => {
setIsLoading(true);
const currentUser = Storage.getCurrentUser();
const roles = currentUser.roles.map(r => r.name);
const role = contains(ADMIN)(roles) ? ADMIN : CHAIR;
let dacIDs = filter({name: CHAIR})(currentUser.roles);
dacIDs = map('dacId')(dacIDs);
if (role === CHAIR) {
setDacIDs(dacIDs);
}
setUserRole(role);
setIsLoading(false);
}, []);

const reloadDacList = useCallback(async () => {
setIsLoading(true);
DAC.list().then(
Expand Down Expand Up @@ -68,20 +82,6 @@ export const ManageDac = function ManageDac() {
}
};

const reloadUserRole = useCallback(async () => {
setIsLoading(true);
const currentUser = Storage.getCurrentUser();
const roles = currentUser.roles.map(r => r.name);
const role = contains(ADMIN)(roles) ? ADMIN : CHAIR;
let dacIDs = filter({name: CHAIR})(currentUser.roles);
dacIDs = map('dacId')(dacIDs);
if (role === CHAIR) {
setDacIDs(dacIDs);
}
setUserRole(role);
setIsLoading(false);
}, []);

const closeViewMembersModal = () => {
setShowMembersModal(false);
setSelectedDac({});
Expand Down

0 comments on commit b04b175

Please sign in to comment.