improve(wizard): auto-shorten name, PKD→category, clean WWW, UX polish
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

1. Auto-strip legal form from name (CONSTELLATION SP. Z O.O. → Constellation)
2. Auto-suggest category from main PKD code (62.02.Z → IT)
3. Clean empty 'https://' from WWW field
4. Rename button to 'Wyszukaj w internecie'
5. Auto-advance to step 4 after logo confirmation
6. Larger logo preview in summary step

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-04-03 12:54:17 +02:00
parent ea45a664bc
commit 5145c67d24
2 changed files with 76 additions and 9 deletions

View File

@ -35,6 +35,64 @@ def _delete_draft_company(db, company_id):
{'cid': company_id})
def _strip_legal_form(name):
"""Strip legal form suffix from company name to get business name."""
suffixes = [
'SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ',
'SPÓŁKA AKCYJNA', 'SPÓŁKA KOMANDYTOWA',
'SPÓŁKA KOMANDYTOWO-AKCYJNA', 'SPÓŁKA JAWNA',
'SPÓŁKA PARTNERSKA', 'SP. Z O.O.', 'S.A.', 'SP.K.',
'SP.J.', 'SP.P.', 'S.K.A.',
]
result = name
for suffix in suffixes:
result = result.replace(suffix, '').strip()
result = result.strip(' ,-').title()
return result or name
# PKD prefix → category_id mapping
_PKD_CATEGORY_MAP = {
'62': 1, # IT i Technologie
'63': 1, # IT
'26': 1, # IT / electronics
'61': 6, # IT i Telekomunikacja
'41': 2, # Budownictwo
'42': 2, # Budownictwo inżynieryjne
'43': 2, # Budownictwo specjalistyczne
'71': 19, # Architektura i Projektowanie
'69': 3, # Usługi prawne
'73': 4, # Marketing i Reklama
'10': 5, # Produkcja spożywcza
'25': 5, # Produkcja metalowa
'22': 5, # Produkcja
'46': 18, # Handel hurtowy
'47': 27, # Handel detaliczny
'35': 9, # Energia
'55': 10, # Hotelarstwo
'56': 10, # Gastronomia/turystyka
'66': 31, # Usługi finansowe
'64': 31, # Finanse
'68': 15, # Nieruchomości
'58': 13, # Wydawnictwa / media
'45': 14, # Motoryzacja
'01': 16, # Rolnictwo
'80': 23, # Bezpieczeństwo
'70': 7, # Usługi biznesowe / doradztwo
'74': 7, # Usługi specjalistyczne
'78': 7, # Usługi HR
'82': 7, # Usługi biurowe
}
def _pkd_to_category_id(pkd_code):
"""Map PKD code to category ID. Returns None if no match."""
if not pkd_code:
return None
prefix = pkd_code[:2]
return _PKD_CATEGORY_MAP.get(prefix)
def _validate_nip(nip: str) -> bool:
"""Validate Polish NIP number (10 digits, checksum)."""
if not nip or not re.match(r'^\d{10}$', nip):
@ -205,12 +263,18 @@ def wizard_step1():
elif registry_source == 'CEIDG' and ceidg_data:
_apply_ceidg_data(company, ceidg_data, db)
# Update name from legal_name if still placeholder
if company.legal_name and company.name.startswith('Firma NIP'):
company.name = company.legal_name
# Set short business name (strip legal form), keep legal_name as full
if company.legal_name and (company.name.startswith('Firma NIP') or company.name == company.legal_name):
company.name = _strip_legal_form(company.legal_name)
company.slug = _generate_slug(company.name)
company.slug = _ensure_unique_slug(db, company.slug, exclude_id=company.id)
# Auto-suggest category from main PKD code
if not company.category_id and company.pkd_code:
suggested = _pkd_to_category_id(company.pkd_code)
if suggested:
company.category_id = suggested
company.wizard_step = 2
db.commit()

View File

@ -411,7 +411,7 @@
<div class="nip-input-row">
<input type="text" id="editWebsite" class="form-control" placeholder="https://">
<button class="btn-wizard btn-secondary" id="btnDiscoverWebsite" onclick="discoverWebsite()">
Wyszukaj stronę
Wyszukaj w internecie
</button>
</div>
<div id="discoverStatus" style="display:none"></div>
@ -729,7 +729,9 @@
document.getElementById('editCity').value = c.address_city || '';
document.getElementById('editEmail').value = c.email || '';
document.getElementById('editPhone').value = c.phone || '';
document.getElementById('editWebsite').value = c.website || '';
var www = c.website || '';
if (www === 'https://' || www === 'http://') www = '';
document.getElementById('editWebsite').value = www;
document.getElementById('editDescShort').value = c.description_short || '';
if (c.category_id) document.getElementById('editCategory').value = c.category_id;
@ -840,7 +842,7 @@
.then(function(r) { return r.json(); })
.then(function(data) {
btn.disabled = false;
btn.innerHTML = 'Wyszukaj stronę';
btn.innerHTML = 'Wyszukaj w internecie';
if (data.success && data.website) {
document.getElementById('editWebsite').value = data.website;
wizardState.companyData.website = data.website;
@ -853,7 +855,7 @@
})
.catch(function(err) {
btn.disabled = false;
btn.innerHTML = 'Wyszukaj stronę';
btn.innerHTML = 'Wyszukaj w internecie';
statusEl.className = 'lookup-status error';
statusEl.innerHTML = 'Błąd: ' + err.message;
});
@ -1002,8 +1004,9 @@
btn.disabled = false;
btn.innerHTML = 'Zatwierdz wybrane logo';
if (data.success) {
showLogoStatus('Logo zapisane!', 'success');
showLogoStatus('Logo zapisane! Przechodze dalej...', 'success');
document.getElementById('btnStep3Next').disabled = false;
setTimeout(function() { goToStep(4); }, 1000);
wizardState.companyData.logo_path = data.logo_path;
} else {
alert(data.error || 'Błąd zapisu logo');
@ -1143,7 +1146,7 @@
var logoHtml = '';
if (c.logo_path) {
logoHtml = '<img src="' + c.logo_path + '?t=' + Date.now() + '" style="max-width:80px;max-height:60px;margin-top:var(--spacing-sm)">';
logoHtml = '<div style="text-align:center;padding:var(--spacing-md);background:var(--background);border-radius:var(--radius);margin-top:var(--spacing-sm)"><img src="' + c.logo_path + '?t=' + Date.now() + '" style="max-width:140px;max-height:100px;object-fit:contain"></div>';
}
var extrasCard = '<div class="summary-card"><h3>Logo i audyty</h3>' +