From 8b59c2a2e0cb89ed4066d1aa82ba21abaf16abbb Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Tue, 23 Jul 2024 17:54:17 +0530 Subject: [PATCH] feat: Refactor AvoidSuspensionAlert in MainOlasBalance component --- frontend/components/Main/MainOlasBalance.tsx | 121 +++++++++---------- frontend/components/Main/MainRewards.tsx | 3 - 2 files changed, 59 insertions(+), 65 deletions(-) diff --git a/frontend/components/Main/MainOlasBalance.tsx b/frontend/components/Main/MainOlasBalance.tsx index 2595a15bf..38e358350 100644 --- a/frontend/components/Main/MainOlasBalance.tsx +++ b/frontend/components/Main/MainOlasBalance.tsx @@ -106,70 +106,69 @@ const CurrentBalance = () => { ); }; -// const AvoidSuspensionAlert = styled(Alert)` -// .anticon.ant-alert-icon { -// height: 20px; -// width: 20px; -// svg { -// width: 100%; -// height: 100%; -// } -// } -// `; +const AvoidSuspensionAlertContainer = styled.div` + .ant-alert-info { + margin-bottom: 8px; + .anticon.ant-alert-icon { + height: 20px; + width: 20px; + svg { + width: 100%; + height: 100%; + } + } + } +`; + const AvoidSuspensionAlert = () => { const { store } = useElectronApi(); return ( - - - Avoid suspension! - - - Run your agent for at least half an hour a day to make sure it hits - its targets. If it misses its targets 2 days in a row, it’ll be - suspended. You won’t be able to run it or earn rewards for several - days. - - - - } - style={{ marginBottom: 8 }} - /> + + + + Avoid suspension! + + + Run your agent for at least half an hour a day to make sure it + hits its targets. If it misses its targets 2 days in a row, it’ll + be suspended. You won’t be able to run it or earn rewards for + several days. + + + + } + /> + ); }; -const AvoidSuspension = () => { +export const MainOlasBalance = () => { const { storeState } = useStore(); - - // console.log(storeState); + const { isBalanceLoaded, totalOlasBalance } = useBalance(); // If first reward notification is shown BUT - // agent eviction alert is not shown, show this alert - const isAvoidSuspensionAlertShown = - storeState?.firstRewardNotificationShown && - !storeState?.agentEvictionAlertShown; - - if (!isAvoidSuspensionAlertShown) { - return ; - } + // agent eviction alert is NOT yet shown, show this alert. + const canShowAvoidSuspensionAlert = useMemo(() => { + if (!storeState) return false; - return null; -}; - -export const MainOlasBalance = () => { - const { isBalanceLoaded, totalOlasBalance } = useBalance(); + return ( + storeState.firstRewardNotificationShown && + !storeState.agentEvictionAlertShown + ); + }, [storeState]); const balance = useMemo(() => { if (totalOlasBalance === undefined) return '--'; @@ -178,17 +177,15 @@ export const MainOlasBalance = () => { return ( - + {canShowAvoidSuspensionAlert ? : null} {isBalanceLoaded ? ( <> -
- - - {UNICODE_SYMBOLS.OLAS} - {balance} - OLAS - -
+ + + {UNICODE_SYMBOLS.OLAS} + {balance} + OLAS + ) : ( diff --git a/frontend/components/Main/MainRewards.tsx b/frontend/components/Main/MainRewards.tsx index bb022d1ec..50ef32f30 100644 --- a/frontend/components/Main/MainRewards.tsx +++ b/frontend/components/Main/MainRewards.tsx @@ -101,9 +101,6 @@ const NotifyRewardsModal = () => { // once the notification is closed, set the flag to true store?.set?.('firstRewardNotificationShown', true); - - // and show the eviction educate information to the user - // store?.set?.('agentEvictionAlertShown', true); }, [store]); const onTwitterShare = useCallback(() => {