|
|
@@ -1,8 +1,9 @@
|
|
|
<script>
|
|
|
import Header from '$lib/layout/Header.svelte';
|
|
|
- import Tables from '$lib/components/Tables.svelte';
|
|
|
- import BuyPanel from '$lib/components/trading/BuyPanel.svelte';
|
|
|
- import SellPanel from '$lib/components/trading/SellPanel.svelte';
|
|
|
+ import TabelaOrdens from '$lib/components/trading/TabelaOrdens.svelte';
|
|
|
+ import GraficoCandlestick from '$lib/components/trading/GraficoCandlestick.svelte';
|
|
|
+ import BoletaCompra from '$lib/components/trading/BoletaCompra.svelte';
|
|
|
+ import BoletaVenda from '$lib/components/trading/BoletaVenda.svelte';
|
|
|
import { writable } from 'svelte/store';
|
|
|
import { onMount } from 'svelte';
|
|
|
import { browser } from '$app/environment';
|
|
|
@@ -84,14 +85,14 @@
|
|
|
{ key: 'status', label: 'Status' }
|
|
|
];
|
|
|
|
|
|
-$: pendingBuys = $orders.filter((o) => o.side === 'Compra' && o.type === 'limit' && o.status === 'Aberta');
|
|
|
-$: pendingSells = $orders.filter((o) => o.side === 'Venda' && o.type === 'limit' && o.status === 'Aberta');
|
|
|
+$: pendingBuys = $orders.filter((o) => o.side === 'Compra' && o.status === 'Aberta');
|
|
|
+$: pendingSells = $orders.filter((o) => o.side === 'Venda' && o.status === 'Aberta');
|
|
|
|
|
|
$: displayPendingBuys = pendingBuys.map((o) => ({
|
|
|
side: o.side,
|
|
|
- price: formatEasyToken(o.price),
|
|
|
+ price: formatBRL(o.price),
|
|
|
amount: formatEasyToken(o.amount),
|
|
|
- total: formatEasyToken(o.total),
|
|
|
+ total: formatBRL(o.total),
|
|
|
status: o.status
|
|
|
}));
|
|
|
|
|
|
@@ -102,26 +103,76 @@ $: displayPendingSells = pendingSells.map((o) => ({
|
|
|
total: formatBRL(o.total),
|
|
|
status: o.status
|
|
|
}));
|
|
|
+
|
|
|
+ const tokens = [
|
|
|
+ { id: 'TK-SOJA', label: 'Soja (saca 60kg)', price: 125.50 },
|
|
|
+ { id: 'TK-MILHO', label: 'Milho (saca 60kg)', price: 78.90 },
|
|
|
+ { id: 'TK-CAFE', name: 'Café (saca 60kg)' },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const stateOptions = ['SP','PR','RS','MG','MT','GO','MS','BA','SC','RO','PA'];
|
|
|
+ let selectedState = 'SP';
|
|
|
+ let selectedCommodity = tokens?.[0]?.id ?? '';
|
|
|
+
|
|
|
+ let showBuyModal = false;
|
|
|
+ let showSellModal = false;
|
|
|
+
|
|
|
+ $: selectedCommodityObj = tokens.find((t) => t.id === selectedCommodity);
|
|
|
+ $: selectedCommodityLabel = selectedCommodityObj?.label || selectedCommodityObj?.name;
|
|
|
+
|
|
|
+ const dadosMock = [
|
|
|
+ { date: '2025-10-01', valor: 9.98 },
|
|
|
+ { date: '2025-10-02', valor: 10.01 },
|
|
|
+ { date: '2025-10-03', valor: 9.97 },
|
|
|
+ { date: '2025-10-04', valor: 10.02 },
|
|
|
+ { date: '2025-10-05', valor: 10.00 },
|
|
|
+ { date: '2025-10-06', valor: 9.99 },
|
|
|
+ { date: '2025-10-07', valor: 10.03 },
|
|
|
+ { date: '2025-10-08', valor: 9.96 },
|
|
|
+ { date: '2025-10-09', valor: 10.05 },
|
|
|
+ { date: '2025-10-10', valor: 10.01 },
|
|
|
+ { date: '2025-10-11', valor: 10.04 },
|
|
|
+ { date: '2025-10-12', valor: 9.98 }
|
|
|
+ ];
|
|
|
</script>
|
|
|
|
|
|
<div>
|
|
|
- <Header title="Trading" subtitle="Trading do sistema" breadcrumb={breadcrumb} />
|
|
|
+ <Header title="Trading" subtitle="Trading do sistema" breadcrumb={breadcrumb}>
|
|
|
+ <svelte:fragment slot="extra">
|
|
|
+ <div class="flex items-center gap-3">
|
|
|
+ <button class="px-3 py-1.5 rounded bg-green-600 hover:bg-green-700 text-white focus:outline-none focus:ring-2 focus:ring-green-500" on:click={() => (showBuyModal = true)}>COMPRAR</button>
|
|
|
+ <button class="px-3 py-1.5 rounded bg-red-600 hover:bg-red-700 text-white focus:outline-none focus:ring-2 focus:ring-red-500" on:click={() => (showSellModal = true)}>VENDER</button>
|
|
|
+ <div class="flex items-center gap-2">
|
|
|
+ <span class="text-xs text-gray-600 dark:text-gray-300">Estado</span>
|
|
|
+ <select bind:value={selectedState} class="block w-32 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700/70 text-gray-900 dark:text-gray-200 px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
|
+ {#each stateOptions as uf}
|
|
|
+ <option value={uf}>{uf}</option>
|
|
|
+ {/each}
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="flex items-center gap-2">
|
|
|
+ <span class="text-xs text-gray-600 dark:text-gray-300">Commodity</span>
|
|
|
+ <select bind:value={selectedCommodity} class="block w-56 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700/70 text-gray-900 dark:text-gray-200 px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
|
+ {#each tokens as t}
|
|
|
+ <option value={t.id}>{t.label || t.name}</option>
|
|
|
+ {/each}
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </svelte:fragment>
|
|
|
+ </Header>
|
|
|
|
|
|
<div class="p-4 space-y-4">
|
|
|
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
|
- <BuyPanel
|
|
|
- referencePrice={currentPrice}
|
|
|
- on:confirm={(e) => addOrder({ side: 'Compra', price: e.detail.price, amount: e.detail.amount, total: e.detail.total, status: 'Aberta', type: e.detail.type })}
|
|
|
- />
|
|
|
- <SellPanel
|
|
|
- referencePrice={currentPrice}
|
|
|
- on:confirm={(e) => addOrder({ side: 'Venda', price: e.detail.price, amount: e.detail.amount, total: e.detail.total, status: 'Aberta', type: e.detail.type })}
|
|
|
- />
|
|
|
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
|
+ <div class="md:col-span-1">
|
|
|
+ <TabelaOrdens />
|
|
|
+ </div>
|
|
|
+ <div class="md:col-span-2">
|
|
|
+ <GraficoCandlestick {dadosMock} />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
-
|
|
|
-<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
|
- <Tables title="Ordens de Compra (pendentes)" columns={orderColumns} data={displayPendingBuys} showActions={false} showAdd={false}/>
|
|
|
- <Tables title="Ordens de Venda (pendentes)" columns={orderColumns} data={displayPendingSells} showActions={false} showAdd={false}/>
|
|
|
-</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <BoletaCompra visible={showBuyModal} onClose={() => (showBuyModal = false)} state={selectedState} commodity={selectedCommodityLabel} />
|
|
|
+ <BoletaVenda visible={showSellModal} onClose={() => (showSellModal = false)} state={selectedState} commodity={selectedCommodityLabel} />
|
|
|
</div>
|