Fix: Remove function prop from client component
Remove onSuccess callback from SyncRoyalMailButton since event handlers cannot be passed to client components from server components. The button already shows success/error messages, so the callback wasn't necessary.
This commit is contained in:
@@ -78,7 +78,8 @@
|
|||||||
"Bash(git commit -m 'Improve: Cart clearing on success page with better state management *)",
|
"Bash(git commit -m 'Improve: Cart clearing on success page with better state management *)",
|
||||||
"Bash(git commit -m 'Feature: Add order tracking and shipping status updates *)",
|
"Bash(git commit -m 'Feature: Add order tracking and shipping status updates *)",
|
||||||
"Bash(git commit -m 'Feature: Royal Mail tracking integration \\(hybrid approach\\) *)",
|
"Bash(git commit -m 'Feature: Royal Mail tracking integration \\(hybrid approach\\) *)",
|
||||||
"Bash(git commit -m 'Fix: Refresh page after updating order tracking details *)"
|
"Bash(git commit -m 'Fix: Refresh page after updating order tracking details *)",
|
||||||
|
"Bash(git commit -m 'Fix: Remove function prop from client component *)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,10 +150,6 @@ export default async function OrderDetailPage({ params }: { params: { id: string
|
|||||||
<SyncRoyalMailButton
|
<SyncRoyalMailButton
|
||||||
orderId={order.id}
|
orderId={order.id}
|
||||||
trackingNumber={order.trackingNumber}
|
trackingNumber={order.trackingNumber}
|
||||||
onSuccess={() => {
|
|
||||||
// In a real app, we'd refresh the page or update state
|
|
||||||
console.log('Tracking synced successfully');
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -5,10 +5,9 @@ import { useState } from 'react';
|
|||||||
interface SyncRoyalMailButtonProps {
|
interface SyncRoyalMailButtonProps {
|
||||||
orderId: string;
|
orderId: string;
|
||||||
trackingNumber?: string | null;
|
trackingNumber?: string | null;
|
||||||
onSuccess?: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SyncRoyalMailButton({ orderId, trackingNumber, onSuccess }: SyncRoyalMailButtonProps) {
|
export default function SyncRoyalMailButton({ orderId, trackingNumber }: SyncRoyalMailButtonProps) {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null);
|
const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null);
|
||||||
|
|
||||||
@@ -37,8 +36,6 @@ export default function SyncRoyalMailButton({ orderId, trackingNumber, onSuccess
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
text: `Tracking synced! Status: ${data.trackingData.status}`,
|
text: `Tracking synced! Status: ${data.trackingData.status}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
onSuccess?.();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setMessage({ type: 'error', text: 'Error syncing with Royal Mail' });
|
setMessage({ type: 'error', text: 'Error syncing with Royal Mail' });
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user