Translate admin pages - Create admin.json files and translate all admin pages
- Create admin.json translation files for es, en, ca with all admin strings - Update IntlProvider to include admin namespace - Translate admin/invites/page.tsx - all strings now use translations - Translate admin/trades/page.tsx - all strings now use translations - Translate admin/price-history/page.tsx - all strings now use translations - Translate admin/availability/page.tsx - all strings now use translations - Add 'saving' key to common.json for all languages - Fix linting errors: add t to useCallback dependencies - All admin pages now fully multilingual
This commit is contained in:
parent
b8b3e8b9f6
commit
e2376855ce
11 changed files with 473 additions and 87 deletions
|
|
@ -5,6 +5,7 @@ import { Permission } from "../../auth-context";
|
|||
import { adminApi } from "../../api";
|
||||
import { Header } from "../../components/Header";
|
||||
import { useRequireAuth } from "../../hooks/useRequireAuth";
|
||||
import { useTranslation } from "../../hooks/useTranslation";
|
||||
import { components } from "../../generated/api";
|
||||
import constants from "../../../../shared/constants.json";
|
||||
import {
|
||||
|
|
@ -49,6 +50,8 @@ interface EditSlot {
|
|||
}
|
||||
|
||||
export default function AdminAvailabilityPage() {
|
||||
const t = useTranslation("admin");
|
||||
const tCommon = useTranslation("common");
|
||||
const { user, isLoading, isAuthorized } = useRequireAuth({
|
||||
requiredPermission: Permission.MANAGE_AVAILABILITY,
|
||||
fallbackRedirect: "/",
|
||||
|
|
@ -145,7 +148,7 @@ export default function AdminAvailabilityPage() {
|
|||
await fetchAvailability();
|
||||
closeModal();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Failed to save");
|
||||
setError(err instanceof Error ? err.message : t("availability.errors.saveFailed"));
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
}
|
||||
|
|
@ -166,7 +169,7 @@ export default function AdminAvailabilityPage() {
|
|||
await fetchAvailability();
|
||||
closeModal();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Failed to clear");
|
||||
setError(err instanceof Error ? err.message : t("availability.errors.clearFailed"));
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
}
|
||||
|
|
@ -208,7 +211,7 @@ export default function AdminAvailabilityPage() {
|
|||
await fetchAvailability();
|
||||
cancelCopyMode();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Failed to copy");
|
||||
setError(err instanceof Error ? err.message : t("availability.errors.copyFailed"));
|
||||
} finally {
|
||||
setIsCopying(false);
|
||||
}
|
||||
|
|
@ -221,7 +224,7 @@ export default function AdminAvailabilityPage() {
|
|||
if (isLoading) {
|
||||
return (
|
||||
<main style={layoutStyles.main}>
|
||||
<div style={layoutStyles.loader}>Loading...</div>
|
||||
<div style={layoutStyles.loader}>{tCommon("loading")}</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
|
@ -238,23 +241,25 @@ export default function AdminAvailabilityPage() {
|
|||
<div style={styles.pageContainer}>
|
||||
<div style={styles.headerRow}>
|
||||
<div>
|
||||
<h1 style={typographyStyles.pageTitle}>Availability</h1>
|
||||
<h1 style={typographyStyles.pageTitle}>{t("availability.title")}</h1>
|
||||
<p style={typographyStyles.pageSubtitle}>
|
||||
Configure your available time slots for the next {maxAdvanceDays} days
|
||||
{t("availability.subtitle", { days: maxAdvanceDays })}
|
||||
</p>
|
||||
</div>
|
||||
{copySource && (
|
||||
<div style={styles.copyActions}>
|
||||
<span style={styles.copyHint}>Select days to copy to, then click Copy</span>
|
||||
<span style={styles.copyHint}>{t("availability.copyMode.hint")}</span>
|
||||
<button
|
||||
onClick={executeCopy}
|
||||
disabled={copyTargets.size === 0 || isCopying}
|
||||
style={buttonStyles.accentButton}
|
||||
>
|
||||
{isCopying ? "Copying..." : `Copy to ${copyTargets.size} day(s)`}
|
||||
{isCopying
|
||||
? t("availability.copyMode.copying")
|
||||
: t("availability.copyMode.copyTo", { count: copyTargets.size })}
|
||||
</button>
|
||||
<button onClick={cancelCopyMode} style={buttonStyles.secondaryButton}>
|
||||
Cancel
|
||||
{t("availability.copyMode.cancel")}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -299,7 +304,7 @@ export default function AdminAvailabilityPage() {
|
|||
startCopyMode(dateStr);
|
||||
}}
|
||||
style={styles.copyFromButton}
|
||||
title="Copy to other days"
|
||||
title={t("availability.copyMode.copyTo", { count: 0 })}
|
||||
>
|
||||
📋
|
||||
</button>
|
||||
|
|
@ -307,7 +312,7 @@ export default function AdminAvailabilityPage() {
|
|||
</div>
|
||||
<div style={styles.slotList}>
|
||||
{slots.length === 0 ? (
|
||||
<span style={styles.noSlots}>No availability</span>
|
||||
<span style={styles.noSlots}>{t("availability.modal.noAvailability")}</span>
|
||||
) : (
|
||||
slots.map((slot, i) => (
|
||||
<span key={i} style={styles.slotBadge}>
|
||||
|
|
@ -328,7 +333,7 @@ export default function AdminAvailabilityPage() {
|
|||
<div style={modalStyles.modalOverlay} onClick={closeModal}>
|
||||
<div style={modalStyles.modal} onClick={(e) => e.stopPropagation()}>
|
||||
<h2 style={modalStyles.modalTitle}>
|
||||
Edit Availability - {formatDisplayDate(selectedDate)}
|
||||
{t("availability.modal.title")} - {formatDisplayDate(selectedDate)}
|
||||
</h2>
|
||||
|
||||
{error && <div style={modalStyles.modalError}>{error}</div>}
|
||||
|
|
@ -362,31 +367,31 @@ export default function AdminAvailabilityPage() {
|
|||
<button
|
||||
onClick={() => removeSlot(index)}
|
||||
style={styles.removeSlotButton}
|
||||
title="Remove slot"
|
||||
title={t("availability.modal.removeSlot")}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
<button onClick={addSlot} style={styles.addSlotButton}>
|
||||
+ Add Time Range
|
||||
+ {t("availability.modal.addSlot")}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div style={modalStyles.modalActions}>
|
||||
<button onClick={clearAvailability} disabled={isSaving} style={styles.clearButton}>
|
||||
Clear All
|
||||
{t("availability.modal.clear")}
|
||||
</button>
|
||||
<div style={modalStyles.modalActionsRight}>
|
||||
<button onClick={closeModal} style={buttonStyles.secondaryButton}>
|
||||
Cancel
|
||||
{t("availability.modal.close")}
|
||||
</button>
|
||||
<button
|
||||
onClick={saveAvailability}
|
||||
disabled={isSaving}
|
||||
style={buttonStyles.accentButton}
|
||||
>
|
||||
{isSaving ? "Saving..." : "Save"}
|
||||
{isSaving ? tCommon("saving") : t("availability.modal.save")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { Header } from "../../components/Header";
|
|||
import { StatusBadge } from "../../components/StatusBadge";
|
||||
import { useRequireAuth } from "../../hooks/useRequireAuth";
|
||||
import { useMutation } from "../../hooks/useMutation";
|
||||
import { useTranslation } from "../../hooks/useTranslation";
|
||||
import { components } from "../../generated/api";
|
||||
import constants from "../../../../shared/constants.json";
|
||||
import {
|
||||
|
|
@ -27,6 +28,8 @@ type PaginatedInvites = components["schemas"]["PaginatedResponse_InviteResponse_
|
|||
type UserOption = components["schemas"]["AdminUserResponse"];
|
||||
|
||||
export default function AdminInvitesPage() {
|
||||
const t = useTranslation("admin");
|
||||
const tCommon = useTranslation("common");
|
||||
const [data, setData] = useState<PaginatedInvites | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [page, setPage] = useState(1);
|
||||
|
|
@ -47,16 +50,19 @@ export default function AdminInvitesPage() {
|
|||
}
|
||||
}, []);
|
||||
|
||||
const fetchInvites = useCallback(async (page: number, status: string) => {
|
||||
setError(null);
|
||||
try {
|
||||
const data = await adminApi.getInvites(page, 10, status || undefined);
|
||||
setData(data);
|
||||
} catch (err) {
|
||||
setData(null);
|
||||
setError(err instanceof Error ? err.message : "Failed to load invites");
|
||||
}
|
||||
}, []);
|
||||
const fetchInvites = useCallback(
|
||||
async (page: number, status: string) => {
|
||||
setError(null);
|
||||
try {
|
||||
const data = await adminApi.getInvites(page, 10, status || undefined);
|
||||
setData(data);
|
||||
} catch (err) {
|
||||
setData(null);
|
||||
setError(err instanceof Error ? err.message : t("invites.errors.loadFailed"));
|
||||
}
|
||||
},
|
||||
[t]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (user && isAuthorized) {
|
||||
|
|
@ -91,7 +97,7 @@ export default function AdminInvitesPage() {
|
|||
fetchInvites(page, statusFilter);
|
||||
},
|
||||
onError: (err) => {
|
||||
setError(err instanceof Error ? err.message : "Failed to revoke invite");
|
||||
setError(err instanceof Error ? err.message : t("invites.errors.revokeFailed"));
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
@ -135,7 +141,7 @@ export default function AdminInvitesPage() {
|
|||
if (isLoading) {
|
||||
return (
|
||||
<main style={layoutStyles.main}>
|
||||
<div style={layoutStyles.loader}>Loading...</div>
|
||||
<div style={layoutStyles.loader}>{tCommon("loading")}</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
|
@ -152,16 +158,16 @@ export default function AdminInvitesPage() {
|
|||
<div style={styles.pageContainer}>
|
||||
{/* Create Invite Section */}
|
||||
<div style={styles.createCard}>
|
||||
<h2 style={styles.createTitle}>Create Invite</h2>
|
||||
<h2 style={styles.createTitle}>{t("invites.createInvite")}</h2>
|
||||
<div style={styles.createForm}>
|
||||
<div style={formStyles.field}>
|
||||
<label style={styles.inputLabel}>Godfather (user who can share this invite)</label>
|
||||
<label style={styles.inputLabel}>{t("invites.godfatherLabel")}</label>
|
||||
<select
|
||||
value={newGodfatherId}
|
||||
onChange={(e) => setNewGodfatherId(e.target.value)}
|
||||
style={{ ...formStyles.select, maxWidth: "400px" }}
|
||||
>
|
||||
<option value="">Select a user...</option>
|
||||
<option value="">{t("invites.selectUser")}</option>
|
||||
{users.map((u) => (
|
||||
<option key={u.id} value={u.id}>
|
||||
{u.email}
|
||||
|
|
@ -169,9 +175,7 @@ export default function AdminInvitesPage() {
|
|||
))}
|
||||
</select>
|
||||
{users.length === 0 && (
|
||||
<span style={formStyles.hint}>
|
||||
No users loaded yet. Create at least one invite to populate the list.
|
||||
</span>
|
||||
<span style={formStyles.hint}>{t("invites.noUsersHint")}</span>
|
||||
)}
|
||||
</div>
|
||||
{createError && <div style={styles.createError}>{createError}</div>}
|
||||
|
|
@ -184,7 +188,7 @@ export default function AdminInvitesPage() {
|
|||
...(!newGodfatherId ? buttonStyles.buttonDisabled : {}),
|
||||
}}
|
||||
>
|
||||
{isCreating ? "Creating..." : "Create Invite"}
|
||||
{isCreating ? t("invites.creating") : t("invites.createInvite")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -192,7 +196,7 @@ export default function AdminInvitesPage() {
|
|||
{/* Invites Table */}
|
||||
<div style={cardStyles.tableCard}>
|
||||
<div style={tableStyles.tableHeader}>
|
||||
<h2 style={tableStyles.tableTitle}>All Invites</h2>
|
||||
<h2 style={tableStyles.tableTitle}>{t("invites.allInvites")}</h2>
|
||||
<div style={utilityStyles.filterGroup}>
|
||||
<select
|
||||
value={statusFilter}
|
||||
|
|
@ -202,12 +206,14 @@ export default function AdminInvitesPage() {
|
|||
}}
|
||||
style={styles.filterSelect}
|
||||
>
|
||||
<option value="">All statuses</option>
|
||||
<option value={READY}>Ready</option>
|
||||
<option value={SPENT}>Spent</option>
|
||||
<option value={REVOKED}>Revoked</option>
|
||||
<option value="">{t("invites.allStatuses")}</option>
|
||||
<option value={READY}>{t("invites.statusReady")}</option>
|
||||
<option value={SPENT}>{t("invites.statusSpent")}</option>
|
||||
<option value={REVOKED}>{t("invites.statusRevoked")}</option>
|
||||
</select>
|
||||
<span style={tableStyles.totalCount}>{data?.total ?? 0} invites</span>
|
||||
<span style={tableStyles.totalCount}>
|
||||
{t("invites.invitesCount", { count: data?.total ?? 0 })}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -215,12 +221,12 @@ export default function AdminInvitesPage() {
|
|||
<table style={tableStyles.table}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style={tableStyles.th}>Code</th>
|
||||
<th style={tableStyles.th}>Godfather</th>
|
||||
<th style={tableStyles.th}>Status</th>
|
||||
<th style={tableStyles.th}>Used By</th>
|
||||
<th style={tableStyles.th}>Created</th>
|
||||
<th style={tableStyles.th}>Actions</th>
|
||||
<th style={tableStyles.th}>{t("invites.tableHeaders.code")}</th>
|
||||
<th style={tableStyles.th}>{t("invites.tableHeaders.godfather")}</th>
|
||||
<th style={tableStyles.th}>{t("invites.tableHeaders.status")}</th>
|
||||
<th style={tableStyles.th}>{t("invites.tableHeaders.usedBy")}</th>
|
||||
<th style={tableStyles.th}>{t("invites.tableHeaders.created")}</th>
|
||||
<th style={tableStyles.th}>{t("invites.tableHeaders.actions")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -249,7 +255,7 @@ export default function AdminInvitesPage() {
|
|||
onClick={() => handleRevoke(record.id)}
|
||||
style={buttonStyles.dangerButton}
|
||||
>
|
||||
Revoke
|
||||
{t("invites.revoke")}
|
||||
</button>
|
||||
)}
|
||||
</td>
|
||||
|
|
@ -258,7 +264,7 @@ export default function AdminInvitesPage() {
|
|||
{!error && (!data || data.records.length === 0) && (
|
||||
<tr>
|
||||
<td colSpan={6} style={tableStyles.emptyRow}>
|
||||
No invites yet
|
||||
{t("invites.noInvites")}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ import { adminApi } from "../../api";
|
|||
import { sharedStyles } from "../../styles/shared";
|
||||
import { PageLayout } from "../../components/PageLayout";
|
||||
import { useRequireAuth } from "../../hooks/useRequireAuth";
|
||||
import { useTranslation } from "../../hooks/useTranslation";
|
||||
import { useAsyncData } from "../../hooks/useAsyncData";
|
||||
|
||||
export default function AdminPriceHistoryPage() {
|
||||
const t = useTranslation("admin");
|
||||
const { user, isLoading, isAuthorized } = useRequireAuth({
|
||||
requiredPermission: Permission.VIEW_AUDIT,
|
||||
fallbackRedirect: "/",
|
||||
|
|
@ -61,14 +63,16 @@ export default function AdminPriceHistoryPage() {
|
|||
>
|
||||
<div style={styles.tableCard}>
|
||||
<div style={styles.tableHeader}>
|
||||
<h2 style={styles.tableTitle}>Bitcoin Price History</h2>
|
||||
<h2 style={styles.tableTitle}>{t("priceHistory.title")}</h2>
|
||||
<div style={styles.headerActions}>
|
||||
<span style={styles.totalCount}>{records?.length ?? 0} records</span>
|
||||
<span style={styles.totalCount}>
|
||||
{t("priceHistory.recordsCount", { count: records?.length ?? 0 })}
|
||||
</span>
|
||||
<button onClick={fetchRecords} style={styles.refreshBtn} disabled={isLoadingData}>
|
||||
Refresh
|
||||
{t("priceHistory.refresh")}
|
||||
</button>
|
||||
<button onClick={handleFetchNow} style={styles.fetchBtn} disabled={isFetching}>
|
||||
{isFetching ? "Fetching..." : "Fetch Now"}
|
||||
{isFetching ? t("priceHistory.fetching") : t("priceHistory.fetchNow")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -77,10 +81,10 @@ export default function AdminPriceHistoryPage() {
|
|||
<table style={styles.table}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style={styles.th}>Source</th>
|
||||
<th style={styles.th}>Pair</th>
|
||||
<th style={styles.th}>Price</th>
|
||||
<th style={styles.th}>Timestamp</th>
|
||||
<th style={styles.th}>{t("priceHistory.tableHeaders.source")}</th>
|
||||
<th style={styles.th}>{t("priceHistory.tableHeaders.pair")}</th>
|
||||
<th style={styles.th}>{t("priceHistory.tableHeaders.price")}</th>
|
||||
<th style={styles.th}>{t("priceHistory.tableHeaders.timestamp")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -94,14 +98,14 @@ export default function AdminPriceHistoryPage() {
|
|||
{!error && isLoadingData && (
|
||||
<tr>
|
||||
<td colSpan={4} style={styles.emptyRow}>
|
||||
Loading...
|
||||
{t("priceHistory.loading")}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{!error && !isLoadingData && (records?.length ?? 0) === 0 && (
|
||||
<tr>
|
||||
<td colSpan={4} style={styles.emptyRow}>
|
||||
No price records yet. Click "Fetch Now" to get the current price.
|
||||
{t("priceHistory.emptyState")}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { StatusBadge } from "../../components/StatusBadge";
|
|||
import { EmptyState } from "../../components/EmptyState";
|
||||
import { ConfirmationButton } from "../../components/ConfirmationButton";
|
||||
import { useRequireAuth } from "../../hooks/useRequireAuth";
|
||||
import { useTranslation } from "../../hooks/useTranslation";
|
||||
import { components } from "../../generated/api";
|
||||
import { formatDateTime } from "../../utils/date";
|
||||
import { formatEur } from "../../utils/exchange";
|
||||
|
|
@ -19,6 +20,8 @@ type AdminExchangeResponse = components["schemas"]["AdminExchangeResponse"];
|
|||
type Tab = "upcoming" | "past";
|
||||
|
||||
export default function AdminTradesPage() {
|
||||
const t = useTranslation("admin");
|
||||
const tCommon = useTranslation("common");
|
||||
const { user, isLoading, isAuthorized } = useRequireAuth({
|
||||
requiredPermission: Permission.VIEW_ALL_EXCHANGES,
|
||||
fallbackRedirect: "/",
|
||||
|
|
@ -48,9 +51,9 @@ export default function AdminTradesPage() {
|
|||
return null;
|
||||
} catch (err) {
|
||||
console.error("Failed to fetch upcoming trades:", err);
|
||||
return "Failed to load upcoming trades";
|
||||
return t("trades.errors.loadUpcomingFailed");
|
||||
}
|
||||
}, []);
|
||||
}, [t]);
|
||||
|
||||
const fetchPastTrades = useCallback(async (): Promise<string | null> => {
|
||||
try {
|
||||
|
|
@ -69,9 +72,9 @@ export default function AdminTradesPage() {
|
|||
return null;
|
||||
} catch (err) {
|
||||
console.error("Failed to fetch past trades:", err);
|
||||
return "Failed to load past trades";
|
||||
return t("trades.errors.loadPastFailed");
|
||||
}
|
||||
}, [statusFilter, userSearch]);
|
||||
}, [statusFilter, userSearch, t]);
|
||||
|
||||
useEffect(() => {
|
||||
if (user && isAuthorized) {
|
||||
|
|
@ -112,7 +115,7 @@ export default function AdminTradesPage() {
|
|||
}
|
||||
setConfirmAction(null);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : `Failed to ${action} trade`);
|
||||
setError(err instanceof Error ? err.message : t("trades.errors.actionFailed", { action }));
|
||||
} finally {
|
||||
// Remove this trade from the set of actioning trades
|
||||
setActioningIds((prev) => {
|
||||
|
|
@ -126,7 +129,7 @@ export default function AdminTradesPage() {
|
|||
if (isLoading) {
|
||||
return (
|
||||
<main style={layoutStyles.main}>
|
||||
<div style={layoutStyles.loader}>Loading...</div>
|
||||
<div style={layoutStyles.loader}>{tCommon("loading")}</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
|
@ -141,8 +144,8 @@ export default function AdminTradesPage() {
|
|||
<main style={layoutStyles.main}>
|
||||
<Header currentPage="admin-trades" />
|
||||
<div style={styles.content}>
|
||||
<h1 style={typographyStyles.pageTitle}>Trades</h1>
|
||||
<p style={typographyStyles.pageSubtitle}>Manage Bitcoin exchange trades</p>
|
||||
<h1 style={typographyStyles.pageTitle}>{t("trades.title")}</h1>
|
||||
<p style={typographyStyles.pageSubtitle}>{t("trades.subtitle")}</p>
|
||||
|
||||
{error && <div style={bannerStyles.errorBanner}>{error}</div>}
|
||||
|
||||
|
|
@ -155,7 +158,7 @@ export default function AdminTradesPage() {
|
|||
...(activeTab === "upcoming" ? styles.tabButtonActive : {}),
|
||||
}}
|
||||
>
|
||||
Upcoming ({upcomingTrades.length})
|
||||
{t("trades.tabs.upcoming", { count: upcomingTrades.length })}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab("past")}
|
||||
|
|
@ -164,7 +167,7 @@ export default function AdminTradesPage() {
|
|||
...(activeTab === "past" ? styles.tabButtonActive : {}),
|
||||
}}
|
||||
>
|
||||
History ({pastTrades.length})
|
||||
{t("trades.tabs.history", { count: pastTrades.length })}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
|
@ -176,15 +179,15 @@ export default function AdminTradesPage() {
|
|||
onChange={(e) => setStatusFilter(e.target.value)}
|
||||
style={styles.filterSelect}
|
||||
>
|
||||
<option value="all">All Statuses</option>
|
||||
<option value="completed">Completed</option>
|
||||
<option value="no_show">No Show</option>
|
||||
<option value="cancelled_by_user">User Cancelled</option>
|
||||
<option value="cancelled_by_admin">Admin Cancelled</option>
|
||||
<option value="all">{t("trades.filters.allStatuses")}</option>
|
||||
<option value="completed">{t("trades.filters.completed")}</option>
|
||||
<option value="no_show">{t("trades.filters.noShow")}</option>
|
||||
<option value="cancelled_by_user">{t("trades.filters.userCancelled")}</option>
|
||||
<option value="cancelled_by_admin">{t("trades.filters.adminCancelled")}</option>
|
||||
</select>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search by email..."
|
||||
placeholder={t("trades.searchPlaceholder")}
|
||||
value={userSearch}
|
||||
onChange={(e) => setUserSearch(e.target.value)}
|
||||
style={styles.searchInput}
|
||||
|
|
@ -193,10 +196,14 @@ export default function AdminTradesPage() {
|
|||
)}
|
||||
|
||||
{isLoadingTrades ? (
|
||||
<EmptyState message="Loading trades..." isLoading={true} />
|
||||
<EmptyState message={t("trades.loading")} isLoading={true} />
|
||||
) : trades.length === 0 ? (
|
||||
<EmptyState
|
||||
message={activeTab === "upcoming" ? "No upcoming trades." : "No trades found."}
|
||||
message={
|
||||
activeTab === "upcoming"
|
||||
? t("trades.emptyStates.upcoming")
|
||||
: t("trades.emptyStates.past")
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<div style={tradeCardStyles.tradeList}>
|
||||
|
|
@ -221,7 +228,7 @@ export default function AdminTradesPage() {
|
|||
)}
|
||||
{trade.user_contact.signal && (
|
||||
<span style={styles.contactBadge}>
|
||||
Signal: {trade.user_contact.signal}
|
||||
{t("trades.tradeDetails.signal", { value: trade.user_contact.signal })}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
|
@ -238,7 +245,9 @@ export default function AdminTradesPage() {
|
|||
color: isBuy ? "#f87171" : "#4ade80",
|
||||
}}
|
||||
>
|
||||
{isBuy ? "SELL BTC" : "BUY BTC"}
|
||||
{isBuy
|
||||
? t("trades.tradeDetails.sellBtc")
|
||||
: t("trades.tradeDetails.buyBtc")}
|
||||
</span>
|
||||
<span
|
||||
style={{
|
||||
|
|
@ -248,8 +257,18 @@ export default function AdminTradesPage() {
|
|||
}}
|
||||
>
|
||||
{isBuy
|
||||
? `Send via ${trade.bitcoin_transfer_method === "onchain" ? "Onchain" : "Lightning"}`
|
||||
: `Receive via ${trade.bitcoin_transfer_method === "onchain" ? "Onchain" : "Lightning"}`}
|
||||
? t("trades.tradeDetails.sendVia", {
|
||||
method:
|
||||
trade.bitcoin_transfer_method === "onchain"
|
||||
? t("trades.tradeDetails.onchain")
|
||||
: t("trades.tradeDetails.lightning"),
|
||||
})
|
||||
: t("trades.tradeDetails.receiveVia", {
|
||||
method:
|
||||
trade.bitcoin_transfer_method === "onchain"
|
||||
? t("trades.tradeDetails.onchain")
|
||||
: t("trades.tradeDetails.lightning"),
|
||||
})}
|
||||
</span>
|
||||
<span style={tradeCardStyles.amount}>{formatEur(trade.eur_amount)}</span>
|
||||
<span style={tradeCardStyles.arrow}>↔</span>
|
||||
|
|
@ -259,7 +278,9 @@ export default function AdminTradesPage() {
|
|||
</div>
|
||||
|
||||
<div style={tradeCardStyles.rateRow}>
|
||||
<span style={tradeCardStyles.rateLabel}>Rate:</span>
|
||||
<span style={tradeCardStyles.rateLabel}>
|
||||
{t("trades.tradeDetails.rate")}
|
||||
</span>
|
||||
<span style={tradeCardStyles.rateValue}>
|
||||
€
|
||||
{trade.agreed_price_eur.toLocaleString("es-ES", {
|
||||
|
|
@ -267,7 +288,9 @@ export default function AdminTradesPage() {
|
|||
})}
|
||||
/BTC
|
||||
</span>
|
||||
<span style={tradeCardStyles.rateLabel}>Market:</span>
|
||||
<span style={tradeCardStyles.rateLabel}>
|
||||
{t("trades.tradeDetails.market")}
|
||||
</span>
|
||||
<span style={tradeCardStyles.rateValue}>
|
||||
€
|
||||
{trade.market_price_eur.toLocaleString("es-ES", {
|
||||
|
|
@ -298,7 +321,7 @@ export default function AdminTradesPage() {
|
|||
type: "complete",
|
||||
})
|
||||
}
|
||||
actionLabel="Complete"
|
||||
actionLabel={t("trades.actions.complete")}
|
||||
isLoading={actioningIds.has(trade.public_id)}
|
||||
confirmVariant="success"
|
||||
confirmButtonStyle={styles.successButton}
|
||||
|
|
@ -317,7 +340,7 @@ export default function AdminTradesPage() {
|
|||
type: "no_show",
|
||||
})
|
||||
}
|
||||
actionLabel="No Show"
|
||||
actionLabel={t("trades.actions.noShow")}
|
||||
isLoading={actioningIds.has(trade.public_id)}
|
||||
confirmVariant="primary"
|
||||
actionButtonStyle={styles.warningButton}
|
||||
|
|
@ -338,7 +361,7 @@ export default function AdminTradesPage() {
|
|||
type: "cancel",
|
||||
})
|
||||
}
|
||||
actionLabel="Cancel"
|
||||
actionLabel={t("trades.actions.cancel")}
|
||||
isLoading={actioningIds.has(trade.public_id)}
|
||||
confirmVariant="danger"
|
||||
confirmButtonStyle={styles.dangerButton}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ import caInvites from "../../locales/ca/invites.json";
|
|||
import esProfile from "../../locales/es/profile.json";
|
||||
import enProfile from "../../locales/en/profile.json";
|
||||
import caProfile from "../../locales/ca/profile.json";
|
||||
import esAdmin from "../../locales/es/admin.json";
|
||||
import enAdmin from "../../locales/en/admin.json";
|
||||
import caAdmin from "../../locales/ca/admin.json";
|
||||
|
||||
const messages = {
|
||||
es: {
|
||||
|
|
@ -36,6 +39,7 @@ const messages = {
|
|||
trades: esTrades,
|
||||
invites: esInvites,
|
||||
profile: esProfile,
|
||||
admin: esAdmin,
|
||||
},
|
||||
en: {
|
||||
common: enCommon,
|
||||
|
|
@ -45,6 +49,7 @@ const messages = {
|
|||
trades: enTrades,
|
||||
invites: enInvites,
|
||||
profile: enProfile,
|
||||
admin: enAdmin,
|
||||
},
|
||||
ca: {
|
||||
common: caCommon,
|
||||
|
|
@ -54,6 +59,7 @@ const messages = {
|
|||
trades: caTrades,
|
||||
invites: caInvites,
|
||||
profile: caProfile,
|
||||
admin: caAdmin,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue