Build issue resolution and production checklist updates

This commit is contained in:
Stephanos A
2026-07-05 15:11:54 +03:00
parent b6dbfe43e3
commit 9e77ca7865
13 changed files with 20 additions and 578 deletions

View File

@@ -165,7 +165,7 @@ export default function AppReleasesPage() {
<div className="flex justify-end gap-2 pt-2 border-t border-muted">
<ActionButton variant="secondary" onClick={() => setFormOpen(false)}>Cancel</ActionButton>
<ActionButton type="submit" isLoading={saveMutation.isPending}>
<ActionButton type="submit" loading={saveMutation.isPending}>
{editing ? 'Save Changes' : 'Create Release'}
</ActionButton>
</div>

View File

@@ -9,6 +9,7 @@ import Badge from '@/components/ui/Badge';
import ActionButton from '@/components/ui/ActionButton';
import ConfirmDialog from '@/components/ui/ConfirmDialog';
import Modal from '@/components/ui/Modal';
import Image from 'next/image';
import { ticketsApi, apiClient, stationsApi, excessBaggageApi } from '@/lib/api';
import { formatDateTime, formatCurrency, formatDateTimeShort } from '@/lib/utils';
import { useAuthStore } from '@/lib/auth-store';
@@ -844,10 +845,13 @@ export default function TicketsPage() {
<SectionHeader title="QR Code" />
<div className="flex justify-center">
<div className="bg-white p-4 rounded-xl border border-muted inline-block">
<img
<Image
src={t.qrCode.startsWith('data:') ? t.qrCode : `data:image/png;base64,${t.qrCode}`}
alt={`QR Code for ${t.ticketNumber}`}
className="w-48 h-48 object-contain"
width={192}
height={192}
className="object-contain"
unoptimized
/>
<p className="text-center text-xs text-muted-foreground mt-2 font-mono">{t.ticketNumber}</p>
</div>

View File

@@ -1,100 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test Routes API</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; }
button { padding: 10px 20px; margin: 10px 0; cursor: pointer; }
pre { background: #f4f4f4; padding: 15px; border-radius: 5px; overflow-x: auto; }
.route { border: 1px solid #ddd; padding: 10px; margin: 10px 0; border-radius: 5px; }
</style>
</head>
<body>
<h1>Routes API Test</h1>
<button onclick="fetchRoutes()">Fetch All Routes</button>
<button onclick="deleteRoute()">Delete ADD-DDW Route</button>
<div id="output"></div>
<script>
const API_URL = 'http://localhost:4000';
const TOKEN = localStorage.getItem('token') || 'YOUR_JWT_TOKEN_HERE';
async function fetchRoutes() {
try {
const response = await fetch(`${API_URL}/routes`, {
headers: {
'Authorization': `Bearer ${TOKEN}`
}
});
const data = await response.json();
console.log('Routes response:', data);
const output = document.getElementById('output');
output.innerHTML = '<h2>Routes Found:</h2>';
if (Array.isArray(data)) {
output.innerHTML += `<p>Total routes: ${data.length}</p>`;
data.forEach(route => {
output.innerHTML += `
<div class="route">
<strong>${route.code}</strong> - ${route.name}<br>
<small>ID: ${route.id}</small><br>
<small>Active: ${route.active}</small><br>
<small>Stops: ${route._count?.stops || route.stops?.length || 0}</small>
</div>
`;
});
} else {
output.innerHTML += '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
}
} catch (error) {
document.getElementById('output').innerHTML =
'<p style="color: red;">Error: ' + error.message + '</p>';
console.error('Error:', error);
}
}
async function deleteRoute() {
const code = 'ADD-DDW';
try {
// First fetch to get the route ID
const listResponse = await fetch(`${API_URL}/routes`, {
headers: { 'Authorization': `Bearer ${TOKEN}` }
});
const routes = await listResponse.json();
const route = routes.find(r => r.code === code);
if (!route) {
alert('Route ADD-DDW not found');
return;
}
if (confirm(`Delete route ${route.code} - ${route.name}?`)) {
const response = await fetch(`${API_URL}/routes/${route.id}`, {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${TOKEN}`
}
});
if (response.ok) {
alert('Route deleted successfully');
fetchRoutes();
} else {
const error = await response.json();
alert('Error: ' + JSON.stringify(error));
}
}
} catch (error) {
alert('Error: ' + error.message);
console.error('Error:', error);
}
}
// Auto-fetch on load
fetchRoutes();
</script>
</body>
</html>

View File

@@ -1,132 +0,0 @@
// Test script for Stations CRUD operations
// Run this in the browser console on the backoffice app
async function testStationsCRUD() {
const API_URL = 'http://localhost:4000';
const token = localStorage.getItem('auth_token');
const headers = {
'Content-Type': 'application/json',
'Authorization': token ? `Bearer ${token}` : ''
};
console.log('🧪 Testing Stations CRUD Operations...\n');
try {
// 1. CREATE - Add a new station
console.log('1⃣ Testing CREATE Station...');
const newStation = {
code: 'TEST',
name: 'Test Station',
city: 'Test City',
countryCode: 'ET',
lat: '9.0320',
lng: '38.7469',
timezone: 'Africa/Addis_Ababa',
isOperational: true
};
const createResponse = await fetch(`${API_URL}/stations`, {
method: 'POST',
headers,
body: JSON.stringify(newStation)
});
if (!createResponse.ok) {
throw new Error(`CREATE failed: ${createResponse.status} ${await createResponse.text()}`);
}
const createdStation = await createResponse.json();
console.log('✅ Station created:', createdStation);
const stationId = createdStation.id || createdStation.data?.id;
if (!stationId) {
throw new Error('No station ID returned from create');
}
// 2. READ - Get the created station
console.log('\n2⃣ Testing READ Station...');
const readResponse = await fetch(`${API_URL}/stations/${stationId}`, {
method: 'GET',
headers
});
if (!readResponse.ok) {
throw new Error(`READ failed: ${readResponse.status}`);
}
const readStation = await readResponse.json();
console.log('✅ Station retrieved:', readStation);
// 3. UPDATE - Modify the station
console.log('\n3⃣ Testing UPDATE Station...');
const updateData = {
name: 'Test Station Updated',
city: 'Test City Updated',
isOperational: false
};
const updateResponse = await fetch(`${API_URL}/stations/${stationId}`, {
method: 'PATCH',
headers,
body: JSON.stringify(updateData)
});
if (!updateResponse.ok) {
throw new Error(`UPDATE failed: ${updateResponse.status} ${await updateResponse.text()}`);
}
const updatedStation = await updateResponse.json();
console.log('✅ Station updated:', updatedStation);
// 4. LIST - Get all stations
console.log('\n4⃣ Testing LIST Stations...');
const listResponse = await fetch(`${API_URL}/stations`, {
method: 'GET',
headers
});
if (!listResponse.ok) {
throw new Error(`LIST failed: ${listResponse.status}`);
}
const stations = await listResponse.json();
console.log('✅ Stations list retrieved:', stations);
// 5. DELETE - Remove the test station
console.log('\n5⃣ Testing DELETE Station...');
const deleteResponse = await fetch(`${API_URL}/stations/${stationId}`, {
method: 'DELETE',
headers
});
if (!deleteResponse.ok) {
throw new Error(`DELETE failed: ${deleteResponse.status} ${await deleteResponse.text()}`);
}
console.log('✅ Station deleted successfully');
// 6. Verify deletion
console.log('\n6⃣ Verifying deletion...');
const verifyResponse = await fetch(`${API_URL}/stations/${stationId}`, {
method: 'GET',
headers
});
if (verifyResponse.status === 404) {
console.log('✅ Station deletion verified (404 Not Found)');
} else {
console.warn('⚠️ Station might still exist');
}
console.log('\n🎉 All tests passed!');
return { success: true, message: 'All CRUD operations working correctly' };
} catch (error) {
console.error('❌ Test failed:', error);
return { success: false, error: error.message };
}
}
// Run the test
testStationsCRUD();