Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(frontend): Fix wordings for auto top-up feature (#9419)

Zamil Majdy58cadeb3b929
diff --git a/autogpt_platform/backend/backend/server/routers/v1.py b/autogpt_platform/backend/backend/server/routers/v1.py
index 1d1aaf3869..ebbad8eb05 100644
--- a/autogpt_platform/backend/backend/server/routers/v1.py
+++ b/autogpt_platform/backend/backend/server/routers/v1.py
@@ -177,7 +177,7 @@ async def configure_user_auto_top_up(
) -> str:
if request.threshold < 0:
raise ValueError("Threshold must be greater than 0")
- if request.amount < 500:
+ if request.amount < 500 and request.amount != 0:
raise ValueError("Amount must be greater than or equal to 500")
if request.amount < request.threshold:
raise ValueError("Amount must be greater than or equal to threshold")
diff --git a/autogpt_platform/frontend/src/app/marketplace/(user)/credits/page.tsx b/autogpt_platform/frontend/src/app/marketplace/(user)/credits/page.tsx
index 6cec264037..8500e458d8 100644
--- a/autogpt_platform/frontend/src/app/marketplace/(user)/credits/page.tsx
+++ b/autogpt_platform/frontend/src/app/marketplace/(user)/credits/page.tsx
@@ -108,7 +108,7 @@ export default function CreditsPage() {
htmlFor="topUpAmount"
className="mb-1 block text-neutral-700"
>
- Top-up Amount (Credits, Minimum 500 = 5 USD)
+ Amount, minimum 500 credits = 5 USD:
</label>
<input
type="number"
@@ -130,21 +130,21 @@ export default function CreditsPage() {
{/* Auto Top-up Form */}
<form onSubmit={submitAutoTopUpConfig} className="mt-6 space-y-4">
- <h3 className="text-lg font-medium">Auto Top-up Configuration</h3>
+ <h3 className="text-lg font-medium">Automatic Refill Settings</h3>
<div>
<label
- htmlFor="autoTopUpAmount"
+ htmlFor="threshold"
className="mb-1 block text-neutral-700"
>
- Auto Top-up Amount (Credits, Minimum 500 = 5 USD)
+ When my balance goes below this amount:
</label>
<input
type="number"
- id="autoTopUpAmount"
- name="topUpAmount"
- defaultValue={autoTopUpConfig?.amount || ""}
- placeholder="Enter auto top-up amount"
+ id="threshold"
+ name="threshold"
+ defaultValue={autoTopUpConfig?.threshold || ""}
+ placeholder="Amount, minimum 500 credits = 5 USD"
min="500"
step="100"
className="w-full rounded-md border border-slate-200 px-4 py-2 dark:border-slate-700 dark:bg-slate-800"
@@ -154,17 +154,17 @@ export default function CreditsPage() {
<div>
<label
- htmlFor="threshold"
+ htmlFor="autoTopUpAmount"
className="mb-1 block text-neutral-700"
>
- Threshold (Credits)
+ Automatically refill my balance with this amount:
</label>
<input
type="number"
- id="threshold"
- name="threshold"
- defaultValue={autoTopUpConfig?.threshold || ""}
- placeholder="Enter threshold value"
+ id="autoTopUpAmount"
+ name="topUpAmount"
+ defaultValue={autoTopUpConfig?.amount || ""}
+ placeholder="Amount, minimum 500 credits = 5 USD"
min="500"
step="100"
className="w-full rounded-md border border-slate-200 px-4 py-2 dark:border-slate-700 dark:bg-slate-800"
@@ -172,9 +172,28 @@ export default function CreditsPage() {
/>
</div>
- <Button type="submit" className="w-full">
- Save
- </Button>
+ {autoTopUpConfig?.amount ? (
+ <>
+ <Button type="submit" className="w-full">
+ Save Changes
+ </Button>
+ <Button
+ className="w-full"
+ variant="destructive"
+ onClick={() =>
+ updateAutoTopUpConfig(0, 0).then(() => {
+ toast({ title: "Auto top-up config disabled! 🎉" });
+ })
+ }
+ >
+ Disable Auto-Refill
+ </Button>
+ </>
+ ) : (
+ <Button type="submit" className="w-full">
+ Enable Auto-Refill
+ </Button>
+ )}
</form>
</div>