Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cde560a2c3 | ||
|
|
e6198e1b67 | ||
|
|
495fdf6da2 | ||
|
|
7d29f40ab2 | ||
|
|
6b9f1dee87 | ||
|
|
687dcb9371 | ||
|
|
9c49015968 |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "app-ts",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "app-ts",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "app-ts",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.3",
|
||||
"description": "",
|
||||
"main": "dist/server.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -975,18 +975,21 @@ export default function InvoiceDetail() {
|
||||
|
||||
// ─── Edit mode: PDF export ───
|
||||
const handleViewPdf = async (_lang = "cs") => {
|
||||
const newWindow = window.open("", "_blank");
|
||||
setPdfLoading(true);
|
||||
try {
|
||||
const response = await apiFetch(`${API_BASE}/invoices/${id}/file`);
|
||||
if (!response.ok) {
|
||||
newWindow?.close();
|
||||
alert.error("PDF soubor nenalezen — uložte fakturu pro vygenerování");
|
||||
return;
|
||||
}
|
||||
const blob = await response.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
window.open(url, "_blank");
|
||||
if (newWindow) newWindow.location.href = url;
|
||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||
} catch {
|
||||
newWindow?.close();
|
||||
alert.error("Chyba připojení");
|
||||
} finally {
|
||||
setPdfLoading(false);
|
||||
|
||||
@@ -356,7 +356,7 @@ export default function OfferDetail() {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
currency:
|
||||
prev.currency === "EUR"
|
||||
prev.currency === "CZK"
|
||||
? companySettings.default_currency || "CZK"
|
||||
: prev.currency,
|
||||
vat_rate:
|
||||
@@ -768,19 +768,25 @@ export default function OfferDetail() {
|
||||
|
||||
const handlePdf = async () => {
|
||||
if (!isEdit || pdfLoading) return;
|
||||
const newWindow = window.open("", "_blank");
|
||||
setPdfLoading(true);
|
||||
try {
|
||||
const response = await apiFetch(`${API_BASE}/offers/${id}/file`);
|
||||
if (response.status === 401) return;
|
||||
if (response.status === 401) {
|
||||
newWindow?.close();
|
||||
return;
|
||||
}
|
||||
if (!response.ok) {
|
||||
newWindow?.close();
|
||||
alert.error("PDF soubor nenalezen — uložte nabídku pro vygenerování");
|
||||
return;
|
||||
}
|
||||
const blob = await response.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
window.open(url, "_blank");
|
||||
if (newWindow) newWindow.location.href = url;
|
||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||
} catch {
|
||||
newWindow?.close();
|
||||
alert.error("Chyba při generování PDF");
|
||||
} finally {
|
||||
setPdfLoading(false);
|
||||
|
||||
@@ -221,26 +221,28 @@ export default function Offers() {
|
||||
|
||||
const handlePdf = async (quotation: Quotation) => {
|
||||
if (pdfLoading) return;
|
||||
const newWindow = window.open("", "_blank");
|
||||
setPdfLoading(quotation.id);
|
||||
try {
|
||||
const response = await apiFetch(`${API_BASE}/offers-pdf/${quotation.id}`);
|
||||
if (response.status === 401) return;
|
||||
if (!response.ok) {
|
||||
alert.error("Nepodařilo se vygenerovat PDF");
|
||||
const response = await apiFetch(
|
||||
`${API_BASE}/offers/${quotation.id}/file`,
|
||||
);
|
||||
if (response.status === 401) {
|
||||
newWindow?.close();
|
||||
return;
|
||||
}
|
||||
const html = await response.text();
|
||||
const w = window.open("", "_blank");
|
||||
if (w) {
|
||||
w.document.open();
|
||||
w.document.write(html);
|
||||
w.document.close();
|
||||
w.onload = () => w.print();
|
||||
} else {
|
||||
alert.error("Prohlížeč zablokoval vyskakovací okno");
|
||||
if (!response.ok) {
|
||||
newWindow?.close();
|
||||
alert.error("PDF soubor nenalezen — otevřete nabídku a uložte ji");
|
||||
return;
|
||||
}
|
||||
const blob = await response.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
if (newWindow) newWindow.location.href = url;
|
||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||
} catch {
|
||||
alert.error("Chyba při generování PDF");
|
||||
newWindow?.close();
|
||||
alert.error("Chyba připojení");
|
||||
} finally {
|
||||
setPdfLoading(null);
|
||||
}
|
||||
@@ -753,7 +755,7 @@ export default function Offers() {
|
||||
<button
|
||||
onClick={() => handlePdf(q)}
|
||||
className="admin-btn-icon"
|
||||
title="PDF"
|
||||
title="Zobrazit nabídku"
|
||||
disabled={pdfLoading === q.id}
|
||||
>
|
||||
{pdfLoading === q.id ? (
|
||||
|
||||
@@ -503,19 +503,22 @@ export default function ReceivedInvoices({
|
||||
};
|
||||
|
||||
const openFile = async (inv: ReceivedInvoice) => {
|
||||
const newWindow = window.open("", "_blank");
|
||||
try {
|
||||
const response = await apiFetch(
|
||||
`${API_BASE}/received-invoices/${inv.id}/file`,
|
||||
);
|
||||
if (!response.ok) {
|
||||
newWindow?.close();
|
||||
alert.error("Nepodařilo se načíst soubor");
|
||||
return;
|
||||
}
|
||||
const blob = await response.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
window.open(url, "_blank");
|
||||
if (newWindow) newWindow.location.href = url;
|
||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||
} catch {
|
||||
newWindow?.close();
|
||||
alert.error("Chyba připojení");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ export default async function companySettingsRoutes(
|
||||
const settings = await prisma.company_settings.findFirst({
|
||||
select: { [column]: true },
|
||||
});
|
||||
const buf = settings?.[column] as Buffer | null;
|
||||
const buf = settings?.[column] as unknown as Buffer | null;
|
||||
if (!buf) return error(reply, "Logo nenalezeno", 404);
|
||||
|
||||
let mime = "image/png";
|
||||
@@ -203,9 +203,15 @@ export default async function companySettingsRoutes(
|
||||
max_requests_per_minute: true,
|
||||
available_vat_rates: true,
|
||||
available_currencies: true,
|
||||
smtp_from: true,
|
||||
smtp_from_name: true,
|
||||
offer_number_pattern: true,
|
||||
order_number_pattern: true,
|
||||
invoice_number_pattern: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
if (!settings) return error(reply, "Nastavení nenalezeno", 500);
|
||||
|
||||
// Check if logo exists
|
||||
const logoCheck = await prisma.company_settings.findFirst({
|
||||
@@ -219,9 +225,8 @@ export default async function companySettingsRoutes(
|
||||
settings.custom_fields as string | null,
|
||||
);
|
||||
|
||||
const pkg = await import("../../../package.json", {
|
||||
assert: { type: "json" },
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const pkg = require("../../../package.json") as { version: string };
|
||||
|
||||
let available_vat_rates: number[] = [0, 10, 12, 15, 21];
|
||||
try {
|
||||
@@ -255,7 +260,7 @@ export default async function companySettingsRoutes(
|
||||
available_currencies,
|
||||
has_logo,
|
||||
has_logo_dark,
|
||||
app_version: pkg.default.version,
|
||||
app_version: pkg.version,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -264,9 +269,8 @@ export default async function companySettingsRoutes(
|
||||
"/system-info",
|
||||
{ preHandler: requirePermission("settings.manage") },
|
||||
async (request, reply) => {
|
||||
const pkg = await import("../../../package.json", {
|
||||
assert: { type: "json" },
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const pkg = require("../../../package.json") as { version: string };
|
||||
const uptimeSec = process.uptime();
|
||||
const days = Math.floor(uptimeSec / 86400);
|
||||
const hours = Math.floor((uptimeSec % 86400) / 3600);
|
||||
@@ -299,7 +303,7 @@ export default async function companySettingsRoutes(
|
||||
const projectNas = new NasFileManager();
|
||||
|
||||
return success(reply, {
|
||||
app_version: pkg.default.version,
|
||||
app_version: pkg.version,
|
||||
node_version: process.version,
|
||||
platform: `${os.type()} ${os.release()}`,
|
||||
uptime: uptimeStr,
|
||||
|
||||
Reference in New Issue
Block a user