2025-12-20 11:12:11 +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 } from "react";
|
2025-12-25 20:32:11 +01:00
|
|
|
import { invitesApi } 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";
|
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";
|
2025-12-25 21:50:34 +01:00
|
|
|
import { EmptyState } from "../components/EmptyState";
|
2025-12-20 11:12:11 +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";
|
2025-12-20 23:06:05 +01:00
|
|
|
import { components } from "../generated/api";
|
|
|
|
|
import constants from "../../../shared/constants.json";
|
2025-12-21 23:50:06 +01:00
|
|
|
import { Permission } from "../auth-context";
|
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 { cardStyles, typographyStyles, buttonStyles } 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-20 11:12:11 +01:00
|
|
|
|
2025-12-20 23:06:05 +01:00
|
|
|
// Use generated type from OpenAPI schema
|
|
|
|
|
type Invite = components["schemas"]["UserInviteResponse"];
|
2025-12-20 11:12:11 +01:00
|
|
|
|
|
|
|
|
export default function InvitesPage() {
|
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("invites");
|
2025-12-20 11:12:11 +01:00
|
|
|
const { user, isLoading, isAuthorized } = useRequireAuth({
|
2025-12-21 23:50:06 +01:00
|
|
|
requiredPermission: Permission.VIEW_OWN_INVITES,
|
2025-12-22 20:18:33 +01:00
|
|
|
fallbackRedirect: "/admin/trades",
|
2025-12-20 11:12:11 +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 { data: invites = [], isLoading: isLoadingInvites } = useAsyncData(
|
|
|
|
|
() => invitesApi.getInvites(),
|
|
|
|
|
{
|
|
|
|
|
enabled: !!user && isAuthorized,
|
|
|
|
|
initialData: [],
|
2025-12-20 11:12:11 +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-20 11:12:11 +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 [copiedId, setCopiedId] = useState<number | null>(null);
|
2025-12-20 11:12:11 +01:00
|
|
|
|
|
|
|
|
const getInviteUrl = (identifier: string) => {
|
|
|
|
|
if (typeof window !== "undefined") {
|
|
|
|
|
return `${window.location.origin}/signup/${identifier}`;
|
|
|
|
|
}
|
|
|
|
|
return `/signup/${identifier}`;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const copyToClipboard = async (invite: Invite) => {
|
|
|
|
|
const url = getInviteUrl(invite.identifier);
|
|
|
|
|
try {
|
|
|
|
|
await navigator.clipboard.writeText(url);
|
|
|
|
|
setCopiedId(invite.id);
|
|
|
|
|
setTimeout(() => setCopiedId(null), 2000);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error("Failed to copy:", err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-20 23:06:05 +01:00
|
|
|
const { READY, SPENT, REVOKED } = constants.inviteStatuses;
|
2025-12-25 21:50:34 +01:00
|
|
|
const readyInvites = (invites ?? []).filter((i) => i.status === READY);
|
|
|
|
|
const spentInvites = (invites ?? []).filter((i) => i.status === SPENT);
|
|
|
|
|
const revokedInvites = (invites ?? []).filter((i) => i.status === REVOKED);
|
2025-12-20 11:12:11 +01:00
|
|
|
|
|
|
|
|
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="invites"
|
|
|
|
|
isLoading={isLoading || isLoadingInvites}
|
|
|
|
|
isAuthorized={!!user && isAuthorized}
|
|
|
|
|
>
|
|
|
|
|
<div style={styles.pageCard}>
|
|
|
|
|
<div style={cardStyles.cardHeader}>
|
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={cardStyles.cardTitle}>{t("page.title")}</h1>
|
|
|
|
|
<p style={cardStyles.cardSubtitle}>{t("page.subtitle")}</p>
|
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>
|
2025-12-20 11:12:11 +01:00
|
|
|
|
2025-12-25 21:50:34 +01:00
|
|
|
{(invites?.length ?? 0) === 0 ? (
|
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.noInvites")} hint={t("page.noInvitesHint")} />
|
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={styles.sections}>
|
|
|
|
|
{/* Ready Invites */}
|
|
|
|
|
{readyInvites.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={typographyStyles.sectionTitle}>
|
|
|
|
|
{t("page.available", { count: readyInvites.length })}
|
|
|
|
|
</h2>
|
|
|
|
|
<p style={typographyStyles.sectionHint}>{t("page.availableHint")}</p>
|
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={styles.inviteList}>
|
|
|
|
|
{readyInvites.map((invite) => (
|
|
|
|
|
<div key={invite.id} style={styles.inviteCard}>
|
|
|
|
|
<div style={styles.inviteCode}>{invite.identifier}</div>
|
|
|
|
|
<div style={styles.inviteActions}>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => copyToClipboard(invite)}
|
|
|
|
|
style={buttonStyles.accentButton}
|
|
|
|
|
>
|
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
|
|
|
{copiedId === invite.id ? t("page.copied") : t("page.copyLink")}
|
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>
|
2025-12-20 11:12:11 +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>
|
|
|
|
|
))}
|
2025-12-20 11:12:11 +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>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Spent Invites */}
|
|
|
|
|
{spentInvites.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={typographyStyles.sectionTitle}>
|
|
|
|
|
{t("page.used", { count: spentInvites.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={styles.inviteList}>
|
|
|
|
|
{spentInvites.map((invite) => (
|
|
|
|
|
<div key={invite.id} style={styles.inviteCardSpent}>
|
|
|
|
|
<div style={styles.inviteCode}>{invite.identifier}</div>
|
|
|
|
|
<div style={styles.inviteeMeta}>
|
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
|
|
|
<StatusBadge variant="success">{t("page.usedStatus")}</StatusBadge>
|
|
|
|
|
{invite.used_by_email && (
|
|
|
|
|
<span style={styles.inviteeEmail}>
|
|
|
|
|
{t("page.usedBy", { email: invite.used_by_email })}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
2025-12-20 11:12:11 +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>
|
|
|
|
|
))}
|
2025-12-20 11:12:11 +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>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Revoked Invites */}
|
|
|
|
|
{revokedInvites.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={typographyStyles.sectionTitle}>
|
|
|
|
|
{t("page.revoked", { count: revokedInvites.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={styles.inviteList}>
|
|
|
|
|
{revokedInvites.map((invite) => (
|
|
|
|
|
<div key={invite.id} style={styles.inviteCardRevoked}>
|
|
|
|
|
<div style={styles.inviteCode}>{invite.identifier}</div>
|
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
|
|
|
<StatusBadge variant="error">{t("page.revokedStatus")}</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>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-12-20 11:12:11 +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
|
|
|
</PageLayout>
|
2025-12-20 11:12:11 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
refactor(frontend): consolidate shared styles into centralized style system
- Create comprehensive shared.ts with design tokens and categorized styles:
- layoutStyles: main, loader, content variants
- cardStyles: card, tableCard, cardHeader
- tableStyles: complete table styling
- paginationStyles: pagination controls
- formStyles: inputs, labels, errors
- buttonStyles: primary, secondary, accent, danger variants
- badgeStyles: status badges with color variants
- bannerStyles: error/success banners
- modalStyles: modal overlay and content
- toastStyles: toast notifications
- utilityStyles: divider, emptyState, etc.
- Refactor all page components to use shared styles:
- page.tsx (counter)
- audit/page.tsx
- booking/page.tsx
- appointments/page.tsx
- profile/page.tsx
- invites/page.tsx
- admin/invites/page.tsx
- admin/availability/page.tsx
- Reduce code duplication significantly (each page now has only
truly page-specific styles)
- Maintain backwards compatibility with sharedStyles export
2025-12-21 23:45:47 +01:00
|
|
|
// Page-specific styles
|
|
|
|
|
const styles: Record<string, React.CSSProperties> = {
|
2025-12-20 11:12:11 +01:00
|
|
|
pageCard: {
|
refactor(frontend): consolidate shared styles into centralized style system
- Create comprehensive shared.ts with design tokens and categorized styles:
- layoutStyles: main, loader, content variants
- cardStyles: card, tableCard, cardHeader
- tableStyles: complete table styling
- paginationStyles: pagination controls
- formStyles: inputs, labels, errors
- buttonStyles: primary, secondary, accent, danger variants
- badgeStyles: status badges with color variants
- bannerStyles: error/success banners
- modalStyles: modal overlay and content
- toastStyles: toast notifications
- utilityStyles: divider, emptyState, etc.
- Refactor all page components to use shared styles:
- page.tsx (counter)
- audit/page.tsx
- booking/page.tsx
- appointments/page.tsx
- profile/page.tsx
- invites/page.tsx
- admin/invites/page.tsx
- admin/availability/page.tsx
- Reduce code duplication significantly (each page now has only
truly page-specific styles)
- Maintain backwards compatibility with sharedStyles export
2025-12-21 23:45:47 +01:00
|
|
|
...cardStyles.card,
|
2025-12-20 11:12:11 +01:00
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "600px",
|
|
|
|
|
},
|
|
|
|
|
emptyState: {
|
|
|
|
|
textAlign: "center",
|
|
|
|
|
padding: "2rem 0",
|
|
|
|
|
},
|
|
|
|
|
emptyText: {
|
|
|
|
|
fontFamily: "'DM Sans', system-ui, sans-serif",
|
|
|
|
|
color: "rgba(255, 255, 255, 0.6)",
|
|
|
|
|
fontSize: "1rem",
|
|
|
|
|
margin: 0,
|
|
|
|
|
},
|
|
|
|
|
emptyHint: {
|
|
|
|
|
fontFamily: "'DM Sans', system-ui, sans-serif",
|
|
|
|
|
color: "rgba(255, 255, 255, 0.4)",
|
|
|
|
|
fontSize: "0.85rem",
|
|
|
|
|
marginTop: "0.5rem",
|
|
|
|
|
},
|
|
|
|
|
sections: {
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "2rem",
|
|
|
|
|
},
|
|
|
|
|
section: {
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "0.75rem",
|
|
|
|
|
},
|
|
|
|
|
inviteList: {
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "0.75rem",
|
|
|
|
|
},
|
|
|
|
|
inviteCard: {
|
|
|
|
|
background: "rgba(99, 102, 241, 0.1)",
|
|
|
|
|
border: "1px solid rgba(99, 102, 241, 0.3)",
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
padding: "1rem",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
},
|
|
|
|
|
inviteCardSpent: {
|
|
|
|
|
background: "rgba(34, 197, 94, 0.08)",
|
|
|
|
|
border: "1px solid rgba(34, 197, 94, 0.2)",
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
padding: "1rem",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
},
|
|
|
|
|
inviteCardRevoked: {
|
|
|
|
|
background: "rgba(239, 68, 68, 0.08)",
|
|
|
|
|
border: "1px solid rgba(239, 68, 68, 0.2)",
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
padding: "1rem",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
opacity: 0.7,
|
|
|
|
|
},
|
|
|
|
|
inviteCode: {
|
|
|
|
|
fontFamily: "'DM Mono', monospace",
|
|
|
|
|
fontSize: "0.95rem",
|
|
|
|
|
color: "#fff",
|
|
|
|
|
letterSpacing: "0.02em",
|
|
|
|
|
},
|
|
|
|
|
inviteActions: {
|
|
|
|
|
display: "flex",
|
|
|
|
|
gap: "0.5rem",
|
|
|
|
|
},
|
|
|
|
|
inviteeMeta: {
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: "0.5rem",
|
|
|
|
|
},
|
|
|
|
|
inviteeEmail: {
|
|
|
|
|
fontFamily: "'DM Sans', system-ui, sans-serif",
|
|
|
|
|
fontSize: "0.8rem",
|
|
|
|
|
color: "rgba(255, 255, 255, 0.6)",
|
|
|
|
|
},
|
|
|
|
|
};
|