Commit graph

194 commits

Author SHA1 Message Date
4be45f8f7c
lots of stuff 2025-12-23 17:03:51 +01:00
f946fbf7b8
Use ApiError type for proper error handling 2025-12-23 15:58:55 +01:00
51a67a8140
Improve error message extraction from API responses 2025-12-23 15:58:37 +01:00
226d5c7976
Make past trade cards clickable too 2025-12-23 15:58:14 +01:00
7019bf2e1d
Make trade cards clickable to navigate to detail page 2025-12-23 15:58:04 +01:00
43a58565c0
Fix test to use different dates for multiple trades 2025-12-23 15:57:43 +01:00
62721cbcf4
Clear existing trade ID when starting new booking 2025-12-23 15:53:37 +01:00
cdda5ec2d5
Update exchange form error handling to show link to existing trade 2025-12-23 15:53:27 +01:00
a499019294
Create individual trade detail page 2025-12-23 15:52:40 +01:00
0c75583930
Add endpoint to get a single trade by ID 2025-12-23 15:52:02 +01:00
04192799ab
Add validation to prevent booking two trades on the same day 2025-12-23 15:50:14 +01:00
8948e3533f
Show trade details from each user's perspective (regular vs admin) and specify units 2025-12-23 15:16:17 +01:00
d89db50937
Add E2E tests for payment method selector and threshold enforcement 2025-12-23 14:51:28 +01:00
5f7cd3da7f
Add payment method badge to admin trades page 2025-12-23 14:51:04 +01:00
3626dc8cfd
Add payment method badge to past trades section 2025-12-23 14:50:45 +01:00
d2bd39362b
Add payment method badge to regular user trades page 2025-12-23 14:50:37 +01:00
4481c6b71a
Add payment method selector to exchange form with threshold enforcement 2025-12-23 14:50:22 +01:00
cb173a7442
Regenerate API types with bitcoin_transfer_method field 2025-12-23 14:49:09 +01:00
8936d802a6
Add Lightning amount threshold validation 2025-12-23 14:46:03 +01:00
28e8ba218f
Update create_exchange endpoint to accept and validate bitcoin_transfer_method 2025-12-23 14:40:42 +01:00
d82829ab40
Add bitcoin_transfer_method to ExchangeRequest and response schemas 2025-12-23 14:36:39 +01:00
e1c7c5209f
Add bitcoin_transfer_method field to Exchange model with default value 2025-12-23 14:34:22 +01:00
0669f951bf
Add bitcoin_transfer_methods to constants endpoint 2025-12-23 14:28:28 +01:00
cecb8b33a7
Update constants validation to check bitcoinTransferMethods and lightningMaxEur 2025-12-23 14:26:24 +01:00
819bb2dd03
Add bitcoinTransferMethods and lightningMaxEur to shared constants 2025-12-23 14:10:10 +01:00
25698188e7
Add BitcoinTransferMethod enum to backend models 2025-12-23 14:09:57 +01:00
f618e5bbd6
fix: use Set for actioningIds to prevent race condition
Replace single actioningId state with a Set of IDs to properly
track multiple concurrent actions. This prevents issues when
a user rapidly clicks actions on different trades before the
previous action completes.
2025-12-23 12:28:16 +01:00
b5d831b364
fix: replace hardcoded wait with explicit wait for loading
Replace page.waitForTimeout(1000) with a proper wait for the
loading state to disappear. This makes the test more reliable
and faster.
2025-12-23 12:26:43 +01:00
06ad7fefe1
fix: improve error handling in admin trades fetch functions
- Return errors from fetch functions instead of setting state directly
- Clear error state before starting a new fetch
- Combine errors when both upcoming and past trades fail to load
- Handle fetch errors in handleAction as well
2025-12-23 12:25:15 +01:00
e8d0ee2eca
refactor: import React types directly instead of namespace
Replace 'import React from "react"' with direct imports of
CSSProperties and ChangeEvent. This eliminates unused imports
and follows modern React patterns where the namespace import
is not required for JSX (React 17+).
2025-12-23 12:23:32 +01:00
c9c36971d8
refactor: extract shared trade card styles to shared.ts
Move duplicate style definitions from trades/page.tsx and
admin/trades/page.tsx to a new tradeCardStyles export in shared.ts.

Both pages now import and use these shared styles, keeping only
page-specific styles locally. This improves maintainability and
ensures visual consistency.
2025-12-23 12:22:04 +01:00
2efbd2c665
fix: derive valid slot minutes from SLOT_DURATION_MINUTES constant
Replace hardcoded (0, 15, 30, 45) tuple with computed range based on
the SLOT_DURATION_MINUTES constant. This ensures the validation stays
in sync if the slot duration is ever changed.

Add test to verify slot minute boundary validation.
2025-12-23 12:17:40 +01:00
0d8369ce65
fix: e2e tests need to click 'Continue to Booking' before date selection
The exchange page is a two-step wizard:
- Step 1: Direction, amount, price selection
- Step 2: Date and slot selection

Tests were looking for date elements before navigating to step 2.
2025-12-23 11:30:27 +01:00
ca3a08a236
test: improve e2e tests and add COMPLETE_EXCHANGE permission tests
- Fix E2E test assertion for buy/sell direction change
- Add data-testid to date buttons for reliable e2e selection
- Update e2e tests to use data-testid instead of fragile weekday matching
- Add tests for regular user cannot complete/no-show trades (COMPLETE_EXCHANGE permission)
2025-12-23 11:00:32 +01:00
ef01a970d5
feat: add /api/admin/users/search endpoint
- Add endpoint to search users by email (case-insensitive)
- Limit results to 10 for autocomplete purposes
- Require VIEW_ALL_EXCHANGES permission (admin only)
- Add tests for search functionality and access control
2025-12-23 10:55:44 +01:00
27896ed136
refactor: use shared constants for MIN/MAX_ADVANCE_DAYS
- Import constants from shared/constants.json in exchange page
- Remove hardcoded values for minAdvanceDays and maxAdvanceDays
2025-12-23 10:54:04 +01:00
110e5ec07f
refactor: extract shared formatEur and getTradeStatusDisplay utilities
- Create frontend/app/utils/exchange.ts with shared formatting functions
- Update exchange/page.tsx to use shared formatEur
- Update trades/page.tsx to use shared formatEur and getTradeStatusDisplay
- Update admin/trades/page.tsx to use shared formatEur and getTradeStatusDisplay
- SatsDisplay was already extracted (confirmed it's in components/SatsDisplay.tsx)
2025-12-23 10:52:53 +01:00
4e6f38e4a1
refactor: Extract SatsDisplay component and fix page IDs
- Extract SatsDisplay component to shared components directory
- Fix page IDs: rename 'admin-appointments' to 'admin-trades'
- Fix trades page using correct 'trades' page ID
2025-12-23 10:44:11 +01:00
ce8f5a1183
test: Add test for cancelled slot becoming available again
Verifies that when a user cancels their trade, the slot becomes
available for booking by other users.
2025-12-23 10:41:08 +01:00
29b0438416
fix: Prevent user from cancelling trades after slot time has passed
Users can no longer cancel trades once the slot time has passed.
Added test to verify this behavior.
2025-12-23 10:39:09 +01:00
3a22534c04
fix: Use COMPLETE_EXCHANGE permission for complete/no-show endpoints
The complete_trade and mark_no_show endpoints now use the dedicated
COMPLETE_EXCHANGE permission instead of CANCEL_ANY_EXCHANGE, which
better reflects the semantics of these operations.
2025-12-23 10:37:32 +01:00
bf57fc6b77
fix: Remove agreed_price from price API response
The agreed_price depends on trade direction (buy/sell) and must be
calculated on the frontend. Returning a buy-side-only agreed_price
from the API was misleading and unused.

Frontend already calculates the direction-aware price correctly.
2025-12-23 10:36:18 +01:00
1008eea2d9
Fix: Update permissions and add missing /api/exchange/slots endpoint
- Updated auth-context.tsx to use new exchange permissions
  (CREATE_EXCHANGE, VIEW_OWN_EXCHANGES, etc.) instead of old
  appointment permissions (BOOK_APPOINTMENT, etc.)

- Updated exchange/page.tsx, trades/page.tsx, admin/trades/page.tsx
  to use correct permission constants

- Updated profile/page.test.tsx mock permissions

- Updated admin/availability/page.tsx to use constants.exchange
  instead of constants.booking

- Added /api/exchange/slots endpoint to return available slots
  for a date, filtering out already booked slots

- Fixed E2E tests:
  - exchange.spec.ts: Wait for button to be enabled before clicking
  - permissions.spec.ts: Use more specific heading selector
  - price-history.spec.ts: Expect /exchange redirect for regular users
2025-12-22 21:42:42 +01:00
65ba4dc42a
Fix: Update auth E2E tests for exchange redirect
The auth tests expected '/' to show user email (old counter page).
Now regular users redirect to '/exchange' after login/signup.

Updated tests to:
- Expect /exchange URL after login/signup
- Check for 'Exchange Bitcoin' heading instead of email
- Update logout tests to verify /exchange access
- Update invite redirect tests for /exchange
2025-12-22 21:15:27 +01:00
fa07490b7b
Fix: Update permission names, models and constants
Permission renames:
- BOOK_APPOINTMENT -> CREATE_EXCHANGE
- VIEW_OWN_APPOINTMENTS -> VIEW_OWN_EXCHANGES
- CANCEL_OWN_APPOINTMENT -> CANCEL_OWN_EXCHANGE
- VIEW_ALL_APPOINTMENTS -> VIEW_ALL_EXCHANGES
- CANCEL_ANY_APPOINTMENT -> CANCEL_ANY_EXCHANGE
- Add COMPLETE_EXCHANGE permission

Model changes:
- Delete AppointmentStatus enum
- Delete Appointment model

Schema changes:
- Delete BookingRequest (was for old booking)
- Delete AppointmentResponse, PaginatedAppointments
- Delete BookableSlot, AvailableSlotsResponse (unused)

Constants changes:
- Remove appointmentStatuses from shared/constants.json
- Merge booking constants into exchange section
- Update shared_constants.py and validate_constants.py
2025-12-22 20:28:21 +01:00
743129b11d
Fix: Update test_permissions.py to use new exchange permissions 2025-12-22 20:23:41 +01:00
edc292986f
Fix: Delete deprecated test_booking.py 2025-12-22 20:23:09 +01:00
3f06103a67
Fix: Remove booking import from main.py 2025-12-22 20:19:23 +01:00
bbd9fae763
Phase 7: Final cleanup - Remove deprecated booking/appointment code
Deleted deprecated files:
- backend/routes/booking.py
- frontend/app/admin/appointments/, booking/, appointments/, sum/, audit/
- frontend/app/utils/appointment.ts
- frontend/e2e/booking.spec.ts, appointments.spec.ts

Updated references:
- exchange/page.tsx: Use /api/exchange/slots instead of /api/booking/slots
- useRequireAuth.ts: Redirect to /admin/trades and /exchange
- profile.tsx, invites.tsx: Update fallback redirect
- E2E tests: Update all /audit references to /admin/trades
- profile.test.tsx: Update admin redirect test
2025-12-22 20:18:33 +01:00
9e8d0af435
Phase 4.2: Add Exchange E2E tests
New exchange.spec.ts with comprehensive E2E coverage:
- Exchange page access and UI elements (price, buy/sell, slider)
- Slot selection with availability
- Confirmation form with trade details
- Access control (regular user vs admin)
- My Trades page
- Admin Trades page with tabs
- Exchange API permission tests
2025-12-22 20:12:19 +01:00