Show canceled orders to user

This commit is contained in:
ekzyis 2023-12-03 00:33:10 +01:00
parent 6171bfebde
commit ac3008ec74
2 changed files with 6 additions and 6 deletions

View File

@ -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 {
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, " +
"CASE WHEN o.order_id IS NOT NULL THEN 'EXECUTED' ELSE 'PENDING' END AS status, o.order_id, o.invoice_id " +
"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' WHEN o.deleted_at IS NOT NULL THEN 'CANCELED' ELSE 'PENDING' END AS status, o.order_id, o.invoice_id " +
"FROM orders o " +
"LEFT JOIN invoices i ON o.invoice_id = i.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"
rows, err := db.Query(query, pubkey)
if err != nil {
@ -140,7 +140,7 @@ func (db *DB) FetchUserOrders(pubkey string, orders *[]Order) error {
defer rows.Close()
for rows.Next() {
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)
}
return nil

View File

@ -24,8 +24,8 @@ const order = ref(props.order)
const showContextMenu = ref(false)
const onMatchClick = ref(props.onMatchClick)
const mine = computed(() => order.value.Pubkey === session?.pubkey)
const showMatch = computed(() => !mine.value && order.value.Status !== 'EXECUTED')
const showCancel = computed(() => mine.value && order.value.Status !== 'EXECUTED')
const showMatch = computed(() => !mine.value && order.value.Status === 'PENDING')
const showCancel = computed(() => mine.value && order.value.Status === 'PENDING')
const statusClassName = computed(() => {
const status = order.value.Status