2025-12-22 20:02:00 +01:00
|
|
|
"use client";
|
|
|
|
|
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
import { useState, CSSProperties } from "react";
|
2025-12-23 15:58:04 +01:00
|
|
|
import { useRouter } from "next/navigation";
|
2025-12-22 20:02:00 +01:00
|
|
|
import { Permission } from "../auth-context";
|
2025-12-25 20:32:11 +01:00
|
|
|
import { tradesApi } from "../api";
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
import { PageLayout } from "../components/PageLayout";
|
2025-12-23 10:44:11 +01:00
|
|
|
import { SatsDisplay } from "../components/SatsDisplay";
|
Extract reusable UI components to reduce DRY violations
- Created StatusBadge component: Standardizes status badge display
- Supports tradeStatus prop for trade-specific styling
- Supports variant prop for simple badges (success/error/ready)
- Eliminates repetitive badge style combinations
- Created EmptyState component: Standardizes empty state display
- Handles loading and empty states consistently
- Supports message, hint, and action props
- Used across trades, invites, admin pages
- Created ConfirmationButton component: Standardizes confirmation flows
- Two-step confirmation pattern (action -> confirm/cancel)
- Supports different variants (danger/success/primary)
- Handles loading states automatically
- Used for cancel, complete, no-show actions
- Migrated pages to use new components:
- trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- trades/[id]/page.tsx: StatusBadge
- invites/page.tsx: StatusBadge, EmptyState
- admin/trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- admin/invites/page.tsx: StatusBadge
Benefits:
- Eliminated ~50+ lines of repetitive badge styling code
- Consistent UI patterns across all pages
- Easier to maintain and update styling
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:40:07 +01:00
|
|
|
import { StatusBadge } from "../components/StatusBadge";
|
|
|
|
|
import { EmptyState } from "../components/EmptyState";
|
2025-12-25 21:50:34 +01:00
|
|
|
import { ConfirmationButton } from "../components/ConfirmationButton";
|
2025-12-22 20:02:00 +01:00
|
|
|
import { useRequireAuth } from "../hooks/useRequireAuth";
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
import { useAsyncData } from "../hooks/useAsyncData";
|
|
|
|
|
import { useMutation } from "../hooks/useMutation";
|
2025-12-22 20:02:00 +01:00
|
|
|
import { formatDateTime } from "../utils/date";
|
Extract reusable UI components to reduce DRY violations
- Created StatusBadge component: Standardizes status badge display
- Supports tradeStatus prop for trade-specific styling
- Supports variant prop for simple badges (success/error/ready)
- Eliminates repetitive badge style combinations
- Created EmptyState component: Standardizes empty state display
- Handles loading and empty states consistently
- Supports message, hint, and action props
- Used across trades, invites, admin pages
- Created ConfirmationButton component: Standardizes confirmation flows
- Two-step confirmation pattern (action -> confirm/cancel)
- Supports different variants (danger/success/primary)
- Handles loading states automatically
- Used for cancel, complete, no-show actions
- Migrated pages to use new components:
- trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- trades/[id]/page.tsx: StatusBadge
- invites/page.tsx: StatusBadge, EmptyState
- admin/trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- admin/invites/page.tsx: StatusBadge
Benefits:
- Eliminated ~50+ lines of repetitive badge styling code
- Consistent UI patterns across all pages
- Easier to maintain and update styling
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:40:07 +01:00
|
|
|
import { formatEur } from "../utils/exchange";
|
|
|
|
|
import { typographyStyles, tradeCardStyles } from "../styles/shared";
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
import { useTranslation } from "../hooks/useTranslation";
|
2025-12-22 20:02:00 +01:00
|
|
|
|
|
|
|
|
export default function TradesPage() {
|
2025-12-23 15:58:04 +01:00
|
|
|
const router = useRouter();
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
const t = useTranslation("trades");
|
|
|
|
|
const tExchange = useTranslation("exchange");
|
2025-12-22 20:02:00 +01:00
|
|
|
const { user, isLoading, isAuthorized } = useRequireAuth({
|
2025-12-22 21:42:42 +01:00
|
|
|
requiredPermission: Permission.VIEW_OWN_EXCHANGES,
|
2025-12-22 20:02:00 +01:00
|
|
|
fallbackRedirect: "/",
|
|
|
|
|
});
|
|
|
|
|
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
const {
|
|
|
|
|
data: trades = [],
|
|
|
|
|
isLoading: isLoadingTrades,
|
|
|
|
|
error,
|
|
|
|
|
refetch: fetchTrades,
|
|
|
|
|
} = useAsyncData(() => tradesApi.getTrades(), {
|
|
|
|
|
enabled: !!user && isAuthorized,
|
|
|
|
|
initialData: [],
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-23 17:03:51 +01:00
|
|
|
const [cancellingId, setCancellingId] = useState<string | null>(null);
|
|
|
|
|
const [confirmCancelId, setConfirmCancelId] = useState<string | null>(null);
|
2025-12-22 20:02:00 +01:00
|
|
|
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
const { mutate: cancelTrade } = useMutation(
|
|
|
|
|
(publicId: string) => tradesApi.cancelTrade(publicId),
|
|
|
|
|
{
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
fetchTrades();
|
|
|
|
|
setConfirmCancelId(null);
|
|
|
|
|
},
|
2025-12-22 20:02:00 +01:00
|
|
|
}
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
);
|
2025-12-22 20:02:00 +01:00
|
|
|
|
2025-12-23 17:03:51 +01:00
|
|
|
const handleCancel = async (publicId: string) => {
|
|
|
|
|
setCancellingId(publicId);
|
2025-12-22 20:02:00 +01:00
|
|
|
try {
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
await cancelTrade(publicId);
|
2025-12-22 20:02:00 +01:00
|
|
|
} finally {
|
|
|
|
|
setCancellingId(null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-25 21:50:34 +01:00
|
|
|
const upcomingTrades = (trades ?? []).filter(
|
2025-12-22 20:02:00 +01:00
|
|
|
(t) => t.status === "booked" && new Date(t.slot_start) > new Date()
|
|
|
|
|
);
|
2025-12-25 21:50:34 +01:00
|
|
|
const pastOrFinalTrades = (trades ?? []).filter(
|
2025-12-22 20:02:00 +01:00
|
|
|
(t) => t.status !== "booked" || new Date(t.slot_start) <= new Date()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
<PageLayout
|
|
|
|
|
currentPage="trades"
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
|
isAuthorized={isAuthorized}
|
|
|
|
|
error={error}
|
|
|
|
|
contentStyle={styles.content}
|
|
|
|
|
>
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
<h1 style={typographyStyles.pageTitle}>{t("page.title")}</h1>
|
|
|
|
|
<p style={typographyStyles.pageSubtitle}>{t("page.subtitle")}</p>
|
2025-12-22 20:02:00 +01:00
|
|
|
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
{isLoadingTrades ? (
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
<EmptyState message={t("page.loadingTrades")} isLoading={true} />
|
2025-12-25 21:50:34 +01:00
|
|
|
) : (trades?.length ?? 0) === 0 ? (
|
Extract reusable UI components to reduce DRY violations
- Created StatusBadge component: Standardizes status badge display
- Supports tradeStatus prop for trade-specific styling
- Supports variant prop for simple badges (success/error/ready)
- Eliminates repetitive badge style combinations
- Created EmptyState component: Standardizes empty state display
- Handles loading and empty states consistently
- Supports message, hint, and action props
- Used across trades, invites, admin pages
- Created ConfirmationButton component: Standardizes confirmation flows
- Two-step confirmation pattern (action -> confirm/cancel)
- Supports different variants (danger/success/primary)
- Handles loading states automatically
- Used for cancel, complete, no-show actions
- Migrated pages to use new components:
- trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- trades/[id]/page.tsx: StatusBadge
- invites/page.tsx: StatusBadge, EmptyState
- admin/trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- admin/invites/page.tsx: StatusBadge
Benefits:
- Eliminated ~50+ lines of repetitive badge styling code
- Consistent UI patterns across all pages
- Easier to maintain and update styling
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:40:07 +01:00
|
|
|
<EmptyState
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
message={t("page.noTrades")}
|
Extract reusable UI components to reduce DRY violations
- Created StatusBadge component: Standardizes status badge display
- Supports tradeStatus prop for trade-specific styling
- Supports variant prop for simple badges (success/error/ready)
- Eliminates repetitive badge style combinations
- Created EmptyState component: Standardizes empty state display
- Handles loading and empty states consistently
- Supports message, hint, and action props
- Used across trades, invites, admin pages
- Created ConfirmationButton component: Standardizes confirmation flows
- Two-step confirmation pattern (action -> confirm/cancel)
- Supports different variants (danger/success/primary)
- Handles loading states automatically
- Used for cancel, complete, no-show actions
- Migrated pages to use new components:
- trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- trades/[id]/page.tsx: StatusBadge
- invites/page.tsx: StatusBadge, EmptyState
- admin/trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- admin/invites/page.tsx: StatusBadge
Benefits:
- Eliminated ~50+ lines of repetitive badge styling code
- Consistent UI patterns across all pages
- Easier to maintain and update styling
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:40:07 +01:00
|
|
|
action={
|
|
|
|
|
<a href="/exchange" style={styles.emptyStateLink}>
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
{t("page.startTrading")}
|
Extract reusable UI components to reduce DRY violations
- Created StatusBadge component: Standardizes status badge display
- Supports tradeStatus prop for trade-specific styling
- Supports variant prop for simple badges (success/error/ready)
- Eliminates repetitive badge style combinations
- Created EmptyState component: Standardizes empty state display
- Handles loading and empty states consistently
- Supports message, hint, and action props
- Used across trades, invites, admin pages
- Created ConfirmationButton component: Standardizes confirmation flows
- Two-step confirmation pattern (action -> confirm/cancel)
- Supports different variants (danger/success/primary)
- Handles loading states automatically
- Used for cancel, complete, no-show actions
- Migrated pages to use new components:
- trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- trades/[id]/page.tsx: StatusBadge
- invites/page.tsx: StatusBadge, EmptyState
- admin/trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- admin/invites/page.tsx: StatusBadge
Benefits:
- Eliminated ~50+ lines of repetitive badge styling code
- Consistent UI patterns across all pages
- Easier to maintain and update styling
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:40:07 +01:00
|
|
|
</a>
|
|
|
|
|
}
|
|
|
|
|
/>
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
{/* Upcoming Trades */}
|
|
|
|
|
{upcomingTrades.length > 0 && (
|
|
|
|
|
<div style={styles.section}>
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
<h2 style={styles.sectionTitle}>
|
|
|
|
|
{t("page.upcoming", { count: upcomingTrades.length })}
|
|
|
|
|
</h2>
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
<div style={tradeCardStyles.tradeList}>
|
|
|
|
|
{upcomingTrades.map((trade) => {
|
|
|
|
|
const isBuy = trade.direction === "buy";
|
|
|
|
|
return (
|
|
|
|
|
<div key={trade.id} style={tradeCardStyles.tradeCard}>
|
|
|
|
|
<div style={tradeCardStyles.tradeHeader}>
|
|
|
|
|
<div style={tradeCardStyles.tradeInfo}>
|
|
|
|
|
<div style={tradeCardStyles.tradeTime}>
|
|
|
|
|
{formatDateTime(trade.slot_start)}
|
|
|
|
|
</div>
|
|
|
|
|
<div style={tradeCardStyles.tradeDetails}>
|
2025-12-22 20:02:00 +01:00
|
|
|
<span
|
|
|
|
|
style={{
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
...tradeCardStyles.directionBadge,
|
|
|
|
|
background: isBuy
|
|
|
|
|
? "rgba(74, 222, 128, 0.15)"
|
|
|
|
|
: "rgba(248, 113, 113, 0.15)",
|
|
|
|
|
color: isBuy ? "#4ade80" : "#f87171",
|
2025-12-22 20:02:00 +01:00
|
|
|
}}
|
|
|
|
|
>
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
{isBuy ? tExchange("direction.buy") : tExchange("direction.sell")}
|
2025-12-22 20:02:00 +01:00
|
|
|
</span>
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
...tradeCardStyles.directionBadge,
|
|
|
|
|
background: "rgba(167, 139, 250, 0.15)",
|
|
|
|
|
color: "#a78bfa",
|
2025-12-23 17:03:51 +01:00
|
|
|
}}
|
|
|
|
|
>
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
{isBuy
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
? `${tExchange("bookingStep.receiveVia")} ${trade.bitcoin_transfer_method === "onchain" ? tExchange("transferMethod.onchain") : tExchange("transferMethod.lightning")}`
|
|
|
|
|
: `${tExchange("bookingStep.sendVia")} ${trade.bitcoin_transfer_method === "onchain" ? tExchange("transferMethod.onchain") : tExchange("transferMethod.lightning")}`}
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
</span>
|
|
|
|
|
<span style={tradeCardStyles.amount}>
|
|
|
|
|
{formatEur(trade.eur_amount)}
|
|
|
|
|
</span>
|
|
|
|
|
<span style={tradeCardStyles.arrow}>↔</span>
|
|
|
|
|
<span style={tradeCardStyles.satsAmount}>
|
|
|
|
|
<SatsDisplay sats={trade.sats_amount} />
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={tradeCardStyles.rateRow}>
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
<span style={tradeCardStyles.rateLabel}>{t("trade.rate")}</span>
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
<span style={tradeCardStyles.rateValue}>
|
|
|
|
|
€
|
|
|
|
|
{trade.agreed_price_eur.toLocaleString("de-DE", {
|
|
|
|
|
maximumFractionDigits: 0,
|
|
|
|
|
})}
|
|
|
|
|
/BTC
|
|
|
|
|
</span>
|
2025-12-23 17:03:51 +01:00
|
|
|
</div>
|
2025-12-25 21:50:34 +01:00
|
|
|
<StatusBadge tradeStatus={trade.status} style={{ marginTop: "0.5rem" }}>
|
|
|
|
|
{""}
|
|
|
|
|
</StatusBadge>
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div style={tradeCardStyles.buttonGroup}>
|
|
|
|
|
{trade.status === "booked" && (
|
Extract reusable UI components to reduce DRY violations
- Created StatusBadge component: Standardizes status badge display
- Supports tradeStatus prop for trade-specific styling
- Supports variant prop for simple badges (success/error/ready)
- Eliminates repetitive badge style combinations
- Created EmptyState component: Standardizes empty state display
- Handles loading and empty states consistently
- Supports message, hint, and action props
- Used across trades, invites, admin pages
- Created ConfirmationButton component: Standardizes confirmation flows
- Two-step confirmation pattern (action -> confirm/cancel)
- Supports different variants (danger/success/primary)
- Handles loading states automatically
- Used for cancel, complete, no-show actions
- Migrated pages to use new components:
- trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- trades/[id]/page.tsx: StatusBadge
- invites/page.tsx: StatusBadge, EmptyState
- admin/trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- admin/invites/page.tsx: StatusBadge
Benefits:
- Eliminated ~50+ lines of repetitive badge styling code
- Consistent UI patterns across all pages
- Easier to maintain and update styling
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:40:07 +01:00
|
|
|
<ConfirmationButton
|
|
|
|
|
isConfirming={confirmCancelId === trade.public_id}
|
|
|
|
|
onConfirm={() => handleCancel(trade.public_id)}
|
|
|
|
|
onCancel={() => setConfirmCancelId(null)}
|
|
|
|
|
onActionClick={() => setConfirmCancelId(trade.public_id)}
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
actionLabel={t("trade.cancel")}
|
Extract reusable UI components to reduce DRY violations
- Created StatusBadge component: Standardizes status badge display
- Supports tradeStatus prop for trade-specific styling
- Supports variant prop for simple badges (success/error/ready)
- Eliminates repetitive badge style combinations
- Created EmptyState component: Standardizes empty state display
- Handles loading and empty states consistently
- Supports message, hint, and action props
- Used across trades, invites, admin pages
- Created ConfirmationButton component: Standardizes confirmation flows
- Two-step confirmation pattern (action -> confirm/cancel)
- Supports different variants (danger/success/primary)
- Handles loading states automatically
- Used for cancel, complete, no-show actions
- Migrated pages to use new components:
- trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- trades/[id]/page.tsx: StatusBadge
- invites/page.tsx: StatusBadge, EmptyState
- admin/trades/page.tsx: StatusBadge, EmptyState, ConfirmationButton
- admin/invites/page.tsx: StatusBadge
Benefits:
- Eliminated ~50+ lines of repetitive badge styling code
- Consistent UI patterns across all pages
- Easier to maintain and update styling
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:40:07 +01:00
|
|
|
isLoading={cancellingId === trade.public_id}
|
|
|
|
|
confirmVariant="danger"
|
|
|
|
|
confirmButtonStyle={styles.confirmButton}
|
|
|
|
|
/>
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
)}
|
2025-12-23 17:03:51 +01:00
|
|
|
<button
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
router.push(`/trades/${trade.public_id}`);
|
|
|
|
|
}}
|
|
|
|
|
style={styles.viewDetailsButton}
|
|
|
|
|
>
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
{t("trade.viewDetails")}
|
2025-12-23 17:03:51 +01:00
|
|
|
</button>
|
|
|
|
|
</div>
|
2025-12-22 20:02:00 +01:00
|
|
|
</div>
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Past/Completed/Cancelled Trades */}
|
|
|
|
|
{pastOrFinalTrades.length > 0 && (
|
|
|
|
|
<div style={styles.section}>
|
|
|
|
|
<h2 style={typographyStyles.sectionTitleMuted}>
|
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00
|
|
|
{t("page.history", { count: pastOrFinalTrades.length })}
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
</h2>
|
|
|
|
|
<div style={tradeCardStyles.tradeList}>
|
|
|
|
|
{pastOrFinalTrades.map((trade) => {
|
|
|
|
|
const isBuy = trade.direction === "buy";
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={trade.id}
|
|
|
|
|
style={{
|
|
|
|
|
...tradeCardStyles.tradeCard,
|
|
|
|
|
...styles.tradeCardPast,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div style={tradeCardStyles.tradeTime}>
|
|
|
|
|
{formatDateTime(trade.slot_start)}
|
|
|
|
|
</div>
|
|
|
|
|
<div style={tradeCardStyles.tradeDetails}>
|
|
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
...tradeCardStyles.directionBadge,
|
|
|
|
|
background: isBuy
|
|
|
|
|
? "rgba(74, 222, 128, 0.1)"
|
|
|
|
|
: "rgba(248, 113, 113, 0.1)",
|
|
|
|
|
color: isBuy ? "rgba(74, 222, 128, 0.7)" : "rgba(248, 113, 113, 0.7)",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{isBuy ? "BUY BTC" : "SELL BTC"}
|
|
|
|
|
</span>
|
|
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
...tradeCardStyles.directionBadge,
|
|
|
|
|
background: "rgba(167, 139, 250, 0.1)",
|
|
|
|
|
color: "rgba(167, 139, 250, 0.7)",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{isBuy
|
|
|
|
|
? `Receive via ${trade.bitcoin_transfer_method === "onchain" ? "Onchain" : "Lightning"}`
|
|
|
|
|
: `Send via ${trade.bitcoin_transfer_method === "onchain" ? "Onchain" : "Lightning"}`}
|
|
|
|
|
</span>
|
|
|
|
|
<span style={tradeCardStyles.amount}>{formatEur(trade.eur_amount)}</span>
|
|
|
|
|
<span style={tradeCardStyles.arrow}>↔</span>
|
|
|
|
|
<span style={tradeCardStyles.satsAmount}>
|
|
|
|
|
<SatsDisplay sats={trade.sats_amount} />
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={tradeCardStyles.buttonGroup}>
|
2025-12-25 21:50:34 +01:00
|
|
|
<StatusBadge tradeStatus={trade.status}>{""}</StatusBadge>
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
<button
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
router.push(`/trades/${trade.public_id}`);
|
|
|
|
|
}}
|
|
|
|
|
style={styles.viewDetailsButton}
|
|
|
|
|
>
|
|
|
|
|
View Details
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2025-12-22 20:02:00 +01:00
|
|
|
</div>
|
Refactor frontend: Add reusable hooks and components
- Created useAsyncData hook: Eliminates repetitive data fetching boilerplate
- Handles loading, error, and data state automatically
- Supports enabled/disabled fetching
- Provides refetch function
- Created PageLayout component: Standardizes page structure
- Handles loading state, authorization checks, header, error display
- Reduces ~10 lines of boilerplate per page
- Created useMutation hook: Simplifies action handling
- Manages loading state and errors for mutations
- Supports success/error callbacks
- Used for cancel, create, revoke actions
- Created ErrorDisplay component: Standardizes error UI
- Consistent error banner styling across app
- Integrated into PageLayout
- Created useForm hook: Foundation for form state management
- Handles form data, validation, dirty checking
- Ready for future form migrations
- Migrated pages to use new patterns:
- invites/page.tsx: useAsyncData + PageLayout
- trades/page.tsx: useAsyncData + PageLayout + useMutation
- trades/[id]/page.tsx: useAsyncData
- admin/price-history/page.tsx: useAsyncData + PageLayout
- admin/invites/page.tsx: useMutation for create/revoke
Benefits:
- ~40% reduction in boilerplate code
- Consistent patterns across pages
- Easier to maintain and extend
- Better type safety
All tests passing (32 frontend, 33 e2e)
2025-12-25 21:30:35 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</PageLayout>
|
2025-12-22 20:02:00 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-23 12:22:04 +01:00
|
|
|
// Page-specific styles (trade card styles are shared via tradeCardStyles)
|
2025-12-23 12:23:32 +01:00
|
|
|
const styles: Record<string, CSSProperties> = {
|
2025-12-22 20:02:00 +01:00
|
|
|
content: {
|
|
|
|
|
flex: 1,
|
|
|
|
|
padding: "2rem",
|
|
|
|
|
maxWidth: "800px",
|
|
|
|
|
margin: "0 auto",
|
|
|
|
|
width: "100%",
|
|
|
|
|
},
|
|
|
|
|
section: {
|
|
|
|
|
marginBottom: "2rem",
|
|
|
|
|
},
|
|
|
|
|
sectionTitle: {
|
|
|
|
|
fontFamily: "'DM Sans', system-ui, sans-serif",
|
|
|
|
|
fontSize: "1.1rem",
|
|
|
|
|
fontWeight: 500,
|
|
|
|
|
color: "#fff",
|
|
|
|
|
marginBottom: "1rem",
|
|
|
|
|
},
|
|
|
|
|
tradeCardPast: {
|
|
|
|
|
opacity: 0.6,
|
|
|
|
|
background: "rgba(255, 255, 255, 0.01)",
|
|
|
|
|
},
|
|
|
|
|
confirmButton: {
|
|
|
|
|
fontFamily: "'DM Sans', system-ui, sans-serif",
|
|
|
|
|
padding: "0.35rem 0.75rem",
|
|
|
|
|
fontSize: "0.75rem",
|
|
|
|
|
background: "rgba(239, 68, 68, 0.2)",
|
|
|
|
|
border: "1px solid rgba(239, 68, 68, 0.3)",
|
|
|
|
|
borderRadius: "6px",
|
|
|
|
|
color: "#f87171",
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
transition: "all 0.2s",
|
|
|
|
|
},
|
|
|
|
|
emptyStateLink: {
|
|
|
|
|
color: "#a78bfa",
|
|
|
|
|
textDecoration: "none",
|
|
|
|
|
},
|
2025-12-23 17:03:51 +01:00
|
|
|
viewDetailsButton: {
|
|
|
|
|
fontFamily: "'DM Sans', system-ui, sans-serif",
|
|
|
|
|
padding: "0.35rem 0.75rem",
|
|
|
|
|
fontSize: "0.75rem",
|
|
|
|
|
background: "rgba(167, 139, 250, 0.15)",
|
|
|
|
|
border: "1px solid rgba(167, 139, 250, 0.3)",
|
|
|
|
|
borderRadius: "6px",
|
|
|
|
|
color: "#a78bfa",
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
transition: "all 0.2s",
|
|
|
|
|
},
|
2025-12-22 20:02:00 +01:00
|
|
|
};
|