feat(120): alert component unification
Phase 120 - Plan 01:
- Reusable PHP alert component (resources/views/components/alert.php)
with inline SVG icon per type, optional dismiss button.
- Missing .alert--info SCSS variant added (#eff6ff/#bfdbfe/#1e3a8a) -
fixes black-on-white alert after Fakturownia test connection.
- Flash::push(type, message) + Flash::all() with BC for set/get;
legacy key heuristic (error/.save/warning -> typed entries).
- Central flash renderer in 3 layouts (app/auth/public) iterating
Flash::all() through component (.alerts-stack wrap).
- Vanilla JS alert-dismiss.js with idempotent guard and delegated
click handler on [data-alert-dismiss].
- 36 views migrated off inline <div class="alert alert--TYPE">;
.flash--error/success removed from views (orders/show, shipments/prepare).
- SCSS rebuilt: public/assets/css/{app,login}.css.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/** @var array<string, mixed>|null $config */
|
||||
$config = is_array($config ?? null) ? $config : null;
|
||||
$accounts = is_array($fakturowniaAccounts ?? null) ? $fakturowniaAccounts : [];
|
||||
$fakturowniaSettings = is_array($fakturowniaSettings ?? null) ? $fakturowniaSettings : [];
|
||||
$isEdit = $config !== null;
|
||||
$cid = (int) ($config['id'] ?? 0);
|
||||
|
||||
@@ -13,8 +13,10 @@ $orderReference = (string) ($config['order_reference'] ?? 'none');
|
||||
$paymentToDays = (int) ($config['payment_to_days'] ?? 7);
|
||||
$defaultKind = (string) ($config['default_kind'] ?? 'vat');
|
||||
$isDelegated = ((int) ($config['is_delegated'] ?? 0)) === 1;
|
||||
$integrationId = (int) ($config['integration_id'] ?? 0);
|
||||
$isActive = $isEdit ? ((int) ($config['is_active'] ?? 0)) === 1 : true;
|
||||
$fakturowniaConfigured = trim((string) ($fakturowniaSettings['account_prefix'] ?? '')) !== ''
|
||||
&& !empty($fakturowniaSettings['has_api_token']);
|
||||
$fakturowniaActive = !empty($fakturowniaSettings['is_active']);
|
||||
|
||||
$success = trim((string) ($successMessage ?? ''));
|
||||
$error = trim((string) ($errorMessage ?? ''));
|
||||
@@ -25,10 +27,10 @@ $error = trim((string) ($errorMessage ?? ''));
|
||||
<h2 class="section-title"><?= $isEdit ? 'Edycja konfiguracji faktury' : 'Nowa konfiguracja faktury' ?></h2>
|
||||
|
||||
<?php if ($error !== ''): ?>
|
||||
<div class="alert alert--danger mt-12" role="alert"><?= $e($error) ?></div>
|
||||
<div class="mt-12"><?php $type='danger'; $message=(string) $error; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($success !== ''): ?>
|
||||
<div class="alert alert--success mt-12" role="status"><?= $e($success) ?></div>
|
||||
<div class="mt-12"><?php $type='success'; $message=(string) $success; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
||||
@@ -105,24 +107,15 @@ $error = trim((string) ($errorMessage ?? ''));
|
||||
</div>
|
||||
|
||||
<div class="form-field mt-12" data-invoice-delegation<?= $isDelegated ? '' : ' style="display:none"' ?>>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Konto Fakturowni *</span>
|
||||
<select class="form-control" name="integration_id"<?= $isDelegated ? ' required' : '' ?>>
|
||||
<option value="">— wybierz konto —</option>
|
||||
<?php foreach ($accounts as $acc):
|
||||
$aid = (int) ($acc['integration_id'] ?? 0);
|
||||
$accName = (string) ($acc['name'] ?? '');
|
||||
$accPrefix = (string) ($acc['account_prefix'] ?? '');
|
||||
?>
|
||||
<option value="<?= $aid ?>"<?= $aid === $integrationId ? ' selected' : '' ?>>
|
||||
<?= $e($accName) ?><?= $accPrefix !== '' ? ' (' . $e($accPrefix) . '.fakturownia.pl)' : '' ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php if ($accounts === []): ?>
|
||||
<small class="field-hint">Brak skonfigurowanych kont Fakturowni. <a href="/settings/integrations/fakturownia/new">Dodaj konto</a> aby moc delegowac.</small>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<span class="field-label">Konto Fakturowni</span>
|
||||
<?php if ($fakturowniaConfigured && $fakturowniaActive): ?>
|
||||
<span class="badge badge--success">Globalna konfiguracja aktywna</span>
|
||||
<?php elseif ($fakturowniaConfigured): ?>
|
||||
<span class="badge badge--muted">Globalna konfiguracja nieaktywna</span>
|
||||
<?php else: ?>
|
||||
<span class="badge badge--muted">Brak konfiguracji</span>
|
||||
<?php endif; ?>
|
||||
<small class="field-hint">Delegowane faktury uzywaja jednej globalnej konfiguracji z <a href="/settings/integrations/fakturownia">Integracje > Fakturownia</a>.</small>
|
||||
</div>
|
||||
|
||||
<div class="form-actions mt-16">
|
||||
|
||||
Reference in New Issue
Block a user