diff --git a/app/components/TradeForm.tsx b/app/components/TradeForm.tsx new file mode 100644 index 0000000..0b6e7c8 --- /dev/null +++ b/app/components/TradeForm.tsx @@ -0,0 +1,47 @@ +import React from 'react' +import { Input } from '@/components/ui/input' +import { Button } from '@/components/ui/button' + +interface TradeFormProps { + type: 'buy' | 'sell' + price: string + amount: string + onPriceChange: (value: string) => void + onAmountChange: (value: string) => void + baseAsset?: string + quoteAsset?: string +} + +export function TradeForm({ + type, + price, + amount, + onPriceChange, + onAmountChange, + baseAsset = 'BTC', + quoteAsset = 'USDT' +}: TradeFormProps) { + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault() + console.log(`${type} order:`, { price, amount }) + } + + return ( +
+

{type === 'buy' ? `Buy ${baseAsset}` : `Sell ${baseAsset}`}

+
+
+ + onPriceChange(e.target.value)} className="mt-1" /> +
+
+ + onAmountChange(e.target.value)} className="mt-1" /> +
+ +
+
+ ) +} diff --git a/app/en/trade/BTCUSDT/page.tsx b/app/en/trade/BTCUSDT/page.tsx index a5c2f4b..c63a555 100644 --- a/app/en/trade/BTCUSDT/page.tsx +++ b/app/en/trade/BTCUSDT/page.tsx @@ -4,12 +4,12 @@ import React, { useState } from 'react' import dynamic from 'next/dynamic' import { useRouter } from 'next/navigation' import { useCandlestickData } from '@/hooks/queries/useCandlestickData' -import { Input } from '@/components/ui/input' import { OrderBook } from '@/components/OrderBook' import { MarketList } from '@/components/MarketList' import { CoinInfo } from '@/components/CoinInfo' import { Button } from '@/components/ui/button' import { cn } from '@/lib/utils' +import { TradeForm } from '@/app/components/TradeForm' const CandlestickChart = dynamic(() => import('@/components/charts/CandlestickChart'), { ssr: false }) @@ -27,10 +27,14 @@ export default function TradePage() { const { data, isLoading, isWebSocketConnected } = useCandlestickData('BTCUSDT', interval) const [buyPrice, setBuyPrice] = useState('') const [sellPrice, setSellPrice] = useState('') + const [buyAmount, setBuyAmount] = useState('') + const [sellAmount, setSellAmount] = useState('') - const handlePriceSelect = (price: number) => { + const handlePriceSelect = (price: number, amount: number) => { setBuyPrice(price.toString()) setSellPrice(price.toString()) + setBuyAmount(amount.toString()) + setSellAmount(amount.toString()) } const handleMarketSelect = (symbol: string) => { @@ -95,42 +99,24 @@ export default function TradePage() { {/* 거래 영역 - 태블릿/데스크톱 */}
-
-

Buy BTC

-
-
- - setBuyPrice(e.target.value)} - className="mt-1" - /> -
-
- - -
-
-
-
-

Sell BTC

-
-
- - setSellPrice(e.target.value)} - className="mt-1" - /> -
-
- - -
-
-
+ +
@@ -152,37 +138,24 @@ export default function TradePage() { {/* 거래 영역 - 모바일 */}
-
-

Buy BTC

-
-
- - setBuyPrice(e.target.value)} className="mt-1" /> -
-
- - -
-
-
-
-

Sell BTC

-
-
- - setSellPrice(e.target.value)} - className="mt-1" - /> -
-
- - -
-
-
+ +
diff --git a/components/OrderBook.tsx b/components/OrderBook.tsx index 8b240ec..8f1998e 100644 --- a/components/OrderBook.tsx +++ b/components/OrderBook.tsx @@ -5,7 +5,7 @@ import { cn } from '@/lib/utils' interface OrderBookProps { symbol: string - onPriceSelect: (price: number) => void + onPriceSelect: (price: number, amount: number) => void } export const OrderBook = ({ symbol, onPriceSelect }: OrderBookProps) => { @@ -68,7 +68,7 @@ export const OrderBook = ({ symbol, onPriceSelect }: OrderBookProps) => { onPriceSelect(ask.price)} + onClick={() => onPriceSelect(ask.price, ask.quantity)} > {formatPrice(ask.price)} {formatAmount(ask.quantity)} @@ -100,7 +100,7 @@ export const OrderBook = ({ symbol, onPriceSelect }: OrderBookProps) => { onPriceSelect(bid.price)} + onClick={() => onPriceSelect(bid.price, bid.quantity)} > {formatPrice(bid.price)} {formatAmount(bid.quantity)}