From 0c00a0c14c979c61a59ba002ead4f90fceacf852 Mon Sep 17 00:00:00 2001 From: Debajyoti Halder Date: Tue, 2 Feb 2021 23:07:42 +0530 Subject: [PATCH] cost-insights: Add better type names from patch --- .../AlertInsights/AlertInsights.tsx | 20 ++++++------- .../src/components/BarChart/BarChartLabel.tsx | 4 +-- .../src/components/BarChart/BarChartSteps.tsx | 4 +-- .../ProductInsights/ProductInsights.tsx | 28 +++++++------------ 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/plugins/cost-insights/src/components/AlertInsights/AlertInsights.tsx b/plugins/cost-insights/src/components/AlertInsights/AlertInsights.tsx index 5204686118..7360c99cf7 100644 --- a/plugins/cost-insights/src/components/AlertInsights/AlertInsights.tsx +++ b/plugins/cost-insights/src/components/AlertInsights/AlertInsights.tsx @@ -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 = ({ {isAlertInsightSectionDisplayed && ( - {active.map((alertItem, index) => ( + {active.map((activeAlert, index) => ( ) => { +}: PropsWithChildren) => { const classes = useBarChartLabelStyles(); const translateX = width * -0.5; diff --git a/plugins/cost-insights/src/components/BarChart/BarChartSteps.tsx b/plugins/cost-insights/src/components/BarChart/BarChartSteps.tsx index ec573da68f..8157e05444 100644 --- a/plugins/cost-insights/src/components/BarChart/BarChartSteps.tsx +++ b/plugins/cost-insights/src/components/BarChart/BarChartSteps.tsx @@ -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, diff --git a/plugins/cost-insights/src/components/ProductInsights/ProductInsights.tsx b/plugins/cost-insights/src/components/ProductInsights/ProductInsights.tsx index b13376d24a..5702e67172 100644 --- a/plugins/cost-insights/src/components/ProductInsights/ProductInsights.tsx +++ b/plugins/cost-insights/src/components/ProductInsights/ProductInsights.tsx @@ -82,32 +82,24 @@ export const ProductInsights = ({ ); useEffect(() => { - async function getAllProductInsights( - groupId: string, - projectId: Maybe, - 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; }