feat: dodaj ishodište i PDF račune za putni nalog
Some checks failed
ERP CI/CD Pipeline / test (push) Has been cancelled
ERP CI/CD Pipeline / Deploy (server git pull + compose) (push) Has been cancelled

Dodano je origin_location polje kroz backend model, serializer, admin i UI
modal za kreiranje/uređivanje putnog naloga (default: Zagreb).

Računi putnog naloga sada prihvaćaju slike i PDF datoteke, uz backend
validaciju formata, podršku za serving PDF-a i prilagodbu preview prikaza.

Za greške uploada računa dodan je error toast kako bi poruke validacije bile
vidljive korisniku odmah u sučelju.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
mariomitte
2026-07-19 19:54:15 +02:00
parent cbcbf0b3af
commit d35eaeccf4
12 changed files with 175 additions and 14 deletions

View File

@@ -23,8 +23,22 @@ function readWorkOrderIdFromQuery() {
return params.get('workOrderId') || '';
}
function InvoiceImagePreview({ imageUrl, alt }) {
function InvoiceImagePreview({ imageUrl, alt, contentType }) {
const [broken, setBroken] = useState(false);
const isPdf = String(contentType || '').toLowerCase() === 'application/pdf';
if (isPdf && imageUrl) {
return (
<a
href={imageUrl}
target="_blank"
rel="noopener noreferrer"
className="flex h-28 w-28 items-center justify-center rounded-lg border border-border-hairline bg-canvas-deep text-center text-[11px] text-text-main hover:bg-canvas-base"
>
Otvori PDF
</a>
);
}
if (!imageUrl || broken) {
return (
@@ -307,6 +321,7 @@ export default function WorkOrderInvoicesPdfPage() {
<InvoiceImagePreview
imageUrl={getAuthenticatedMediaSrc(invoice.image_url || invoice.image) || resolveMediaUrl(invoice.image_url || invoice.image)}
alt={`Račun ${invoice.naziv_racuna}`}
contentType={invoice.image_content_type}
/>
</div>
</article>