Skip to content

Commit

Permalink
Merge pull request #13 from Chia-Network/develop
Browse files Browse the repository at this point in the history
fix: various race conditions
  • Loading branch information
MichaelTaylor3D authored Sep 7, 2023
2 parents df71f27 + aafee8a commit f4ff924
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "core-registry-cadt-ui",
"version": "1.2.10",
"version": "1.2.11",
"private": true,
"author": "Chia Network Inc. <[email protected]>",
"homepage": "./",
Expand Down
10 changes: 8 additions & 2 deletions src/components/blocks/UnitsDetailViewModal.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import React, { useEffect, useState } from 'react';
import styled from 'styled-components';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { useIntl } from 'react-intl';

import { Tab, Tabs, TabPanel, Modal, modalTypeEnum } from '..';
Expand Down Expand Up @@ -53,12 +53,17 @@ const UnitsDetailViewModal = ({
],
item => item,
);
const { projects } = useSelector(store => store.climateWarehouse);

useEffect(() => {
dispatch(getIssuances());
dispatch(getProjects({ useMockedResponse: false, useApiMock: false }));
}, []);

if (!projects) {
return null;
}

return (
<Modal
modalSizeAndPosition={modalSizeAndPosition}
Expand Down Expand Up @@ -88,7 +93,8 @@ const UnitsDetailViewModal = ({
key={labelValue.id}
noHeight
value={tabValue}
index={!_.isEmpty(unitsTabs) ? 2 - unitsTabs.length : 2}>
index={!_.isEmpty(unitsTabs) ? 2 - unitsTabs.length : 2}
>
<UnitsLabelsDetails data={labelValue} />
</TabPanel>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/components/blocks/UnitsDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const UnitsDetails = ({ data, stagingData, changeColor }) => {

const unitBelongsToProjectName =
data &&
projects?.filter(
projects.filter(
projectItem => projectItem.warehouseProjectId === unitBelongsToProjectId,
)[0]?.projectName;

Expand Down
11 changes: 11 additions & 0 deletions src/pages/Projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import {
addIsMakerPropToChangeGroups,
convertProcessedOfferToStagingChangeGroups,
} from '../../utils/transferOfferUtils';
import {
getIssuances,
getProjects,
} from '../../store/actions/climateWarehouseActions';

import {
APIDataTable,
Expand Down Expand Up @@ -322,6 +326,8 @@ const Projects = withTheme(({ theme }) => {
return null;
}

console.log('projects', projects);

return projects.map(project =>
_.pick(project, [
'warehouseProjectId',
Expand Down Expand Up @@ -377,6 +383,11 @@ const Projects = withTheme(({ theme }) => {
[stagingData],
);

useEffect(() => {
dispatch(getIssuances());
dispatch(getProjects({ useMockedResponse: false, useApiMock: false }));
}, []);

if (!filteredColumnsTableData) {
return null;
}
Expand Down
9 changes: 9 additions & 0 deletions src/pages/Units/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import { downloadTxtFile } from '../../utils/xlsxUtils';
import constants from '../../constants';
import { getUpdatedUrl } from '../../utils/urlUtils';
import { useWindowSize } from '../../components/hooks/useWindowSize';
import {
getIssuances,
getProjects,
} from '../../store/actions/climateWarehouseActions';

import {
deleteStagingData,
Expand Down Expand Up @@ -193,6 +197,11 @@ const Units = withTheme(({ theme }) => {
setTabValue(0);
}, [searchParams.get('orgUid')]);

useEffect(() => {
dispatch(getIssuances());
dispatch(getProjects({ useMockedResponse: false, useApiMock: false }));
}, []);

useEffect(() => {
if (unitsContainerRef && unitsContainerRef.current) {
setModalSizeAndPosition({
Expand Down
19 changes: 15 additions & 4 deletions src/store/actions/climateWarehouseActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,21 @@ const getClimateWarehouseTable = (
dispatch(setConnectionCheck(true));
const results = await response.json();

dispatch({
type: action,
payload: results,
});
if (
typeof results === 'object' &&
results !== null &&
'data' in results
) {
dispatch({
type: action,
payload: results.data,
});
} else {
dispatch({
type: action,
payload: results,
});
}
}
}
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/functionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ const stagingDetailsViewLinkInfo = (info, dataType, changeColor) => {
};

export const detailsViewData = (type, detailData, dataType, changeColor) => {
if (detailData[dataType]?.changes[0] === null) {
if (detailData[dataType]?.changes?.[0] === null) {
return <Body>{'---'}</Body>;
}

Expand Down

0 comments on commit f4ff924

Please sign in to comment.