Add shipping dialog with tracking number to order page
Introduces a shipping dialog to the order details page, allowing users to optionally enter a tracking number when marking an order as shipped. Updates API client logic to better handle HTTP-only authentication cookies. Improves broadcast dialog validation and message handling.
This commit is contained in:
@@ -83,7 +83,7 @@ export default function BroadcastDialog({ open, setOpen }: BroadcastDialogProps)
|
||||
};
|
||||
|
||||
const sendBroadcast = async () => {
|
||||
if (!broadcastMessage.trim() && !selectedImage) {
|
||||
if ((!broadcastMessage || !broadcastMessage.trim()) && !selectedImage) {
|
||||
toast.warning("Please provide a message or image to broadcast.");
|
||||
return;
|
||||
}
|
||||
@@ -110,9 +110,8 @@ export default function BroadcastDialog({ open, setOpen }: BroadcastDialogProps)
|
||||
if (selectedImage) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', selectedImage);
|
||||
if (broadcastMessage.trim()) {
|
||||
formData.append('message', broadcastMessage);
|
||||
}
|
||||
// Always append message, even if empty (backend will validate)
|
||||
formData.append('message', broadcastMessage || '');
|
||||
if (selectedProducts.length > 0) {
|
||||
formData.append('productIds', JSON.stringify(selectedProducts));
|
||||
}
|
||||
@@ -336,7 +335,7 @@ __italic text__
|
||||
</Button>
|
||||
<Button
|
||||
onClick={sendBroadcast}
|
||||
disabled={isSending || (broadcastMessage.length > 4096) || (!broadcastMessage.trim() && !selectedImage)}
|
||||
disabled={isSending || (broadcastMessage.length > 4096) || ((!broadcastMessage || !broadcastMessage.trim()) && !selectedImage)}
|
||||
className="bg-emerald-600 hover:bg-emerald-700"
|
||||
>
|
||||
{isSending ? "Sending..." : "Send Broadcast"}
|
||||
|
||||
@@ -600,6 +600,7 @@ export default function OrderTable() {
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user