Skip to content

Commit

Permalink
[DUOS-2869] Fix various errors in dev (#2431)
Browse files Browse the repository at this point in the history
  • Loading branch information
fboulnois authored Jan 11, 2024
1 parent d8cbb41 commit c2a0bb8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/components/SignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const SignIn = (props) => {
if (isSubscribed) {
const googleClientId = await Config.getGoogleClientId();
setClientId(googleClientId);
if (GoogleIS.client === null) {
if (window.google !== undefined && GoogleIS.client === null) {
await GoogleIS.initTokenClient(googleClientId, onSuccess, onFailure);
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/pages/DatasetCatalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ export default function DatasetCatalog(props) {
const [filterToOnlySelected, setFilterToOnlySelected] = useState(false);


const applyDatasetSort = useCallback((sortParams, datasets) => {
const sortedList = datasets.sort((a, b) => {
const aVal = a[sortParams.field] || findPropertyValue(a, sortParams.field);
const bVal = b[sortParams.field] || findPropertyValue(b, sortParams.field);
return aVal.localeCompare(bVal, 'en', {numeric: true}) * sortParams.dir;
});
setSort(sortParams);
setDatasetList(sortedList);
}, []);

const getDatasets = useCallback(async () => {
let datasets = await DataSet.getDatasets();
let localDacs = await getDacs();
Expand Down Expand Up @@ -172,16 +182,6 @@ export default function DatasetCatalog(props) {

}, [searchDulText, pageSize, selectedDatasets, datasetList, filterToOnlySelected, currentPageOnlySelected, currentPageAllDatasets, dacFilter, useCustomFilter]);

const applyDatasetSort = useCallback((sortParams, datasets) => {
const sortedList = datasets.sort((a, b) => {
const aVal = a[sortParams.field] || findPropertyValue(a, sortParams.field);
const bVal = b[sortParams.field] || findPropertyValue(b, sortParams.field);
return aVal.localeCompare(bVal, 'en', {numeric: true}) * sortParams.dir;
});
setSort(sortParams);
setDatasetList(sortedList);
}, []);

const getDacs = async () => {
let dacs = await DAC.list(false);
dacs = dacs.map(dac => {
Expand Down
27 changes: 13 additions & 14 deletions src/pages/manage_dac/ManageDac.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ export const ManageDac = function ManageDac() {
const [selectedDatasets, setSelectedDatasets] = useState([]);


const reloadDacList = useCallback(async () => {
setIsLoading(true);
DAC.list().then(
dacs => {
if (userRole === CHAIR) {
dacs = dacs.filter((dac) => dacIDs.includes(dac.dacId));
}
setDacs(dacs);
setIsLoading(false);
}
);
}, [dacIDs, userRole]);

useEffect(() => {
Promise.all([
reloadUserRole(),
Expand All @@ -55,20 +68,6 @@ export const ManageDac = function ManageDac() {
}
};

const reloadDacList = useCallback(async () => {
setIsLoading(true);
DAC.list().then(
dacs => {
if (userRole === CHAIR) {
dacs = dacs.filter((dac) => dacIDs.includes(dac.dacId));
}
setDacs(dacs);
setIsLoading(false);
}
);
}, [dacIDs, userRole]);


const reloadUserRole = useCallback(async () => {
setIsLoading(true);
const currentUser = Storage.getCurrentUser();
Expand Down

0 comments on commit c2a0bb8

Please sign in to comment.