feat: Complete Shiplogic integration with mobile-optimized ops workflow
**Shiplogic API Integration:**
- Fixed API base URL configuration (removed /api suffix)
- Implemented comprehensive request/response logging for rates and shipments endpoints
- Fixed PDF fetching: API returns S3 URLs, now downloads actual PDFs from S3
- Added tests and mock API responses for local development (routes/shiplogic-mock.php)
**Courier Service Enhancements:**
- Added redownloadShipmentPdfs() public method for re-downloading corrupted PDFs
- Enhanced error logging with full request/response bodies for debugging
- Proper binary PDF storage using Laravel Storage facade
- URL and S3 download handling for Shiplogic API responses
**Workflow & Operations:**
- Changed to manual "Ready for Collection" button instead of automatic move
- Operators now: scan QR → apply labels → click "Ready for Collection" → moves to Awaiting Collection
- Removed duplicate PDF attachments to Trello (was adding twice from two listeners)
- Fixed NotifySlackOnShipmentCreated to only handle Slack notifications
**Mobile-Optimized Ops Page:**
- Removed QR code display from order detail page
- Implemented responsive single-column layout for mobile phones
- Large touch-friendly buttons (full width, increased padding)
- Bold typography for better readability on small screens
- Larger input fields and tracking number displays
- Clear step-by-step instructions for warehouse operators
- Re-download PDF button for damaged/corrupted labels
**New Features:**
- POST /ops/orders/{uuid}/ready-for-collection endpoint
- Re-download PDFs functionality accessible from awaiting_collection and in_transit states
- Full audit logging for all operations via ops interface
- Proper error handling and user feedback
**Testing:**
- Added ShipmentCreationTest with mock HTTP client
- Created comprehensive testing guide (SHIPLOGIC_TESTING.md)
- Mock API routes for local development without hitting live API
This commit is contained in:
@@ -24,6 +24,20 @@
|
||||
<strong>Waybill:</strong> <code class="bg-gray-100 px-2 py-1 rounded"><?php echo e($order->courier_waybill_id); ?></code>
|
||||
</p>
|
||||
<?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
|
||||
|
||||
<!-- Re-download PDFs Button -->
|
||||
<?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($order->courier_shipment_id): ?>
|
||||
<div class="mt-4">
|
||||
<button
|
||||
type="button"
|
||||
onclick="redownloadPdfs('<?php echo e($order->uuid); ?>')"
|
||||
class="bg-orange-500 hover:bg-orange-600 text-white font-bold py-2 px-4 rounded transition duration-200"
|
||||
>
|
||||
🔄 Re-download Shipment PDFs
|
||||
</button>
|
||||
<p class="text-gray-600 text-sm mt-2">If the shipment PDFs are corrupted, click this button to re-download them.</p>
|
||||
</div>
|
||||
<?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
|
||||
</div>
|
||||
<?php elseif($order->status === 'in_transit'): ?>
|
||||
<div class="bg-white border-l-4 border-green-500 p-4 rounded">
|
||||
@@ -35,6 +49,20 @@
|
||||
<strong>Tracking:</strong> <code class="bg-gray-100 px-2 py-1 rounded"><?php echo e($order->courier_tracking_number); ?></code>
|
||||
</p>
|
||||
<?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
|
||||
|
||||
<!-- Re-download PDFs Button -->
|
||||
<?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($order->courier_shipment_id): ?>
|
||||
<div class="mt-4">
|
||||
<button
|
||||
type="button"
|
||||
onclick="redownloadPdfs('<?php echo e($order->uuid); ?>')"
|
||||
class="bg-orange-500 hover:bg-orange-600 text-white font-bold py-2 px-4 rounded transition duration-200"
|
||||
>
|
||||
🔄 Re-download Shipment PDFs
|
||||
</button>
|
||||
<p class="text-gray-600 text-sm mt-2">If the shipment PDFs are corrupted, click this button to re-download them.</p>
|
||||
</div>
|
||||
<?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="bg-white border-l-4 border-gray-500 p-4 rounded">
|
||||
@@ -46,4 +74,53 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function redownloadPdfs(orderUuid) {
|
||||
if (!confirm('Re-download shipment PDFs from Shiplogic API?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const button = document.querySelector('[onclick*="redownloadPdfs"]');
|
||||
button.disabled = true;
|
||||
button.classList.add('opacity-50');
|
||||
const originalText = button.innerText;
|
||||
button.innerText = '⏳ Downloading...';
|
||||
|
||||
try {
|
||||
// Get CSRF token from the page
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') ||
|
||||
document.querySelector('input[name="_token"]')?.value;
|
||||
|
||||
if (!csrfToken) {
|
||||
throw new Error('CSRF token not found on page');
|
||||
}
|
||||
|
||||
const response = await fetch(`/ops/orders/${orderUuid}/redownload-pdfs`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-Token': csrfToken,
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
alert('✓ PDFs re-downloaded successfully!\n\nSticker: ' + data.sticker_path + '\nLabel: ' + data.waybill_path);
|
||||
location.reload();
|
||||
} else {
|
||||
alert('✗ Failed to re-download PDFs:\n' + data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
alert('✗ Error: ' + error.message);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
button.classList.remove('opacity-50');
|
||||
button.innerText = originalText;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php /**PATH /var/www/additional_design/resources/views/ops/actions/read-only.blade.php ENDPATH**/ ?>
|
||||
Reference in New Issue
Block a user