cost-insights: Add better type names from patch

This commit is contained in:
Debajyoti Halder
2021-02-02 23:07:42 +05:30
parent 39e7f4a81e
commit 0c00a0c14c
4 changed files with 24 additions and 32 deletions
@@ -124,18 +124,18 @@ export const AlertInsights = ({
setSnackbarOpen(!!error);
}, [error]);
function onSnooze(alertProp: Alert) {
setAlert(alertProp);
function onSnooze(alertToSnooze: Alert) {
setAlert(alertToSnooze);
setStatus(AlertStatus.Snoozed);
}
function onAccept(alertProp: Alert) {
setAlert(alertProp);
function onAccept(alertToAccept: Alert) {
setAlert(alertToAccept);
setStatus(AlertStatus.Accepted);
}
function onDismiss(alertProp: Alert) {
setAlert(alertProp);
function onDismiss(alertToDismiss: Alert) {
setAlert(alertToDismiss);
setStatus(AlertStatus.Dismissed);
}
@@ -148,8 +148,8 @@ export const AlertInsights = ({
setStatus(null);
}
function onDialogFormSubmit(inputData: any) {
setData(inputData);
function onDialogFormSubmit(formData: any) {
setData(formData);
}
function onSummaryButtonClick() {
@@ -175,10 +175,10 @@ export const AlertInsights = ({
</Grid>
{isAlertInsightSectionDisplayed && (
<Grid item container direction="column" spacing={4}>
{active.map((alertItem, index) => (
{active.map((activeAlert, index) => (
<Grid item key={`alert-insights-section-${index}`}>
<AlertInsightsSection
alert={alertItem}
alert={activeAlert}
number={index + 1}
onSnooze={onSnooze}
onAccept={onAccept}
@@ -18,7 +18,7 @@ import React, { PropsWithChildren } from 'react';
import { Box, Typography } from '@material-ui/core';
import { useBarChartLabelStyles } from '../../utils/styles';
type BarChartLabelObject = {
type BarChartLabelProps = {
x: number;
y: number;
height: number;
@@ -33,7 +33,7 @@ export const BarChartLabel = ({
width,
details,
children,
}: PropsWithChildren<BarChartLabelObject>) => {
}: PropsWithChildren<BarChartLabelProps>) => {
const classes = useBarChartLabelStyles();
const translateX = width * -0.5;
@@ -18,7 +18,7 @@ import React from 'react';
import { ButtonBase } from '@material-ui/core';
import { useBarChartStepperStyles as useStyles } from '../../utils/styles';
export type BarChartStepsObject = {
export type BarChartStepsProps = {
steps: number;
activeStep: number;
onClick: (index: number) => void;
@@ -28,7 +28,7 @@ export const BarChartSteps = ({
steps,
activeStep,
onClick,
}: BarChartStepsObject) => {
}: BarChartStepsProps) => {
const classes = useStyles();
const handleOnClick = (index: number) => (
event: React.MouseEvent<HTMLButtonElement, MouseEvent>,
@@ -82,32 +82,24 @@ export const ProductInsights = ({
);
useEffect(() => {
async function getAllProductInsights(
groupId: string,
projectId: Maybe<string>,
productIds: Product[],
lastCompleteBillingDateString: string,
) {
async function getAllProductInsights() {
try {
dispatchLoadingProducts(true);
const responses = await Promise.allSettled(
productIds.map(product =>
products.map(product =>
client.getProductInsights({
group: groupId,
project: projectId,
group: group,
project: project,
product: product.kind,
intervals: intervalsOf(
DEFAULT_DURATION,
lastCompleteBillingDateString,
),
intervals: intervalsOf(DEFAULT_DURATION, lastCompleteBillingDate),
}),
),
).then(settledResponseOf);
const initialStatesNow = initialStatesOf(productIds, responses).sort(
const updatedInitialStates = initialStatesOf(products, responses).sort(
totalAggregationSort,
);
setStates(initialStatesNow);
setStates(updatedInitialStates);
} catch (e) {
setError(e);
} finally {
@@ -115,7 +107,7 @@ export const ProductInsights = ({
}
}
getAllProductInsights(group, project, products, lastCompleteBillingDate);
getAllProductInsights();
}, [
client,
group,
@@ -128,8 +120,8 @@ export const ProductInsights = ({
useEffect(
function handleOnLoaded() {
if (onceRef.current) {
const currentProducts = initialStates.map(state => state.product);
onLoaded(currentProducts);
const initialProducts = initialStates.map(state => state.product);
onLoaded(initialProducts);
} else {
onceRef.current = true;
}