requested changes

This commit is contained in:
Gala
2022-10-27 11:05:19 +02:00
parent fca32424b4
commit 7cdfdf8437
4 changed files with 20 additions and 8 deletions
+4
View File
@@ -0,0 +1,4 @@
export const config = {
IS_DEV_MODE: process.env.NODE_ENV === 'development',
LOG_TAURI_OPERATIONS: process.env.NODE_ENV === 'development',
};
+1 -1
View File
@@ -42,6 +42,6 @@ export const useApiState = <T>(
setValue(newValue);
return newValue;
}
}, [setValue, fn]);
}, [setValue, fn, id, errorMessage]);
return [value, wrappedFetchFn, clearValueFn];
};
+5 -7
View File
@@ -8,7 +8,7 @@ import { ComponentError } from '../../components/ComponentError';
import { ContentCard } from '../../components/ContentCard';
import { TwoColSmallTable } from '../../components/TwoColSmallTable';
import { UptimeChart } from '../../components/UptimeChart';
// import { GatewayDetailSection } from '../../components/Gateways/DetailSection';
import { Console } from '../../utils/console';
import { GatewayContextProvider, useGatewayContext } from '../../context/gateway';
import { useMainContext } from '../../context/main';
import { Title } from '../../components/Title';
@@ -64,9 +64,7 @@ const columns: ColumnsType[] = [
/**
* Shows gateway details
*/
const PageGatewayDetailsWithState: React.FC<{ selectedGateway: GatewayResponseItem | undefined }> = ({
selectedGateway,
}) => {
const PageGatewayDetailsWithState = ({ selectedGateway }: { selectedGateway: GatewayResponseItem | undefined }) => {
const [enrichGateway, setEnrichGateway] = React.useState<GatewayEnrichedRowType>();
const [status, setStatus] = React.useState<number[] | undefined>();
const { uptimeReport, uptimeStory } = useGatewayContext();
@@ -105,7 +103,7 @@ const PageGatewayDetailsWithState: React.FC<{ selectedGateway: GatewayResponseIt
loading={false}
keys={['Mix port', 'Client WS API Port']}
values={status.map((each) => each)}
icons={status.map((elem) => !!elem) || [false, false]}
icons={status.map((elem) => !!elem)}
/>
</ContentCard>
)}
@@ -135,7 +133,7 @@ const PageGatewayDetailGuard: React.FC = () => {
if (gateways?.data) {
setSelectedGateway(gateways.data.find((gateway) => gateway.gateway.identity_key === id));
}
}, [gateways]);
}, [gateways, id]);
if (gateways?.isLoading) {
return <CircularProgress />;
@@ -143,7 +141,7 @@ const PageGatewayDetailGuard: React.FC = () => {
if (gateways?.error) {
// eslint-disable-next-line no-console
console.error(gateways?.error);
Console.error(gateways?.error);
return (
<Alert severity="error">
Oh no! Could not load mixnode <code>{id || ''}</code>
+10
View File
@@ -0,0 +1,10 @@
/* eslint-disable no-console */
import { config } from '../config';
export const Console = {
log: (message?: any, ...optionalParams: any[]) =>
config.IS_DEV_MODE ? console.log(message, ...optionalParams) : undefined,
warn: (message?: any, ...optionalParams: any[]) =>
config.IS_DEV_MODE ? console.warn(message, ...optionalParams) : undefined,
error: (message?: any, ...optionalParams: any[]) => console.error(message, ...optionalParams),
};