From 971d4927309c366089353f97d8c887b4f9873977 Mon Sep 17 00:00:00 2001 From: Tim Pechersky Date: Wed, 24 Nov 2021 17:46:48 +0000 Subject: [PATCH] fix and cleanup --- frontend/src/components/NewDashboard.js | 81 ++++++++----------------- 1 file changed, 25 insertions(+), 56 deletions(-) diff --git a/frontend/src/components/NewDashboard.js b/frontend/src/components/NewDashboard.js index 9c45ff1e..840fb26c 100644 --- a/frontend/src/components/NewDashboard.js +++ b/frontend/src/components/NewDashboard.js @@ -65,6 +65,30 @@ const NewDashboard = (props) => { subscriptions.subscriptionsCache.data?.subscriptions ); + useEffect(() => { + newDashboardForm.subscriptions.forEach((element, idx) => { + const subscription = + subscriptions.subscriptionsCache.data?.subscriptions.find( + (subscription_item) => + element.subscription_id === subscription_item.id + ); + + if ( + element.subscription_id && + subscription && + newDashboardForm.subscriptions[idx].abi !== subscription?.abi + ) { + const newestDashboardForm = { ...newDashboardForm }; + newestDashboardForm.subscriptions[idx].abi = subscription.abi; + setNewDashboardForm(newestDashboardForm); + } + }); + }, [ + subscriptions.subscriptionsCache.data, + newDashboardForm, + setNewDashboardForm, + ]); + useEffect(() => { if (!subscriptions.subscriptionsCache.isLoading) { const massaged = subscriptions.subscriptionsCache.data?.subscriptions.map( @@ -195,7 +219,6 @@ const NewDashboard = (props) => { }; setNewDashboardForm(newState); }} - // isOpen={showSuggestions} itemToString={(item) => (item ? item.label : "")} initialSelectedItem={subscibedItem ?? undefined} > @@ -208,7 +231,6 @@ const NewDashboard = (props) => { isOpen, inputValue, highlightedIndex, - // selectedItem, getRootProps, }) => { const labelColor = @@ -217,7 +239,6 @@ const NewDashboard = (props) => { return ( { placeholder="Subscription to use in dashboard" isTruncated fontSize="sm" - // defaultValue={ - // subscibedItem?.label ?? "yoyoy" - // } {...getInputProps({ defaultValue: subscibedItem?.label ?? "iha", @@ -271,18 +289,6 @@ const NewDashboard = (props) => { - {/* */} {isOpen ? ( { }} - // - // - // - // {pickerItems?.map((subscription, oid) => ( - // - // {/* */} - // {subscription.label} - // - // ))} - // {/* - // {({ value }) => ( - // New Subscription: {value} - // )} - // */} - // - // )} @@ -460,7 +437,7 @@ const NewDashboard = (props) => { onClick={() => overlay.toggleModal({ type: MODAL_TYPES.UPLOAD_ABI, - props: { id: subscibedItem.id }, + props: { id: subscibedItem.subscription_id }, }) } > @@ -620,14 +597,6 @@ const NewDashboard = (props) => { - - {/* - ABI -