exchange page

This commit is contained in:
Boki 2025-06-18 07:20:55 -04:00
parent 263e9513b7
commit 344478c577
4 changed files with 22 additions and 15 deletions

View file

@ -21,7 +21,7 @@ const app = new Hono();
app.use(
'*',
cors({
origin: ['http://localhost:4200', 'http://localhost:3000'], // React dev server ports
origin: ['http://localhost:4200', 'http://localhost:3000', 'http://localhost:3002'], // React dev server ports
allowMethods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
allowHeaders: ['Content-Type', 'Authorization'],
credentials: true,

View file

@ -6,10 +6,8 @@ import {
} from '@heroicons/react/24/outline';
import { useEffect, useState } from 'react';
import { ExchangesTable } from './components/ExchangesTable';
import { useExchanges } from './hooks/useExchanges';
export function ExchangesPage() {
const { syncExchanges } = useExchanges();
const [syncing, setSyncing] = useState(false);
const [syncStatus, setSyncStatus] = useState<{
type: 'success' | 'error' | null;
@ -31,18 +29,12 @@ export function ExchangesPage() {
setSyncStatus({ type: null, message: '' });
try {
const result = await syncExchanges();
if (result) {
setSyncStatus({
type: 'success',
message: `Exchange sync completed successfully! Job ID: ${result.jobId || 'Unknown'}`,
});
} else {
setSyncStatus({
type: 'error',
message: 'Sync failed - no result returned from server',
});
}
// TODO: Implement sync functionality
await new Promise(resolve => setTimeout(resolve, 2000)); // Simulate sync
setSyncStatus({
type: 'success',
message: 'Exchange sync functionality coming soon!',
});
} catch (error) {
setSyncStatus({
type: 'error',

View file

@ -18,6 +18,8 @@ export function ExchangesTable() {
createProviderMapping,
refetch
} = useExchanges();
console.log('ExchangesTable render:', { exchanges, loading, error });
const [editingCell, setEditingCell] = useState<{ id: string; field: string } | null>(null);
const [editValue, setEditValue] = useState('');
const [addProviderDialog, setAddProviderDialog] = useState<{
@ -381,6 +383,13 @@ export function ExchangesTable() {
);
};
console.log('About to render DataTable with:', {
dataLength: (exchanges || []).length,
columnsLength: columns.length,
loading,
error
});
return (
<>
<div className="space-y-0">
@ -388,6 +397,7 @@ export function ExchangesTable() {
data={exchanges || []}
columns={columns}
loading={loading}
height={600}
className="rounded-lg border border-border"
/>

View file

@ -18,10 +18,12 @@ export function useExchanges() {
const [error, setError] = useState<string | null>(null);
const fetchExchanges = useCallback(async () => {
console.log('fetchExchanges called');
try {
setLoading(true);
setError(null);
console.log('Making fetch request to:', `${API_BASE_URL}/exchanges`);
const response = await fetch(`${API_BASE_URL}/exchanges`);
if (!response.ok) {
@ -29,8 +31,10 @@ export function useExchanges() {
}
const data = await response.json();
console.log('API response:', data);
if (data.success) {
console.log('Setting exchanges:', data.data);
setExchanges(data.data || []);
} else {
throw new Error(data.error || 'API returned error status');
@ -249,6 +253,7 @@ export function useExchanges() {
);
useEffect(() => {
console.log('useExchanges useEffect triggered');
fetchExchanges();
}, [fetchExchanges]);