diff --git a/src/components/run-job/select-resources.module.css b/src/components/run-job/select-resources.module.css index 0e2456cd..a4e91878 100644 --- a/src/components/run-job/select-resources.module.css +++ b/src/components/run-job/select-resources.module.css @@ -62,11 +62,6 @@ } .costCard { - display: flex; - flex-direction: column; - gap: 4px; - padding: 12px 24px; - .costEstimation { align-items: center; display: flex; diff --git a/src/components/run-job/select-resources.tsx b/src/components/run-job/select-resources.tsx index 5276ae8f..1fb23ec9 100644 --- a/src/components/run-job/select-resources.tsx +++ b/src/components/run-job/select-resources.tsx @@ -5,6 +5,7 @@ import useEnvResources from '@/components/hooks/use-env-resources'; import Input from '@/components/input/input'; import Select from '@/components/input/select'; import Slider from '@/components/slider/slider'; +import config from '@/config'; import { SelectedToken, useRunJobContext } from '@/context/run-job-context'; import { useP2P } from '@/contexts/P2PContext'; import { useOceanAccount } from '@/lib/use-ocean-account'; @@ -275,45 +276,83 @@ const SelectResources = ({ environment, freeCompute, token }: SelectResourcesPro formik.setFieldValue('maxJobDurationValue', Math.max(0, num)); }; - const renderCostEstimation = () => { - if (isLoadingCost) { - return ( -

- - Estimating cost... -

- ); - } - if (!!initComputeError || !token) { - let errorText; - if (initComputeError instanceof Error) { - errorText = initComputeError.message; + const renderCostCard = () => { + const renderCostEstimation = () => { + if (isLoadingCost) { + return ( +

+ + Estimating cost... +

+ ); + } + if (!p2pNode || (!estimatedTotalCost && estimatedTotalCost !== 0)) { + return ( +

+ + Connecting to node... +

+ ); } return ( -

- Cost estimation failed{' '} - {errorText ? ( - - - - ) : null} -

+
+ {token?.symbol} +   + {token ? formatTokenAmount(estimatedTotalCost, token.address) : null} +
); + }; + + return ( + +
+

Estimated total cost

+ {renderCostEstimation()} +
+
+ If your job finishes earlier than estimated, the unconsumed tokens remain in your escrow +
+
+ ); + }; + + const renderConnectionErrorCard = () => { + if (!initComputeError) { + return null; } - if (!p2pNode || (!estimatedTotalCost && estimatedTotalCost !== 0)) { - return ( -

- - Connecting to node... -

- ); + let errorText; + if (initComputeError instanceof Error) { + errorText = initComputeError.message; } return ( -
- {token?.symbol} -   - {formatTokenAmount(estimatedTotalCost, token.address)} -
+ +

Could not reach this node

+ {errorText ?

{errorText}

: null} +

+ This may be due to missing WSS, TLS, or P2P circuit relay configuration on the node. +
+ If you are the node operator, please check your node's network setup. +

+ +
); }; @@ -439,21 +478,12 @@ const SelectResources = ({ environment, freeCompute, token }: SelectResourcesPro value={formik.values.maxJobDurationValue} /> - - {formik.isValid && !freeCompute ? ( - - -
-

Estimated total cost

- {renderCostEstimation()} -
-
- If your job finishes earlier than estimated, the unconsumed tokens remain in your escrow -
-
-
- ) : null} -
+ {freeCompute ? null : ( + + {initComputeError ? {renderConnectionErrorCard()} : null} + {!initComputeError && formik.isValid ? {renderCostCard()} : null} + + )}