From 8706c223cd39e626cb4ca0ab13d7d90ca01fc3a2 Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Wed, 4 Oct 2023 12:38:30 -0700 Subject: [PATCH] simplify the map function Signed-off-by: Shenoy Pratik --- .../acceleration/selectors/index_type_selector.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/public/components/acceleration/selectors/index_type_selector.tsx b/public/components/acceleration/selectors/index_type_selector.tsx index 0a64aa17..5c8c9bca 100644 --- a/public/components/acceleration/selectors/index_type_selector.tsx +++ b/public/components/acceleration/selectors/index_type_selector.tsx @@ -52,13 +52,11 @@ export const IndexTypeSelector = ({ }; getJobId(query, http, (id: string) => { pollQueryStatus(id, http, (data: any[]) => { - let dataTableFields: DataTableFieldsType[] = []; - if (data.length > 0) - dataTableFields = data.map((field, index) => ({ - id: `${idPrefix}${index + 1}`, - fieldName: field.col_name, - dataType: field.data_type, - })); + const dataTableFields: DataTableFieldsType[] = data.map((field, index) => ({ + id: `${idPrefix}${index + 1}`, + fieldName: field.col_name, + dataType: field.data_type, + })); setAccelerationFormData({ ...accelerationFormData, dataTableFields: dataTableFields,