|
|
|
|
@ -5,7 +5,11 @@
|
|
|
|
|
import { Input } from '$lib/components/ui/input'
|
|
|
|
|
import { superForm } from 'sveltekit-superforms'
|
|
|
|
|
import { zod } from 'sveltekit-superforms/adapters'
|
|
|
|
|
import { formSchema, percentSchema } from './schema'
|
|
|
|
|
import {
|
|
|
|
|
closePositionSchema,
|
|
|
|
|
formSchema,
|
|
|
|
|
percentSchema,
|
|
|
|
|
} from './schema'
|
|
|
|
|
import { Slider } from '$lib/components/ui/slider/index.js'
|
|
|
|
|
import { JsonView } from '@zerodevx/svelte-json-view'
|
|
|
|
|
import copy from 'copy-to-clipboard'
|
|
|
|
|
@ -65,6 +69,31 @@
|
|
|
|
|
|
|
|
|
|
const { form: percentFormData, enhance: percentEnhance } =
|
|
|
|
|
percentForm
|
|
|
|
|
|
|
|
|
|
const closePositionForm = superForm(data.closePositionForm, {
|
|
|
|
|
resetForm: false,
|
|
|
|
|
SPA: true,
|
|
|
|
|
validators: zod(closePositionSchema),
|
|
|
|
|
onSubmit: ({}) => {
|
|
|
|
|
copy(
|
|
|
|
|
JSON.stringify(
|
|
|
|
|
{
|
|
|
|
|
type: 'Close Position',
|
|
|
|
|
...$closePositionFormData,
|
|
|
|
|
entryPrice: '{trigger_entry_value}',
|
|
|
|
|
},
|
|
|
|
|
null,
|
|
|
|
|
2,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
toast.success('Copied to Clipboard')
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
form: closePositionFormData,
|
|
|
|
|
enhance: closePositionEnhance,
|
|
|
|
|
} = closePositionForm
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="flex flex-1 flex-col items-center justify-center">
|
|
|
|
|
@ -72,6 +101,7 @@
|
|
|
|
|
<Tabs.List class="grid w-full grid-cols-2">
|
|
|
|
|
<Tabs.Trigger value="flat">Flat</Tabs.Trigger>
|
|
|
|
|
<Tabs.Trigger value="percent">Percent</Tabs.Trigger>
|
|
|
|
|
<Tabs.Trigger value="close">Close</Tabs.Trigger>
|
|
|
|
|
</Tabs.List>
|
|
|
|
|
<Tabs.Content value="flat">
|
|
|
|
|
<form method="POST" use:enhance class="grid grid-cols-2 gap-4">
|
|
|
|
|
@ -309,5 +339,53 @@
|
|
|
|
|
$percentFormData.stopLossPercent.toString(),
|
|
|
|
|
}} />
|
|
|
|
|
</Tabs.Content>
|
|
|
|
|
<Tabs.Content value="close">
|
|
|
|
|
<form
|
|
|
|
|
method="POST"
|
|
|
|
|
use:closePositionEnhance
|
|
|
|
|
class="grid grid-cols-2 gap-4">
|
|
|
|
|
<Form.Field form={closePositionForm} name="key">
|
|
|
|
|
<Form.Control>
|
|
|
|
|
{#snippet children({ props })}
|
|
|
|
|
<Form.Label>Key</Form.Label>
|
|
|
|
|
<Input {...props} bind:value={$percentFormData.key} />
|
|
|
|
|
{/snippet}
|
|
|
|
|
</Form.Control>
|
|
|
|
|
<Form.Description>Key</Form.Description>
|
|
|
|
|
<Form.FieldErrors />
|
|
|
|
|
</Form.Field>
|
|
|
|
|
<Form.Field form={closePositionForm} name="secret">
|
|
|
|
|
<Form.Control>
|
|
|
|
|
{#snippet children({ props })}
|
|
|
|
|
<Form.Label>Secret</Form.Label>
|
|
|
|
|
<Input
|
|
|
|
|
{...props}
|
|
|
|
|
bind:value={$percentFormData.secret} />
|
|
|
|
|
{/snippet}
|
|
|
|
|
</Form.Control>
|
|
|
|
|
<Form.Description>Secret</Form.Description>
|
|
|
|
|
<Form.FieldErrors />
|
|
|
|
|
</Form.Field>
|
|
|
|
|
<Form.Field form={closePositionForm} name="symbol">
|
|
|
|
|
<Form.Control>
|
|
|
|
|
{#snippet children({ props })}
|
|
|
|
|
<Form.Label>Symbol</Form.Label>
|
|
|
|
|
<Input
|
|
|
|
|
{...props}
|
|
|
|
|
bind:value={$percentFormData.symbol} />
|
|
|
|
|
{/snippet}
|
|
|
|
|
</Form.Control>
|
|
|
|
|
<Form.Description>Symbol</Form.Description>
|
|
|
|
|
<Form.FieldErrors />
|
|
|
|
|
</Form.Field>
|
|
|
|
|
<Form.Button class="col-span-2">Copy</Form.Button>
|
|
|
|
|
</form>
|
|
|
|
|
<JsonView
|
|
|
|
|
json={{
|
|
|
|
|
type: 'Close Position',
|
|
|
|
|
...$closePositionFormData,
|
|
|
|
|
entryPrice: '{trigger_entry_value}',
|
|
|
|
|
}} />
|
|
|
|
|
</Tabs.Content>
|
|
|
|
|
</Tabs.Root>
|
|
|
|
|
</div>
|
|
|
|
|
|