Show canceled orders to user
This commit is contained in:
parent
6171bfebde
commit
ac3008ec74
|
@ -126,12 +126,12 @@ func (db *DB) FetchOrder(tx *sql.Tx, ctx context.Context, orderId string, order
|
||||||
|
|
||||||
func (db *DB) FetchUserOrders(pubkey string, orders *[]Order) error {
|
func (db *DB) FetchUserOrders(pubkey string, orders *[]Order) error {
|
||||||
query := "" +
|
query := "" +
|
||||||
"SELECT o.id, share_id, o.pubkey, o.side, o.quantity, o.price, o.created_at, s.description, s.market_id, i.confirmed_at, " +
|
"SELECT o.id, share_id, o.pubkey, o.side, o.quantity, o.price, o.created_at, o.deleted_at, s.description, s.market_id, i.confirmed_at, " +
|
||||||
"CASE WHEN o.order_id IS NOT NULL THEN 'EXECUTED' ELSE 'PENDING' END AS status, o.order_id, o.invoice_id " +
|
"CASE WHEN o.order_id IS NOT NULL THEN 'EXECUTED' WHEN o.deleted_at IS NOT NULL THEN 'CANCELED' ELSE 'PENDING' END AS status, o.order_id, o.invoice_id " +
|
||||||
"FROM orders o " +
|
"FROM orders o " +
|
||||||
"LEFT JOIN invoices i ON o.invoice_id = i.id " +
|
"LEFT JOIN invoices i ON o.invoice_id = i.id " +
|
||||||
"JOIN shares s ON o.share_id = s.id " +
|
"JOIN shares s ON o.share_id = s.id " +
|
||||||
"WHERE o.pubkey = $1 AND ( (o.side = 'BUY' AND i.confirmed_at IS NOT NULL) OR o.side = 'SELL' ) AND o.deleted_at IS NULL " +
|
"WHERE o.pubkey = $1 AND ( (o.side = 'BUY' AND i.confirmed_at IS NOT NULL) OR o.side = 'SELL' ) " +
|
||||||
"ORDER BY o.created_at DESC"
|
"ORDER BY o.created_at DESC"
|
||||||
rows, err := db.Query(query, pubkey)
|
rows, err := db.Query(query, pubkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -140,7 +140,7 @@ func (db *DB) FetchUserOrders(pubkey string, orders *[]Order) error {
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var order Order
|
var order Order
|
||||||
rows.Scan(&order.Id, &order.ShareId, &order.Pubkey, &order.Side, &order.Quantity, &order.Price, &order.CreatedAt, &order.ShareDescription, &order.Share.MarketId, &order.Invoice.ConfirmedAt, &order.Status, &order.OrderId, &order.InvoiceId)
|
rows.Scan(&order.Id, &order.ShareId, &order.Pubkey, &order.Side, &order.Quantity, &order.Price, &order.CreatedAt, &order.DeletedAt, &order.ShareDescription, &order.Share.MarketId, &order.Invoice.ConfirmedAt, &order.Status, &order.OrderId, &order.InvoiceId)
|
||||||
*orders = append(*orders, order)
|
*orders = append(*orders, order)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -24,8 +24,8 @@ const order = ref(props.order)
|
||||||
const showContextMenu = ref(false)
|
const showContextMenu = ref(false)
|
||||||
const onMatchClick = ref(props.onMatchClick)
|
const onMatchClick = ref(props.onMatchClick)
|
||||||
const mine = computed(() => order.value.Pubkey === session?.pubkey)
|
const mine = computed(() => order.value.Pubkey === session?.pubkey)
|
||||||
const showMatch = computed(() => !mine.value && order.value.Status !== 'EXECUTED')
|
const showMatch = computed(() => !mine.value && order.value.Status === 'PENDING')
|
||||||
const showCancel = computed(() => mine.value && order.value.Status !== 'EXECUTED')
|
const showCancel = computed(() => mine.value && order.value.Status === 'PENDING')
|
||||||
|
|
||||||
const statusClassName = computed(() => {
|
const statusClassName = computed(() => {
|
||||||
const status = order.value.Status
|
const status = order.value.Status
|
||||||
|
|
Loading…
Reference in New Issue