'use client' import { useState } from 'react' import { Card, Input, Button, Form, InputNumber, message, Descriptions, Typography, Space, } from 'antd' import { CopyOutlined, LoadingOutlined } from '@ant-design/icons' const { Title, Text } = Typography export default function LpCopyPage() { const [loading, setLoading] = useState(false) const [positionInfo, setPositionInfo] = useState<{ poolAddress: string tickLower: number tickUpper: number base: string baseAmount: string otherAmountMax: string estimatedValue: number priceLower: string priceUpper: string } | null>(null) const [form] = Form.useForm() const handleCopy = async (values: { positionAddress: string maxUsdValue: number }) => { setLoading(true) setPositionInfo(null) try { const response = await fetch('/api/lp-copy', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ positionAddress: values.positionAddress, maxUsdValue: values.maxUsdValue, }), }) const data = await response.json() if (!response.ok) { throw new Error(data.error || 'Failed to copy position') } setPositionInfo(data.positionInfo) message.success('Position copied successfully!') message.info(`Transaction ID: ${data.txid}`) } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Failed to copy position' message.error(errorMessage) } finally { setLoading(false) } } return (