improve(wizard): green checkmarks on filled fields + fix website discovery
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- Green checkmarks appear next to correctly filled fields in Step 2 - Live validation on input (checkmarks update as user types) - 'Wyszukaj stronę' recognizes when URL already from KRS - Backend returns existing website without Brave search if already known Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
60b2abb2b2
commit
ea45a664bc
@ -454,6 +454,10 @@ def wizard_discover_website():
|
||||
if not company:
|
||||
return jsonify({'success': False, 'error': 'Firma nie znaleziona'}), 404
|
||||
|
||||
# If website already known from registry, return it
|
||||
if company.website and company.website not in ('https://', 'http://'):
|
||||
return jsonify({'success': True, 'website': company.website, 'confidence': 'registry'})
|
||||
|
||||
# Build a clean short name for search
|
||||
search_name = company.name
|
||||
for suffix in ['SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ', 'SP. Z O.O.',
|
||||
@ -465,13 +469,9 @@ def wizard_discover_website():
|
||||
from services.website_discovery_service import WebsiteDiscoveryService
|
||||
service = WebsiteDiscoveryService(db=db)
|
||||
|
||||
# Temporarily override company.name with enriched search query
|
||||
# Include NIP and city for better matching
|
||||
# Temporarily override company.name — discover_for_company uses it for query
|
||||
original_name = company.name
|
||||
parts = [search_name]
|
||||
if company.nip:
|
||||
parts.append(f'NIP {company.nip}')
|
||||
company.name = ' '.join(parts)
|
||||
company.name = search_name
|
||||
|
||||
result = service.discover_for_company(company)
|
||||
company.name = original_name # Restore
|
||||
|
||||
@ -233,6 +233,17 @@
|
||||
.draft-banner-text { font-size: var(--font-size-sm); color: var(--text-primary); }
|
||||
.draft-banner-actions { display: flex; gap: var(--spacing-sm); }
|
||||
|
||||
/* Field validation checkmarks */
|
||||
.form-group { position: relative; }
|
||||
.field-check {
|
||||
position: absolute; right: 8px; top: 50%;
|
||||
color: var(--success); font-size: 18px;
|
||||
display: none; pointer-events: none;
|
||||
}
|
||||
.form-group.has-nip-row .field-check { right: 140px; }
|
||||
.form-group.validated .field-check { display: block; }
|
||||
.form-control.validated { border-color: var(--success); padding-right: 32px; }
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.wizard-steps { gap: var(--spacing-sm); }
|
||||
.wizard-step span { display: none; }
|
||||
@ -753,9 +764,66 @@
|
||||
'. Użyj przycisku <strong>Wyszukaj stronę</strong> lub uzupełnij ręcznie.';
|
||||
}
|
||||
}
|
||||
|
||||
validateFields();
|
||||
}
|
||||
|
||||
function validateFields() {
|
||||
var checks = [
|
||||
{id: 'editName', ok: function(v) { return v.length > 1 && !v.startsWith('Firma NIP'); }},
|
||||
{id: 'editLegalName', ok: function(v) { return v.length > 1; }},
|
||||
{id: 'editNip', ok: function(v) { return /^\d{10}$/.test(v); }},
|
||||
{id: 'editRegon', ok: function(v) { return /^\d{9,14}$/.test(v); }},
|
||||
{id: 'editKrs', ok: function(v) { return /^\d{10}$/.test(v); }},
|
||||
{id: 'editLegalForm', ok: function(v) { return v.length > 2; }},
|
||||
{id: 'editStreet', ok: function(v) { return v.length > 2; }},
|
||||
{id: 'editPostal', ok: function(v) { return /^\d{2}-\d{3}$/.test(v); }},
|
||||
{id: 'editCity', ok: function(v) { return v.length > 1; }},
|
||||
{id: 'editEmail', ok: function(v) { return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v); }},
|
||||
{id: 'editPhone', ok: function(v) { return v.length >= 7; }},
|
||||
{id: 'editWebsite', ok: function(v) { return v.length > 8 && v !== 'https://'; }},
|
||||
];
|
||||
checks.forEach(function(c) {
|
||||
var el = document.getElementById(c.id);
|
||||
if (!el) return;
|
||||
var val = el.value.trim();
|
||||
var group = el.closest('.form-group');
|
||||
if (!group) return;
|
||||
// Add checkmark span if not exists
|
||||
var checkEl = group.querySelector('.field-check');
|
||||
if (!checkEl) {
|
||||
checkEl = document.createElement('span');
|
||||
checkEl.className = 'field-check';
|
||||
checkEl.innerHTML = '✓';
|
||||
el.parentNode.style.position = 'relative';
|
||||
el.parentNode.appendChild(checkEl);
|
||||
}
|
||||
if (val && c.ok(val)) {
|
||||
group.classList.add('validated');
|
||||
el.classList.add('validated');
|
||||
} else {
|
||||
group.classList.remove('validated');
|
||||
el.classList.remove('validated');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Live validation on input
|
||||
document.addEventListener('input', function(e) {
|
||||
if (e.target.closest('#step2')) validateFields();
|
||||
});
|
||||
|
||||
function discoverWebsite() {
|
||||
// If website already filled, just confirm it
|
||||
var existing = document.getElementById('editWebsite').value.trim();
|
||||
if (existing && existing !== 'https://' && existing.length > 10) {
|
||||
var statusEl = document.getElementById('discoverStatus');
|
||||
statusEl.style.display = 'block';
|
||||
statusEl.className = 'lookup-status success';
|
||||
statusEl.innerHTML = 'Strona WWW już pobrana z rejestru: <strong>' + esc(existing) + '</strong>';
|
||||
return;
|
||||
}
|
||||
|
||||
var btn = document.getElementById('btnDiscoverWebsite');
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<span class="spinner"></span> Szukam...';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user