feat: click a coin row to view its trade history; edit transactions

Matches CoinMarketCap's flow: clicking anywhere on a coin's row in the
holdings table opens its transaction history (previously only a dedicated
icon button did). The table's own History icon is gone since the row now
does that job; the remaining "+"/delete icons get stopPropagation so they
don't also trigger the row click.

Adds the missing piece: transactions could be viewed and deleted but not
edited. New PATCH /crypto/transactions/{id} (partial update, never calls
CoinGecko, same oversell guard as creating a sell) backs a pencil button on
each history row that opens CryptoTransactionModal pre-filled — the same
dialog used for "+", now doing double duty as create/edit.

86/86 backend tests passing (4 new). Verified live against the real API:
create, edit quantity/note, 404 on unknown id, cleanup — real user data
untouched throughout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01855PiW5Wd8n4aRW4n9kByY
This commit is contained in:
ZProger
2026-08-30 05:06:20 +03:00
parent dc9421e08a
commit c3309b9d60
12 changed files with 238 additions and 45 deletions

View File

@@ -10,6 +10,7 @@ from app.schemas.crypto import (
CryptoSyncResult,
CryptoTransactionCreate,
CryptoTransactionRead,
CryptoTransactionUpdate,
)
from app.services.crypto_service import (
CRYPTO_RANGE_DAYS,
@@ -20,6 +21,7 @@ from app.services.crypto_service import (
list_transactions,
refresh_prices,
search_coins,
update_transaction,
)
router = APIRouter(prefix="/crypto", tags=["crypto"])
@@ -63,6 +65,13 @@ async def list_transactions_route(
return await list_transactions(session, asset_id)
@router.patch("/transactions/{transaction_id}", response_model=CryptoHoldingRead)
async def update_transaction_route(
transaction_id: int, payload: CryptoTransactionUpdate, session: AsyncSession = Depends(get_session)
) -> CryptoHoldingRead:
return await update_transaction(session, transaction_id, payload)
@router.delete("/transactions/{transaction_id}", status_code=204)
async def delete_transaction_route(transaction_id: int, session: AsyncSession = Depends(get_session)) -> None:
await delete_transaction(session, transaction_id)