feat: dodaj ishodište i PDF račune za putni nalog
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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user