suvodip ghosh 2025-07-14 15:25:14 +00:00
parent e8f62c18a6
commit 65a37ad477
3 changed files with 28 additions and 6 deletions

View File

@ -9,12 +9,13 @@ import { useToast } from "../ui/toast";
import { useIsLoggedIn } from '../../lib/isLoggedIn'; import { useIsLoggedIn } from '../../lib/isLoggedIn';
export default function Kubernetes() { export default function Kubernetes() {
const { isLoggedIn, loading } = useIsLoggedIn(); const { isLoggedIn, loading, balance } = useIsLoggedIn();
const { showToast } = useToast(); const { showToast } = useToast();
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [deployError, setDeployError] = useState(null); const [deployError, setDeployError] = useState(null);
const [deployStatus, setDeployStatus] = useState({}); const [deployStatus, setDeployStatus] = useState({});
const [clusterStatus, setClusterStatus] = useState(''); const [clusterStatus, setClusterStatus] = useState('');
const [productAmount, setProductAmount] = useState(100);
const [nodePools, setNodePools] = useState([{ const [nodePools, setNodePools] = useState([{
label: `${getRandomString()}`, label: `${getRandomString()}`,
size: '10215', size: '10215',
@ -88,6 +89,9 @@ export default function Kubernetes() {
}, [deployStatus.clusterId, deployStatus.isReady]); }, [deployStatus.clusterId, deployStatus.isReady]);
const handleSubmit = async (e) => { const handleSubmit = async (e) => {
if(balance < productAmount){
return;
}
e.preventDefault(); e.preventDefault();
setIsLoading(true); setIsLoading(true);
setDeployError(null); setDeployError(null);
@ -229,6 +233,13 @@ export default function Kubernetes() {
); );
} }
if (balance < productAmount) {
return (
<p>
You have insufficient balance to deploy this service. Please <a href="/profile" className="text-[#6d9e37]"> click here </a> to go to your profile and add balance, then try again.</p>
);
}
if (deployStatus.status === 'success') { if (deployStatus.status === 'success') {
return ( return (
<Card className="w-full max-w-2xl mx-auto my-4"> <Card className="w-full max-w-2xl mx-auto my-4">

View File

@ -13,13 +13,14 @@ import { useIsLoggedIn } from '../../lib/isLoggedIn';
export default function NewCloudInstance() { export default function NewCloudInstance() {
const PUBLIC_UTHO_API_KEY = import.meta.env.PUBLIC_UTHO_API_KEY; const PUBLIC_UTHO_API_KEY = import.meta.env.PUBLIC_UTHO_API_KEY;
const { isLoggedIn, loading, error, sessionData } = useIsLoggedIn(); const { isLoggedIn, loading, error, sessionData, balance } = useIsLoggedIn();
const { showToast } = useToast(); const { showToast } = useToast();
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [isFetchingData, setIsFetchingData] = useState(true); const [isFetchingData, setIsFetchingData] = useState(true);
const [deployError, setDeployError] = useState() const [deployError, setDeployError] = useState()
const [deployStatus, setDeployStatus] = useState({}); const [deployStatus, setDeployStatus] = useState({});
const [copied, setCopied] = useState(false); const [copied, setCopied] = useState(false);
const [productAmount, setProductAmount] = useState(100);
const [plans, setPlans] = useState([ const [plans, setPlans] = useState([
{ {
"id": "10027", "id": "10027",
@ -313,6 +314,9 @@ export default function NewCloudInstance() {
const handleSubmit = async (e) => { const handleSubmit = async (e) => {
if(balance < productAmount){
return;
}
e.preventDefault(); e.preventDefault();
setIsLoading(true); setIsLoading(true);
@ -441,6 +445,13 @@ export default function NewCloudInstance() {
return <Loader />; return <Loader />;
} }
if (balance < productAmount) {
return (
<p>
You have insufficient balance to deploy this service. Please <a href="/profile" className="text-[#6d9e37]"> click here </a> to go to your profile and add balance, then try again.</p>
);
}
if (deployError) return <p>Error: {deployError?.message}</p>; if (deployError) return <p>Error: {deployError?.message}</p>;
if (!isLoggedIn) { if (!isLoggedIn) {
@ -529,7 +540,7 @@ export default function NewCloudInstance() {
<SelectContent> <SelectContent>
{plans.map(plan => ( {plans.map(plan => (
<SelectItem key={plan.id} value={plan.id}> <SelectItem key={plan.id} value={plan.id}>
{`${plan.cpu} vCPU, ${plan.ram}MB RAM - ${plan.price_cur}/mo`} {`${plan.cpu} vCPU, ${plan.ram}MB RAM`} {/* {`${plan.cpu} vCPU, ${plan.ram}MB RAM - ${plan.price_cur}/mo`} */}
</SelectItem> </SelectItem>
))} ))}
{/* <SelectItem key={plans[0].id} value={plans[0].id}> {/* <SelectItem key={plans[0].id} value={plans[0].id}>

View File

@ -14,9 +14,9 @@ export default function TopicItems(props) {
return <div className="loading-indicator">Loading...</div>; return <div className="loading-indicator">Loading...</div>;
} }
if (error) { // if (error) {
return <div className="error-message">Error loading authentication status</div>; // return <div className="error-message">Error loading authentication status</div>;
} // }
const handleSearchChange = (e) => { const handleSearchChange = (e) => {
setLocalSearchTerm(e.target.value); setLocalSearchTerm(e.target.value);