Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
add button to clear worth
Browse files Browse the repository at this point in the history
  • Loading branch information
CelestialCrafter committed Nov 16, 2023
1 parent 0008bba commit cb0bc59
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</script>

<dialog
class="{open ? 'pointer-events-auto opacity-100' : 'opacity-0'}
class="{open ? 'pointer-events-auto cursor-auto opacity-100' : 'opacity-0'}
pointer-events-none z-50 max-w-3xl
bg-transparent text-white transition-opacity duration-[500ms]"
bind:this={dialog}
Expand Down
7 changes: 6 additions & 1 deletion src/routes/bots/+page.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const actions = {
const id = formData.get('id');
const chosenAlgorithm = formData.get('algorithm');
const strengthToUSD = formData.get('strengthToUSD');
const clearWorth = formData.get('clearWorth');
const status = formData.get('status');
const time = formData.get('time');

Expand All @@ -40,7 +41,8 @@ export const actions = {
if (!token) return fail(401, 'Unauthorized');
const owner = jwt.verify(token, JWT_SECRET);

if (!(chosenAlgorithm || strengthToUSD || status) || !id) return fail(400, 'Bad Request');
if (!(chosenAlgorithm || strengthToUSD || status || clearWorth) || !id)
return fail(400, 'Bad Request');
if (status === 'tempPause' && !Number(time)) return fail(400, 'Bad Request');
if (status && !validStatuses.includes(status)) return fail(400, 'Bad Request');
if (!(await Bot.exists({ _id: id, owner: owner._id }))) return fail(401, 'Unauthorized');
Expand All @@ -59,6 +61,9 @@ export const actions = {
name: status,
time: time || 0
}
}),
...(clearWorth && {
worth: []
})
},
{
Expand Down
11 changes: 11 additions & 0 deletions src/routes/dashboard/botControls/menus/BotOptions.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
<script>
import { getContext } from 'svelte';
import { enhance } from '$app/forms';
import { ChartBar } from 'svelte-heros-v2';
const selectedAccount = getContext('selectedAccount');
</script>

<section class="overflow-hidden">
{#if $selectedAccount}
<form method="post" use:enhance>
<input class="hidden" type="text" name="id" bind:value={$selectedAccount.id} />
<input class="hidden" type="text" name="clearWorth" value={true} />
<button class="square" title="Clear Worths" formaction="/bots?/update">
<ChartBar class="icon" />
</button>
</form>
{/if}
<button on:click={() => (location.href = `/dashboard/deposit#${$selectedAccount.address}`)}>
/dashboard/deposit
</button>
Expand Down

0 comments on commit cb0bc59

Please sign in to comment.