Files
tilbudgivern/archive/test-files/test-customer-search.html
alexpolo1 4a372d2e28 clean up
2025-10-30 18:28:58 +00:00

331 lines
12 KiB
HTML

<!DOCTYPE html>
<html lang="da">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Kunde-søgning - Alexander Warme</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.container {
background: white;
border-radius: 20px;
padding: 40px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
h1 {
color: #667eea;
margin-bottom: 10px;
}
.subtitle {
color: #6b7280;
margin-bottom: 30px;
}
.demo-section {
margin-bottom: 30px;
padding: 20px;
background: #f9fafb;
border-radius: 12px;
border: 2px solid #e5e7eb;
}
.demo-title {
font-weight: 600;
color: #1f2937;
margin-bottom: 15px;
font-size: 18px;
}
input[type="text"] {
width: 100%;
padding: 12px;
border: 2px solid #e5e7eb;
border-radius: 8px;
font-size: 16px;
transition: all 0.2s;
box-sizing: border-box;
}
input[type="text"]:focus {
outline: none;
border-color: #8b5cf6;
box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
button {
background: #8b5cf6;
color: white;
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
margin-top: 10px;
}
button:hover {
background: #7c3aed;
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}
.result {
margin-top: 20px;
padding: 15px;
background: white;
border-radius: 8px;
border-left: 4px solid #10b981;
}
.result-item {
margin-bottom: 8px;
display: flex;
align-items: center;
}
.result-label {
font-weight: 600;
color: #374151;
min-width: 150px;
}
.result-value {
color: #6b7280;
}
.loading {
text-align: center;
padding: 20px;
color: #8b5cf6;
}
.success {
background: #f0fdf4;
color: #166534;
padding: 15px;
border-radius: 8px;
margin-top: 15px;
border-left: 4px solid #10b981;
}
.feature-list {
list-style: none;
padding: 0;
}
.feature-list li {
padding: 8px 0;
padding-left: 30px;
position: relative;
}
.feature-list li:before {
content: "✅";
position: absolute;
left: 0;
}
.customer-card {
background: white;
padding: 20px;
border-radius: 12px;
border: 2px solid #e5e7eb;
margin-top: 15px;
}
.customer-header {
display: flex;
align-items: center;
margin-bottom: 15px;
padding-bottom: 15px;
border-bottom: 2px solid #f3f4f6;
}
.customer-number {
background: #8b5cf6;
color: white;
padding: 5px 12px;
border-radius: 6px;
font-weight: 600;
margin-right: 12px;
}
.customer-name {
font-size: 20px;
font-weight: 700;
color: #1f2937;
}
.customer-details {
display: grid;
gap: 12px;
}
.detail-row {
display: flex;
align-items: center;
}
.detail-icon {
width: 40px;
text-align: center;
font-size: 20px;
}
.detail-content {
flex: 1;
}
.detail-label {
font-size: 12px;
color: #6b7280;
text-transform: uppercase;
font-weight: 600;
}
.detail-value {
font-size: 16px;
color: #1f2937;
margin-top: 2px;
}
</style>
</head>
<body>
<div class="container">
<h1>🔍 Test Kunde-søgning Integration</h1>
<p class="subtitle">Demonstration af automatisk kunde-udfyldning</p>
<div class="demo-section">
<div class="demo-title">📊 System Status</div>
<ul class="feature-list">
<li>Backend API kører på port 4031</li>
<li>1,356 kunder i database (ordrestyring_local)</li>
<li>CustomerSearch komponent integreret i frontend</li>
<li>Auto-udfyldning af alle kunde-felter</li>
</ul>
</div>
<div class="demo-section">
<div class="demo-title">🧪 Test: Søg efter Alexander Warme</div>
<input type="text" id="searchInput" placeholder="Søg efter kunde (prøv: 3352, Alexander, eller Warme)" value="3352">
<button onclick="searchCustomer()">🔍 Søg Kunde</button>
<div id="loading" class="loading" style="display:none;">
⏳ Søger...
</div>
<div id="result" style="display:none;">
<!-- Results will be inserted here -->
</div>
</div>
<div class="demo-section">
<div class="demo-title">💡 Sådan virker det i UI</div>
<ol style="line-height: 1.8; color: #4b5563;">
<li>Bruger åbner "Opret Nyt Projekt"</li>
<li>Starter at skrive i kunde-feltet (f.eks. "Alex" eller "3352")</li>
<li>Dropdown vises med matchende kunder efter 300ms</li>
<li>Bruger klikker på en kunde</li>
<li><strong>AUTOMATISK:</strong> Navn, email, telefon, adresse udfyldes</li>
<li>Felter bliver disabled med grøn baggrund</li>
<li>Bruger indtaster projektnavn og beskrivelse</li>
<li>Klikker "Opret Projekt" → Færdig! 🎉</li>
</ol>
</div>
</div>
<script>
async function searchCustomer() {
const query = document.getElementById('searchInput').value;
const loadingDiv = document.getElementById('loading');
const resultDiv = document.getElementById('result');
if (!query || query.length < 2) {
alert('Indtast mindst 2 tegn for at søge');
return;
}
loadingDiv.style.display = 'block';
resultDiv.style.display = 'none';
try {
const response = await fetch(`http://localhost:4031/api/customers/search?q=${encodeURIComponent(query)}`);
const data = await response.json();
loadingDiv.style.display = 'none';
if (data.success && data.customers.length > 0) {
const customer = data.customers[0]; // Show first result
resultDiv.innerHTML = `
<div class="success">
✅ Kunde fundet! Dette er hvad der ville blive udfyldt automatisk:
</div>
<div class="customer-card">
<div class="customer-header">
<div class="customer-number">#${customer.customerNumber}</div>
<div class="customer-name">${customer.name}</div>
</div>
<div class="customer-details">
<div class="detail-row">
<div class="detail-icon">📍</div>
<div class="detail-content">
<div class="detail-label">Adresse</div>
<div class="detail-value">${customer.address || 'Ikke angivet'}, ${customer.postalCode || ''} ${customer.city || ''}</div>
</div>
</div>
<div class="detail-row">
<div class="detail-icon">✉️</div>
<div class="detail-content">
<div class="detail-label">Email</div>
<div class="detail-value">${customer.email || 'Ikke angivet'}</div>
</div>
</div>
<div class="detail-row">
<div class="detail-icon">📞</div>
<div class="detail-content">
<div class="detail-label">Telefon</div>
<div class="detail-value">${customer.phone || customer.mobile || 'Ikke angivet'}</div>
</div>
</div>
<div class="detail-row">
<div class="detail-icon">📊</div>
<div class="detail-content">
<div class="detail-label">Tidligere sager</div>
<div class="detail-value">${customer.caseCount || 0} sager (${customer.totalRevenue || '0.00'} DKK total)</div>
</div>
</div>
</div>
</div>
${data.customers.length > 1 ? `
<div style="margin-top: 15px; padding: 10px; background: #fef3c7; border-radius: 8px; color: #92400e;">
💡 Der blev fundet ${data.customers.length} kunder i alt. I UI'et ville alle vises i dropdown.
</div>
` : ''}
`;
resultDiv.style.display = 'block';
} else {
resultDiv.innerHTML = `
<div style="padding: 20px; text-align: center; color: #6b7280;">
Ingen kunder fundet for "${query}"
</div>
`;
resultDiv.style.display = 'block';
}
} catch (error) {
loadingDiv.style.display = 'none';
resultDiv.innerHTML = `
<div style="padding: 20px; background: #fef2f2; color: #dc2626; border-radius: 8px;">
❌ Fejl: ${error.message}
</div>
`;
resultDiv.style.display = 'block';
}
}
// Allow Enter key to trigger search
document.getElementById('searchInput').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
searchCustomer();
}
});
// Auto-search on page load
window.addEventListener('load', function() {
searchCustomer();
});
</script>
</body>
</html>