Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9dd49591e | ||
|
|
8cdf057ab3 | ||
|
|
a3ef37d0d2 | ||
|
|
e0ea997c24 | ||
|
|
cde560a2c3 | ||
|
|
e6198e1b67 | ||
|
|
495fdf6da2 | ||
|
|
7d29f40ab2 | ||
|
|
6b9f1dee87 | ||
|
|
687dcb9371 | ||
|
|
9c49015968 | ||
|
|
0021f5d46e | ||
|
|
16e48d4e5f | ||
|
|
6b31b2f74b | ||
|
|
f49015a627 | ||
|
|
c201958689 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -6,3 +6,10 @@ dist/
|
|||||||
*.log
|
*.log
|
||||||
dist-client/
|
dist-client/
|
||||||
*.css.map
|
*.css.map
|
||||||
|
|
||||||
|
# Release archives
|
||||||
|
*.tar.gz
|
||||||
|
|
||||||
|
# Claude worktrees
|
||||||
|
.claude/worktrees/
|
||||||
|
.claude/settings.local.json
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
|
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<link rel="shortcut icon" href="/favicon.ico" />
|
<link rel="shortcut icon" href="/favicon.ico" />
|
||||||
<title>BOHA | Admin</title>
|
<title>Admin</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
33
package-lock.json
generated
33
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "boha-app-ts",
|
"name": "app-ts",
|
||||||
"version": "1.1.3",
|
"version": "1.3.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "boha-app-ts",
|
"name": "app-ts",
|
||||||
"version": "1.1.3",
|
"version": "1.3.5",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
"framer-motion": "^12.38.0",
|
"framer-motion": "^12.38.0",
|
||||||
"hi-base32": "^0.5.1",
|
"hi-base32": "^0.5.1",
|
||||||
"jsonwebtoken": "^9.0.3",
|
"jsonwebtoken": "^9.0.3",
|
||||||
|
"leaflet": "^1.9.4",
|
||||||
"node-cron": "^4.2.1",
|
"node-cron": "^4.2.1",
|
||||||
"nodemailer": "^8.0.2",
|
"nodemailer": "^8.0.2",
|
||||||
"otpauth": "^9.5.0",
|
"otpauth": "^9.5.0",
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
"@types/bcryptjs": "^2.4.6",
|
"@types/bcryptjs": "^2.4.6",
|
||||||
"@types/dompurify": "^3.0.5",
|
"@types/dompurify": "^3.0.5",
|
||||||
"@types/jsonwebtoken": "^9.0.10",
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
|
"@types/leaflet": "^1.9.21",
|
||||||
"@types/mysql": "^2.15.27",
|
"@types/mysql": "^2.15.27",
|
||||||
"@types/node": "^25.5.0",
|
"@types/node": "^25.5.0",
|
||||||
"@types/node-cron": "^3.0.11",
|
"@types/node-cron": "^3.0.11",
|
||||||
@@ -1504,6 +1506,13 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/geojson": {
|
||||||
|
"version": "7946.0.16",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz",
|
||||||
|
"integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/jsonwebtoken": {
|
"node_modules/@types/jsonwebtoken": {
|
||||||
"version": "9.0.10",
|
"version": "9.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.10.tgz",
|
||||||
@@ -1515,6 +1524,16 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/leaflet": {
|
||||||
|
"version": "1.9.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.21.tgz",
|
||||||
|
"integrity": "sha512-TbAd9DaPGSnzp6QvtYngntMZgcRk+igFELwR2N99XZn7RXUdKgsXMR+28bUO0rPsWp8MIu/f47luLIQuSLYv/w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/geojson": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/methods": {
|
"node_modules/@types/methods": {
|
||||||
"version": "1.1.4",
|
"version": "1.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/@types/methods/-/methods-1.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/methods/-/methods-1.1.4.tgz",
|
||||||
@@ -3699,6 +3718,12 @@
|
|||||||
"safe-buffer": "^5.0.1"
|
"safe-buffer": "^5.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/leaflet": {
|
||||||
|
"version": "1.9.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz",
|
||||||
|
"integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==",
|
||||||
|
"license": "BSD-2-Clause"
|
||||||
|
},
|
||||||
"node_modules/light-my-request": {
|
"node_modules/light-my-request": {
|
||||||
"version": "6.6.0",
|
"version": "6.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-6.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-6.6.0.tgz",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "app-ts",
|
"name": "app-ts",
|
||||||
"version": "1.1.3",
|
"version": "1.3.5",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/server.js",
|
"main": "dist/server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -43,6 +43,7 @@
|
|||||||
"framer-motion": "^12.38.0",
|
"framer-motion": "^12.38.0",
|
||||||
"hi-base32": "^0.5.1",
|
"hi-base32": "^0.5.1",
|
||||||
"jsonwebtoken": "^9.0.3",
|
"jsonwebtoken": "^9.0.3",
|
||||||
|
"leaflet": "^1.9.4",
|
||||||
"node-cron": "^4.2.1",
|
"node-cron": "^4.2.1",
|
||||||
"nodemailer": "^8.0.2",
|
"nodemailer": "^8.0.2",
|
||||||
"otpauth": "^9.5.0",
|
"otpauth": "^9.5.0",
|
||||||
@@ -60,6 +61,7 @@
|
|||||||
"@types/bcryptjs": "^2.4.6",
|
"@types/bcryptjs": "^2.4.6",
|
||||||
"@types/dompurify": "^3.0.5",
|
"@types/dompurify": "^3.0.5",
|
||||||
"@types/jsonwebtoken": "^9.0.10",
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
|
"@types/leaflet": "^1.9.21",
|
||||||
"@types/mysql": "^2.15.27",
|
"@types/mysql": "^2.15.27",
|
||||||
"@types/node": "^25.5.0",
|
"@types/node": "^25.5.0",
|
||||||
"@types/node-cron": "^3.0.11",
|
"@types/node-cron": "^3.0.11",
|
||||||
|
|||||||
1
prisma/migrations/20260327_add_dark_logo/migration.sql
Normal file
1
prisma/migrations/20260327_add_dark_logo/migration.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `company_settings` ADD COLUMN `logo_data_dark` MEDIUMBLOB NULL AFTER `logo_data`;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE `company_settings`
|
||||||
|
ADD COLUMN `offer_number_pattern` VARCHAR(100) NULL,
|
||||||
|
ADD COLUMN `order_number_pattern` VARCHAR(100) NULL,
|
||||||
|
ADD COLUMN `invoice_number_pattern` VARCHAR(100) NULL;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE `company_settings`
|
||||||
|
ADD COLUMN `smtp_from` VARCHAR(255) NULL,
|
||||||
|
ADD COLUMN `smtp_from_name` VARCHAR(255) NULL;
|
||||||
13
prisma/migrations/20260327_add_system_settings/migration.sql
Normal file
13
prisma/migrations/20260327_add_system_settings/migration.sql
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
-- System settings columns on company_settings
|
||||||
|
ALTER TABLE `company_settings`
|
||||||
|
ADD COLUMN `break_threshold_hours` DECIMAL(4,2) DEFAULT 6,
|
||||||
|
ADD COLUMN `break_duration_short` INT DEFAULT 15,
|
||||||
|
ADD COLUMN `break_duration_long` INT DEFAULT 30,
|
||||||
|
ADD COLUMN `clock_rounding_minutes` INT DEFAULT 15,
|
||||||
|
ADD COLUMN `invoice_alert_email` VARCHAR(255) NULL,
|
||||||
|
ADD COLUMN `leave_notify_email` VARCHAR(255) NULL,
|
||||||
|
ADD COLUMN `max_login_attempts` INT DEFAULT 5,
|
||||||
|
ADD COLUMN `lockout_minutes` INT DEFAULT 15,
|
||||||
|
ADD COLUMN `max_requests_per_minute` INT DEFAULT 300,
|
||||||
|
ADD COLUMN `available_vat_rates` LONGTEXT NULL,
|
||||||
|
ADD COLUMN `available_currencies` LONGTEXT NULL;
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
-- Create new unified permission
|
||||||
|
INSERT INTO permissions (name, display_name, description, module)
|
||||||
|
VALUES ('settings.manage', 'Správa nastavení', 'Správa všech nastavení systému', 'settings')
|
||||||
|
ON DUPLICATE KEY UPDATE display_name = VALUES(display_name);
|
||||||
|
|
||||||
|
-- Grant to all roles that had any of the old 3
|
||||||
|
INSERT IGNORE INTO role_permissions (role_id, permission_id)
|
||||||
|
SELECT DISTINCT rp.role_id, (SELECT id FROM permissions WHERE name = 'settings.manage')
|
||||||
|
FROM role_permissions rp
|
||||||
|
JOIN permissions p ON p.id = rp.permission_id
|
||||||
|
WHERE p.name IN ('offers.settings', 'settings.roles', 'settings.security');
|
||||||
|
|
||||||
|
-- Clean up old role_permissions
|
||||||
|
DELETE FROM role_permissions
|
||||||
|
WHERE permission_id IN (SELECT id FROM permissions WHERE name IN ('offers.settings', 'settings.roles', 'settings.security'));
|
||||||
|
|
||||||
|
-- Remove old permissions
|
||||||
|
DELETE FROM permissions WHERE name IN ('offers.settings', 'settings.roles', 'settings.security');
|
||||||
@@ -100,6 +100,7 @@ model company_settings {
|
|||||||
vat_id String? @db.VarChar(50)
|
vat_id String? @db.VarChar(50)
|
||||||
custom_fields String? @db.LongText
|
custom_fields String? @db.LongText
|
||||||
logo_data Bytes?
|
logo_data Bytes?
|
||||||
|
logo_data_dark Bytes?
|
||||||
quotation_prefix String? @db.VarChar(20)
|
quotation_prefix String? @db.VarChar(20)
|
||||||
default_currency String? @default("CZK") @db.VarChar(10)
|
default_currency String? @default("CZK") @db.VarChar(10)
|
||||||
default_vat_rate Decimal? @default(21.00) @db.Decimal(5, 2)
|
default_vat_rate Decimal? @default(21.00) @db.Decimal(5, 2)
|
||||||
@@ -109,7 +110,23 @@ model company_settings {
|
|||||||
sync_version Int? @default(0)
|
sync_version Int? @default(0)
|
||||||
order_type_code String? @db.VarChar(10)
|
order_type_code String? @db.VarChar(10)
|
||||||
invoice_type_code String? @db.VarChar(10)
|
invoice_type_code String? @db.VarChar(10)
|
||||||
require_2fa Boolean @default(false)
|
require_2fa Boolean @default(false)
|
||||||
|
break_threshold_hours Decimal? @default(6) @db.Decimal(4, 2)
|
||||||
|
break_duration_short Int? @default(15)
|
||||||
|
break_duration_long Int? @default(30)
|
||||||
|
clock_rounding_minutes Int? @default(15)
|
||||||
|
invoice_alert_email String? @db.VarChar(255)
|
||||||
|
leave_notify_email String? @db.VarChar(255)
|
||||||
|
max_login_attempts Int? @default(5)
|
||||||
|
lockout_minutes Int? @default(15)
|
||||||
|
max_requests_per_minute Int? @default(300)
|
||||||
|
available_vat_rates String? @db.LongText
|
||||||
|
available_currencies String? @db.LongText
|
||||||
|
smtp_from String? @db.VarChar(255)
|
||||||
|
smtp_from_name String? @db.VarChar(255)
|
||||||
|
offer_number_pattern String? @db.VarChar(100)
|
||||||
|
order_number_pattern String? @db.VarChar(100)
|
||||||
|
invoice_number_pattern String? @db.VarChar(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
model customers {
|
model customers {
|
||||||
|
|||||||
@@ -7,7 +7,18 @@ import AdminLayout from "./components/AdminLayout";
|
|||||||
import AlertContainer from "./components/AlertContainer";
|
import AlertContainer from "./components/AlertContainer";
|
||||||
import Login from "./pages/Login";
|
import Login from "./pages/Login";
|
||||||
import Dashboard from "./pages/Dashboard";
|
import Dashboard from "./pages/Dashboard";
|
||||||
import "./admin.css";
|
import "./variables.css";
|
||||||
|
import "./base.css";
|
||||||
|
import "./forms.css";
|
||||||
|
import "./buttons.css";
|
||||||
|
import "./layout.css";
|
||||||
|
import "./components.css";
|
||||||
|
import "./tables.css";
|
||||||
|
import "./skeleton.css";
|
||||||
|
import "./datepicker.css";
|
||||||
|
import "./filemanager.css";
|
||||||
|
import "./pagination.css";
|
||||||
|
import "./responsive.css";
|
||||||
import "./login.css";
|
import "./login.css";
|
||||||
import "./dashboard.css";
|
import "./dashboard.css";
|
||||||
import "./attendance.css";
|
import "./attendance.css";
|
||||||
@@ -32,7 +43,6 @@ const Offers = lazy(() => import("./pages/Offers"));
|
|||||||
const OfferDetail = lazy(() => import("./pages/OfferDetail"));
|
const OfferDetail = lazy(() => import("./pages/OfferDetail"));
|
||||||
const OffersCustomers = lazy(() => import("./pages/OffersCustomers"));
|
const OffersCustomers = lazy(() => import("./pages/OffersCustomers"));
|
||||||
const OffersTemplates = lazy(() => import("./pages/OffersTemplates"));
|
const OffersTemplates = lazy(() => import("./pages/OffersTemplates"));
|
||||||
const CompanySettings = lazy(() => import("./pages/CompanySettings"));
|
|
||||||
const Orders = lazy(() => import("./pages/Orders"));
|
const Orders = lazy(() => import("./pages/Orders"));
|
||||||
const OrderDetail = lazy(() => import("./pages/OrderDetail"));
|
const OrderDetail = lazy(() => import("./pages/OrderDetail"));
|
||||||
const Projects = lazy(() => import("./pages/Projects"));
|
const Projects = lazy(() => import("./pages/Projects"));
|
||||||
@@ -91,7 +101,6 @@ export default function AdminApp() {
|
|||||||
<Route path="offers/:id" element={<OfferDetail />} />
|
<Route path="offers/:id" element={<OfferDetail />} />
|
||||||
<Route path="offers/customers" element={<OffersCustomers />} />
|
<Route path="offers/customers" element={<OffersCustomers />} />
|
||||||
<Route path="offers/templates" element={<OffersTemplates />} />
|
<Route path="offers/templates" element={<OffersTemplates />} />
|
||||||
<Route path="company/settings" element={<CompanySettings />} />
|
|
||||||
<Route path="orders" element={<Orders />} />
|
<Route path="orders" element={<Orders />} />
|
||||||
<Route path="orders/:id" element={<OrderDetail />} />
|
<Route path="orders/:id" element={<OrderDetail />} />
|
||||||
<Route path="projects" element={<Projects />} />
|
<Route path="projects" element={<Projects />} />
|
||||||
|
|||||||
3228
src/admin/admin.css
3228
src/admin/admin.css
File diff suppressed because it is too large
Load Diff
420
src/admin/base.css
Normal file
420
src/admin/base.css
Normal file
@@ -0,0 +1,420 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
Reset & Base
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
#root {
|
||||||
|
min-height: 100%;
|
||||||
|
min-height: 100dvh;
|
||||||
|
max-width: 100vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: var(--font-body);
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: var(--text-primary);
|
||||||
|
background: var(--bg-primary);
|
||||||
|
overflow-x: hidden;
|
||||||
|
overscroll-behavior-x: none;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
transition:
|
||||||
|
background-color 0.3s ease,
|
||||||
|
color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar,
|
||||||
|
.admin-header,
|
||||||
|
.admin-card,
|
||||||
|
.admin-modal {
|
||||||
|
transition:
|
||||||
|
background-color 0.3s ease,
|
||||||
|
color 0.3s ease,
|
||||||
|
border-color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#root {
|
||||||
|
overflow-x: hidden;
|
||||||
|
touch-action: pan-y pinch-zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3,
|
||||||
|
h4,
|
||||||
|
h5,
|
||||||
|
h6 {
|
||||||
|
font-family: var(--font-heading);
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.2;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: clamp(2.5rem, 5vw, 4rem);
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size: clamp(2rem, 4vw, 3rem);
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
font-size: clamp(1.25rem, 2vw, 1.5rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-track {
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
background: var(--border-color);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
::selection {
|
||||||
|
background: var(--accent-color);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Base / Utilities
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.text-warning {
|
||||||
|
color: var(--warning) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-danger {
|
||||||
|
color: var(--danger) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-success {
|
||||||
|
color: var(--success) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-muted {
|
||||||
|
color: var(--text-muted) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-secondary {
|
||||||
|
color: var(--text-secondary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-tertiary {
|
||||||
|
color: var(--text-tertiary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-accent {
|
||||||
|
color: var(--accent-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fw-600 {
|
||||||
|
font-weight: 600 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.link-accent {
|
||||||
|
color: var(--accent-color);
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.link-accent:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Layout utilities */
|
||||||
|
.flex-1 {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.flex-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.flex-row-gap {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-3);
|
||||||
|
}
|
||||||
|
.flex-between {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Spacing utilities */
|
||||||
|
.mb-2 {
|
||||||
|
margin-bottom: var(--space-2);
|
||||||
|
}
|
||||||
|
.mb-4 {
|
||||||
|
margin-bottom: var(--space-4);
|
||||||
|
}
|
||||||
|
.mb-6 {
|
||||||
|
margin-bottom: var(--space-6);
|
||||||
|
}
|
||||||
|
.mt-2 {
|
||||||
|
margin-top: var(--space-2);
|
||||||
|
}
|
||||||
|
.mt-6 {
|
||||||
|
margin-top: var(--space-6);
|
||||||
|
}
|
||||||
|
.gap-2 {
|
||||||
|
gap: var(--space-2);
|
||||||
|
}
|
||||||
|
.gap-4 {
|
||||||
|
gap: var(--space-4);
|
||||||
|
}
|
||||||
|
.gap-5 {
|
||||||
|
gap: var(--space-5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Typography utilities */
|
||||||
|
.fw-500 {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.text-right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
.text-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Spinner variant */
|
||||||
|
.admin-spinner-sm {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border-width: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Monospace for data values (times, dates, numbers, IDs) */
|
||||||
|
.admin-mono {
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 0.875em;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Drag handle */
|
||||||
|
.admin-drag-handle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
color: var(--text-muted);
|
||||||
|
cursor: grab;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0;
|
||||||
|
transition:
|
||||||
|
color 0.15s,
|
||||||
|
background 0.15s;
|
||||||
|
touch-action: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-drag-handle:hover {
|
||||||
|
color: var(--text-primary);
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-drag-handle:active {
|
||||||
|
cursor: grabbing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Error stack (DEV only) */
|
||||||
|
.admin-error-stack {
|
||||||
|
max-width: 600px;
|
||||||
|
max-height: 200px;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
margin: 0;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
color: var(--danger-color);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.5;
|
||||||
|
text-align: left;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Keyboard shortcut badge */
|
||||||
|
.admin-kbd {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 2px 7px;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.4;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loading & Animations */
|
||||||
|
.admin-spinner {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border: 2px solid var(--accent-color);
|
||||||
|
border-top-color: transparent;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 0.8s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-loading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 256px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes float {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translate(0, 0);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translate(30px, -30px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes shimmer {
|
||||||
|
0% {
|
||||||
|
background-position: -200% 0;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
background-position: 200% 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Additional Utilities ─────────────────────────────────────────── */
|
||||||
|
|
||||||
|
/* Font sizes */
|
||||||
|
.text-xs {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
.text-sm {
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
}
|
||||||
|
.text-md {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
.text-base {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Width utilities */
|
||||||
|
.w-full {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.max-w-xs {
|
||||||
|
max-width: 120px;
|
||||||
|
}
|
||||||
|
.max-w-sm {
|
||||||
|
max-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Whitespace */
|
||||||
|
.whitespace-nowrap {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Additional gaps */
|
||||||
|
.gap-1 {
|
||||||
|
gap: 0.25rem;
|
||||||
|
}
|
||||||
|
.gap-3 {
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
.gap-6 {
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Additional margins */
|
||||||
|
.mb-1 {
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
|
.mb-3 {
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
.mt-1 {
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
}
|
||||||
|
.mt-3 {
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Display */
|
||||||
|
.inline-flex {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prefers reduced motion */
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
animation-duration: 0.01ms !important;
|
||||||
|
animation-iteration-count: 1 !important;
|
||||||
|
transition-duration: 0.01ms !important;
|
||||||
|
scroll-behavior: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-spinner {
|
||||||
|
animation-duration: 0.8s !important;
|
||||||
|
animation-iteration-count: infinite !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
130
src/admin/buttons.css
Normal file
130
src/admin/buttons.css
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
Buttons
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
padding: 8px 14px;
|
||||||
|
border: none;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 550;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: var(--transition);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn:disabled {
|
||||||
|
opacity: 0.7;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prevent buttons from growing when text changes to spinner + loading text */
|
||||||
|
.admin-modal-footer .admin-btn {
|
||||||
|
min-width: 100px;
|
||||||
|
}
|
||||||
|
.admin-modal-footer .admin-btn .admin-spinner {
|
||||||
|
margin: -2px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-sm {
|
||||||
|
padding: 6px 11px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-primary {
|
||||||
|
background: var(--accent-color);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-primary:hover:not(:disabled) {
|
||||||
|
background: var(--accent-hover);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 4px 12px rgba(214, 48, 49, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn .admin-spinner {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border-width: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-primary .admin-spinner {
|
||||||
|
border-color: rgba(255, 255, 255, 0.3);
|
||||||
|
border-top-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-secondary .admin-spinner {
|
||||||
|
border-color: rgba(var(--text-secondary-rgb, 107, 114, 128), 0.3);
|
||||||
|
border-top-color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-secondary {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-secondary:hover:not(:disabled) {
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border-color: var(--border-color-hover);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-icon {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-icon:hover {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-icon.accent {
|
||||||
|
color: var(--info);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-icon.accent:hover {
|
||||||
|
background: color-mix(in srgb, var(--info) 15%, transparent);
|
||||||
|
color: var(--info);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-icon.danger {
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-icon.danger:hover {
|
||||||
|
background: var(--danger-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Touch targets - min 44px on mobile */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.admin-btn {
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 10px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-sm {
|
||||||
|
min-height: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-btn-icon {
|
||||||
|
min-width: 44px;
|
||||||
|
min-height: 44px;
|
||||||
|
}
|
||||||
|
}
|
||||||
925
src/admin/components.css
Normal file
925
src/admin/components.css
Normal file
@@ -0,0 +1,925 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
Cards
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-card {
|
||||||
|
background: var(--card-bg);
|
||||||
|
border: 1px solid var(--glass-border);
|
||||||
|
box-shadow: var(--glass-shadow);
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-card:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-card-header {
|
||||||
|
padding: 14px 18px;
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-card-title {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 650;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin: 0 0 12px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-card-body {
|
||||||
|
padding: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.admin-card-body {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-card-header {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Badges
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
padding: 3px 9px;
|
||||||
|
border-radius: 9999px;
|
||||||
|
font-size: 11.5px;
|
||||||
|
font-weight: 600;
|
||||||
|
border: none;
|
||||||
|
font-family: inherit;
|
||||||
|
white-space: nowrap;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-wrap {
|
||||||
|
white-space: normal;
|
||||||
|
word-break: break-word;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-admin {
|
||||||
|
background: var(--accent-soft);
|
||||||
|
color: var(--accent-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-viewer {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-active {
|
||||||
|
background: var(--success-soft);
|
||||||
|
color: var(--success);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-active:hover {
|
||||||
|
background: color-mix(in srgb, var(--success) 20%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-inactive {
|
||||||
|
background: var(--danger-soft);
|
||||||
|
color: var(--danger);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-inactive:hover {
|
||||||
|
background: color-mix(in srgb, var(--danger) 20%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-success {
|
||||||
|
background: var(--success-soft);
|
||||||
|
color: var(--success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-warning {
|
||||||
|
background: var(--warning-soft);
|
||||||
|
color: var(--warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-secondary {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-info {
|
||||||
|
background: var(--info-soft);
|
||||||
|
color: var(--info);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-badge-danger {
|
||||||
|
background: var(--danger-soft);
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status Badges - Leave Requests */
|
||||||
|
.badge-pending {
|
||||||
|
background: color-mix(in srgb, var(--warning) 15%, transparent);
|
||||||
|
color: var(--warning);
|
||||||
|
}
|
||||||
|
.badge-approved {
|
||||||
|
background: color-mix(in srgb, var(--success) 15%, transparent);
|
||||||
|
color: var(--success);
|
||||||
|
}
|
||||||
|
.badge-rejected {
|
||||||
|
background: color-mix(in srgb, var(--danger) 15%, transparent);
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
.badge-cancelled {
|
||||||
|
background: var(--muted-light);
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status Badges - Orders */
|
||||||
|
.admin-badge-order-prijata {
|
||||||
|
background: color-mix(in srgb, var(--info) 15%, transparent);
|
||||||
|
color: var(--info);
|
||||||
|
}
|
||||||
|
.admin-badge-order-realizace {
|
||||||
|
background: color-mix(in srgb, var(--warning) 15%, transparent);
|
||||||
|
color: var(--warning);
|
||||||
|
}
|
||||||
|
.admin-badge-order-dokoncena {
|
||||||
|
background: color-mix(in srgb, var(--success) 15%, transparent);
|
||||||
|
color: var(--success);
|
||||||
|
}
|
||||||
|
.admin-badge-order-stornovana {
|
||||||
|
background: color-mix(in srgb, var(--danger) 15%, transparent);
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status Badges - Projects */
|
||||||
|
.admin-badge-project-aktivni {
|
||||||
|
background: color-mix(in srgb, var(--success) 15%, transparent);
|
||||||
|
color: var(--success);
|
||||||
|
}
|
||||||
|
.admin-badge-project-dokonceny {
|
||||||
|
background: color-mix(in srgb, var(--info) 15%, transparent);
|
||||||
|
color: var(--info);
|
||||||
|
}
|
||||||
|
.admin-badge-project-zruseny {
|
||||||
|
background: color-mix(in srgb, var(--danger) 15%, transparent);
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Badge on mobile - larger for touch */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.admin-badge {
|
||||||
|
padding: 4px 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.admin-badge {
|
||||||
|
min-height: 32px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Modals
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-modal-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 50;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 1rem;
|
||||||
|
overflow: hidden;
|
||||||
|
overscroll-behavior: none;
|
||||||
|
touch-action: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal-backdrop {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.6);
|
||||||
|
touch-action: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 480px;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
max-height: calc(100vh - 2rem);
|
||||||
|
max-height: calc(100dvh - 2rem);
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
touch-action: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal-lg {
|
||||||
|
max-width: 900px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal-header {
|
||||||
|
padding: 18px;
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal-body {
|
||||||
|
padding: 18px;
|
||||||
|
overflow-y: auto;
|
||||||
|
flex: 1;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal-footer {
|
||||||
|
padding: 14px 18px;
|
||||||
|
border-top: 1px solid var(--border-color);
|
||||||
|
display: flex;
|
||||||
|
gap: 0.75rem;
|
||||||
|
justify-content: flex-end;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.admin-modal-overlay {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal,
|
||||||
|
.admin-modal.admin-modal-lg {
|
||||||
|
max-width: 100%;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
height: 100dvh;
|
||||||
|
max-height: 100%;
|
||||||
|
max-height: 100dvh;
|
||||||
|
border-radius: 0;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal-header {
|
||||||
|
padding: 1rem;
|
||||||
|
padding-top: calc(1rem + env(safe-area-inset-top, 0px));
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal-body {
|
||||||
|
padding: 1rem;
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal-footer {
|
||||||
|
padding: 1rem;
|
||||||
|
padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-modal .admin-form-input,
|
||||||
|
.admin-modal .admin-form-select,
|
||||||
|
.admin-modal .admin-form-textarea {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Confirm Modal */
|
||||||
|
.admin-confirm-modal {
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-content {
|
||||||
|
text-align: center;
|
||||||
|
padding: 2rem 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-icon {
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin: 0 auto 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-icon-danger {
|
||||||
|
background: var(--danger-light);
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-icon-warning {
|
||||||
|
background: var(--warning-light);
|
||||||
|
color: var(--warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-icon-info {
|
||||||
|
background: var(--info-light);
|
||||||
|
color: var(--info);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-icon-default {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-title {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-message {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 0.95rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.admin-confirm-modal {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
max-height: calc(100% - 2rem);
|
||||||
|
max-height: calc(100dvh - 2rem);
|
||||||
|
margin: 1rem;
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-modal .admin-modal-footer {
|
||||||
|
padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Confirm modal on small mobile */
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.admin-confirm-content {
|
||||||
|
padding: 1.5rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-title {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-confirm-message {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Toast Alerts
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-alert-container {
|
||||||
|
position: fixed;
|
||||||
|
bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
|
||||||
|
right: 1rem;
|
||||||
|
z-index: 100;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
gap: 0.5rem;
|
||||||
|
max-width: 400px;
|
||||||
|
width: calc(100% - 2rem);
|
||||||
|
pointer-events: none;
|
||||||
|
transform: translateZ(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 640px) {
|
||||||
|
.admin-alert-container {
|
||||||
|
bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
|
||||||
|
right: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-toast {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 0.875rem 1rem;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-toast-icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-toast-message {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-toast-close {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 0.25rem;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: var(--text-muted);
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
transition: var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-toast-close:hover {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-toast-success .admin-toast-icon {
|
||||||
|
color: var(--success);
|
||||||
|
}
|
||||||
|
.admin-toast-error .admin-toast-icon {
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
.admin-toast-warning .admin-toast-icon {
|
||||||
|
color: var(--warning);
|
||||||
|
}
|
||||||
|
.admin-toast-info .admin-toast-icon {
|
||||||
|
color: var(--info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Tabs (Global)
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-tabs {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 4px;
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 0.625rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-tab {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
padding: 0.5rem 1.25rem;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
transition:
|
||||||
|
color 0.2s ease,
|
||||||
|
background 0.2s ease,
|
||||||
|
box-shadow 0.2s ease;
|
||||||
|
letter-spacing: 0.01em;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-tab:hover {
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-tab.active {
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-weight: 600;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
box-shadow:
|
||||||
|
0 1px 3px rgba(0, 0, 0, 0.12),
|
||||||
|
0 0 0 1px var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Empty State
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-empty-state {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
padding: 3rem 1.5rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-empty-icon {
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
color: var(--text-muted);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-empty-state p {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
max-width: 320px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-role-locked-notice {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
background: var(--warning-light);
|
||||||
|
border: 1px solid color-mix(in srgb, var(--warning) 25%, transparent);
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
color: var(--warning);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Forbidden (403)
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.forbidden-page {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 60vh;
|
||||||
|
text-align: center;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.forbidden-icon {
|
||||||
|
color: var(--accent-color);
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.forbidden-title {
|
||||||
|
font-family: var(--font-heading);
|
||||||
|
font-size: 2rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin: 0 0 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.forbidden-text {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 1rem;
|
||||||
|
max-width: 400px;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin: 0 0 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.forbidden-link {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
background: var(--accent-color);
|
||||||
|
color: #fff;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 600;
|
||||||
|
transition: var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
.forbidden-link:hover {
|
||||||
|
background: var(--accent-hover);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Stat Cards
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-stat-card {
|
||||||
|
position: relative;
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
|
-webkit-backdrop-filter: blur(12px);
|
||||||
|
border: 1px solid var(--glass-border);
|
||||||
|
box-shadow: var(--glass-shadow);
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
padding: 1.25rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-stat-card::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 3px;
|
||||||
|
background: var(--accent-color);
|
||||||
|
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-stat-card.success::before {
|
||||||
|
background: var(--success);
|
||||||
|
}
|
||||||
|
.admin-stat-card.warning::before {
|
||||||
|
background: var(--warning);
|
||||||
|
}
|
||||||
|
.admin-stat-card.danger::before {
|
||||||
|
background: var(--danger);
|
||||||
|
}
|
||||||
|
.admin-stat-card.info::before {
|
||||||
|
background: var(--info);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-stat-icon {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
background: var(--accent-soft);
|
||||||
|
color: var(--accent-color);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-stat-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.125rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-stat-value {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-stat-label {
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-muted);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.04em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-stat-footer {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-stat-icon.danger {
|
||||||
|
background: var(--danger-soft);
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
.admin-stat-icon.info {
|
||||||
|
background: var(--info-soft);
|
||||||
|
color: var(--info);
|
||||||
|
}
|
||||||
|
.admin-stat-icon.success {
|
||||||
|
background: var(--success-soft);
|
||||||
|
color: var(--success);
|
||||||
|
}
|
||||||
|
.admin-stat-icon.warning {
|
||||||
|
background: var(--warning-soft);
|
||||||
|
color: var(--warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
KPI Grid
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-kpi-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-kpi-4 {
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
}
|
||||||
|
.admin-kpi-3 {
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
}
|
||||||
|
.admin-kpi-2 {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
.admin-kpi-1 {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
max-width: 320px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1024px) {
|
||||||
|
.admin-kpi-4 {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.admin-kpi-grid {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.admin-kpi-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Editor Section Cards
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-editor-section {
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
|
-webkit-backdrop-filter: blur(12px);
|
||||||
|
border: 1px solid var(--glass-border);
|
||||||
|
box-shadow: var(--glass-shadow);
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
padding: 1.5rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.admin-editor-section {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Totals Summary
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-totals-summary {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
gap: 0.25rem;
|
||||||
|
padding-top: 0.75rem;
|
||||||
|
border-top: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-totals-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 2rem;
|
||||||
|
justify-content: flex-end;
|
||||||
|
min-width: 250px;
|
||||||
|
padding: 0.25rem 0;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-totals-row span:last-child {
|
||||||
|
min-width: 100px;
|
||||||
|
text-align: right;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-totals-total {
|
||||||
|
border-top: 2px solid var(--text-primary);
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
padding-top: 0.5rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-totals-total span:last-child {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.admin-totals-summary {
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-totals-row {
|
||||||
|
min-width: unset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Scope Sections
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-scope-list {
|
||||||
|
margin-top: 1.25rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-scope-section {
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
overflow: visible;
|
||||||
|
transition: border-color var(--transition);
|
||||||
|
background: var(--bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-scope-content {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-scope-section:hover {
|
||||||
|
border-color: color-mix(
|
||||||
|
in srgb,
|
||||||
|
var(--border-color) 70%,
|
||||||
|
var(--accent-color)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-scope-section-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0.625rem 1rem;
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
border-radius: 0.5rem 0.5rem 0 0;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-scope-section-header .admin-scope-number {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
flex-shrink: 0;
|
||||||
|
min-width: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-scope-section-header .admin-scope-title {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: var(--text-primary);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-scope-section-header .admin-scope-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.25rem;
|
||||||
|
margin-left: auto;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-scope-section .admin-form {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Logo Section
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-logo-section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-logo-preview {
|
||||||
|
max-width: 200px;
|
||||||
|
max-height: 100px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0.5rem;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-logo-preview img {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 80px;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
@@ -161,7 +161,7 @@ export default function RichEditor({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="rich-editor"
|
className="admin-rich-editor"
|
||||||
style={{ "--re-min-height": minHeight } as React.CSSProperties}
|
style={{ "--re-min-height": minHeight } as React.CSSProperties}
|
||||||
>
|
>
|
||||||
<ReactQuill
|
<ReactQuill
|
||||||
|
|||||||
@@ -330,22 +330,6 @@ const menuSections: MenuSection[] = [
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: "/company/settings",
|
|
||||||
label: "Firma",
|
|
||||||
permission: "offers.settings",
|
|
||||||
icon: (
|
|
||||||
<svg
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeWidth="2"
|
|
||||||
>
|
|
||||||
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
|
|
||||||
<polyline points="9 22 9 12 15 12 15 22" />
|
|
||||||
</svg>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -372,7 +356,7 @@ const menuSections: MenuSection[] = [
|
|||||||
{
|
{
|
||||||
path: "/settings",
|
path: "/settings",
|
||||||
label: "Nastavení",
|
label: "Nastavení",
|
||||||
permission: ["settings.roles", "settings.security"],
|
permission: "settings.manage",
|
||||||
icon: (
|
icon: (
|
||||||
<svg
|
<svg
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
@@ -464,11 +448,17 @@ export default function Sidebar({ isOpen, onClose, onLogout }: SidebarProps) {
|
|||||||
<img
|
<img
|
||||||
src={
|
src={
|
||||||
theme === "dark"
|
theme === "dark"
|
||||||
? "/images/logo-dark.png"
|
? "/api/admin/company-settings/logo?variant=dark"
|
||||||
: "/images/logo-light.png"
|
: "/api/admin/company-settings/logo?variant=light"
|
||||||
}
|
}
|
||||||
alt="Logo"
|
alt="Logo"
|
||||||
className="admin-sidebar-logo"
|
className="admin-sidebar-logo"
|
||||||
|
onError={(e) => {
|
||||||
|
(e.target as HTMLImageElement).src =
|
||||||
|
theme === "dark"
|
||||||
|
? "/images/logo-dark.png"
|
||||||
|
: "/images/logo-light.png";
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
|
|||||||
@@ -109,10 +109,10 @@ function buildInvoiceKpi(invoices: InvoicesData): KpiCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const KPI_CLASS_MAP: Record<number, string> = {
|
const KPI_CLASS_MAP: Record<number, string> = {
|
||||||
4: "dash-kpi-4",
|
4: "admin-kpi-4",
|
||||||
3: "dash-kpi-3",
|
3: "admin-kpi-3",
|
||||||
2: "dash-kpi-2",
|
2: "admin-kpi-2",
|
||||||
1: "dash-kpi-1",
|
1: "admin-kpi-1",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function DashKpiCards({ dashData }: DashKpiCardsProps) {
|
export default function DashKpiCards({ dashData }: DashKpiCardsProps) {
|
||||||
@@ -121,11 +121,11 @@ export default function DashKpiCards({ dashData }: DashKpiCardsProps) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const kpiClass = KPI_CLASS_MAP[Math.min(kpiCards.length, 4)] || "dash-kpi-4";
|
const kpiClass = KPI_CLASS_MAP[Math.min(kpiCards.length, 4)] || "admin-kpi-4";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
className={`dash-kpi-grid ${kpiClass}`}
|
className={`admin-kpi-grid ${kpiClass}`}
|
||||||
initial={{ opacity: 0, y: 12 }}
|
initial={{ opacity: 0, y: 12 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 0.25, delay: 0.06 }}
|
transition={{ duration: 0.25, delay: 0.06 }}
|
||||||
|
|||||||
@@ -218,17 +218,17 @@ export default function DashSessions() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!sessionsLoading && sessions.length > 0 && (
|
{!sessionsLoading && sessions.length > 0 && (
|
||||||
<div className="sessions-list">
|
<div className="dash-sessions-list">
|
||||||
{sessions.map((session) => (
|
{sessions.map((session) => (
|
||||||
<div
|
<div
|
||||||
key={session.id}
|
key={session.id}
|
||||||
className={`session-item ${session.is_current ? "session-item-current" : ""}`}
|
className={`dash-session-item ${session.is_current ? "dash-session-item-current" : ""}`}
|
||||||
>
|
>
|
||||||
<div className="session-icon">
|
<div className="dash-session-icon">
|
||||||
{getDeviceIcon(session.device_info?.icon)}
|
{getDeviceIcon(session.device_info?.icon)}
|
||||||
</div>
|
</div>
|
||||||
<div className="session-info">
|
<div className="dash-session-info">
|
||||||
<div className="session-device">
|
<div className="dash-session-device">
|
||||||
{session.device_info?.browser} na{" "}
|
{session.device_info?.browser} na{" "}
|
||||||
{session.device_info?.os}
|
{session.device_info?.os}
|
||||||
{session.is_current && (
|
{session.is_current && (
|
||||||
@@ -240,13 +240,13 @@ export default function DashSessions() {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="session-meta">
|
<div className="dash-session-meta">
|
||||||
<span>{session.ip_address}</span>
|
<span>{session.ip_address}</span>
|
||||||
<span className="session-meta-separator">|</span>
|
<span className="dash-session-meta-separator">|</span>
|
||||||
<span>{formatSessionDate(session.created_at)}</span>
|
<span>{formatSessionDate(session.created_at)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="session-actions">
|
<div className="dash-session-actions">
|
||||||
{!session.is_current && (
|
{!session.is_current && (
|
||||||
<button
|
<button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
|
|||||||
@@ -1,103 +1,3 @@
|
|||||||
/* ============================================================================
|
|
||||||
Stat Cards
|
|
||||||
============================================================================ */
|
|
||||||
|
|
||||||
.admin-stat-card {
|
|
||||||
position: relative;
|
|
||||||
background: var(--glass-bg);
|
|
||||||
backdrop-filter: blur(12px);
|
|
||||||
-webkit-backdrop-filter: blur(12px);
|
|
||||||
border: 1px solid var(--glass-border);
|
|
||||||
box-shadow: var(--glass-shadow);
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
padding: 1.25rem;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.5rem;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-stat-card::before {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 3px;
|
|
||||||
background: var(--accent-color);
|
|
||||||
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-stat-card.success::before {
|
|
||||||
background: var(--success);
|
|
||||||
}
|
|
||||||
.admin-stat-card.warning::before {
|
|
||||||
background: var(--warning);
|
|
||||||
}
|
|
||||||
.admin-stat-card.danger::before {
|
|
||||||
background: var(--danger);
|
|
||||||
}
|
|
||||||
.admin-stat-card.info::before {
|
|
||||||
background: var(--info);
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-stat-icon {
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
border-radius: var(--border-radius-sm);
|
|
||||||
background: var(--accent-soft);
|
|
||||||
color: var(--accent-color);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-stat-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.125rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-stat-value {
|
|
||||||
font-size: 28px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
letter-spacing: -0.02em;
|
|
||||||
line-height: 1.2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-stat-label {
|
|
||||||
font-size: 0.6875rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-muted);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.04em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-stat-footer {
|
|
||||||
font-size: 0.75rem;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-stat-icon.danger {
|
|
||||||
background: var(--danger-soft);
|
|
||||||
color: var(--danger);
|
|
||||||
}
|
|
||||||
.admin-stat-icon.info {
|
|
||||||
background: var(--info-soft);
|
|
||||||
color: var(--info);
|
|
||||||
}
|
|
||||||
.admin-stat-icon.success {
|
|
||||||
background: var(--success-soft);
|
|
||||||
color: var(--success);
|
|
||||||
}
|
|
||||||
.admin-stat-icon.warning {
|
|
||||||
background: var(--warning-soft);
|
|
||||||
color: var(--warning);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ============================================================================
|
/* ============================================================================
|
||||||
Dashboard
|
Dashboard
|
||||||
============================================================================ */
|
============================================================================ */
|
||||||
@@ -113,26 +13,6 @@
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* KPI grid */
|
|
||||||
.dash-kpi-grid {
|
|
||||||
display: grid;
|
|
||||||
gap: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dash-kpi-4 {
|
|
||||||
grid-template-columns: repeat(4, 1fr);
|
|
||||||
}
|
|
||||||
.dash-kpi-3 {
|
|
||||||
grid-template-columns: repeat(3, 1fr);
|
|
||||||
}
|
|
||||||
.dash-kpi-2 {
|
|
||||||
grid-template-columns: repeat(2, 1fr);
|
|
||||||
}
|
|
||||||
.dash-kpi-1 {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
max-width: 320px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Quick actions */
|
/* Quick actions */
|
||||||
.dash-quick-actions {
|
.dash-quick-actions {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -512,16 +392,9 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dash-kpi-4 {
|
|
||||||
grid-template-columns: repeat(2, 1fr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.dash-kpi-grid {
|
|
||||||
grid-template-columns: repeat(2, 1fr);
|
|
||||||
}
|
|
||||||
.dash-quick-actions {
|
.dash-quick-actions {
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, 1fr);
|
||||||
}
|
}
|
||||||
@@ -543,9 +416,6 @@
|
|||||||
.dash-quick-actions {
|
.dash-quick-actions {
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
}
|
}
|
||||||
.dash-kpi-grid {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
.dash-profile-grid {
|
.dash-profile-grid {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
@@ -555,12 +425,12 @@
|
|||||||
Sessions / Devices
|
Sessions / Devices
|
||||||
============================================================================ */
|
============================================================================ */
|
||||||
|
|
||||||
.sessions-list {
|
.dash-sessions-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-item {
|
.dash-session-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
@@ -569,23 +439,23 @@
|
|||||||
transition: var(--transition);
|
transition: var(--transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-item:last-child {
|
.dash-session-item:last-child {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-item:hover {
|
.dash-session-item:hover {
|
||||||
background: var(--bg-tertiary);
|
background: var(--bg-tertiary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-item-current {
|
.dash-session-item-current {
|
||||||
background: var(--row-current);
|
background: var(--row-current);
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-item-current:hover {
|
.dash-session-item-current:hover {
|
||||||
background: var(--row-current-hover);
|
background: var(--row-current-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-icon {
|
.dash-session-icon {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
border-radius: var(--border-radius-sm);
|
border-radius: var(--border-radius-sm);
|
||||||
@@ -597,17 +467,17 @@
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-item-current .session-icon {
|
.dash-session-item-current .dash-session-icon {
|
||||||
background: color-mix(in srgb, var(--success) 15%, transparent);
|
background: color-mix(in srgb, var(--success) 15%, transparent);
|
||||||
color: var(--success);
|
color: var(--success);
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-info {
|
.dash-session-info {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-device {
|
.dash-session-device {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -616,7 +486,7 @@
|
|||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-meta {
|
.dash-session-meta {
|
||||||
font-size: 0.8125rem;
|
font-size: 0.8125rem;
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
margin-top: 0.25rem;
|
margin-top: 0.25rem;
|
||||||
@@ -626,30 +496,30 @@
|
|||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-meta-separator {
|
.dash-session-meta-separator {
|
||||||
color: var(--border-color);
|
color: var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-actions {
|
.dash-session-actions {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 640px) {
|
||||||
.session-item {
|
.dash-session-item {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
gap: 0.75rem;
|
gap: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-icon {
|
.dash-session-icon {
|
||||||
width: 36px;
|
width: 36px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-device {
|
.dash-session-device {
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-meta {
|
.dash-session-meta {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
199
src/admin/datepicker.css
Normal file
199
src/admin/datepicker.css
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
React DatePicker Overrides
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.react-datepicker-wrapper {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker-popper {
|
||||||
|
z-index: 100 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prevent flash at top-left before popper calculates position */
|
||||||
|
#datepicker-portal .react-datepicker-popper {
|
||||||
|
opacity: 0;
|
||||||
|
animation: dp-fade-in 0.01s forwards 0.02s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes dp-fade-in {
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker {
|
||||||
|
font-family: inherit !important;
|
||||||
|
background-color: var(--bg-secondary) !important;
|
||||||
|
border: 1px solid var(--border-color) !important;
|
||||||
|
border-radius: var(--border-radius-sm) !important;
|
||||||
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25) !important;
|
||||||
|
color: var(--text-primary) !important;
|
||||||
|
font-size: 0.875rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__triangle {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header */
|
||||||
|
.react-datepicker__header {
|
||||||
|
background-color: var(--bg-tertiary) !important;
|
||||||
|
border-bottom: 1px solid var(--border-color) !important;
|
||||||
|
padding-top: 0.75rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__current-month,
|
||||||
|
.react-datepicker-time__header {
|
||||||
|
color: var(--text-primary) !important;
|
||||||
|
font-weight: 600 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__day-name {
|
||||||
|
color: var(--text-secondary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Days */
|
||||||
|
.react-datepicker__day {
|
||||||
|
color: var(--text-primary) !important;
|
||||||
|
border-radius: 6px !important;
|
||||||
|
transition:
|
||||||
|
background 0.15s,
|
||||||
|
color 0.15s !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__day:hover {
|
||||||
|
background-color: var(--accent-light) !important;
|
||||||
|
color: var(--text-primary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__day--selected,
|
||||||
|
.react-datepicker__day--keyboard-selected {
|
||||||
|
background-color: var(--accent-color) !important;
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__day--today {
|
||||||
|
font-weight: 700 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__day--outside-month {
|
||||||
|
color: var(--text-muted) !important;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__day--disabled {
|
||||||
|
color: var(--text-muted) !important;
|
||||||
|
opacity: 0.3 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Navigation arrows */
|
||||||
|
.react-datepicker__navigation {
|
||||||
|
top: 0.75rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__navigation-icon::before {
|
||||||
|
border-color: var(--text-secondary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__navigation:hover *::before {
|
||||||
|
border-color: var(--accent-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Year dropdown */
|
||||||
|
.react-datepicker__year-dropdown,
|
||||||
|
.react-datepicker__month-dropdown,
|
||||||
|
.react-datepicker__year-read-view,
|
||||||
|
.react-datepicker__month-read-view {
|
||||||
|
color: var(--text-primary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Time picker */
|
||||||
|
.react-datepicker__time-container {
|
||||||
|
border-left: 1px solid var(--border-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__time-container .react-datepicker__time {
|
||||||
|
background-color: var(--bg-secondary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__time-container
|
||||||
|
.react-datepicker__time
|
||||||
|
.react-datepicker__time-box {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__time-container
|
||||||
|
.react-datepicker__time
|
||||||
|
.react-datepicker__time-box
|
||||||
|
ul.react-datepicker__time-list
|
||||||
|
li.react-datepicker__time-list-item {
|
||||||
|
color: var(--text-primary) !important;
|
||||||
|
transition: background 0.15s !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__time-container
|
||||||
|
.react-datepicker__time
|
||||||
|
.react-datepicker__time-box
|
||||||
|
ul.react-datepicker__time-list
|
||||||
|
li.react-datepicker__time-list-item:hover {
|
||||||
|
background-color: var(--accent-light) !important;
|
||||||
|
color: var(--text-primary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__time-container
|
||||||
|
.react-datepicker__time
|
||||||
|
.react-datepicker__time-box
|
||||||
|
ul.react-datepicker__time-list
|
||||||
|
li.react-datepicker__time-list-item--selected {
|
||||||
|
background-color: var(--accent-color) !important;
|
||||||
|
color: #fff !important;
|
||||||
|
font-weight: 600 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Month picker */
|
||||||
|
.react-datepicker__monthPicker {
|
||||||
|
background-color: var(--bg-secondary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker-year-header {
|
||||||
|
background-color: var(--bg-tertiary) !important;
|
||||||
|
color: var(--text-primary) !important;
|
||||||
|
border-bottom: 1px solid var(--border-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__month-wrapper {
|
||||||
|
background-color: var(--bg-secondary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__month-text {
|
||||||
|
color: var(--text-primary) !important;
|
||||||
|
padding: 0.5rem !important;
|
||||||
|
border-radius: 6px !important;
|
||||||
|
transition: background 0.15s !important;
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__month-text:hover {
|
||||||
|
background-color: var(--accent-light) !important;
|
||||||
|
color: var(--text-primary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__month-text--keyboard-selected,
|
||||||
|
.react-datepicker__month-text--selected {
|
||||||
|
background-color: var(--accent-color) !important;
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__month-text--today {
|
||||||
|
font-weight: 700 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Input */
|
||||||
|
.react-datepicker__input-container input {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-datepicker__close-icon::after {
|
||||||
|
background-color: var(--accent-color) !important;
|
||||||
|
}
|
||||||
171
src/admin/filemanager.css
Normal file
171
src/admin/filemanager.css
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
File Manager
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.fm-toolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.75rem;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-full-path {
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
user-select: all;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-toolbar-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-breadcrumb {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0;
|
||||||
|
font-size: 12px;
|
||||||
|
min-height: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-breadcrumb-segment {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-breadcrumb-sep {
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
margin: 0 4px;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-breadcrumb-btn {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 12px;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-breadcrumb-btn:hover {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-breadcrumb-btn.active {
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-new-folder {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-new-folder .admin-form-input {
|
||||||
|
max-width: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-content {
|
||||||
|
position: relative;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
transition: border-color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-content.fm-drag-over {
|
||||||
|
border: 2px dashed var(--accent-color);
|
||||||
|
background: var(--accent-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-dropzone-overlay {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
background: color-mix(in srgb, var(--bg-primary) 90%, transparent);
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
z-index: 5;
|
||||||
|
color: var(--accent-color);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-empty {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
padding: 2.5rem 1rem;
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-folder-link {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
|
color: var(--accent-color);
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: inherit;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-folder-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-item-count {
|
||||||
|
font-size: 10px;
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-file-name {
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-meta {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-actions {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 2px;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-name-cell {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-symlink-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
cursor: help;
|
||||||
|
}
|
||||||
488
src/admin/forms.css
Normal file
488
src/admin/forms.css
Normal file
@@ -0,0 +1,488 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
Forms
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-label {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 9px 12px;
|
||||||
|
background: var(--input-bg);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-size: 13px;
|
||||||
|
font-family: inherit;
|
||||||
|
outline: none;
|
||||||
|
transition:
|
||||||
|
border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
||||||
|
box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
box-sizing: border-box;
|
||||||
|
min-height: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-input:focus {
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
box-shadow: 0 0 0 3px var(--accent-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-input::placeholder {
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-input[type="date"],
|
||||||
|
.admin-form-input[type="time"],
|
||||||
|
.admin-form-input[type="month"],
|
||||||
|
.admin-form-input[type="number"] {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
text-align: left;
|
||||||
|
height: 36px;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-input[type="number"]::-webkit-inner-spin-button,
|
||||||
|
.admin-form-input[type="number"]::-webkit-outer-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-input[type="date"]::-webkit-date-and-time-value,
|
||||||
|
.admin-form-input[type="time"]::-webkit-date-and-time-value,
|
||||||
|
.admin-form-input[type="month"]::-webkit-date-and-time-value {
|
||||||
|
text-align: left;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-input[type="date"]::-webkit-datetime-edit,
|
||||||
|
.admin-form-input[type="time"]::-webkit-datetime-edit,
|
||||||
|
.admin-form-input[type="month"]::-webkit-datetime-edit {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-input[type="date"]::-webkit-calendar-picker-indicator,
|
||||||
|
.admin-form-input[type="time"]::-webkit-calendar-picker-indicator,
|
||||||
|
.admin-form-input[type="month"]::-webkit-calendar-picker-indicator {
|
||||||
|
filter: var(--calendar-icon-filter, none);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Select */
|
||||||
|
.admin-form-select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 9px 12px;
|
||||||
|
background: var(--input-bg);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-size: 13px;
|
||||||
|
font-family: inherit;
|
||||||
|
outline: none;
|
||||||
|
transition:
|
||||||
|
border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
||||||
|
box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
min-height: 36px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
cursor: pointer;
|
||||||
|
appearance: none;
|
||||||
|
background-image: var(--select-arrow);
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: right 0.75rem center;
|
||||||
|
padding-right: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-select:focus {
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
box-shadow: 0 0 0 3px var(--accent-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-select option {
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Textarea */
|
||||||
|
.admin-form-textarea {
|
||||||
|
width: 100%;
|
||||||
|
padding: 9px 12px;
|
||||||
|
background: var(--input-bg);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-size: 13px;
|
||||||
|
font-family: inherit;
|
||||||
|
outline: none;
|
||||||
|
transition:
|
||||||
|
border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
||||||
|
box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
resize: vertical;
|
||||||
|
box-sizing: border-box;
|
||||||
|
min-height: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-textarea:focus {
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
box-shadow: 0 0 0 3px var(--accent-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Checkbox */
|
||||||
|
.admin-form-checkbox {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox input {
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox input + span::before {
|
||||||
|
content: "";
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
margin-right: 8px;
|
||||||
|
background: var(--input-bg);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 4px;
|
||||||
|
vertical-align: middle;
|
||||||
|
transition:
|
||||||
|
border-color var(--transition),
|
||||||
|
box-shadow var(--transition),
|
||||||
|
background var(--transition);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox input:checked + span::before {
|
||||||
|
background: var(--accent-color);
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
|
||||||
|
background-size: 12px;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox input:focus + span::before {
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
box-shadow: 0 0 0 3px var(--accent-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox:hover
|
||||||
|
input:not(:checked):not(:disabled):not(:indeterminate)
|
||||||
|
+ span::before {
|
||||||
|
border-color: var(--border-color-hover);
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox input:indeterminate + span::before {
|
||||||
|
background: var(--accent-color);
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'%3E%3Cline x1='6' y1='12' x2='18' y2='12'%3E%3C/line%3E%3C/svg%3E");
|
||||||
|
background-size: 12px;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox input:disabled + span::before {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox:has(input:disabled) {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox span {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reorderable List */
|
||||||
|
.admin-reorder-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-reorder-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 5px 8px;
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-reorder-arrows {
|
||||||
|
display: flex;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-reorder-label {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-reorder-label.accent {
|
||||||
|
color: var(--accent-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-reorder-arrows .admin-btn-icon {
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-reorder-arrows .admin-btn-icon:hover:not(:disabled) {
|
||||||
|
background: var(--bg-primary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-reorder-arrows .admin-btn-icon:disabled {
|
||||||
|
opacity: 0.25;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Form Rows (Grid Layouts) */
|
||||||
|
.admin-form-row {
|
||||||
|
display: grid;
|
||||||
|
gap: 1rem;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-row-3 {
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-row-4 {
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-row-5 {
|
||||||
|
grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.admin-form-row-4 {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
.admin-form-row-5 {
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.admin-form-row,
|
||||||
|
.admin-form-row-3 {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
.admin-form-row-5 {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.admin-form-row-4,
|
||||||
|
.admin-form-row-5 {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Form Utilities */
|
||||||
|
.admin-form-hint {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Required field indicator */
|
||||||
|
.admin-form-label.required::after {
|
||||||
|
content: " *";
|
||||||
|
color: var(--danger);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Inline field errors */
|
||||||
|
.admin-form-group.has-error .admin-form-input,
|
||||||
|
.admin-form-group.has-error .admin-form-select,
|
||||||
|
.admin-form-group.has-error .admin-form-textarea {
|
||||||
|
border-color: var(--danger);
|
||||||
|
box-shadow: 0 0 0 3px var(--danger-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-group.has-error .admin-form-label {
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-error {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--danger);
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.75rem;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
padding-top: 1.5rem;
|
||||||
|
border-top: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Touch targets - min 44px on mobile */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.admin-form-input,
|
||||||
|
.admin-form-select,
|
||||||
|
.admin-form-textarea {
|
||||||
|
min-height: 44px;
|
||||||
|
font-size: 16px; /* prevent auto-zoom on iOS */
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox {
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-checkbox input + span::before {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-label {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Customer Selector
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-customer-select {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-selected {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 12px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
background: var(--input-bg);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-selected span {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-selected .admin-btn-icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
margin-right: -4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-dropdown {
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 100;
|
||||||
|
max-height: 260px;
|
||||||
|
overflow-y: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-top: none;
|
||||||
|
border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-dropdown::-webkit-scrollbar {
|
||||||
|
width: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-dropdown::-webkit-scrollbar-track {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-dropdown::-webkit-scrollbar-thumb {
|
||||||
|
background: var(--border-color);
|
||||||
|
border-radius: 99px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-dropdown::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-dropdown-item {
|
||||||
|
padding: 8px 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background var(--transition);
|
||||||
|
border-radius: 4px;
|
||||||
|
margin: 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-dropdown-item:hover {
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-dropdown-item div:first-child {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-primary);
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-dropdown-item div:last-child {
|
||||||
|
font-size: 11.5px;
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
margin-top: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-customer-dropdown-empty {
|
||||||
|
padding: 0.75rem;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
}
|
||||||
@@ -358,6 +358,7 @@ function buildPrintHtml(
|
|||||||
userSections: string,
|
userSections: string,
|
||||||
emptyMsg: string,
|
emptyMsg: string,
|
||||||
filterNote: string,
|
filterNote: string,
|
||||||
|
companyName: string,
|
||||||
): string {
|
): string {
|
||||||
return `<!DOCTYPE html>
|
return `<!DOCTYPE html>
|
||||||
<html lang="cs">
|
<html lang="cs">
|
||||||
@@ -424,10 +425,10 @@ function buildPrintHtml(
|
|||||||
<thead><tr><td>
|
<thead><tr><td>
|
||||||
<div class="print-header">
|
<div class="print-header">
|
||||||
<div class="print-header-left">
|
<div class="print-header-left">
|
||||||
<img src="/images/logo-light.png" alt="BOHA" class="print-logo" />
|
<img src="/api/admin/company-settings/logo?variant=light" alt="" class="print-logo" />
|
||||||
<div class="print-header-text">
|
<div class="print-header-text">
|
||||||
<h1>EVIDENCE DOCHÁZKY</h1>
|
<h1>EVIDENCE DOCHÁZKY</h1>
|
||||||
<div class="company">BOHA Automation s.r.o.</div>
|
<div class="company">${companyName}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="print-header-right">
|
<div class="print-header-right">
|
||||||
@@ -1010,9 +1011,16 @@ export default function useAttendanceAdmin({ alert }: AlertContext) {
|
|||||||
// =========================================================================
|
// =========================================================================
|
||||||
const handlePrint = async () => {
|
const handlePrint = async () => {
|
||||||
try {
|
try {
|
||||||
let url = `${API_BASE}/attendance?action=print&month=${month}`;
|
const [response, settingsRes] = await Promise.all([
|
||||||
if (filterUserId) url += `&user_id=${filterUserId}`;
|
apiFetch(
|
||||||
const response = await apiFetch(url);
|
`${API_BASE}/attendance?action=print&month=${month}${filterUserId ? `&user_id=${filterUserId}` : ""}`,
|
||||||
|
),
|
||||||
|
apiFetch(`${API_BASE}/company-settings`),
|
||||||
|
]);
|
||||||
|
const settingsData = await settingsRes.json();
|
||||||
|
const companyName = settingsData.success
|
||||||
|
? settingsData.data.company_name || ""
|
||||||
|
: "";
|
||||||
if (response.status === 401) return;
|
if (response.status === 401) return;
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -1034,6 +1042,7 @@ export default function useAttendanceAdmin({ alert }: AlertContext) {
|
|||||||
userSections,
|
userSections,
|
||||||
emptyMsg,
|
emptyMsg,
|
||||||
filterNote,
|
filterNote,
|
||||||
|
companyName,
|
||||||
);
|
);
|
||||||
const printWindow = window.open("", "_blank");
|
const printWindow = window.open("", "_blank");
|
||||||
if (printWindow) {
|
if (printWindow) {
|
||||||
|
|||||||
582
src/admin/layout.css
Normal file
582
src/admin/layout.css
Normal file
@@ -0,0 +1,582 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
Layout
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-layout {
|
||||||
|
display: flex;
|
||||||
|
min-height: 100vh;
|
||||||
|
min-height: 100dvh;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.admin-layout {
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Sidebar
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
/* -- Theme variables for sidebar -- */
|
||||||
|
[data-theme="dark"] .admin-sidebar {
|
||||||
|
--sb-bg: #141414;
|
||||||
|
--sb-border: #2a2a2a;
|
||||||
|
--sb-text: #a0a0a0;
|
||||||
|
--sb-text-hover: #ddd;
|
||||||
|
--sb-hover-bg: #1f1f1f;
|
||||||
|
--sb-active-bg: #ffffff;
|
||||||
|
--sb-active-text: #141414;
|
||||||
|
--sb-label: #444;
|
||||||
|
--sb-muted: #555;
|
||||||
|
--sb-scrollbar: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="light"] .admin-sidebar {
|
||||||
|
--sb-bg: #ffffff;
|
||||||
|
--sb-border: #e8e6e1;
|
||||||
|
--sb-text: #7c7c84;
|
||||||
|
--sb-text-hover: #1a1a1a;
|
||||||
|
--sb-hover-bg: #f5f4f2;
|
||||||
|
--sb-active-bg: #141414;
|
||||||
|
--sb-active-text: #ffffff;
|
||||||
|
--sb-label: #a0a0a0;
|
||||||
|
--sb-muted: #a0a0a0;
|
||||||
|
--sb-scrollbar: #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
height: 100dvh;
|
||||||
|
z-index: 50;
|
||||||
|
background: var(--sb-bg);
|
||||||
|
border-right: 1px solid var(--sb-border);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-top: env(safe-area-inset-top, 0px);
|
||||||
|
padding-bottom: env(safe-area-inset-bottom, 0px);
|
||||||
|
padding-left: env(safe-area-inset-left, 0px);
|
||||||
|
padding-right: env(safe-area-inset-right, 0px);
|
||||||
|
transform: translateX(-100%);
|
||||||
|
visibility: hidden;
|
||||||
|
transition:
|
||||||
|
transform 0.3s ease,
|
||||||
|
visibility 0.3s ease;
|
||||||
|
overflow: hidden;
|
||||||
|
overscroll-behavior: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar.open {
|
||||||
|
transform: translateX(0);
|
||||||
|
visibility: visible;
|
||||||
|
touch-action: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.admin-sidebar {
|
||||||
|
right: auto;
|
||||||
|
width: 220px;
|
||||||
|
height: 100%;
|
||||||
|
transform: none;
|
||||||
|
visibility: visible;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="light"] .admin-sidebar {
|
||||||
|
box-shadow:
|
||||||
|
1px 0 0 0 var(--sb-border),
|
||||||
|
4px 0 16px rgba(0, 0, 0, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sidebar Overlay (mobile) */
|
||||||
|
.admin-sidebar-overlay {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
z-index: 49;
|
||||||
|
backdrop-filter: blur(2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar-overlay.open {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.admin-sidebar-overlay {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sidebar Header */
|
||||||
|
.admin-sidebar-header {
|
||||||
|
padding: 0 18px;
|
||||||
|
height: 73px;
|
||||||
|
border-bottom: 1px solid var(--sb-border);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar-logo {
|
||||||
|
height: 28px;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar-close {
|
||||||
|
display: block;
|
||||||
|
padding: 0.5rem;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: var(--sb-text);
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar-close:hover {
|
||||||
|
background: var(--sb-hover-bg);
|
||||||
|
color: var(--sb-text-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.admin-sidebar-close {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sidebar Navigation */
|
||||||
|
.admin-sidebar-nav {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar-nav::-webkit-scrollbar {
|
||||||
|
width: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar-nav::-webkit-scrollbar-track {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-sidebar-nav::-webkit-scrollbar-thumb {
|
||||||
|
background: var(--sb-scrollbar);
|
||||||
|
border-radius: 99px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Nav Section */
|
||||||
|
.admin-nav-section {
|
||||||
|
padding: 14px 10px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-nav-label {
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--sb-label);
|
||||||
|
padding: 0 8px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Nav Item */
|
||||||
|
.admin-nav-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 9px;
|
||||||
|
padding: 7px 10px;
|
||||||
|
border-radius: 7px;
|
||||||
|
color: var(--sb-text);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 450;
|
||||||
|
margin-bottom: 1px;
|
||||||
|
text-decoration: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-nav-item:hover {
|
||||||
|
background: var(--sb-hover-bg);
|
||||||
|
color: var(--sb-text-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-nav-item.active {
|
||||||
|
background: var(--sb-active-bg);
|
||||||
|
color: var(--sb-active-text);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-nav-item.active svg {
|
||||||
|
color: var(--accent-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-nav-item svg {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1023px) {
|
||||||
|
.admin-nav-item {
|
||||||
|
padding: 10px 12px;
|
||||||
|
font-size: 15px;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-nav-item svg {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sidebar Footer */
|
||||||
|
.admin-sidebar-footer {
|
||||||
|
margin-top: auto;
|
||||||
|
border-top: 1px solid var(--sb-border);
|
||||||
|
padding: 14px 10px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-user-chip {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 8px;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-user-avatar {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--accent-color);
|
||||||
|
color: #fff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 12px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-user-details {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-user-name {
|
||||||
|
color: var(--sb-text-hover);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-user-role {
|
||||||
|
color: var(--sb-muted);
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-logout-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 7px 10px;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: var(--sb-text);
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 7px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-family: inherit;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-logout-btn:hover {
|
||||||
|
background: var(--sb-hover-bg);
|
||||||
|
color: var(--sb-text-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-logout-btn svg {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.admin-sidebar-footer {
|
||||||
|
padding: 10px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-user-chip {
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-logout-btn {
|
||||||
|
padding: 8px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Main Content Area
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-main {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 100vh;
|
||||||
|
min-height: 100dvh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.admin-main {
|
||||||
|
margin-left: 220px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header */
|
||||||
|
.admin-header {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 30;
|
||||||
|
height: calc(73px + env(safe-area-inset-top, 0px));
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0 1rem;
|
||||||
|
padding-top: env(safe-area-inset-top, 0px);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.admin-header {
|
||||||
|
left: 220px;
|
||||||
|
padding: 0 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-menu-btn {
|
||||||
|
display: block;
|
||||||
|
padding: 0.5rem;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-menu-btn:hover {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.admin-menu-btn {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-header-theme-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
padding: 0;
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 50%;
|
||||||
|
transition: var(--transition);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-header-theme-btn:hover {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border-color: var(--border-color-hover);
|
||||||
|
transform: scale(1.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-theme-icon {
|
||||||
|
position: absolute;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--text-primary);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
opacity: 0;
|
||||||
|
transform: rotate(180deg) scale(0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-theme-icon.visible {
|
||||||
|
opacity: 1;
|
||||||
|
transform: rotate(0) scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Content */
|
||||||
|
.admin-content {
|
||||||
|
flex: 1;
|
||||||
|
padding: 1rem;
|
||||||
|
padding-top: calc(73px + 1rem + env(safe-area-inset-top, 0px));
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.admin-content {
|
||||||
|
padding: 28px 32px;
|
||||||
|
padding-top: calc(73px + 28px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Page Headers
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-page-header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 640px) {
|
||||||
|
.admin-page-header {
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-page-title {
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-family: var(--font-heading);
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-page-subtitle {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-page-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.75rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.admin-page-actions {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-page-actions .admin-btn {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Grid System
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-grid > .admin-card {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-grid-3 {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 640px) {
|
||||||
|
.admin-grid-3 {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.admin-grid-3 {
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-grid-4 {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.admin-grid-4 {
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Page header on mobile */
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.admin-page-title {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-page-subtitle {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-content {
|
||||||
|
padding: 12px !important;
|
||||||
|
padding-top: calc(73px + 12px + env(safe-area-inset-top, 0px)) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grid - single column on small mobile */
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.admin-grid-4 {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================================
|
||||||
|
Settings Grid
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-settings-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-settings-grid > .admin-card {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.admin-settings-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,63 +2,6 @@
|
|||||||
Offers Module
|
Offers Module
|
||||||
============================================ */
|
============================================ */
|
||||||
|
|
||||||
/* Editor section cards */
|
|
||||||
.offers-editor-section {
|
|
||||||
background: var(--glass-bg);
|
|
||||||
backdrop-filter: blur(12px);
|
|
||||||
-webkit-backdrop-filter: blur(12px);
|
|
||||||
border: 1px solid var(--glass-border);
|
|
||||||
box-shadow: var(--glass-shadow);
|
|
||||||
border-radius: 0.75rem;
|
|
||||||
padding: 1.5rem;
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Settings grid */
|
|
||||||
.offers-settings-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-settings-grid > .admin-card {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 900px) {
|
|
||||||
.offers-settings-grid {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Logo section */
|
|
||||||
.offers-logo-section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: 1rem;
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-logo-preview {
|
|
||||||
max-width: 200px;
|
|
||||||
max-height: 100px;
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
overflow: hidden;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 0.5rem;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-logo-preview img {
|
|
||||||
max-width: 100%;
|
|
||||||
max-height: 80px;
|
|
||||||
object-fit: contain;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Items table */
|
/* Items table */
|
||||||
.offers-items-table {
|
.offers-items-table {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
@@ -103,213 +46,6 @@
|
|||||||
min-height: 32px;
|
min-height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Totals summary */
|
|
||||||
.offers-totals-summary {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-end;
|
|
||||||
gap: 0.25rem;
|
|
||||||
padding-top: 0.75rem;
|
|
||||||
border-top: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-totals-row {
|
|
||||||
display: flex;
|
|
||||||
gap: 2rem;
|
|
||||||
justify-content: flex-end;
|
|
||||||
min-width: 250px;
|
|
||||||
padding: 0.25rem 0;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-totals-row span:last-child {
|
|
||||||
min-width: 100px;
|
|
||||||
text-align: right;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-totals-total {
|
|
||||||
border-top: 2px solid var(--text-primary);
|
|
||||||
margin-top: 0.25rem;
|
|
||||||
padding-top: 0.5rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-totals-total span:last-child {
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scope sections list wrapper */
|
|
||||||
.offers-scope-list {
|
|
||||||
margin-top: 1.25rem;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scope section card */
|
|
||||||
.offers-scope-section {
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
overflow: visible;
|
|
||||||
transition: border-color var(--transition);
|
|
||||||
background: var(--bg-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-scope-content {
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-scope-section:hover {
|
|
||||||
border-color: color-mix(
|
|
||||||
in srgb,
|
|
||||||
var(--border-color) 70%,
|
|
||||||
var(--accent-color)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-scope-section-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0.625rem 1rem;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
border-radius: 0.5rem 0.5rem 0 0;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-scope-section-header .offers-scope-number {
|
|
||||||
font-size: 0.75rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-tertiary);
|
|
||||||
flex-shrink: 0;
|
|
||||||
min-width: 1.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-scope-section-header .offers-scope-title {
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
color: var(--text-primary);
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-scope-section-header .offers-scope-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.25rem;
|
|
||||||
margin-left: auto;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-scope-section .admin-form {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Customer selector */
|
|
||||||
.offers-customer-select {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-selected {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
height: 36px;
|
|
||||||
padding: 0 12px;
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: var(--border-radius-sm);
|
|
||||||
background: var(--input-bg);
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-selected span {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-selected .admin-btn-icon {
|
|
||||||
flex-shrink: 0;
|
|
||||||
width: 22px;
|
|
||||||
height: 22px;
|
|
||||||
margin-right: -4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-dropdown {
|
|
||||||
position: absolute;
|
|
||||||
top: 100%;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
z-index: 100;
|
|
||||||
max-height: 260px;
|
|
||||||
overflow-y: auto;
|
|
||||||
overscroll-behavior: contain;
|
|
||||||
background: var(--bg-primary);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-top: none;
|
|
||||||
border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
|
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
||||||
padding: 4px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-dropdown::-webkit-scrollbar {
|
|
||||||
width: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-dropdown::-webkit-scrollbar-track {
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-dropdown::-webkit-scrollbar-thumb {
|
|
||||||
background: var(--border-color);
|
|
||||||
border-radius: 99px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-dropdown::-webkit-scrollbar-thumb:hover {
|
|
||||||
background: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-dropdown-item {
|
|
||||||
padding: 8px 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background var(--transition);
|
|
||||||
border-radius: 4px;
|
|
||||||
margin: 0 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-dropdown-item:hover {
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-dropdown-item div:first-child {
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--text-primary);
|
|
||||||
line-height: 1.3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-dropdown-item div:last-child {
|
|
||||||
font-size: 11.5px;
|
|
||||||
color: var(--text-tertiary);
|
|
||||||
margin-top: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-customer-dropdown-empty {
|
|
||||||
padding: 0.75rem;
|
|
||||||
text-align: center;
|
|
||||||
color: var(--text-tertiary);
|
|
||||||
font-size: 0.8125rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Template dropdown menu */
|
/* Template dropdown menu */
|
||||||
.offers-template-menu {
|
.offers-template-menu {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -361,81 +97,20 @@
|
|||||||
color: var(--danger);
|
color: var(--danger);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compact form row for 3+ columns */
|
|
||||||
.offers-form-row-3 {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.offers-form-row-3 {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tabs - zachovany pro zpetnou kompatibilitu, nove pouzivat admin-tabs/admin-tab */
|
|
||||||
.offers-tabs {
|
|
||||||
display: inline-flex;
|
|
||||||
gap: 4px;
|
|
||||||
padding: 4px;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 0.625rem;
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
max-width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-tab {
|
|
||||||
position: relative;
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
padding: 0.5rem 1.25rem;
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
color: var(--text-muted);
|
|
||||||
font-size: 0.8125rem;
|
|
||||||
font-weight: 500;
|
|
||||||
font-family: inherit;
|
|
||||||
cursor: pointer;
|
|
||||||
transition:
|
|
||||||
color 0.2s ease,
|
|
||||||
background 0.2s ease,
|
|
||||||
box-shadow 0.2s ease;
|
|
||||||
letter-spacing: 0.01em;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-tab:hover {
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-tab.active {
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-weight: 600;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
box-shadow:
|
|
||||||
0 1px 3px rgba(0, 0, 0, 0.12),
|
|
||||||
0 0 0 1px var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* RichEditor (Quill) */
|
/* RichEditor (Quill) */
|
||||||
.rich-editor {
|
.admin-rich-editor {
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-editor .quill {
|
.admin-rich-editor .quill {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Toolbar */
|
/* Toolbar */
|
||||||
.rich-editor .ql-toolbar.ql-snow {
|
.admin-rich-editor .ql-toolbar.ql-snow {
|
||||||
background: var(--bg-secondary);
|
background: var(--bg-secondary);
|
||||||
border: none;
|
border: none;
|
||||||
border-bottom: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
@@ -445,60 +120,60 @@
|
|||||||
gap: 2px;
|
gap: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-editor .ql-toolbar .ql-formats {
|
.admin-rich-editor .ql-toolbar .ql-formats {
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Toolbar buttons */
|
/* Toolbar buttons */
|
||||||
.rich-editor .ql-snow .ql-stroke {
|
.admin-rich-editor .ql-snow .ql-stroke {
|
||||||
stroke: var(--text-secondary);
|
stroke: var(--text-secondary);
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow .ql-fill {
|
.admin-rich-editor .ql-snow .ql-fill {
|
||||||
fill: var(--text-secondary);
|
fill: var(--text-secondary);
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow .ql-picker-label {
|
.admin-rich-editor .ql-snow .ql-picker-label {
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
border-color: var(--border-color);
|
border-color: var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-editor .ql-snow button:hover .ql-stroke,
|
.admin-rich-editor .ql-snow button:hover .ql-stroke,
|
||||||
.rich-editor .ql-snow .ql-picker-label:hover .ql-stroke {
|
.admin-rich-editor .ql-snow .ql-picker-label:hover .ql-stroke {
|
||||||
stroke: var(--text-primary);
|
stroke: var(--text-primary);
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow button:hover .ql-fill,
|
.admin-rich-editor .ql-snow button:hover .ql-fill,
|
||||||
.rich-editor .ql-snow .ql-picker-label:hover .ql-fill {
|
.admin-rich-editor .ql-snow .ql-picker-label:hover .ql-fill {
|
||||||
fill: var(--text-primary);
|
fill: var(--text-primary);
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow button:hover,
|
.admin-rich-editor .ql-snow button:hover,
|
||||||
.rich-editor .ql-snow .ql-picker-label:hover {
|
.admin-rich-editor .ql-snow .ql-picker-label:hover {
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Active state */
|
/* Active state */
|
||||||
.rich-editor .ql-snow button.ql-active {
|
.admin-rich-editor .ql-snow button.ql-active {
|
||||||
color: var(--accent-color);
|
color: var(--accent-color);
|
||||||
background: color-mix(in srgb, var(--accent-color) 15%, transparent);
|
background: color-mix(in srgb, var(--accent-color) 15%, transparent);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow button.ql-active .ql-stroke {
|
.admin-rich-editor .ql-snow button.ql-active .ql-stroke {
|
||||||
stroke: var(--accent-color);
|
stroke: var(--accent-color);
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow button.ql-active .ql-fill,
|
.admin-rich-editor .ql-snow button.ql-active .ql-fill,
|
||||||
.rich-editor .ql-snow button.ql-active .ql-stroke.ql-fill {
|
.admin-rich-editor .ql-snow button.ql-active .ql-stroke.ql-fill {
|
||||||
fill: var(--accent-color);
|
fill: var(--accent-color);
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow .ql-picker-item.ql-selected {
|
.admin-rich-editor .ql-snow .ql-picker-item.ql-selected {
|
||||||
color: var(--accent-color);
|
color: var(--accent-color);
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow .ql-picker-label.ql-active {
|
.admin-rich-editor .ql-snow .ql-picker-label.ql-active {
|
||||||
color: var(--accent-color);
|
color: var(--accent-color);
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow .ql-picker-label.ql-active .ql-stroke {
|
.admin-rich-editor .ql-snow .ql-picker-label.ql-active .ql-stroke {
|
||||||
stroke: var(--accent-color);
|
stroke: var(--accent-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dropdowns (font, size, color, align) */
|
/* Dropdowns (font, size, color, align) */
|
||||||
.rich-editor .ql-snow .ql-picker-options {
|
.admin-rich-editor .ql-snow .ql-picker-options {
|
||||||
background: var(--bg-primary);
|
background: var(--bg-primary);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: 0.375rem;
|
border-radius: 0.375rem;
|
||||||
@@ -507,23 +182,23 @@
|
|||||||
padding: 0.25rem;
|
padding: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-editor .ql-snow .ql-picker-item {
|
.admin-rich-editor .ql-snow .ql-picker-item {
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
padding: 0.25rem 0.5rem;
|
padding: 0.25rem 0.5rem;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow .ql-picker-item:hover {
|
.admin-rich-editor .ql-snow .ql-picker-item:hover {
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
background: var(--bg-secondary);
|
background: var(--bg-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Font picker */
|
/* Font picker */
|
||||||
.rich-editor .ql-snow .ql-font .ql-picker-options {
|
.admin-rich-editor .ql-snow .ql-font .ql-picker-options {
|
||||||
min-width: 11rem;
|
min-width: 11rem;
|
||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
.rich-editor .ql-snow .ql-size .ql-picker-options {
|
.admin-rich-editor .ql-snow .ql-size .ql-picker-options {
|
||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
@@ -703,13 +378,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Editor area */
|
/* Editor area */
|
||||||
.rich-editor .ql-container.ql-snow {
|
.admin-rich-editor .ql-container.ql-snow {
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0 0 0.5rem 0.5rem;
|
border-radius: 0 0 0.5rem 0.5rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-editor .ql-editor {
|
.admin-rich-editor .ql-editor {
|
||||||
min-height: var(--re-min-height, 120px);
|
min-height: var(--re-min-height, 120px);
|
||||||
padding: 0.75rem;
|
padding: 0.75rem;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
@@ -718,19 +393,22 @@
|
|||||||
background: var(--input-bg);
|
background: var(--input-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-editor .ql-editor.ql-blank::before {
|
.admin-rich-editor .ql-editor.ql-blank::before {
|
||||||
color: var(--text-tertiary);
|
color: var(--text-tertiary);
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lists inside editor */
|
/* Lists inside editor */
|
||||||
.rich-editor .ql-editor ul,
|
.admin-rich-editor .ql-editor ul,
|
||||||
.rich-editor .ql-editor ol {
|
.admin-rich-editor .ql-editor ol {
|
||||||
padding-left: 1.5rem;
|
padding-left: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Color picker */
|
/* Color picker */
|
||||||
.rich-editor .ql-snow .ql-color-picker .ql-picker-options[aria-hidden="false"] {
|
.admin-rich-editor
|
||||||
|
.ql-snow
|
||||||
|
.ql-color-picker
|
||||||
|
.ql-picker-options[aria-hidden="false"] {
|
||||||
width: 176px;
|
width: 176px;
|
||||||
padding: 0.375rem;
|
padding: 0.375rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -738,7 +416,7 @@
|
|||||||
gap: 2px;
|
gap: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-editor .ql-snow .ql-color-picker .ql-picker-item {
|
.admin-rich-editor .ql-snow .ql-color-picker .ql-picker-item {
|
||||||
width: 18px;
|
width: 18px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
@@ -748,7 +426,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Tooltip (link editor) */
|
/* Tooltip (link editor) */
|
||||||
.rich-editor .ql-snow .ql-tooltip {
|
.admin-rich-editor .ql-snow .ql-tooltip {
|
||||||
background: var(--bg-primary);
|
background: var(--bg-primary);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: 0.375rem;
|
border-radius: 0.375rem;
|
||||||
@@ -756,7 +434,7 @@
|
|||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-editor .ql-snow .ql-tooltip input[type="text"] {
|
.admin-rich-editor .ql-snow .ql-tooltip input[type="text"] {
|
||||||
background: var(--bg-secondary);
|
background: var(--bg-secondary);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
@@ -764,12 +442,12 @@
|
|||||||
padding: 0.25rem 0.5rem;
|
padding: 0.25rem 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-editor .ql-snow .ql-tooltip a {
|
.admin-rich-editor .ql-snow .ql-tooltip a {
|
||||||
color: var(--accent-color);
|
color: var(--accent-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read-only rendered rich text (Quill HTML output) */
|
/* Read-only rendered rich text (Quill HTML output) */
|
||||||
.rich-text-view {
|
.admin-rich-text-view {
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
@@ -778,56 +456,44 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-text-view ul,
|
.admin-rich-text-view ul,
|
||||||
.rich-text-view ol {
|
.admin-rich-text-view ol {
|
||||||
padding-left: 1.5rem;
|
padding-left: 1.5rem;
|
||||||
margin: 0.25rem 0 0.75rem;
|
margin: 0.25rem 0 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-text-view li {
|
.admin-rich-text-view li {
|
||||||
margin-bottom: 0.15rem;
|
margin-bottom: 0.15rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-text-view a {
|
.admin-rich-text-view a {
|
||||||
color: var(--accent-color);
|
color: var(--accent-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-text-view strong,
|
.admin-rich-text-view strong,
|
||||||
.rich-text-view b {
|
.admin-rich-text-view b {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-text-view br + b,
|
.admin-rich-text-view br + b,
|
||||||
.rich-text-view br + strong {
|
.admin-rich-text-view br + strong {
|
||||||
margin-top: 0.75rem;
|
margin-top: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-text-view > br:first-child,
|
.admin-rich-text-view > br:first-child,
|
||||||
.rich-text-view ul + br,
|
.admin-rich-text-view ul + br,
|
||||||
.rich-text-view ol + br {
|
.admin-rich-text-view ol + br {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 640px) {
|
||||||
.offers-editor-section {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-items-table {
|
.offers-items-table {
|
||||||
margin: 0 -1rem;
|
margin: 0 -1rem;
|
||||||
width: calc(100% + 2rem);
|
width: calc(100% + 2rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
.offers-totals-summary {
|
|
||||||
align-items: stretch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.offers-totals-row {
|
|
||||||
min-width: unset;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Offer draft row in table */
|
/* Offer draft row in table */
|
||||||
|
|||||||
@@ -576,10 +576,7 @@ export default function Attendance() {
|
|||||||
<div className="attendance-project-header">
|
<div className="attendance-project-header">
|
||||||
<span className="attendance-shift-label">Projekt</span>
|
<span className="attendance-shift-label">Projekt</span>
|
||||||
{activeProjectId ? (
|
{activeProjectId ? (
|
||||||
<span
|
<span className="admin-badge admin-badge-wrap text-sm">
|
||||||
className="admin-badge admin-badge-wrap"
|
|
||||||
style={{ fontSize: "0.8125rem" }}
|
|
||||||
>
|
|
||||||
{projects.find(
|
{projects.find(
|
||||||
(p) => String(p.id) === String(activeProjectId),
|
(p) => String(p.id) === String(activeProjectId),
|
||||||
)
|
)
|
||||||
@@ -587,12 +584,7 @@ export default function Attendance() {
|
|||||||
: `Projekt #${activeProjectId}`}
|
: `Projekt #${activeProjectId}`}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span
|
<span className="text-muted text-sm">Žádný</span>
|
||||||
className="text-muted"
|
|
||||||
style={{ fontSize: "0.8125rem" }}
|
|
||||||
>
|
|
||||||
Žádný
|
|
||||||
</span>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<select
|
<select
|
||||||
@@ -601,8 +593,7 @@ export default function Attendance() {
|
|||||||
handleSwitchProject(e.target.value || null)
|
handleSwitchProject(e.target.value || null)
|
||||||
}
|
}
|
||||||
disabled={switchingProject}
|
disabled={switchingProject}
|
||||||
className="admin-form-select"
|
className="admin-form-select text-md"
|
||||||
style={{ fontSize: "0.875rem" }}
|
|
||||||
>
|
>
|
||||||
<option value="">— Bez projektu —</option>
|
<option value="">— Bez projektu —</option>
|
||||||
{projects.map((p) => (
|
{projects.map((p) => (
|
||||||
@@ -654,8 +645,7 @@ export default function Attendance() {
|
|||||||
<button
|
<button
|
||||||
onClick={handleBreak}
|
onClick={handleBreak}
|
||||||
disabled={submitting}
|
disabled={submitting}
|
||||||
className="admin-btn admin-btn-secondary"
|
className="admin-btn admin-btn-secondary w-full"
|
||||||
style={{ width: "100%" }}
|
|
||||||
>
|
>
|
||||||
Pauza (30 min)
|
Pauza (30 min)
|
||||||
</button>
|
</button>
|
||||||
@@ -663,15 +653,13 @@ export default function Attendance() {
|
|||||||
<button
|
<button
|
||||||
onClick={() => handlePunch("departure")}
|
onClick={() => handlePunch("departure")}
|
||||||
disabled={submitting}
|
disabled={submitting}
|
||||||
className="admin-btn admin-btn-primary"
|
className="admin-btn admin-btn-primary w-full"
|
||||||
style={{ width: "100%" }}
|
|
||||||
>
|
>
|
||||||
{submitting ? "Zpracovávám..." : "Odchod"}
|
{submitting ? "Zpracovávám..." : "Odchod"}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowLeaveModal(true)}
|
onClick={() => setShowLeaveModal(true)}
|
||||||
className="admin-btn admin-btn-secondary"
|
className="admin-btn admin-btn-secondary w-full"
|
||||||
style={{ width: "100%" }}
|
|
||||||
>
|
>
|
||||||
Žádost o nepřítomnost
|
Žádost o nepřítomnost
|
||||||
</button>
|
</button>
|
||||||
@@ -703,16 +691,14 @@ export default function Attendance() {
|
|||||||
<button
|
<button
|
||||||
onClick={() => handlePunch("arrival")}
|
onClick={() => handlePunch("arrival")}
|
||||||
disabled={submitting}
|
disabled={submitting}
|
||||||
className="admin-btn admin-btn-primary"
|
className="admin-btn admin-btn-primary w-full"
|
||||||
style={{ width: "100%" }}
|
|
||||||
>
|
>
|
||||||
{submitting ? "Zpracovávám..." : "Příchod"}
|
{submitting ? "Zpracovávám..." : "Příchod"}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowLeaveModal(true)}
|
onClick={() => setShowLeaveModal(true)}
|
||||||
className="admin-btn admin-btn-secondary"
|
className="admin-btn admin-btn-secondary w-full"
|
||||||
style={{ width: "100%" }}
|
|
||||||
>
|
>
|
||||||
Žádost o nepřítomnost
|
Žádost o nepřítomnost
|
||||||
</button>
|
</button>
|
||||||
@@ -877,11 +863,10 @@ export default function Attendance() {
|
|||||||
</div>
|
</div>
|
||||||
<div style={{ marginTop: "0.75rem" }}>
|
<div style={{ marginTop: "0.75rem" }}>
|
||||||
<div
|
<div
|
||||||
className="text-secondary"
|
className="text-secondary text-sm"
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
fontSize: "0.8125rem",
|
|
||||||
marginBottom: "0.5rem",
|
marginBottom: "0.5rem",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -905,8 +890,8 @@ export default function Attendance() {
|
|||||||
</div>
|
</div>
|
||||||
{data.monthly_fund.leave_hours > 0 && (
|
{data.monthly_fund.leave_hours > 0 && (
|
||||||
<div
|
<div
|
||||||
className="text-muted"
|
className="text-muted text-xs"
|
||||||
style={{ fontSize: "0.75rem", marginTop: "0.375rem" }}
|
style={{ marginTop: "0.375rem" }}
|
||||||
>
|
>
|
||||||
{"Pokryto: "}
|
{"Pokryto: "}
|
||||||
{data.monthly_fund.covered}h (práce{" "}
|
{data.monthly_fund.covered}h (práce{" "}
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ export default function AttendanceHistory() {
|
|||||||
const alert = useAlert();
|
const alert = useAlert();
|
||||||
const { user, hasPermission } = useAuth();
|
const { user, hasPermission } = useAuth();
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [companyName, setCompanyName] = useState("");
|
||||||
const printRef = useRef<HTMLDivElement>(null);
|
const printRef = useRef<HTMLDivElement>(null);
|
||||||
const [month, setMonth] = useState(() => {
|
const [month, setMonth] = useState(() => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
@@ -156,6 +157,15 @@ export default function AttendanceHistory() {
|
|||||||
fetchData();
|
fetchData();
|
||||||
}, [fetchData]);
|
}, [fetchData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
apiFetch(`${API_BASE}/company-settings`)
|
||||||
|
.then((r) => r.json())
|
||||||
|
.then((d) => {
|
||||||
|
if (d.success) setCompanyName(d.data.company_name || "");
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
const computed = useMemo(() => {
|
const computed = useMemo(() => {
|
||||||
const [yearStr, monthStr] = month.split("-");
|
const [yearStr, monthStr] = month.split("-");
|
||||||
const monthIndex = parseInt(monthStr, 10) - 1;
|
const monthIndex = parseInt(monthStr, 10) - 1;
|
||||||
@@ -637,13 +647,13 @@ export default function AttendanceHistory() {
|
|||||||
<div className="print-header">
|
<div className="print-header">
|
||||||
<div className="print-header-left">
|
<div className="print-header-left">
|
||||||
<img
|
<img
|
||||||
src="/images/logo-light.png"
|
src="/api/admin/company-settings/logo?variant=light"
|
||||||
alt="BOHA"
|
alt=""
|
||||||
className="print-logo"
|
className="print-logo"
|
||||||
/>
|
/>
|
||||||
<div className="print-header-text">
|
<div className="print-header-text">
|
||||||
<h1>EVIDENCE DOCHÁZKY</h1>
|
<h1>EVIDENCE DOCHÁZKY</h1>
|
||||||
<div className="company">BOHA Automation s.r.o.</div>
|
<div className="company">{companyName}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="print-header-right">
|
<div className="print-header-right">
|
||||||
|
|||||||
@@ -5,12 +5,13 @@ import Forbidden from "../components/Forbidden";
|
|||||||
import { useNavigate, useParams, Link } from "react-router-dom";
|
import { useNavigate, useParams, Link } from "react-router-dom";
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
|
|
||||||
|
import L from "leaflet";
|
||||||
|
import "leaflet/dist/leaflet.css";
|
||||||
|
|
||||||
import { formatDate, formatTime } from "../utils/attendanceHelpers";
|
import { formatDate, formatTime } from "../utils/attendanceHelpers";
|
||||||
import apiFetch from "../utils/api";
|
import apiFetch from "../utils/api";
|
||||||
const API_BASE = "/api/admin";
|
const API_BASE = "/api/admin";
|
||||||
|
|
||||||
declare const L: any;
|
|
||||||
|
|
||||||
interface LocationRecord {
|
interface LocationRecord {
|
||||||
user_name: string;
|
user_name: string;
|
||||||
shift_date: string;
|
shift_date: string;
|
||||||
@@ -74,23 +75,6 @@ export default function AttendanceLocation() {
|
|||||||
|
|
||||||
if (!hasAnyLocation || !mapRef.current) return;
|
if (!hasAnyLocation || !mapRef.current) return;
|
||||||
|
|
||||||
const loadLeaflet = async () => {
|
|
||||||
if ((window as unknown as Record<string, unknown>).L) {
|
|
||||||
initMap();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const link = document.createElement("link");
|
|
||||||
link.rel = "stylesheet";
|
|
||||||
link.href = "https://unpkg.com/leaflet@1.9.4/dist/leaflet.css";
|
|
||||||
document.head.appendChild(link);
|
|
||||||
|
|
||||||
const script = document.createElement("script");
|
|
||||||
script.src = "https://unpkg.com/leaflet@1.9.4/dist/leaflet.js";
|
|
||||||
script.onload = initMap;
|
|
||||||
document.body.appendChild(script);
|
|
||||||
};
|
|
||||||
|
|
||||||
const initMap = () => {
|
const initMap = () => {
|
||||||
if (mapInstanceRef.current) {
|
if (mapInstanceRef.current) {
|
||||||
(mapInstanceRef.current as { remove: () => void }).remove();
|
(mapInstanceRef.current as { remove: () => void }).remove();
|
||||||
@@ -175,7 +159,7 @@ export default function AttendanceLocation() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
loadLeaflet();
|
initMap();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (mapInstanceRef.current) {
|
if (mapInstanceRef.current) {
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ const FIELD_LABELS: Record<string, string> = {
|
|||||||
vat_id: "DIČ",
|
vat_id: "DIČ",
|
||||||
};
|
};
|
||||||
|
|
||||||
const currentYear = new Date().getFullYear().toString().slice(-2);
|
|
||||||
|
|
||||||
interface CustomField {
|
interface CustomField {
|
||||||
name: string;
|
name: string;
|
||||||
value: string;
|
value: string;
|
||||||
@@ -41,11 +39,6 @@ interface CompanyForm {
|
|||||||
country: string;
|
country: string;
|
||||||
company_id: string;
|
company_id: string;
|
||||||
vat_id: string;
|
vat_id: string;
|
||||||
quotation_prefix: string;
|
|
||||||
default_currency: string;
|
|
||||||
default_vat_rate: number;
|
|
||||||
order_type_code: string;
|
|
||||||
invoice_type_code: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BankAccount {
|
interface BankAccount {
|
||||||
@@ -69,14 +62,19 @@ interface BankForm {
|
|||||||
is_default: boolean;
|
is_default: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CompanySettings() {
|
export default function CompanySettings({
|
||||||
|
embedded,
|
||||||
|
}: { embedded?: boolean } = {}) {
|
||||||
const alert = useAlert();
|
const alert = useAlert();
|
||||||
const { hasPermission } = useAuth();
|
const { hasPermission } = useAuth();
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [uploadingLogo, setUploadingLogo] = useState(false);
|
const [uploadingLogo, setUploadingLogo] = useState(false);
|
||||||
|
const [uploadingLogoDark, setUploadingLogoDark] = useState(false);
|
||||||
const [logoUrl, setLogoUrl] = useState<string | null>(null);
|
const [logoUrl, setLogoUrl] = useState<string | null>(null);
|
||||||
|
const [logoUrlDark, setLogoUrlDark] = useState<string | null>(null);
|
||||||
const logoUrlRef = useRef<string | null>(null);
|
const logoUrlRef = useRef<string | null>(null);
|
||||||
|
const logoUrlDarkRef = useRef<string | null>(null);
|
||||||
const [form, setForm] = useState<CompanyForm>({
|
const [form, setForm] = useState<CompanyForm>({
|
||||||
company_name: "",
|
company_name: "",
|
||||||
street: "",
|
street: "",
|
||||||
@@ -85,11 +83,6 @@ export default function CompanySettings() {
|
|||||||
country: "",
|
country: "",
|
||||||
company_id: "",
|
company_id: "",
|
||||||
vat_id: "",
|
vat_id: "",
|
||||||
quotation_prefix: "N",
|
|
||||||
default_currency: "EUR",
|
|
||||||
default_vat_rate: 21,
|
|
||||||
order_type_code: "71",
|
|
||||||
invoice_type_code: "81",
|
|
||||||
});
|
});
|
||||||
const [customFields, setCustomFields] = useState<CustomField[]>([]);
|
const [customFields, setCustomFields] = useState<CustomField[]>([]);
|
||||||
const customFieldKeyCounter = useRef(0);
|
const customFieldKeyCounter = useRef(0);
|
||||||
@@ -97,6 +90,12 @@ export default function CompanySettings() {
|
|||||||
...DEFAULT_FIELD_ORDER,
|
...DEFAULT_FIELD_ORDER,
|
||||||
]);
|
]);
|
||||||
const [bankAccounts, setBankAccounts] = useState<BankAccount[]>([]);
|
const [bankAccounts, setBankAccounts] = useState<BankAccount[]>([]);
|
||||||
|
const [availableCurrencies, setAvailableCurrencies] = useState<string[]>([
|
||||||
|
"CZK",
|
||||||
|
"EUR",
|
||||||
|
"USD",
|
||||||
|
"GBP",
|
||||||
|
]);
|
||||||
const [bankLoading, setBankLoading] = useState(true);
|
const [bankLoading, setBankLoading] = useState(true);
|
||||||
const [bankSaving, setBankSaving] = useState(false);
|
const [bankSaving, setBankSaving] = useState(false);
|
||||||
const [editingBank, setEditingBank] = useState<number | null>(null);
|
const [editingBank, setEditingBank] = useState<number | null>(null);
|
||||||
@@ -151,17 +150,28 @@ export default function CompanySettings() {
|
|||||||
return key;
|
return key;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchLogo = useCallback(async () => {
|
const fetchLogo = useCallback(async (variant: "light" | "dark" = "light") => {
|
||||||
try {
|
try {
|
||||||
const resp = await apiFetch(`${API_BASE}/company-settings/logo`);
|
const resp = await apiFetch(
|
||||||
|
`${API_BASE}/company-settings/logo?variant=${variant}`,
|
||||||
|
);
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
const blob = await resp.blob();
|
const blob = await resp.blob();
|
||||||
setLogoUrl((prev) => {
|
if (variant === "dark") {
|
||||||
if (prev) URL.revokeObjectURL(prev);
|
setLogoUrlDark((prev) => {
|
||||||
const url = URL.createObjectURL(blob);
|
if (prev) URL.revokeObjectURL(prev);
|
||||||
logoUrlRef.current = url;
|
const url = URL.createObjectURL(blob);
|
||||||
return url;
|
logoUrlDarkRef.current = url;
|
||||||
});
|
return url;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setLogoUrl((prev) => {
|
||||||
|
if (prev) URL.revokeObjectURL(prev);
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
logoUrlRef.current = url;
|
||||||
|
return url;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// ignore - no logo
|
// ignore - no logo
|
||||||
@@ -183,11 +193,6 @@ export default function CompanySettings() {
|
|||||||
country: d.country || "",
|
country: d.country || "",
|
||||||
company_id: d.company_id || "",
|
company_id: d.company_id || "",
|
||||||
vat_id: d.vat_id || "",
|
vat_id: d.vat_id || "",
|
||||||
quotation_prefix: d.quotation_prefix || "N",
|
|
||||||
default_currency: d.default_currency || "EUR",
|
|
||||||
default_vat_rate: d.default_vat_rate || 21,
|
|
||||||
order_type_code: d.order_type_code || "71",
|
|
||||||
invoice_type_code: d.invoice_type_code || "81",
|
|
||||||
});
|
});
|
||||||
const cf =
|
const cf =
|
||||||
Array.isArray(d.custom_fields) && d.custom_fields.length > 0
|
Array.isArray(d.custom_fields) && d.custom_fields.length > 0
|
||||||
@@ -207,8 +212,17 @@ export default function CompanySettings() {
|
|||||||
} else {
|
} else {
|
||||||
setFieldOrder([...DEFAULT_FIELD_ORDER]);
|
setFieldOrder([...DEFAULT_FIELD_ORDER]);
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
Array.isArray(d.available_currencies) &&
|
||||||
|
d.available_currencies.length > 0
|
||||||
|
) {
|
||||||
|
setAvailableCurrencies(d.available_currencies);
|
||||||
|
}
|
||||||
if (d.has_logo) {
|
if (d.has_logo) {
|
||||||
fetchLogo();
|
fetchLogo("light");
|
||||||
|
}
|
||||||
|
if (d.has_logo_dark) {
|
||||||
|
fetchLogo("dark");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert.error(result.error || "Nepodařilo se načíst nastavení");
|
alert.error(result.error || "Nepodařilo se načíst nastavení");
|
||||||
@@ -316,10 +330,11 @@ export default function CompanySettings() {
|
|||||||
fetchBankAccounts();
|
fetchBankAccounts();
|
||||||
}, [fetchData, fetchBankAccounts]);
|
}, [fetchData, fetchBankAccounts]);
|
||||||
|
|
||||||
// Cleanup blob URL on unmount
|
// Cleanup blob URLs on unmount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
if (logoUrlRef.current) URL.revokeObjectURL(logoUrlRef.current);
|
if (logoUrlRef.current) URL.revokeObjectURL(logoUrlRef.current);
|
||||||
|
if (logoUrlDarkRef.current) URL.revokeObjectURL(logoUrlDarkRef.current);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -351,30 +366,38 @@ export default function CompanySettings() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLogoUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleLogoUpload = async (
|
||||||
|
e: React.ChangeEvent<HTMLInputElement>,
|
||||||
|
variant: "light" | "dark" = "light",
|
||||||
|
) => {
|
||||||
const file = e.target.files?.[0];
|
const file = e.target.files?.[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
setUploadingLogo(true);
|
const setUploading =
|
||||||
|
variant === "dark" ? setUploadingLogoDark : setUploadingLogo;
|
||||||
|
setUploading(true);
|
||||||
try {
|
try {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("logo", file);
|
formData.append("logo", file);
|
||||||
|
|
||||||
const response = await apiFetch(`${API_BASE}/company-settings/logo`, {
|
const response = await apiFetch(
|
||||||
method: "POST",
|
`${API_BASE}/company-settings/logo?variant=${variant}`,
|
||||||
body: formData,
|
{
|
||||||
});
|
method: "POST",
|
||||||
|
body: formData,
|
||||||
|
},
|
||||||
|
);
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
alert.success(result.message || "Logo bylo nahráno");
|
alert.success(result.message || "Logo bylo nahráno");
|
||||||
fetchLogo();
|
fetchLogo(variant);
|
||||||
} else {
|
} else {
|
||||||
alert.error(result.error || "Nepodařilo se nahrát logo");
|
alert.error(result.error || "Nepodařilo se nahrát logo");
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
alert.error("Chyba připojení");
|
alert.error("Chyba připojení");
|
||||||
} finally {
|
} finally {
|
||||||
setUploadingLogo(false);
|
setUploading(false);
|
||||||
e.target.value = "";
|
e.target.value = "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -383,7 +406,7 @@ export default function CompanySettings() {
|
|||||||
setForm((prev) => ({ ...prev, [field]: value }));
|
setForm((prev) => ({ ...prev, [field]: value }));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!hasPermission("offers.settings")) return <Forbidden />;
|
if (!embedded && !hasPermission("settings.manage")) return <Forbidden />;
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
@@ -464,35 +487,35 @@ export default function CompanySettings() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<motion.div
|
{!embedded && (
|
||||||
className="admin-page-header"
|
<motion.div
|
||||||
initial={{ opacity: 0, y: 12 }}
|
className="admin-page-header"
|
||||||
animate={{ opacity: 1, y: 0 }}
|
initial={{ opacity: 0, y: 12 }}
|
||||||
transition={{ duration: 0.25 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
>
|
transition={{ duration: 0.25 }}
|
||||||
<div>
|
|
||||||
<h1 className="admin-page-title">Nastavení firmy</h1>
|
|
||||||
<p className="admin-page-subtitle">
|
|
||||||
Firemní údaje, číslování dokladů a výchozí hodnoty
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
onClick={handleSave}
|
|
||||||
className="admin-btn admin-btn-primary"
|
|
||||||
disabled={saving}
|
|
||||||
>
|
>
|
||||||
{saving ? (
|
<div>
|
||||||
<>
|
<h1 className="admin-page-title">Nastavení firmy</h1>
|
||||||
<div className="admin-spinner admin-spinner-sm" />
|
<p className="admin-page-subtitle">Firemní údaje a bankovní účty</p>
|
||||||
Ukládání...
|
</div>
|
||||||
</>
|
<button
|
||||||
) : (
|
onClick={handleSave}
|
||||||
"Uložit nastavení"
|
className="admin-btn admin-btn-primary"
|
||||||
)}
|
disabled={saving}
|
||||||
</button>
|
>
|
||||||
</motion.div>
|
{saving ? (
|
||||||
|
<>
|
||||||
|
<div className="admin-spinner admin-spinner-sm" />
|
||||||
|
Ukládání...
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
"Uložit nastavení"
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</motion.div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="offers-settings-grid">
|
<div className="admin-settings-grid">
|
||||||
{/* Company Info */}
|
{/* Company Info */}
|
||||||
<motion.div
|
<motion.div
|
||||||
className="admin-card"
|
className="admin-card"
|
||||||
@@ -898,10 +921,11 @@ export default function CompanySettings() {
|
|||||||
}
|
}
|
||||||
className="admin-form-select"
|
className="admin-form-select"
|
||||||
>
|
>
|
||||||
<option value="CZK">CZK</option>
|
{availableCurrencies.map((c) => (
|
||||||
<option value="EUR">EUR</option>
|
<option key={c} value={c}>
|
||||||
<option value="USD">USD</option>
|
{c}
|
||||||
<option value="GBP">GBP</option>
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
</FormField>
|
</FormField>
|
||||||
</div>
|
</div>
|
||||||
@@ -1055,177 +1079,135 @@ export default function CompanySettings() {
|
|||||||
<h3 className="admin-card-title">Logo</h3>
|
<h3 className="admin-card-title">Logo</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="admin-card-body">
|
<div className="admin-card-body">
|
||||||
<div className="offers-logo-section">
|
<div className="admin-form-row">
|
||||||
{logoUrl && (
|
<div className="admin-logo-section">
|
||||||
<div className="offers-logo-preview">
|
<label
|
||||||
<img src={logoUrl} alt="Logo" />
|
className="admin-form-label"
|
||||||
</div>
|
style={{ display: "block", marginBottom: 4 }}
|
||||||
)}
|
>
|
||||||
<label
|
Logo (světlý režim)
|
||||||
className="admin-btn admin-btn-secondary"
|
</label>
|
||||||
style={{ cursor: "pointer" }}
|
{logoUrl && (
|
||||||
>
|
<div className="admin-logo-preview">
|
||||||
{uploadingLogo ? (
|
<img src={logoUrl} alt="Logo (světlý režim)" />
|
||||||
<>
|
</div>
|
||||||
<div className="admin-spinner admin-spinner-sm" />
|
|
||||||
Nahrávání...
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<svg
|
|
||||||
width="16"
|
|
||||||
height="16"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeWidth="2"
|
|
||||||
>
|
|
||||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
|
||||||
<polyline points="17 8 12 3 7 8" />
|
|
||||||
<line x1="12" y1="3" x2="12" y2="15" />
|
|
||||||
</svg>
|
|
||||||
Nahrát logo
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
<input
|
<label
|
||||||
type="file"
|
className="admin-btn admin-btn-secondary"
|
||||||
accept="image/*"
|
style={{ cursor: "pointer" }}
|
||||||
onChange={handleLogoUpload}
|
>
|
||||||
style={{ display: "none" }}
|
{uploadingLogo ? (
|
||||||
disabled={uploadingLogo}
|
<>
|
||||||
/>
|
<div className="admin-spinner admin-spinner-sm" />
|
||||||
</label>
|
Nahrávání...
|
||||||
<small className="admin-form-hint">
|
</>
|
||||||
PNG, JPEG, GIF nebo WebP, max 5 MB
|
) : (
|
||||||
</small>
|
<>
|
||||||
</div>
|
<svg
|
||||||
</div>
|
width="16"
|
||||||
</motion.div>
|
height="16"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
{/* Cislovani dokladu */}
|
fill="none"
|
||||||
<motion.div
|
stroke="currentColor"
|
||||||
className="admin-card"
|
strokeWidth="2"
|
||||||
initial={{ opacity: 0, y: 12 }}
|
>
|
||||||
animate={{ opacity: 1, y: 0 }}
|
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
||||||
transition={{ duration: 0.25, delay: 0.15 }}
|
<polyline points="17 8 12 3 7 8" />
|
||||||
>
|
<line x1="12" y1="3" x2="12" y2="15" />
|
||||||
<div className="admin-card-header">
|
</svg>
|
||||||
<h3 className="admin-card-title">Číslování dokladů</h3>
|
Nahrát logo
|
||||||
</div>
|
</>
|
||||||
<div className="admin-card-body">
|
)}
|
||||||
<div className="admin-form">
|
|
||||||
<FormField label="Nabídky — prefix">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={form.quotation_prefix}
|
|
||||||
onChange={(e) =>
|
|
||||||
updateField("quotation_prefix", e.target.value)
|
|
||||||
}
|
|
||||||
className="admin-form-input"
|
|
||||||
placeholder="N"
|
|
||||||
style={{ maxWidth: 120 }}
|
|
||||||
/>
|
|
||||||
<small className="admin-form-hint">
|
|
||||||
Formát: ROK/PREFIX/ČÍSLO — ukázka: {new Date().getFullYear()}/
|
|
||||||
{form.quotation_prefix || "N"}/001
|
|
||||||
</small>
|
|
||||||
</FormField>
|
|
||||||
<hr
|
|
||||||
style={{
|
|
||||||
border: "none",
|
|
||||||
borderTop: "1px solid var(--border-color)",
|
|
||||||
margin: "0.75rem 0",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<FormField label="Objednávky a projekty — typový kód">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={form.order_type_code}
|
|
||||||
onChange={(e) =>
|
|
||||||
updateField("order_type_code", e.target.value)
|
|
||||||
}
|
|
||||||
className="admin-form-input"
|
|
||||||
placeholder="71"
|
|
||||||
style={{ maxWidth: 120 }}
|
|
||||||
/>
|
|
||||||
<small className="admin-form-hint">
|
|
||||||
Formát: RRKÓD#### — ukázka: {currentYear}
|
|
||||||
{form.order_type_code || "71"}0001
|
|
||||||
</small>
|
|
||||||
</FormField>
|
|
||||||
<hr
|
|
||||||
style={{
|
|
||||||
border: "none",
|
|
||||||
borderTop: "1px solid var(--border-color)",
|
|
||||||
margin: "0.75rem 0",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<FormField label="Faktury — typový kód">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={form.invoice_type_code}
|
|
||||||
onChange={(e) =>
|
|
||||||
updateField("invoice_type_code", e.target.value)
|
|
||||||
}
|
|
||||||
className="admin-form-input"
|
|
||||||
placeholder="81"
|
|
||||||
style={{ maxWidth: 120 }}
|
|
||||||
/>
|
|
||||||
<small className="admin-form-hint">
|
|
||||||
Formát: RRKÓD#### — ukázka: {currentYear}
|
|
||||||
{form.invoice_type_code || "81"}0001
|
|
||||||
</small>
|
|
||||||
</FormField>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</motion.div>
|
|
||||||
|
|
||||||
{/* Default values */}
|
|
||||||
<motion.div
|
|
||||||
className="admin-card"
|
|
||||||
initial={{ opacity: 0, y: 12 }}
|
|
||||||
animate={{ opacity: 1, y: 0 }}
|
|
||||||
transition={{ duration: 0.25, delay: 0.15 }}
|
|
||||||
>
|
|
||||||
<div className="admin-card-header">
|
|
||||||
<h3 className="admin-card-title">Výchozí hodnoty</h3>
|
|
||||||
</div>
|
|
||||||
<div className="admin-card-body">
|
|
||||||
<div className="admin-form">
|
|
||||||
<div className="admin-form-row">
|
|
||||||
<FormField label="Výchozí měna">
|
|
||||||
<select
|
|
||||||
value={form.default_currency}
|
|
||||||
onChange={(e) =>
|
|
||||||
updateField("default_currency", e.target.value)
|
|
||||||
}
|
|
||||||
className="admin-form-select"
|
|
||||||
>
|
|
||||||
<option value="EUR">EUR</option>
|
|
||||||
<option value="USD">USD</option>
|
|
||||||
<option value="CZK">CZK</option>
|
|
||||||
<option value="GBP">GBP</option>
|
|
||||||
</select>
|
|
||||||
</FormField>
|
|
||||||
<FormField label="Výchozí sazba DPH (%)">
|
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="file"
|
||||||
value={form.default_vat_rate}
|
accept="image/*"
|
||||||
onChange={(e) =>
|
onChange={(e) => handleLogoUpload(e, "light")}
|
||||||
updateField(
|
style={{ display: "none" }}
|
||||||
"default_vat_rate",
|
disabled={uploadingLogo}
|
||||||
parseFloat(e.target.value) || 0,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
className="admin-form-input"
|
|
||||||
step="0.1"
|
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</label>
|
||||||
|
<small className="admin-form-hint">
|
||||||
|
PNG, JPEG, GIF nebo WebP, max 5 MB
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
<div className="admin-logo-section">
|
||||||
|
<label
|
||||||
|
className="admin-form-label"
|
||||||
|
style={{ display: "block", marginBottom: 4 }}
|
||||||
|
>
|
||||||
|
Logo (tmavý režim)
|
||||||
|
</label>
|
||||||
|
{logoUrlDark && (
|
||||||
|
<div className="admin-logo-preview">
|
||||||
|
<img src={logoUrlDark} alt="Logo (tmavý režim)" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<label
|
||||||
|
className="admin-btn admin-btn-secondary"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
{uploadingLogoDark ? (
|
||||||
|
<>
|
||||||
|
<div className="admin-spinner admin-spinner-sm" />
|
||||||
|
Nahrávání...
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<svg
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
>
|
||||||
|
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
||||||
|
<polyline points="17 8 12 3 7 8" />
|
||||||
|
<line x1="12" y1="3" x2="12" y2="15" />
|
||||||
|
</svg>
|
||||||
|
Nahrát logo
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
accept="image/*"
|
||||||
|
onChange={(e) => handleLogoUpload(e, "dark")}
|
||||||
|
style={{ display: "none" }}
|
||||||
|
disabled={uploadingLogoDark}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<small className="admin-form-hint">
|
||||||
|
PNG, JPEG, GIF nebo WebP, max 5 MB
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{embedded && (
|
||||||
|
<motion.div
|
||||||
|
initial={{ opacity: 0, y: 12 }}
|
||||||
|
animate={{ opacity: 1, y: 0 }}
|
||||||
|
transition={{ duration: 0.25, delay: 0.2 }}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
onClick={handleSave}
|
||||||
|
className="admin-btn admin-btn-primary"
|
||||||
|
style={{ width: "100%", marginTop: "1rem" }}
|
||||||
|
disabled={saving}
|
||||||
|
>
|
||||||
|
{saving ? (
|
||||||
|
<>
|
||||||
|
<div className="admin-spinner admin-spinner-sm" />
|
||||||
|
Ukládání...
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
"Uložit nastavení firmy"
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</motion.div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ export default function Dashboard() {
|
|||||||
{/* Skeleton loading */}
|
{/* Skeleton loading */}
|
||||||
{dashLoading && (
|
{dashLoading && (
|
||||||
<div className="admin-skeleton" style={{ padding: 0, gap: "1.25rem" }}>
|
<div className="admin-skeleton" style={{ padding: 0, gap: "1.25rem" }}>
|
||||||
<div className="dash-kpi-grid dash-kpi-4">
|
<div className="admin-kpi-grid admin-kpi-4">
|
||||||
{[0, 1, 2, 3].map((i) => (
|
{[0, 1, 2, 3].map((i) => (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={i}
|
||||||
|
|||||||
@@ -56,12 +56,6 @@ const TRANSITION_CLASSES: Record<string, string> = {
|
|||||||
paid: "admin-btn admin-btn-primary",
|
paid: "admin-btn admin-btn-primary",
|
||||||
};
|
};
|
||||||
|
|
||||||
const VAT_OPTIONS = [
|
|
||||||
{ value: 21, label: "21%" },
|
|
||||||
{ value: 12, label: "12%" },
|
|
||||||
{ value: 0, label: "0%" },
|
|
||||||
];
|
|
||||||
|
|
||||||
interface InvoiceItem {
|
interface InvoiceItem {
|
||||||
id?: number;
|
id?: number;
|
||||||
_key: string;
|
_key: string;
|
||||||
@@ -145,6 +139,7 @@ function SortableInvoiceRow({
|
|||||||
index,
|
index,
|
||||||
currency,
|
currency,
|
||||||
apply_vat,
|
apply_vat,
|
||||||
|
vatOptions,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
onRemove,
|
onRemove,
|
||||||
canDelete,
|
canDelete,
|
||||||
@@ -153,6 +148,7 @@ function SortableInvoiceRow({
|
|||||||
index: number;
|
index: number;
|
||||||
currency: string;
|
currency: string;
|
||||||
apply_vat: boolean;
|
apply_vat: boolean;
|
||||||
|
vatOptions: { value: number; label: string }[];
|
||||||
onUpdate: (
|
onUpdate: (
|
||||||
index: number,
|
index: number,
|
||||||
field: keyof InvoiceItem,
|
field: keyof InvoiceItem,
|
||||||
@@ -266,7 +262,7 @@ function SortableInvoiceRow({
|
|||||||
minWidth: "4.5rem",
|
minWidth: "4.5rem",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{VAT_OPTIONS.map((o) => (
|
{vatOptions.map((o) => (
|
||||||
<option key={o.value} value={o.value}>
|
<option key={o.value} value={o.value}>
|
||||||
{o.label}
|
{o.label}
|
||||||
</option>
|
</option>
|
||||||
@@ -274,7 +270,7 @@ function SortableInvoiceRow({
|
|||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
) : null}
|
) : null}
|
||||||
<td style={{ textAlign: "right", fontWeight: 600, whiteSpace: "nowrap" }}>
|
<td className="text-right fw-600 whitespace-nowrap">
|
||||||
{formatCurrency(lineTotal, currency)}
|
{formatCurrency(lineTotal, currency)}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -309,6 +305,7 @@ function SortableInvoiceEditRow({
|
|||||||
item,
|
item,
|
||||||
index,
|
index,
|
||||||
apply_vat,
|
apply_vat,
|
||||||
|
vatOptions,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
onRemove,
|
onRemove,
|
||||||
canDelete,
|
canDelete,
|
||||||
@@ -316,6 +313,7 @@ function SortableInvoiceEditRow({
|
|||||||
item: InvoiceItem;
|
item: InvoiceItem;
|
||||||
index: number;
|
index: number;
|
||||||
apply_vat: boolean;
|
apply_vat: boolean;
|
||||||
|
vatOptions: { value: number; label: string }[];
|
||||||
onUpdate: (index: number, field: string, value: string | number) => void;
|
onUpdate: (index: number, field: string, value: string | number) => void;
|
||||||
onRemove: (index: number) => void;
|
onRemove: (index: number) => void;
|
||||||
canDelete: boolean;
|
canDelete: boolean;
|
||||||
@@ -356,12 +354,7 @@ function SortableInvoiceEditRow({
|
|||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td className="text-tertiary text-center fw-500">{index + 1}</td>
|
||||||
className="text-tertiary"
|
|
||||||
style={{ textAlign: "center", fontWeight: 500 }}
|
|
||||||
>
|
|
||||||
{index + 1}
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@@ -427,7 +420,7 @@ function SortableInvoiceEditRow({
|
|||||||
minWidth: "4.5rem",
|
minWidth: "4.5rem",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{VAT_OPTIONS.map((o) => (
|
{vatOptions.map((o) => (
|
||||||
<option key={o.value} value={o.value}>
|
<option key={o.value} value={o.value}>
|
||||||
{o.label}
|
{o.label}
|
||||||
</option>
|
</option>
|
||||||
@@ -543,6 +536,45 @@ export default function InvoiceDetail() {
|
|||||||
const [customerSearch, setCustomerSearch] = useState("");
|
const [customerSearch, setCustomerSearch] = useState("");
|
||||||
const [showCustomerDropdown, setShowCustomerDropdown] = useState(false);
|
const [showCustomerDropdown, setShowCustomerDropdown] = useState(false);
|
||||||
|
|
||||||
|
const [companySettings, setCompanySettings] = useState<{
|
||||||
|
default_currency: string;
|
||||||
|
default_vat_rate: number;
|
||||||
|
available_currencies: string[];
|
||||||
|
available_vat_rates: number[];
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
apiFetch(`${API_BASE}/company-settings`)
|
||||||
|
.then((r) => r.json())
|
||||||
|
.then((d) => {
|
||||||
|
if (d.success) setCompanySettings(d.data);
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const vatOptions = (
|
||||||
|
companySettings?.available_vat_rates || [0, 10, 12, 15, 21]
|
||||||
|
).map((v) => ({
|
||||||
|
value: v,
|
||||||
|
label: `${v}%`,
|
||||||
|
}));
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (companySettings && !isEdit) {
|
||||||
|
setForm((prev) => ({
|
||||||
|
...prev,
|
||||||
|
currency:
|
||||||
|
prev.currency === "CZK"
|
||||||
|
? companySettings.default_currency || "CZK"
|
||||||
|
: prev.currency,
|
||||||
|
vat_rate:
|
||||||
|
prev.vat_rate === 21
|
||||||
|
? (companySettings.default_vat_rate ?? 21)
|
||||||
|
: prev.vat_rate,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, [companySettings, isEdit]);
|
||||||
|
|
||||||
const DRAFT_KEY = "boha_invoice_draft";
|
const DRAFT_KEY = "boha_invoice_draft";
|
||||||
|
|
||||||
const clearDraft = useCallback(() => {
|
const clearDraft = useCallback(() => {
|
||||||
@@ -634,13 +666,16 @@ export default function InvoiceDetail() {
|
|||||||
const orderData = await results[3].json();
|
const orderData = await results[3].json();
|
||||||
if (orderData.success) {
|
if (orderData.success) {
|
||||||
const order = orderData.data;
|
const order = orderData.data;
|
||||||
const vatRate = Number(order.vat_rate) || 21;
|
const vatRate =
|
||||||
|
Number(order.vat_rate) ||
|
||||||
|
(companySettings?.default_vat_rate ?? 21);
|
||||||
setForm((prev) => ({
|
setForm((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
customer_id: order.customer_id,
|
customer_id: order.customer_id,
|
||||||
customer_name: order.customer_name || "",
|
customer_name: order.customer_name || "",
|
||||||
order_id: order.id,
|
order_id: order.id,
|
||||||
currency: order.currency || "CZK",
|
currency:
|
||||||
|
order.currency || companySettings?.default_currency || "CZK",
|
||||||
apply_vat: Number(order.apply_vat) || 0,
|
apply_vat: Number(order.apply_vat) || 0,
|
||||||
vat_rate: vatRate,
|
vat_rate: vatRate,
|
||||||
}));
|
}));
|
||||||
@@ -935,18 +970,21 @@ export default function InvoiceDetail() {
|
|||||||
|
|
||||||
// ─── Edit mode: PDF export ───
|
// ─── Edit mode: PDF export ───
|
||||||
const handleViewPdf = async (_lang = "cs") => {
|
const handleViewPdf = async (_lang = "cs") => {
|
||||||
|
const newWindow = window.open("", "_blank");
|
||||||
setPdfLoading(true);
|
setPdfLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await apiFetch(`${API_BASE}/invoices/${id}/file`);
|
const response = await apiFetch(`${API_BASE}/invoices/${id}/file`);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
newWindow?.close();
|
||||||
alert.error("PDF soubor nenalezen — uložte fakturu pro vygenerování");
|
alert.error("PDF soubor nenalezen — uložte fakturu pro vygenerování");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
window.open(url, "_blank");
|
if (newWindow) newWindow.location.href = url;
|
||||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||||
} catch {
|
} catch {
|
||||||
|
newWindow?.close();
|
||||||
alert.error("Chyba připojení");
|
alert.error("Chyba připojení");
|
||||||
} finally {
|
} finally {
|
||||||
setPdfLoading(false);
|
setPdfLoading(false);
|
||||||
@@ -963,7 +1001,8 @@ export default function InvoiceDetail() {
|
|||||||
quantity: Number(item.quantity) || 1,
|
quantity: Number(item.quantity) || 1,
|
||||||
unit: item.unit || "",
|
unit: item.unit || "",
|
||||||
unit_price: Number(item.unit_price) || 0,
|
unit_price: Number(item.unit_price) || 0,
|
||||||
vat_rate: Number(item.vat_rate) || 21,
|
vat_rate:
|
||||||
|
Number(item.vat_rate) || (companySettings?.default_vat_rate ?? 21),
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
setEditingItems(true);
|
setEditingItems(true);
|
||||||
@@ -988,7 +1027,7 @@ export default function InvoiceDetail() {
|
|||||||
quantity: 1,
|
quantity: 1,
|
||||||
unit: "ks",
|
unit: "ks",
|
||||||
unit_price: 0,
|
unit_price: 0,
|
||||||
vat_rate: 21,
|
vat_rate: companySettings?.default_vat_rate ?? 21,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
@@ -1176,14 +1215,14 @@ export default function InvoiceDetail() {
|
|||||||
<form onSubmit={handleCreateSubmit}>
|
<form onSubmit={handleCreateSubmit}>
|
||||||
{/* Basic info */}
|
{/* Basic info */}
|
||||||
<motion.div
|
<motion.div
|
||||||
className="offers-editor-section"
|
className="admin-editor-section"
|
||||||
initial={{ opacity: 0, y: 12 }}
|
initial={{ opacity: 0, y: 12 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 0.25, delay: 0.06 }}
|
transition={{ duration: 0.25, delay: 0.06 }}
|
||||||
>
|
>
|
||||||
<h3 className="admin-card-title">Základní údaje</h3>
|
<h3 className="admin-card-title">Základní údaje</h3>
|
||||||
<div className="admin-form">
|
<div className="admin-form">
|
||||||
<div className="offers-form-row-3">
|
<div className="admin-form-row admin-form-row-3">
|
||||||
<FormField label="Číslo faktury">
|
<FormField label="Číslo faktury">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@@ -1198,7 +1237,7 @@ export default function InvoiceDetail() {
|
|||||||
required
|
required
|
||||||
>
|
>
|
||||||
{form.customer_id ? (
|
{form.customer_id ? (
|
||||||
<div className="offers-customer-selected">
|
<div className="admin-customer-selected">
|
||||||
<span>{form.customer_name}</span>
|
<span>{form.customer_name}</span>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -1227,7 +1266,7 @@ export default function InvoiceDetail() {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div
|
<div
|
||||||
className="offers-customer-select"
|
className="admin-customer-select"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
@@ -1243,16 +1282,16 @@ export default function InvoiceDetail() {
|
|||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
/>
|
/>
|
||||||
{showCustomerDropdown && (
|
{showCustomerDropdown && (
|
||||||
<div className="offers-customer-dropdown">
|
<div className="admin-customer-dropdown">
|
||||||
{filteredCustomers.length === 0 ? (
|
{filteredCustomers.length === 0 ? (
|
||||||
<div className="offers-customer-dropdown-empty">
|
<div className="admin-customer-dropdown-empty">
|
||||||
Žádní zákazníci
|
Žádní zákazníci
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
filteredCustomers.slice(0, 10).map((c) => (
|
filteredCustomers.slice(0, 10).map((c) => (
|
||||||
<div
|
<div
|
||||||
key={c.id}
|
key={c.id}
|
||||||
className="offers-customer-dropdown-item"
|
className="admin-customer-dropdown-item"
|
||||||
onMouseDown={() => selectCustomer(c)}
|
onMouseDown={() => selectCustomer(c)}
|
||||||
>
|
>
|
||||||
<div>{c.name}</div>
|
<div>{c.name}</div>
|
||||||
@@ -1327,10 +1366,7 @@ export default function InvoiceDetail() {
|
|||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
{form.due_date && (
|
{form.due_date && (
|
||||||
<span
|
<span className="text-tertiary text-xs mt-1">
|
||||||
className="text-tertiary"
|
|
||||||
style={{ fontSize: "0.75rem", marginTop: "0.25rem" }}
|
|
||||||
>
|
|
||||||
Splatnost:{" "}
|
Splatnost:{" "}
|
||||||
{new Date(form.due_date).toLocaleDateString("cs-CZ")}
|
{new Date(form.due_date).toLocaleDateString("cs-CZ")}
|
||||||
</span>
|
</span>
|
||||||
@@ -1348,7 +1384,7 @@ export default function InvoiceDetail() {
|
|||||||
</FormField>
|
</FormField>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="offers-form-row-3">
|
<div className="admin-form-row admin-form-row-3">
|
||||||
<FormField label="Forma úhrady">
|
<FormField label="Forma úhrady">
|
||||||
<select
|
<select
|
||||||
value={form.payment_method}
|
value={form.payment_method}
|
||||||
@@ -1373,9 +1409,18 @@ export default function InvoiceDetail() {
|
|||||||
}
|
}
|
||||||
className="admin-form-select"
|
className="admin-form-select"
|
||||||
>
|
>
|
||||||
<option value="CZK">CZK (Kč)</option>
|
{(
|
||||||
<option value="EUR">EUR</option>
|
companySettings?.available_currencies || [
|
||||||
<option value="USD">USD ($)</option>
|
"CZK",
|
||||||
|
"EUR",
|
||||||
|
"USD",
|
||||||
|
"GBP",
|
||||||
|
]
|
||||||
|
).map((c) => (
|
||||||
|
<option key={c} value={c}>
|
||||||
|
{c}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
</FormField>
|
</FormField>
|
||||||
<FormField label="Jazyk faktury">
|
<FormField label="Jazyk faktury">
|
||||||
@@ -1395,10 +1440,7 @@ export default function InvoiceDetail() {
|
|||||||
</FormField>
|
</FormField>
|
||||||
<FormField label="DPH">
|
<FormField label="DPH">
|
||||||
<div className="flex-row-gap">
|
<div className="flex-row-gap">
|
||||||
<label
|
<label className="admin-form-checkbox whitespace-nowrap">
|
||||||
className="admin-form-checkbox"
|
|
||||||
style={{ whiteSpace: "nowrap" }}
|
|
||||||
>
|
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={!!form.apply_vat}
|
checked={!!form.apply_vat}
|
||||||
@@ -1514,6 +1556,7 @@ export default function InvoiceDetail() {
|
|||||||
index={index}
|
index={index}
|
||||||
currency={form.currency}
|
currency={form.currency}
|
||||||
apply_vat={!!form.apply_vat}
|
apply_vat={!!form.apply_vat}
|
||||||
|
vatOptions={vatOptions}
|
||||||
onUpdate={updateItem}
|
onUpdate={updateItem}
|
||||||
onRemove={removeItem}
|
onRemove={removeItem}
|
||||||
canDelete={items.length > 1}
|
canDelete={items.length > 1}
|
||||||
@@ -1526,8 +1569,8 @@ export default function InvoiceDetail() {
|
|||||||
</DndContext>
|
</DndContext>
|
||||||
|
|
||||||
{/* Totals */}
|
{/* Totals */}
|
||||||
<div className="offers-totals-summary">
|
<div className="admin-totals-summary">
|
||||||
<div className="offers-totals-row">
|
<div className="admin-totals-row">
|
||||||
<span>Mezisoučet:</span>
|
<span>Mezisoučet:</span>
|
||||||
<span>
|
<span>
|
||||||
{formatCurrency(createTotals.subtotal, form.currency)}
|
{formatCurrency(createTotals.subtotal, form.currency)}
|
||||||
@@ -1536,13 +1579,13 @@ export default function InvoiceDetail() {
|
|||||||
{form.apply_vat &&
|
{form.apply_vat &&
|
||||||
Object.entries(createTotals.vatByRate).map(
|
Object.entries(createTotals.vatByRate).map(
|
||||||
([rate, amount]) => (
|
([rate, amount]) => (
|
||||||
<div key={rate} className="offers-totals-row">
|
<div key={rate} className="admin-totals-row">
|
||||||
<span>DPH {rate}%:</span>
|
<span>DPH {rate}%:</span>
|
||||||
<span>{formatCurrency(amount, form.currency)}</span>
|
<span>{formatCurrency(amount, form.currency)}</span>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
<div className="offers-totals-row offers-totals-total">
|
<div className="admin-totals-row admin-totals-total">
|
||||||
<span>Celkem k úhradě:</span>
|
<span>Celkem k úhradě:</span>
|
||||||
<span>
|
<span>
|
||||||
{formatCurrency(createTotals.total, form.currency)}
|
{formatCurrency(createTotals.total, form.currency)}
|
||||||
@@ -1554,7 +1597,7 @@ export default function InvoiceDetail() {
|
|||||||
|
|
||||||
{/* Notes */}
|
{/* Notes */}
|
||||||
<motion.div
|
<motion.div
|
||||||
className="offers-editor-section"
|
className="admin-editor-section"
|
||||||
initial={{ opacity: 0, y: 12 }}
|
initial={{ opacity: 0, y: 12 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 0.25, delay: 0.15 }}
|
transition={{ duration: 0.25, delay: 0.15 }}
|
||||||
@@ -1684,14 +1727,14 @@ export default function InvoiceDetail() {
|
|||||||
|
|
||||||
{/* Info */}
|
{/* Info */}
|
||||||
<motion.div
|
<motion.div
|
||||||
className="offers-editor-section"
|
className="admin-editor-section"
|
||||||
initial={{ opacity: 0, y: 12 }}
|
initial={{ opacity: 0, y: 12 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 0.25, delay: 0.06 }}
|
transition={{ duration: 0.25, delay: 0.06 }}
|
||||||
>
|
>
|
||||||
<h3 className="admin-card-title">Informace</h3>
|
<h3 className="admin-card-title">Informace</h3>
|
||||||
<div className="admin-form">
|
<div className="admin-form">
|
||||||
<div className="offers-form-row-3 mb-2">
|
<div className="admin-form-row admin-form-row-3 mb-2">
|
||||||
<FormField label="Zákazník">
|
<FormField label="Zákazník">
|
||||||
<div className="fw-500">{invoice.customer_name || "\u2014"}</div>
|
<div className="fw-500">{invoice.customer_name || "\u2014"}</div>
|
||||||
{invoice.customer && (
|
{invoice.customer && (
|
||||||
@@ -1724,7 +1767,7 @@ export default function InvoiceDetail() {
|
|||||||
<div>{invoice.currency}</div>
|
<div>{invoice.currency}</div>
|
||||||
</FormField>
|
</FormField>
|
||||||
</div>
|
</div>
|
||||||
<div className="offers-form-row-3 mb-2">
|
<div className="admin-form-row admin-form-row-3 mb-2">
|
||||||
<FormField label="Datum vystavení">
|
<FormField label="Datum vystavení">
|
||||||
<div>{formatDate(invoice.issue_date)}</div>
|
<div>{formatDate(invoice.issue_date)}</div>
|
||||||
</FormField>
|
</FormField>
|
||||||
@@ -1741,7 +1784,7 @@ export default function InvoiceDetail() {
|
|||||||
<div>{formatDate(invoice.tax_date)}</div>
|
<div>{formatDate(invoice.tax_date)}</div>
|
||||||
</FormField>
|
</FormField>
|
||||||
</div>
|
</div>
|
||||||
<div className="offers-form-row-3">
|
<div className="admin-form-row admin-form-row-3">
|
||||||
<FormField label="Forma úhrady">
|
<FormField label="Forma úhrady">
|
||||||
<div>{invoice.payment_method}</div>
|
<div>{invoice.payment_method}</div>
|
||||||
</FormField>
|
</FormField>
|
||||||
@@ -1755,7 +1798,7 @@ export default function InvoiceDetail() {
|
|||||||
{invoice.paid_date && (
|
{invoice.paid_date && (
|
||||||
<div className="admin-form-row mt-2">
|
<div className="admin-form-row mt-2">
|
||||||
<FormField label="Datum úhrady">
|
<FormField label="Datum úhrady">
|
||||||
<div style={{ color: "var(--success)", fontWeight: 500 }}>
|
<div className="fw-500" style={{ color: "var(--success)" }}>
|
||||||
{formatDate(invoice.paid_date)}
|
{formatDate(invoice.paid_date)}
|
||||||
</div>
|
</div>
|
||||||
</FormField>
|
</FormField>
|
||||||
@@ -1851,6 +1894,7 @@ export default function InvoiceDetail() {
|
|||||||
item={item}
|
item={item}
|
||||||
index={index}
|
index={index}
|
||||||
apply_vat={!!Number(invoice.apply_vat)}
|
apply_vat={!!Number(invoice.apply_vat)}
|
||||||
|
vatOptions={vatOptions}
|
||||||
onUpdate={updateEditItem}
|
onUpdate={updateEditItem}
|
||||||
onRemove={removeEditItem}
|
onRemove={removeEditItem}
|
||||||
canDelete={editItems.length > 1}
|
canDelete={editItems.length > 1}
|
||||||
@@ -1899,16 +1943,13 @@ export default function InvoiceDetail() {
|
|||||||
: 0;
|
: 0;
|
||||||
return (
|
return (
|
||||||
<tr key={item.id || index}>
|
<tr key={item.id || index}>
|
||||||
<td
|
<td className="text-tertiary text-center fw-500">
|
||||||
className="text-tertiary"
|
|
||||||
style={{ textAlign: "center", fontWeight: 500 }}
|
|
||||||
>
|
|
||||||
{index + 1}
|
{index + 1}
|
||||||
</td>
|
</td>
|
||||||
<td className="fw-500">
|
<td className="fw-500">
|
||||||
{item.description || "\u2014"}
|
{item.description || "\u2014"}
|
||||||
</td>
|
</td>
|
||||||
<td style={{ textAlign: "center" }}>
|
<td className="text-center">
|
||||||
{item.quantity}{" "}
|
{item.quantity}{" "}
|
||||||
{item.unit && (
|
{item.unit && (
|
||||||
<span className="text-tertiary">
|
<span className="text-tertiary">
|
||||||
@@ -1916,7 +1957,7 @@ export default function InvoiceDetail() {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td style={{ textAlign: "center" }}>
|
<td className="text-center">
|
||||||
{item.unit || "\u2014"}
|
{item.unit || "\u2014"}
|
||||||
</td>
|
</td>
|
||||||
<td className="admin-mono text-right">
|
<td className="admin-mono text-right">
|
||||||
@@ -1925,16 +1966,13 @@ export default function InvoiceDetail() {
|
|||||||
invoice.currency,
|
invoice.currency,
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td style={{ textAlign: "center" }}>
|
<td className="text-center">
|
||||||
{Number(invoice.apply_vat)
|
{Number(invoice.apply_vat)
|
||||||
? Number(item.vat_rate)
|
? Number(item.vat_rate)
|
||||||
: 0}
|
: 0}
|
||||||
%
|
%
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td className="admin-mono text-right fw-600">
|
||||||
className="admin-mono"
|
|
||||||
style={{ textAlign: "right", fontWeight: 600 }}
|
|
||||||
>
|
|
||||||
{formatCurrency(
|
{formatCurrency(
|
||||||
lineSubtotal + lineVat,
|
lineSubtotal + lineVat,
|
||||||
invoice.currency,
|
invoice.currency,
|
||||||
@@ -1952,8 +1990,8 @@ export default function InvoiceDetail() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="offers-totals-summary">
|
<div className="admin-totals-summary">
|
||||||
<div className="offers-totals-row">
|
<div className="admin-totals-row">
|
||||||
<span>Mezisoučet:</span>
|
<span>Mezisoučet:</span>
|
||||||
<span>
|
<span>
|
||||||
{formatCurrency(editTotals.subtotal, invoice.currency)}
|
{formatCurrency(editTotals.subtotal, invoice.currency)}
|
||||||
@@ -1961,12 +1999,12 @@ export default function InvoiceDetail() {
|
|||||||
</div>
|
</div>
|
||||||
{Number(invoice.apply_vat) > 0 &&
|
{Number(invoice.apply_vat) > 0 &&
|
||||||
Object.entries(editTotals.vatByRate).map(([rate, amount]) => (
|
Object.entries(editTotals.vatByRate).map(([rate, amount]) => (
|
||||||
<div key={rate} className="offers-totals-row">
|
<div key={rate} className="admin-totals-row">
|
||||||
<span>DPH {rate}%:</span>
|
<span>DPH {rate}%:</span>
|
||||||
<span>{formatCurrency(amount, invoice.currency)}</span>
|
<span>{formatCurrency(amount, invoice.currency)}</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<div className="offers-totals-row offers-totals-total">
|
<div className="admin-totals-row admin-totals-total">
|
||||||
<span>Celkem k úhradě:</span>
|
<span>Celkem k úhradě:</span>
|
||||||
<span>{formatCurrency(editTotals.total, invoice.currency)}</span>
|
<span>{formatCurrency(editTotals.total, invoice.currency)}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -1976,7 +2014,7 @@ export default function InvoiceDetail() {
|
|||||||
|
|
||||||
{/* Notes */}
|
{/* Notes */}
|
||||||
<motion.div
|
<motion.div
|
||||||
className="offers-editor-section"
|
className="admin-editor-section"
|
||||||
initial={{ opacity: 0, y: 12 }}
|
initial={{ opacity: 0, y: 12 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 0.25, delay: 0.15 }}
|
transition={{ duration: 0.25, delay: 0.15 }}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
} from "react";
|
} from "react";
|
||||||
import { useAlert } from "../context/AlertContext";
|
import { useAlert } from "../context/AlertContext";
|
||||||
import { useAuth } from "../context/AuthContext";
|
import { useAuth } from "../context/AuthContext";
|
||||||
import { Link } from "react-router-dom";
|
import { Link, useSearchParams } from "react-router-dom";
|
||||||
import { motion, AnimatePresence } from "framer-motion";
|
import { motion, AnimatePresence } from "framer-motion";
|
||||||
import ConfirmModal from "../components/ConfirmModal";
|
import ConfirmModal from "../components/ConfirmModal";
|
||||||
import Forbidden from "../components/Forbidden";
|
import Forbidden from "../components/Forbidden";
|
||||||
@@ -56,7 +56,7 @@ function formatCzkWithDetail(
|
|||||||
if (!Array.isArray(amounts) || amounts.length === 0)
|
if (!Array.isArray(amounts) || amounts.length === 0)
|
||||||
return { value: "0 Kč", detail: null };
|
return { value: "0 Kč", detail: null };
|
||||||
const hasForeign = amounts.some((a) => a.currency !== "CZK");
|
const hasForeign = amounts.some((a) => a.currency !== "CZK");
|
||||||
if (hasForeign && totalCzk !== null && totalCzk !== undefined) {
|
if (hasForeign && totalCzk != null) {
|
||||||
return {
|
return {
|
||||||
value: formatCurrency(totalCzk, "CZK"),
|
value: formatCurrency(totalCzk, "CZK"),
|
||||||
detail: formatMultiCurrency(amounts),
|
detail: formatMultiCurrency(amounts),
|
||||||
@@ -119,7 +119,11 @@ export default function Invoices() {
|
|||||||
const alert = useAlert();
|
const alert = useAlert();
|
||||||
const { hasPermission } = useAuth();
|
const { hasPermission } = useAuth();
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useState("issued");
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const activeTab =
|
||||||
|
searchParams.get("tab") === "received" ? "received" : "issued";
|
||||||
|
const setActiveTab = (tab: string) =>
|
||||||
|
setSearchParams({ tab }, { replace: true });
|
||||||
const [receivedUploadOpen, setReceivedUploadOpen] = useState(false);
|
const [receivedUploadOpen, setReceivedUploadOpen] = useState(false);
|
||||||
const { sort, order, handleSort, activeSort } =
|
const { sort, order, handleSort, activeSort } =
|
||||||
useTableSort("invoice_number");
|
useTableSort("invoice_number");
|
||||||
@@ -330,7 +334,7 @@ export default function Invoices() {
|
|||||||
style={{ width: "140px", borderRadius: "8px" }}
|
style={{ width: "140px", borderRadius: "8px" }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="dash-kpi-grid dash-kpi-4">
|
<div className="admin-kpi-grid admin-kpi-4">
|
||||||
{[0, 1, 2, 3].map((i) => (
|
{[0, 1, 2, 3].map((i) => (
|
||||||
<div key={i} className="admin-stat-card">
|
<div key={i} className="admin-stat-card">
|
||||||
<div
|
<div
|
||||||
@@ -493,15 +497,15 @@ export default function Invoices() {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="offers-tabs mb-4" style={{ justifyContent: "center" }}>
|
<div className="admin-tabs mb-4" style={{ justifyContent: "center" }}>
|
||||||
<button
|
<button
|
||||||
className={`offers-tab ${activeTab === "issued" ? "active" : ""}`}
|
className={`admin-tab ${activeTab === "issued" ? "active" : ""}`}
|
||||||
onClick={() => setActiveTab("issued")}
|
onClick={() => setActiveTab("issued")}
|
||||||
>
|
>
|
||||||
Vydané
|
Vydané
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`offers-tab ${activeTab === "received" ? "active" : ""}`}
|
className={`admin-tab ${activeTab === "received" ? "active" : ""}`}
|
||||||
onClick={() => setActiveTab("received")}
|
onClick={() => setActiveTab("received")}
|
||||||
>
|
>
|
||||||
Přijaté
|
Přijaté
|
||||||
@@ -518,7 +522,7 @@ export default function Invoices() {
|
|||||||
<Suspense
|
<Suspense
|
||||||
fallback={
|
fallback={
|
||||||
<div
|
<div
|
||||||
className="dash-kpi-grid dash-kpi-4"
|
className="admin-kpi-grid admin-kpi-4"
|
||||||
style={{ marginBottom: "1.5rem" }}
|
style={{ marginBottom: "1.5rem" }}
|
||||||
>
|
>
|
||||||
{[0, 1, 2, 3].map((i) => (
|
{[0, 1, 2, 3].map((i) => (
|
||||||
@@ -565,7 +569,7 @@ export default function Invoices() {
|
|||||||
>
|
>
|
||||||
{!hasLoadedOnce.current && statsLoading ? (
|
{!hasLoadedOnce.current && statsLoading ? (
|
||||||
<div
|
<div
|
||||||
className="dash-kpi-grid dash-kpi-4"
|
className="admin-kpi-grid admin-kpi-4"
|
||||||
style={{ marginBottom: "1.5rem" }}
|
style={{ marginBottom: "1.5rem" }}
|
||||||
>
|
>
|
||||||
{[0, 1, 2, 3].map((i) => (
|
{[0, 1, 2, 3].map((i) => (
|
||||||
@@ -603,7 +607,7 @@ export default function Invoices() {
|
|||||||
>
|
>
|
||||||
<motion.div
|
<motion.div
|
||||||
key={slideKey}
|
key={slideKey}
|
||||||
className="dash-kpi-grid dash-kpi-4"
|
className="admin-kpi-grid admin-kpi-4"
|
||||||
custom={slideDirection.current}
|
custom={slideDirection.current}
|
||||||
variants={{
|
variants={{
|
||||||
enter: (dir: number) => ({
|
enter: (dir: number) => ({
|
||||||
@@ -736,11 +740,11 @@ export default function Invoices() {
|
|||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 0.25, delay: 0.12 }}
|
transition={{ duration: 0.25, delay: 0.12 }}
|
||||||
>
|
>
|
||||||
<div className="offers-tabs mb-6">
|
<div className="admin-tabs mb-6">
|
||||||
{STATUS_FILTERS.map((f) => (
|
{STATUS_FILTERS.map((f) => (
|
||||||
<button
|
<button
|
||||||
key={f.value}
|
key={f.value}
|
||||||
className={`offers-tab ${statusFilter === f.value ? "active" : ""}`}
|
className={`admin-tab ${statusFilter === f.value ? "active" : ""}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setStatusFilter(f.value);
|
setStatusFilter(f.value);
|
||||||
setPage(1);
|
setPage(1);
|
||||||
|
|||||||
@@ -313,9 +313,9 @@ export default function LeaveApproval() {
|
|||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 0.25, delay: 0.06 }}
|
transition={{ duration: 0.25, delay: 0.06 }}
|
||||||
>
|
>
|
||||||
<div className="offers-tabs mb-6">
|
<div className="admin-tabs mb-6">
|
||||||
<button
|
<button
|
||||||
className={`offers-tab ${activeTab === "pending" ? "active" : ""}`}
|
className={`admin-tab ${activeTab === "pending" ? "active" : ""}`}
|
||||||
onClick={() => setActiveTab("pending")}
|
onClick={() => setActiveTab("pending")}
|
||||||
>
|
>
|
||||||
Ke schválení
|
Ke schválení
|
||||||
@@ -333,7 +333,7 @@ export default function LeaveApproval() {
|
|||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`offers-tab ${activeTab === "processed" ? "active" : ""}`}
|
className={`admin-tab ${activeTab === "processed" ? "active" : ""}`}
|
||||||
onClick={() => setActiveTab("processed")}
|
onClick={() => setActiveTab("processed")}
|
||||||
>
|
>
|
||||||
Vyřízené
|
Vyřízené
|
||||||
|
|||||||
@@ -190,11 +190,17 @@ export default function Login() {
|
|||||||
<img
|
<img
|
||||||
src={
|
src={
|
||||||
theme === "dark"
|
theme === "dark"
|
||||||
? "/images/logo-dark.png"
|
? "/api/admin/company-settings/logo?variant=dark"
|
||||||
: "/images/logo-light.png"
|
: "/api/admin/company-settings/logo?variant=light"
|
||||||
}
|
}
|
||||||
alt="Logo"
|
alt="Logo"
|
||||||
className="admin-login-logo"
|
className="admin-login-logo"
|
||||||
|
onError={(e) => {
|
||||||
|
(e.target as HTMLImageElement).src =
|
||||||
|
theme === "dark"
|
||||||
|
? "/images/logo-dark.png"
|
||||||
|
: "/images/logo-light.png";
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<h1 className="admin-login-title">Interní systém</h1>
|
<h1 className="admin-login-title">Interní systém</h1>
|
||||||
<p className="admin-login-subtitle">Přihlaste se ke svému účtu</p>
|
<p className="admin-login-subtitle">Přihlaste se ke svému účtu</p>
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ const emptyForm: OfferForm = {
|
|||||||
customer_name: "",
|
customer_name: "",
|
||||||
created_at: new Date().toISOString().split("T")[0],
|
created_at: new Date().toISOString().split("T")[0],
|
||||||
valid_until: "",
|
valid_until: "",
|
||||||
currency: "EUR",
|
currency: "CZK",
|
||||||
language: "EN",
|
language: "EN",
|
||||||
vat_rate: 21,
|
vat_rate: 21,
|
||||||
apply_vat: false,
|
apply_vat: false,
|
||||||
@@ -180,9 +180,7 @@ function SortableItemRow({
|
|||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
)}
|
)}
|
||||||
<td style={{ textAlign: "center", color: "var(--text-tertiary)" }}>
|
<td className="text-center text-tertiary">{index + 1}</td>
|
||||||
{index + 1}
|
|
||||||
</td>
|
|
||||||
<td style={{ verticalAlign: "top" }}>
|
<td style={{ verticalAlign: "top" }}>
|
||||||
<div
|
<div
|
||||||
style={{ display: "flex", flexDirection: "column", gap: "0.25rem" }}
|
style={{ display: "flex", flexDirection: "column", gap: "0.25rem" }}
|
||||||
@@ -191,10 +189,9 @@ function SortableItemRow({
|
|||||||
type="text"
|
type="text"
|
||||||
value={item.description}
|
value={item.description}
|
||||||
onChange={(e) => onUpdate("description", e.target.value)}
|
onChange={(e) => onUpdate("description", e.target.value)}
|
||||||
className="admin-form-input"
|
className="admin-form-input fw-500"
|
||||||
placeholder="Název položky"
|
placeholder="Název položky"
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
style={{ fontWeight: 500 }}
|
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@@ -240,7 +237,7 @@ function SortableItemRow({
|
|||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td style={{ textAlign: "center" }}>
|
<td className="text-center">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={item.is_included_in_total}
|
checked={item.is_included_in_total}
|
||||||
@@ -248,10 +245,7 @@ function SortableItemRow({
|
|||||||
disabled={readOnly}
|
disabled={readOnly}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td className="admin-mono text-right fw-600">
|
||||||
className="admin-mono"
|
|
||||||
style={{ textAlign: "right", fontWeight: 600 }}
|
|
||||||
>
|
|
||||||
{formatCurrency(lineTotal, currency)}
|
{formatCurrency(lineTotal, currency)}
|
||||||
</td>
|
</td>
|
||||||
{!readOnly && (
|
{!readOnly && (
|
||||||
@@ -327,6 +321,12 @@ export default function OfferDetail() {
|
|||||||
const [customerOrderNumber, setCustomerOrderNumber] = useState("");
|
const [customerOrderNumber, setCustomerOrderNumber] = useState("");
|
||||||
const [orderAttachment, setOrderAttachment] = useState<File | null>(null);
|
const [orderAttachment, setOrderAttachment] = useState<File | null>(null);
|
||||||
const [pdfLoading, setPdfLoading] = useState(false);
|
const [pdfLoading, setPdfLoading] = useState(false);
|
||||||
|
const [companySettings, setCompanySettings] = useState<{
|
||||||
|
default_currency: string;
|
||||||
|
default_vat_rate: number;
|
||||||
|
available_currencies: string[];
|
||||||
|
available_vat_rates: number[];
|
||||||
|
} | null>(null);
|
||||||
const [lockedBy, setLockedBy] = useState<{
|
const [lockedBy, setLockedBy] = useState<{
|
||||||
user_id: number;
|
user_id: number;
|
||||||
username: string;
|
username: string;
|
||||||
@@ -336,6 +336,31 @@ export default function OfferDetail() {
|
|||||||
|
|
||||||
useModalLock(showOrderModal);
|
useModalLock(showOrderModal);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
apiFetch(`${API_BASE}/company-settings`)
|
||||||
|
.then((r) => r.json())
|
||||||
|
.then((d) => {
|
||||||
|
if (d.success) setCompanySettings(d.data);
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (companySettings && !isEdit) {
|
||||||
|
setForm((prev) => ({
|
||||||
|
...prev,
|
||||||
|
currency:
|
||||||
|
prev.currency === "CZK"
|
||||||
|
? companySettings.default_currency || "CZK"
|
||||||
|
: prev.currency,
|
||||||
|
vat_rate:
|
||||||
|
prev.vat_rate === 21
|
||||||
|
? (companySettings.default_vat_rate ?? 21)
|
||||||
|
: prev.vat_rate,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, [companySettings, isEdit]);
|
||||||
|
|
||||||
const isInvalidated = offerStatus === "invalidated";
|
const isInvalidated = offerStatus === "invalidated";
|
||||||
const isLockedByOther = !!lockedBy;
|
const isLockedByOther = !!lockedBy;
|
||||||
const isExpiredNotInvalidated =
|
const isExpiredNotInvalidated =
|
||||||
@@ -362,9 +387,9 @@ export default function OfferDetail() {
|
|||||||
valid_until: d.valid_until
|
valid_until: d.valid_until
|
||||||
? String(d.valid_until).substring(0, 10)
|
? String(d.valid_until).substring(0, 10)
|
||||||
: "",
|
: "",
|
||||||
currency: d.currency || "EUR",
|
currency: d.currency || companySettings?.default_currency || "CZK",
|
||||||
language: d.language || "EN",
|
language: d.language || "EN",
|
||||||
vat_rate: d.vat_rate ?? 21,
|
vat_rate: d.vat_rate ?? companySettings?.default_vat_rate ?? 21,
|
||||||
apply_vat: !!d.apply_vat,
|
apply_vat: !!d.apply_vat,
|
||||||
exchange_rate: d.exchange_rate || "",
|
exchange_rate: d.exchange_rate || "",
|
||||||
scope_title: d.scope_title || "",
|
scope_title: d.scope_title || "",
|
||||||
@@ -408,7 +433,7 @@ export default function OfferDetail() {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [id, alert, navigate, hasPermission]);
|
}, [id, alert, navigate, hasPermission, companySettings]);
|
||||||
|
|
||||||
// Heartbeat to keep lock alive + cleanup on unmount
|
// Heartbeat to keep lock alive + cleanup on unmount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -737,19 +762,25 @@ export default function OfferDetail() {
|
|||||||
|
|
||||||
const handlePdf = async () => {
|
const handlePdf = async () => {
|
||||||
if (!isEdit || pdfLoading) return;
|
if (!isEdit || pdfLoading) return;
|
||||||
|
const newWindow = window.open("", "_blank");
|
||||||
setPdfLoading(true);
|
setPdfLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await apiFetch(`${API_BASE}/offers/${id}/file`);
|
const response = await apiFetch(`${API_BASE}/offers/${id}/file`);
|
||||||
if (response.status === 401) return;
|
if (response.status === 401) {
|
||||||
|
newWindow?.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
newWindow?.close();
|
||||||
alert.error("PDF soubor nenalezen — uložte nabídku pro vygenerování");
|
alert.error("PDF soubor nenalezen — uložte nabídku pro vygenerování");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
window.open(url, "_blank");
|
if (newWindow) newWindow.location.href = url;
|
||||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||||
} catch {
|
} catch {
|
||||||
|
newWindow?.close();
|
||||||
alert.error("Chyba při generování PDF");
|
alert.error("Chyba při generování PDF");
|
||||||
} finally {
|
} finally {
|
||||||
setPdfLoading(false);
|
setPdfLoading(false);
|
||||||
@@ -837,11 +868,10 @@ export default function OfferDetail() {
|
|||||||
{isEdit ? `Nabídka ${form.quotation_number}` : "Nová nabídka"}
|
{isEdit ? `Nabídka ${form.quotation_number}` : "Nová nabídka"}
|
||||||
{isInvalidated && (
|
{isInvalidated && (
|
||||||
<span
|
<span
|
||||||
className="admin-badge admin-badge-danger"
|
className="admin-badge admin-badge-danger text-xs"
|
||||||
style={{
|
style={{
|
||||||
marginLeft: "0.75rem",
|
marginLeft: "0.75rem",
|
||||||
verticalAlign: "middle",
|
verticalAlign: "middle",
|
||||||
fontSize: "0.75rem",
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Zneplatněna
|
Zneplatněna
|
||||||
@@ -974,14 +1004,14 @@ export default function OfferDetail() {
|
|||||||
|
|
||||||
{/* Quotation Form */}
|
{/* Quotation Form */}
|
||||||
<motion.div
|
<motion.div
|
||||||
className={`offers-editor-section${isInvalidated || isLockedByOther ? " offers-readonly" : ""}`}
|
className={`admin-editor-section${isInvalidated || isLockedByOther ? " offers-readonly" : ""}`}
|
||||||
initial={{ opacity: 0, y: 12 }}
|
initial={{ opacity: 0, y: 12 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 0.25, delay: 0.06 }}
|
transition={{ duration: 0.25, delay: 0.06 }}
|
||||||
>
|
>
|
||||||
<h3 className="admin-card-title">Základní údaje</h3>
|
<h3 className="admin-card-title">Základní údaje</h3>
|
||||||
<div className="admin-form">
|
<div className="admin-form">
|
||||||
<div className="offers-form-row-3">
|
<div className="admin-form-row admin-form-row-3">
|
||||||
<FormField label="Číslo nabídky">
|
<FormField label="Číslo nabídky">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@@ -1007,7 +1037,7 @@ export default function OfferDetail() {
|
|||||||
</FormField>
|
</FormField>
|
||||||
<FormField label="Zákazník" error={errors.customer_id}>
|
<FormField label="Zákazník" error={errors.customer_id}>
|
||||||
{form.customer_id ? (
|
{form.customer_id ? (
|
||||||
<div className="offers-customer-selected">
|
<div className="admin-customer-selected">
|
||||||
<span>{form.customer_name}</span>
|
<span>{form.customer_name}</span>
|
||||||
{!isInvalidated && !isLockedByOther && (
|
{!isInvalidated && !isLockedByOther && (
|
||||||
<button
|
<button
|
||||||
@@ -1032,7 +1062,7 @@ export default function OfferDetail() {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div
|
<div
|
||||||
className="offers-customer-select"
|
className="admin-customer-select"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
@@ -1048,16 +1078,16 @@ export default function OfferDetail() {
|
|||||||
readOnly={isInvalidated || isLockedByOther}
|
readOnly={isInvalidated || isLockedByOther}
|
||||||
/>
|
/>
|
||||||
{showCustomerDropdown && !isInvalidated && (
|
{showCustomerDropdown && !isInvalidated && (
|
||||||
<div className="offers-customer-dropdown">
|
<div className="admin-customer-dropdown">
|
||||||
{filteredCustomers.length === 0 ? (
|
{filteredCustomers.length === 0 ? (
|
||||||
<div className="offers-customer-dropdown-empty">
|
<div className="admin-customer-dropdown-empty">
|
||||||
Žádní zákazníci
|
Žádní zákazníci
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
filteredCustomers.slice(0, 20).map((c) => (
|
filteredCustomers.slice(0, 20).map((c) => (
|
||||||
<div
|
<div
|
||||||
key={c.id}
|
key={c.id}
|
||||||
className="offers-customer-dropdown-item"
|
className="admin-customer-dropdown-item"
|
||||||
onMouseDown={() => selectCustomer(c)}
|
onMouseDown={() => selectCustomer(c)}
|
||||||
>
|
>
|
||||||
<div>{c.name}</div>
|
<div>{c.name}</div>
|
||||||
@@ -1125,10 +1155,18 @@ export default function OfferDetail() {
|
|||||||
className="admin-form-select"
|
className="admin-form-select"
|
||||||
disabled={isInvalidated || isLockedByOther}
|
disabled={isInvalidated || isLockedByOther}
|
||||||
>
|
>
|
||||||
<option value="EUR">EUR</option>
|
{(
|
||||||
<option value="USD">USD</option>
|
companySettings?.available_currencies || [
|
||||||
<option value="CZK">CZK</option>
|
"CZK",
|
||||||
<option value="GBP">GBP</option>
|
"EUR",
|
||||||
|
"USD",
|
||||||
|
"GBP",
|
||||||
|
]
|
||||||
|
).map((c) => (
|
||||||
|
<option key={c} value={c}>
|
||||||
|
{c}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
</FormField>
|
</FormField>
|
||||||
<FormField label="Jazyk nabídky">
|
<FormField label="Jazyk nabídky">
|
||||||
@@ -1144,23 +1182,26 @@ export default function OfferDetail() {
|
|||||||
</FormField>
|
</FormField>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="offers-form-row-3">
|
<div className="admin-form-row admin-form-row-3">
|
||||||
<FormField label="Sazba DPH (%)">
|
<FormField label="Sazba DPH (%)">
|
||||||
<div className="flex-row-gap">
|
<div className="flex-row-gap">
|
||||||
<input
|
<select
|
||||||
type="number"
|
|
||||||
value={form.vat_rate}
|
value={form.vat_rate}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateForm("vat_rate", parseFloat(e.target.value) || 0)
|
updateForm("vat_rate", parseFloat(e.target.value) || 0)
|
||||||
}
|
}
|
||||||
className="admin-form-input flex-1"
|
className="admin-form-select flex-1"
|
||||||
step="0.1"
|
disabled={isInvalidated || isLockedByOther}
|
||||||
readOnly={isInvalidated || isLockedByOther}
|
|
||||||
/>
|
|
||||||
<label
|
|
||||||
className="admin-form-checkbox"
|
|
||||||
style={{ whiteSpace: "nowrap" }}
|
|
||||||
>
|
>
|
||||||
|
{(
|
||||||
|
companySettings?.available_vat_rates || [0, 10, 12, 15, 21]
|
||||||
|
).map((r) => (
|
||||||
|
<option key={r} value={r}>
|
||||||
|
{r}%
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
<label className="admin-form-checkbox whitespace-nowrap">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={form.apply_vat}
|
checked={form.apply_vat}
|
||||||
@@ -1281,18 +1322,18 @@ export default function OfferDetail() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Totals */}
|
{/* Totals */}
|
||||||
<div className="offers-totals-summary">
|
<div className="admin-totals-summary">
|
||||||
<div className="offers-totals-row">
|
<div className="admin-totals-row">
|
||||||
<span>Mezisoučet:</span>
|
<span>Mezisoučet:</span>
|
||||||
<span>{formatCurrency(subtotal, form.currency)}</span>
|
<span>{formatCurrency(subtotal, form.currency)}</span>
|
||||||
</div>
|
</div>
|
||||||
{form.apply_vat && (
|
{form.apply_vat && (
|
||||||
<div className="offers-totals-row">
|
<div className="admin-totals-row">
|
||||||
<span>DPH ({form.vat_rate}%):</span>
|
<span>DPH ({form.vat_rate}%):</span>
|
||||||
<span>{formatCurrency(vatAmount, form.currency)}</span>
|
<span>{formatCurrency(vatAmount, form.currency)}</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="offers-totals-row offers-totals-total">
|
<div className="admin-totals-row admin-totals-total">
|
||||||
<span>Celkem:</span>
|
<span>Celkem:</span>
|
||||||
<span>{formatCurrency(total, form.currency)}</span>
|
<span>{formatCurrency(total, form.currency)}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -1621,7 +1662,7 @@ export default function OfferDetail() {
|
|||||||
<FormField label="Příloha (PDF)">
|
<FormField label="Příloha (PDF)">
|
||||||
{orderAttachment ? (
|
{orderAttachment ? (
|
||||||
<div className="flex-row gap-2">
|
<div className="flex-row gap-2">
|
||||||
<span style={{ fontSize: "0.875rem" }}>
|
<span className="text-md">
|
||||||
{orderAttachment.name}{" "}
|
{orderAttachment.name}{" "}
|
||||||
<span className="text-tertiary">
|
<span className="text-tertiary">
|
||||||
({(orderAttachment.size / 1024).toFixed(0)} KB)
|
({(orderAttachment.size / 1024).toFixed(0)} KB)
|
||||||
|
|||||||
@@ -221,26 +221,28 @@ export default function Offers() {
|
|||||||
|
|
||||||
const handlePdf = async (quotation: Quotation) => {
|
const handlePdf = async (quotation: Quotation) => {
|
||||||
if (pdfLoading) return;
|
if (pdfLoading) return;
|
||||||
|
const newWindow = window.open("", "_blank");
|
||||||
setPdfLoading(quotation.id);
|
setPdfLoading(quotation.id);
|
||||||
try {
|
try {
|
||||||
const response = await apiFetch(`${API_BASE}/offers-pdf/${quotation.id}`);
|
const response = await apiFetch(
|
||||||
if (response.status === 401) return;
|
`${API_BASE}/offers/${quotation.id}/file`,
|
||||||
if (!response.ok) {
|
);
|
||||||
alert.error("Nepodařilo se vygenerovat PDF");
|
if (response.status === 401) {
|
||||||
|
newWindow?.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const html = await response.text();
|
if (!response.ok) {
|
||||||
const w = window.open("", "_blank");
|
newWindow?.close();
|
||||||
if (w) {
|
alert.error("PDF soubor nenalezen — otevřete nabídku a uložte ji");
|
||||||
w.document.open();
|
return;
|
||||||
w.document.write(html);
|
|
||||||
w.document.close();
|
|
||||||
w.onload = () => w.print();
|
|
||||||
} else {
|
|
||||||
alert.error("Prohlížeč zablokoval vyskakovací okno");
|
|
||||||
}
|
}
|
||||||
|
const blob = await response.blob();
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
if (newWindow) newWindow.location.href = url;
|
||||||
|
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||||
} catch {
|
} catch {
|
||||||
alert.error("Chyba při generování PDF");
|
newWindow?.close();
|
||||||
|
alert.error("Chyba připojení");
|
||||||
} finally {
|
} finally {
|
||||||
setPdfLoading(null);
|
setPdfLoading(null);
|
||||||
}
|
}
|
||||||
@@ -324,7 +326,7 @@ export default function Offers() {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="admin-page-actions">
|
<div className="admin-page-actions">
|
||||||
{hasPermission("offers.settings") && (
|
{hasPermission("settings.manage") && (
|
||||||
<Link
|
<Link
|
||||||
to="/offers/templates"
|
to="/offers/templates"
|
||||||
className="admin-btn admin-btn-secondary"
|
className="admin-btn admin-btn-secondary"
|
||||||
@@ -753,7 +755,7 @@ export default function Offers() {
|
|||||||
<button
|
<button
|
||||||
onClick={() => handlePdf(q)}
|
onClick={() => handlePdf(q)}
|
||||||
className="admin-btn-icon"
|
className="admin-btn-icon"
|
||||||
title="PDF"
|
title="Zobrazit nabídku"
|
||||||
disabled={pdfLoading === q.id}
|
disabled={pdfLoading === q.id}
|
||||||
>
|
>
|
||||||
{pdfLoading === q.id ? (
|
{pdfLoading === q.id ? (
|
||||||
@@ -812,8 +814,8 @@ export default function Offers() {
|
|||||||
<tr>
|
<tr>
|
||||||
<td
|
<td
|
||||||
colSpan={8}
|
colSpan={8}
|
||||||
className="text-muted"
|
className="text-muted text-center"
|
||||||
style={{ textAlign: "center", padding: "1.5rem" }}
|
style={{ padding: "1.5rem" }}
|
||||||
>
|
>
|
||||||
Žádné nabídky odpovídající hledání.
|
Žádné nabídky odpovídající hledání.
|
||||||
</td>
|
</td>
|
||||||
@@ -877,8 +879,8 @@ export default function Offers() {
|
|||||||
<div className="admin-modal-header">
|
<div className="admin-modal-header">
|
||||||
<h2 className="admin-modal-title">Vytvořit objednávku</h2>
|
<h2 className="admin-modal-title">Vytvořit objednávku</h2>
|
||||||
<p
|
<p
|
||||||
className="text-secondary"
|
className="text-secondary text-md"
|
||||||
style={{ marginTop: "0.25rem", fontSize: "0.875rem" }}
|
style={{ marginTop: "0.25rem" }}
|
||||||
>
|
>
|
||||||
Nabídka:{" "}
|
Nabídka:{" "}
|
||||||
<strong>{orderModal.quotation?.quotation_number}</strong>
|
<strong>{orderModal.quotation?.quotation_number}</strong>
|
||||||
@@ -915,7 +917,7 @@ export default function Offers() {
|
|||||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
||||||
<polyline points="14 2 14 8 20 8" />
|
<polyline points="14 2 14 8 20 8" />
|
||||||
</svg>
|
</svg>
|
||||||
<span style={{ fontSize: "0.875rem" }}>
|
<span className="text-md">
|
||||||
{orderAttachment.name}{" "}
|
{orderAttachment.name}{" "}
|
||||||
<span className="text-tertiary">
|
<span className="text-tertiary">
|
||||||
({(orderAttachment.size / 1024).toFixed(0)} KB)
|
({(orderAttachment.size / 1024).toFixed(0)} KB)
|
||||||
@@ -942,11 +944,9 @@ export default function Offers() {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<label
|
<label
|
||||||
className="admin-btn admin-btn-secondary admin-btn-sm"
|
className="admin-btn admin-btn-secondary admin-btn-sm inline-flex"
|
||||||
style={{
|
style={{
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
display: "inline-flex",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: "0.4rem",
|
gap: "0.4rem",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export default function OffersTemplates() {
|
|||||||
const { hasPermission } = useAuth();
|
const { hasPermission } = useAuth();
|
||||||
const [activeTab, setActiveTab] = useState<"items" | "scopes">("items");
|
const [activeTab, setActiveTab] = useState<"items" | "scopes">("items");
|
||||||
|
|
||||||
if (!hasPermission("offers.settings")) return <Forbidden />;
|
if (!hasPermission("settings.manage")) return <Forbidden />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -73,15 +73,15 @@ export default function OffersTemplates() {
|
|||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
<div className="offers-tabs">
|
<div className="admin-tabs">
|
||||||
<button
|
<button
|
||||||
className={`offers-tab ${activeTab === "items" ? "active" : ""}`}
|
className={`admin-tab ${activeTab === "items" ? "active" : ""}`}
|
||||||
onClick={() => setActiveTab("items")}
|
onClick={() => setActiveTab("items")}
|
||||||
>
|
>
|
||||||
Šablony položek
|
Šablony položek
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`offers-tab ${activeTab === "scopes" ? "active" : ""}`}
|
className={`admin-tab ${activeTab === "scopes" ? "active" : ""}`}
|
||||||
onClick={() => setActiveTab("scopes")}
|
onClick={() => setActiveTab("scopes")}
|
||||||
>
|
>
|
||||||
Šablony rozsahu
|
Šablony rozsahu
|
||||||
@@ -826,22 +826,19 @@ function ScopeTemplatesTab() {
|
|||||||
|
|
||||||
<div className="admin-form-group">
|
<div className="admin-form-group">
|
||||||
<label className="admin-form-label mb-2">Sekce</label>
|
<label className="admin-form-label mb-2">Sekce</label>
|
||||||
<div className="offers-scope-list">
|
<div className="admin-scope-list">
|
||||||
{form.sections.map((section, index) => (
|
{form.sections.map((section, index) => (
|
||||||
<div
|
<div key={section._key} className="admin-scope-section">
|
||||||
key={section._key}
|
<div className="admin-scope-section-header">
|
||||||
className="offers-scope-section"
|
<span className="admin-scope-number">
|
||||||
>
|
|
||||||
<div className="offers-scope-section-header">
|
|
||||||
<span className="offers-scope-number">
|
|
||||||
{index + 1}.
|
{index + 1}.
|
||||||
</span>
|
</span>
|
||||||
<span className="offers-scope-title">
|
<span className="admin-scope-title">
|
||||||
{section.title ||
|
{section.title ||
|
||||||
section.title_cz ||
|
section.title_cz ||
|
||||||
`Sekce ${index + 1}`}
|
`Sekce ${index + 1}`}
|
||||||
</span>
|
</span>
|
||||||
<div className="offers-scope-actions">
|
<div className="admin-scope-actions">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => moveSection(index, -1)}
|
onClick={() => moveSection(index, -1)}
|
||||||
|
|||||||
@@ -747,18 +747,18 @@ export default function OrderDetail() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Totals */}
|
{/* Totals */}
|
||||||
<div className="offers-totals-summary">
|
<div className="admin-totals-summary">
|
||||||
<div className="offers-totals-row">
|
<div className="admin-totals-row">
|
||||||
<span>Mezisoučet:</span>
|
<span>Mezisoučet:</span>
|
||||||
<span>{formatCurrency(totals.subtotal, order.currency)}</span>
|
<span>{formatCurrency(totals.subtotal, order.currency)}</span>
|
||||||
</div>
|
</div>
|
||||||
{Number(order.apply_vat) > 0 && (
|
{Number(order.apply_vat) > 0 && (
|
||||||
<div className="offers-totals-row">
|
<div className="admin-totals-row">
|
||||||
<span>DPH ({order.vat_rate}%):</span>
|
<span>DPH ({order.vat_rate}%):</span>
|
||||||
<span>{formatCurrency(totals.vatAmount, order.currency)}</span>
|
<span>{formatCurrency(totals.vatAmount, order.currency)}</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="offers-totals-row offers-totals-total">
|
<div className="admin-totals-row admin-totals-total">
|
||||||
<span>Celkem k úhradě:</span>
|
<span>Celkem k úhradě:</span>
|
||||||
<span>{formatCurrency(totals.total, order.currency)}</span>
|
<span>{formatCurrency(totals.total, order.currency)}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -788,16 +788,16 @@ export default function OrderDetail() {
|
|||||||
{order.scope_description}
|
{order.scope_description}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="offers-scope-list">
|
<div className="admin-scope-list">
|
||||||
{order.sections.map((section, index) => (
|
{order.sections.map((section, index) => (
|
||||||
<div
|
<div
|
||||||
key={section.id || index}
|
key={section.id || index}
|
||||||
className="offers-scope-section"
|
className="admin-scope-section"
|
||||||
style={{ cursor: "default" }}
|
style={{ cursor: "default" }}
|
||||||
>
|
>
|
||||||
<div className="offers-scope-section-header">
|
<div className="admin-scope-section-header">
|
||||||
<span className="offers-scope-number">{index + 1}.</span>
|
<span className="admin-scope-number">{index + 1}.</span>
|
||||||
<span className="offers-scope-title">
|
<span className="admin-scope-title">
|
||||||
{(order.language === "CZ"
|
{(order.language === "CZ"
|
||||||
? section.title_cz || section.title
|
? section.title_cz || section.title
|
||||||
: section.title || section.title_cz) ||
|
: section.title || section.title_cz) ||
|
||||||
@@ -806,7 +806,7 @@ export default function OrderDetail() {
|
|||||||
</div>
|
</div>
|
||||||
{section.content && (
|
{section.content && (
|
||||||
<div
|
<div
|
||||||
className="offers-scope-content rich-text-view"
|
className="admin-scope-content admin-rich-text-view"
|
||||||
style={{ padding: "1rem" }}
|
style={{ padding: "1rem" }}
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: DOMPurify.sanitize(section.content),
|
__html: DOMPurify.sanitize(section.content),
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ export default function ProjectCreate() {
|
|||||||
<div className="admin-form-row">
|
<div className="admin-form-row">
|
||||||
<FormField label="Zákazník" error={errors.customer_id} required>
|
<FormField label="Zákazník" error={errors.customer_id} required>
|
||||||
{form.customer_id ? (
|
{form.customer_id ? (
|
||||||
<div className="offers-customer-selected">
|
<div className="admin-customer-selected">
|
||||||
<span>{form.customer_name}</span>
|
<span>{form.customer_name}</span>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -308,7 +308,7 @@ export default function ProjectCreate() {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div
|
<div
|
||||||
className="offers-customer-select"
|
className="admin-customer-select"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
@@ -323,16 +323,16 @@ export default function ProjectCreate() {
|
|||||||
placeholder="Hledat zákazníka..."
|
placeholder="Hledat zákazníka..."
|
||||||
/>
|
/>
|
||||||
{showCustomerDropdown && (
|
{showCustomerDropdown && (
|
||||||
<div className="offers-customer-dropdown">
|
<div className="admin-customer-dropdown">
|
||||||
{filteredCustomers.length === 0 ? (
|
{filteredCustomers.length === 0 ? (
|
||||||
<div className="offers-customer-dropdown-empty">
|
<div className="admin-customer-dropdown-empty">
|
||||||
Žádní zákazníci
|
Žádní zákazníci
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
filteredCustomers.slice(0, 20).map((c) => (
|
filteredCustomers.slice(0, 20).map((c) => (
|
||||||
<div
|
<div
|
||||||
key={c.id}
|
key={c.id}
|
||||||
className="offers-customer-dropdown-item"
|
className="admin-customer-dropdown-item"
|
||||||
onMouseDown={() => selectCustomer(c)}
|
onMouseDown={() => selectCustomer(c)}
|
||||||
>
|
>
|
||||||
<div>{c.name}</div>
|
<div>{c.name}</div>
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ const STATUS_CLASSES: Record<string, string> = {
|
|||||||
unpaid: "admin-badge-invoice-overdue",
|
unpaid: "admin-badge-invoice-overdue",
|
||||||
paid: "admin-badge-invoice-paid",
|
paid: "admin-badge-invoice-paid",
|
||||||
};
|
};
|
||||||
const CURRENCY_OPTIONS = ["CZK", "EUR", "USD", "GBP"];
|
const DEFAULT_CURRENCIES = ["CZK", "EUR", "USD", "GBP"];
|
||||||
const VAT_RATE_OPTIONS = [0, 10, 12, 15, 21];
|
const DEFAULT_VAT_RATES = [0, 10, 12, 15, 21];
|
||||||
|
|
||||||
const MONTH_NAMES = [
|
const MONTH_NAMES = [
|
||||||
"leden",
|
"leden",
|
||||||
@@ -115,7 +115,7 @@ function formatCzkWithDetail(
|
|||||||
return { value: "0 Kč", detail: null };
|
return { value: "0 Kč", detail: null };
|
||||||
}
|
}
|
||||||
const hasForeign = amounts.some((a) => a.currency !== "CZK");
|
const hasForeign = amounts.some((a) => a.currency !== "CZK");
|
||||||
if (hasForeign && totalCzk !== null && totalCzk !== undefined) {
|
if (hasForeign && totalCzk != null) {
|
||||||
return {
|
return {
|
||||||
value: formatCurrency(totalCzk, "CZK"),
|
value: formatCurrency(totalCzk, "CZK"),
|
||||||
detail: formatMultiCurrency(amounts),
|
detail: formatMultiCurrency(amounts),
|
||||||
@@ -124,13 +124,20 @@ function formatCzkWithDetail(
|
|||||||
return { value: formatMultiCurrency(amounts), detail: null };
|
return { value: formatMultiCurrency(amounts), detail: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
function emptyMeta(): UploadMeta {
|
interface CompanySettings {
|
||||||
|
default_currency: string;
|
||||||
|
default_vat_rate: number;
|
||||||
|
available_currencies: string[];
|
||||||
|
available_vat_rates: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
function emptyMeta(settings: CompanySettings | null): UploadMeta {
|
||||||
return {
|
return {
|
||||||
supplier_name: "",
|
supplier_name: "",
|
||||||
invoice_number: "",
|
invoice_number: "",
|
||||||
amount: "",
|
amount: "",
|
||||||
currency: "CZK",
|
currency: settings?.default_currency || "CZK",
|
||||||
vat_rate: "21",
|
vat_rate: String(settings?.default_vat_rate ?? 21),
|
||||||
issue_date: "",
|
issue_date: "",
|
||||||
due_date: "",
|
due_date: "",
|
||||||
notes: "",
|
notes: "",
|
||||||
@@ -168,6 +175,8 @@ export default function ReceivedInvoices({
|
|||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
|
|
||||||
const [supplierNames, setSupplierNames] = useState<string[]>([]);
|
const [supplierNames, setSupplierNames] = useState<string[]>([]);
|
||||||
|
const [companySettings, setCompanySettings] =
|
||||||
|
useState<CompanySettings | null>(null);
|
||||||
|
|
||||||
const [uploadFiles, setUploadFiles] = useState<File[]>([]);
|
const [uploadFiles, setUploadFiles] = useState<File[]>([]);
|
||||||
const [uploadMeta, setUploadMeta] = useState<UploadMeta[]>([]);
|
const [uploadMeta, setUploadMeta] = useState<UploadMeta[]>([]);
|
||||||
@@ -231,6 +240,22 @@ export default function ReceivedInvoices({
|
|||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
apiFetch(`${API_BASE}/company-settings`)
|
||||||
|
.then((r) => r.json())
|
||||||
|
.then((d) => {
|
||||||
|
if (d.success) setCompanySettings(d.data);
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const currencyOptions =
|
||||||
|
companySettings?.available_currencies || DEFAULT_CURRENCIES;
|
||||||
|
const vatRateOptions =
|
||||||
|
companySettings?.available_vat_rates || DEFAULT_VAT_RATES;
|
||||||
|
const defaultCurrency = companySettings?.default_currency || "CZK";
|
||||||
|
const defaultVatRate = String(companySettings?.default_vat_rate ?? 21);
|
||||||
|
|
||||||
// Fetch stats (silent refresh without animation)
|
// Fetch stats (silent refresh without animation)
|
||||||
const refreshStats = useCallback(async () => {
|
const refreshStats = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -292,7 +317,10 @@ export default function ReceivedInvoices({
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
setUploadFiles((prev) => [...prev, ...valid]);
|
setUploadFiles((prev) => [...prev, ...valid]);
|
||||||
setUploadMeta((prev) => [...prev, ...valid.map(() => emptyMeta())]);
|
setUploadMeta((prev) => [
|
||||||
|
...prev,
|
||||||
|
...valid.map(() => emptyMeta(companySettings)),
|
||||||
|
]);
|
||||||
e.target.value = "";
|
e.target.value = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -475,19 +503,22 @@ export default function ReceivedInvoices({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const openFile = async (inv: ReceivedInvoice) => {
|
const openFile = async (inv: ReceivedInvoice) => {
|
||||||
|
const newWindow = window.open("", "_blank");
|
||||||
try {
|
try {
|
||||||
const response = await apiFetch(
|
const response = await apiFetch(
|
||||||
`${API_BASE}/received-invoices/${inv.id}/file`,
|
`${API_BASE}/received-invoices/${inv.id}/file`,
|
||||||
);
|
);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
newWindow?.close();
|
||||||
alert.error("Nepodařilo se načíst soubor");
|
alert.error("Nepodařilo se načíst soubor");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
window.open(url, "_blank");
|
if (newWindow) newWindow.location.href = url;
|
||||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||||
} catch {
|
} catch {
|
||||||
|
newWindow?.close();
|
||||||
alert.error("Chyba připojení");
|
alert.error("Chyba připojení");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -518,7 +549,7 @@ export default function ReceivedInvoices({
|
|||||||
const renderKpi = () => {
|
const renderKpi = () => {
|
||||||
if (!hasLoadedOnce.current && statsLoading) {
|
if (!hasLoadedOnce.current && statsLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="dash-kpi-grid dash-kpi-4 mb-6">
|
<div className="admin-kpi-grid admin-kpi-4 mb-6">
|
||||||
{[0, 1, 2, 3].map((i) => (
|
{[0, 1, 2, 3].map((i) => (
|
||||||
<div key={i} className="admin-stat-card">
|
<div key={i} className="admin-stat-card">
|
||||||
<div
|
<div
|
||||||
@@ -555,7 +586,7 @@ export default function ReceivedInvoices({
|
|||||||
>
|
>
|
||||||
<motion.div
|
<motion.div
|
||||||
key={slideKey}
|
key={slideKey}
|
||||||
className="dash-kpi-grid dash-kpi-4"
|
className="admin-kpi-grid admin-kpi-4"
|
||||||
custom={slideDirection.current}
|
custom={slideDirection.current}
|
||||||
variants={{
|
variants={{
|
||||||
enter: (dir: number) => ({
|
enter: (dir: number) => ({
|
||||||
@@ -678,9 +709,9 @@ export default function ReceivedInvoices({
|
|||||||
<p>Žádné přijaté faktury v tomto měsíci.</p>
|
<p>Žádné přijaté faktury v tomto měsíci.</p>
|
||||||
{hasPermission("invoices.create") && (
|
{hasPermission("invoices.create") && (
|
||||||
<p
|
<p
|
||||||
|
className="text-md"
|
||||||
style={{
|
style={{
|
||||||
color: "var(--text-tertiary)",
|
color: "var(--text-tertiary)",
|
||||||
fontSize: "0.875rem",
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Nahrajte faktury tlačítkem výše.
|
Nahrajte faktury tlačítkem výše.
|
||||||
@@ -749,7 +780,8 @@ export default function ReceivedInvoices({
|
|||||||
/>
|
/>
|
||||||
</th>
|
</th>
|
||||||
<th
|
<th
|
||||||
style={{ textAlign: "right", cursor: "pointer" }}
|
className="text-right"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
onClick={() => handleSort("amount")}
|
onClick={() => handleSort("amount")}
|
||||||
>
|
>
|
||||||
Částka{" "}
|
Částka{" "}
|
||||||
@@ -928,9 +960,9 @@ export default function ReceivedInvoices({
|
|||||||
Vybrat soubory
|
Vybrat soubory
|
||||||
</button>
|
</button>
|
||||||
<span
|
<span
|
||||||
|
className="text-sm"
|
||||||
style={{
|
style={{
|
||||||
marginLeft: "0.75rem",
|
marginLeft: "0.75rem",
|
||||||
fontSize: "0.8125rem",
|
|
||||||
color: "var(--text-tertiary)",
|
color: "var(--text-tertiary)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -1041,12 +1073,14 @@ export default function ReceivedInvoices({
|
|||||||
<FormField label="Měna" style={{ width: "90px" }}>
|
<FormField label="Měna" style={{ width: "90px" }}>
|
||||||
<select
|
<select
|
||||||
className="admin-form-select"
|
className="admin-form-select"
|
||||||
value={uploadMeta[idx]?.currency || "CZK"}
|
value={
|
||||||
|
uploadMeta[idx]?.currency || defaultCurrency
|
||||||
|
}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateMeta(idx, "currency", e.target.value)
|
updateMeta(idx, "currency", e.target.value)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{CURRENCY_OPTIONS.map((c) => (
|
{currencyOptions.map((c) => (
|
||||||
<option key={c} value={c}>
|
<option key={c} value={c}>
|
||||||
{c}
|
{c}
|
||||||
</option>
|
</option>
|
||||||
@@ -1056,12 +1090,14 @@ export default function ReceivedInvoices({
|
|||||||
<FormField label="DPH %" style={{ width: "90px" }}>
|
<FormField label="DPH %" style={{ width: "90px" }}>
|
||||||
<select
|
<select
|
||||||
className="admin-form-select"
|
className="admin-form-select"
|
||||||
value={uploadMeta[idx]?.vat_rate || "21"}
|
value={
|
||||||
|
uploadMeta[idx]?.vat_rate || defaultVatRate
|
||||||
|
}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateMeta(idx, "vat_rate", e.target.value)
|
updateMeta(idx, "vat_rate", e.target.value)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{VAT_RATE_OPTIONS.map((r) => (
|
{vatRateOptions.map((r) => (
|
||||||
<option key={r} value={String(r)}>
|
<option key={r} value={String(r)}>
|
||||||
{r}%
|
{r}%
|
||||||
</option>
|
</option>
|
||||||
@@ -1071,8 +1107,8 @@ export default function ReceivedInvoices({
|
|||||||
</div>
|
</div>
|
||||||
{uploadMeta[idx]?.amount && (
|
{uploadMeta[idx]?.amount && (
|
||||||
<div
|
<div
|
||||||
|
className="text-xs"
|
||||||
style={{
|
style={{
|
||||||
fontSize: "0.75rem",
|
|
||||||
color: "var(--text-tertiary)",
|
color: "var(--text-tertiary)",
|
||||||
marginTop: "-0.25rem",
|
marginTop: "-0.25rem",
|
||||||
marginBottom: "0.5rem",
|
marginBottom: "0.5rem",
|
||||||
@@ -1085,14 +1121,14 @@ export default function ReceivedInvoices({
|
|||||||
uploadMeta[idx].amount || "0",
|
uploadMeta[idx].amount || "0",
|
||||||
);
|
);
|
||||||
const r = parseFloat(
|
const r = parseFloat(
|
||||||
uploadMeta[idx].vat_rate || "21",
|
uploadMeta[idx].vat_rate || defaultVatRate,
|
||||||
);
|
);
|
||||||
return r > 0
|
return r > 0
|
||||||
? Math.round((a - a / (1 + r / 100)) * 100) /
|
? Math.round((a - a / (1 + r / 100)) * 100) /
|
||||||
100
|
100
|
||||||
: 0;
|
: 0;
|
||||||
})(),
|
})(),
|
||||||
uploadMeta[idx].currency || "CZK",
|
uploadMeta[idx].currency || defaultCurrency,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -1255,7 +1291,7 @@ export default function ReceivedInvoices({
|
|||||||
}
|
}
|
||||||
disabled={ro}
|
disabled={ro}
|
||||||
>
|
>
|
||||||
{CURRENCY_OPTIONS.map((c) => (
|
{currencyOptions.map((c) => (
|
||||||
<option key={c} value={c}>
|
<option key={c} value={c}>
|
||||||
{c}
|
{c}
|
||||||
</option>
|
</option>
|
||||||
@@ -1275,7 +1311,7 @@ export default function ReceivedInvoices({
|
|||||||
}
|
}
|
||||||
disabled={ro}
|
disabled={ro}
|
||||||
>
|
>
|
||||||
{VAT_RATE_OPTIONS.map((r) => (
|
{vatRateOptions.map((r) => (
|
||||||
<option key={r} value={String(r)}>
|
<option key={r} value={String(r)}>
|
||||||
{r}%
|
{r}%
|
||||||
</option>
|
</option>
|
||||||
@@ -1285,8 +1321,8 @@ export default function ReceivedInvoices({
|
|||||||
</div>
|
</div>
|
||||||
{editInvoice.amount && (
|
{editInvoice.amount && (
|
||||||
<div
|
<div
|
||||||
|
className="text-xs"
|
||||||
style={{
|
style={{
|
||||||
fontSize: "0.75rem",
|
|
||||||
color: "var(--text-tertiary)",
|
color: "var(--text-tertiary)",
|
||||||
marginBottom: "0.75rem",
|
marginBottom: "0.75rem",
|
||||||
}}
|
}}
|
||||||
@@ -1296,14 +1332,14 @@ export default function ReceivedInvoices({
|
|||||||
(() => {
|
(() => {
|
||||||
const a = parseFloat(editInvoice.amount || "0");
|
const a = parseFloat(editInvoice.amount || "0");
|
||||||
const r = parseFloat(
|
const r = parseFloat(
|
||||||
editInvoice.vat_rate || "21",
|
editInvoice.vat_rate || defaultVatRate,
|
||||||
);
|
);
|
||||||
return r > 0
|
return r > 0
|
||||||
? Math.round((a - a / (1 + r / 100)) * 100) /
|
? Math.round((a - a / (1 + r / 100)) * 100) /
|
||||||
100
|
100
|
||||||
: 0;
|
: 0;
|
||||||
})(),
|
})(),
|
||||||
editInvoice.currency || "CZK",
|
editInvoice.currency || defaultCurrency,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -89,6 +89,7 @@ export default function TripsAdmin() {
|
|||||||
const alert = useAlert();
|
const alert = useAlert();
|
||||||
const { hasPermission } = useAuth();
|
const { hasPermission } = useAuth();
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [companyName, setCompanyName] = useState("");
|
||||||
const [filterMonth, setFilterMonth] = useState(() =>
|
const [filterMonth, setFilterMonth] = useState(() =>
|
||||||
String(new Date().getMonth() + 1),
|
String(new Date().getMonth() + 1),
|
||||||
);
|
);
|
||||||
@@ -124,13 +125,16 @@ export default function TripsAdmin() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchLookups = async () => {
|
const fetchLookups = async () => {
|
||||||
try {
|
try {
|
||||||
const [vRes, uRes] = await Promise.all([
|
const [vRes, uRes, csRes] = await Promise.all([
|
||||||
apiFetch(`${API_BASE}/vehicles`),
|
apiFetch(`${API_BASE}/vehicles`),
|
||||||
apiFetch(`${API_BASE}/users?limit=1000`),
|
apiFetch(`${API_BASE}/users?limit=1000`),
|
||||||
|
apiFetch(`${API_BASE}/company-settings`),
|
||||||
]);
|
]);
|
||||||
const vJson = await vRes.json();
|
const vJson = await vRes.json();
|
||||||
const uJson = await uRes.json();
|
const uJson = await uRes.json();
|
||||||
|
const csJson = await csRes.json();
|
||||||
if (vJson.success) setVehicles(vJson.data);
|
if (vJson.success) setVehicles(vJson.data);
|
||||||
|
if (csJson.success) setCompanyName(csJson.data.company_name || "");
|
||||||
if (uJson.success) {
|
if (uJson.success) {
|
||||||
setUsers(
|
setUsers(
|
||||||
uJson.data.map(
|
uJson.data.map(
|
||||||
@@ -886,13 +890,13 @@ export default function TripsAdmin() {
|
|||||||
<div className="print-header">
|
<div className="print-header">
|
||||||
<div className="print-header-left">
|
<div className="print-header-left">
|
||||||
<img
|
<img
|
||||||
src="/images/logo-light.png"
|
src="/api/admin/company-settings/logo?variant=light"
|
||||||
alt="BOHA"
|
alt=""
|
||||||
className="print-logo"
|
className="print-logo"
|
||||||
/>
|
/>
|
||||||
<div className="print-header-text">
|
<div className="print-header-text">
|
||||||
<h1>KNIHA JÍZD</h1>
|
<h1>KNIHA JÍZD</h1>
|
||||||
<div className="company">BOHA Automation s.r.o.</div>
|
<div className="company">{companyName}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="print-header-right">
|
<div className="print-header-right">
|
||||||
|
|||||||
91
src/admin/pagination.css
Normal file
91
src/admin/pagination.css
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
Pagination
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-pagination {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
border-top: 1px solid var(--border-color);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-pagination-info {
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 12px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-pagination-controls {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-pagination-page {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
padding: 0 6px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
background: none;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
cursor: pointer;
|
||||||
|
transition:
|
||||||
|
background 0.15s,
|
||||||
|
color 0.15s,
|
||||||
|
border-color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-pagination-page:hover {
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-pagination-page.active {
|
||||||
|
background: var(--accent-color);
|
||||||
|
color: #fff;
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-pagination-ellipsis {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 28px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-pagination-select {
|
||||||
|
padding: 4px 8px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: var(--border-radius-sm);
|
||||||
|
background: var(--bg-primary);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.admin-pagination {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-pagination-info {
|
||||||
|
order: 2;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
6
src/admin/responsive.css
Normal file
6
src/admin/responsive.css
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
Responsive — Cross-component media queries
|
||||||
|
============================================================================
|
||||||
|
Component-specific media queries live in their respective files.
|
||||||
|
This file is reserved for responsive rules that span multiple components.
|
||||||
|
============================================================================ */
|
||||||
72
src/admin/skeleton.css
vendored
Normal file
72
src/admin/skeleton.css
vendored
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
Skeleton Loading
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-skeleton {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1.5rem;
|
||||||
|
opacity: 0;
|
||||||
|
animation: skeleton-fade-in 0.15s ease 0.08s forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes skeleton-fade-in {
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-skeleton-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-skeleton-line {
|
||||||
|
height: 14px;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: linear-gradient(
|
||||||
|
90deg,
|
||||||
|
var(--bg-tertiary) 25%,
|
||||||
|
var(--border-color) 50%,
|
||||||
|
var(--bg-tertiary) 75%
|
||||||
|
);
|
||||||
|
background-size: 200% 100%;
|
||||||
|
animation: shimmer 1.2s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-skeleton-line.w-full {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.admin-skeleton-line.w-3\/4 {
|
||||||
|
width: 75%;
|
||||||
|
}
|
||||||
|
.admin-skeleton-line.w-1\/2 {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
.admin-skeleton-line.w-1\/3 {
|
||||||
|
width: 33%;
|
||||||
|
}
|
||||||
|
.admin-skeleton-line.w-1\/4 {
|
||||||
|
width: 25%;
|
||||||
|
}
|
||||||
|
.admin-skeleton-line.h-8 {
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
.admin-skeleton-line.h-10 {
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
.admin-skeleton-line.circle {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 50%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skeleton loading on mobile */
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.admin-skeleton {
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
132
src/admin/tables.css
Normal file
132
src/admin/tables.css
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
Tables
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
.admin-table-wrapper,
|
||||||
|
.admin-table-responsive {
|
||||||
|
overflow-x: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 650px;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table th {
|
||||||
|
text-align: left;
|
||||||
|
padding: 10px 16px;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-muted);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table td {
|
||||||
|
padding: 11px 16px;
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.5;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table tr:last-child td {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.admin-table th,
|
||||||
|
.admin-table td {
|
||||||
|
padding: 8px 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table th {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table-avatar {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table-name {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table-username {
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table-user {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table-avatar {
|
||||||
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--accent-light);
|
||||||
|
color: var(--accent-color);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table-name {
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-primary);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table-username {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tables - compact on mobile, better scroll indication */
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.admin-table-wrapper,
|
||||||
|
.admin-table-responsive {
|
||||||
|
margin: 0 -1rem;
|
||||||
|
padding: 0 1rem;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table {
|
||||||
|
min-width: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table th,
|
||||||
|
.admin-table td {
|
||||||
|
padding: 8px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table th {
|
||||||
|
font-size: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-table-actions {
|
||||||
|
gap: 0.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
159
src/admin/variables.css
Normal file
159
src/admin/variables.css
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
CSS Variables
|
||||||
|
============================================================================ */
|
||||||
|
|
||||||
|
:root {
|
||||||
|
/* Spacing scale */
|
||||||
|
--space-1: 0.25rem;
|
||||||
|
--space-2: 0.5rem;
|
||||||
|
--space-3: 0.75rem;
|
||||||
|
--space-4: 1rem;
|
||||||
|
--space-5: 1.25rem;
|
||||||
|
--space-6: 1.5rem;
|
||||||
|
--space-8: 2rem;
|
||||||
|
--space-10: 2.5rem;
|
||||||
|
--space-12: 3rem;
|
||||||
|
|
||||||
|
/* Shared colors */
|
||||||
|
--accent-color: #d63031;
|
||||||
|
--accent-hover: #b52626;
|
||||||
|
--success: #22c55e;
|
||||||
|
--warning: #f59e0b;
|
||||||
|
--danger: #ef4444;
|
||||||
|
--info: #3b82f6;
|
||||||
|
--error: var(--danger);
|
||||||
|
--muted: #9ca3af;
|
||||||
|
--gradient: #d63031;
|
||||||
|
--gradient-subtle: rgba(214, 48, 49, 0.9);
|
||||||
|
|
||||||
|
/* Shared layout */
|
||||||
|
--border-radius: 10px;
|
||||||
|
--border-radius-sm: 8px;
|
||||||
|
--border-radius-lg: 16px;
|
||||||
|
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
--transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
--font-heading: "Urbanist", sans-serif;
|
||||||
|
--font-body: "Plus Jakarta Sans", sans-serif;
|
||||||
|
--font-mono: "DM Mono", "Menlo", monospace;
|
||||||
|
--safe-top: env(safe-area-inset-top, 0px);
|
||||||
|
--safe-bottom: env(safe-area-inset-bottom, 0px);
|
||||||
|
--safe-left: env(safe-area-inset-left, 0px);
|
||||||
|
--safe-right: env(safe-area-inset-right, 0px);
|
||||||
|
--navbar-height: calc(76px + var(--safe-top));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- Dark theme ---- */
|
||||||
|
[data-theme="dark"] {
|
||||||
|
--bg-primary: #0f0f0f;
|
||||||
|
--bg-secondary: #171717;
|
||||||
|
--bg-tertiary: #1e1e1e;
|
||||||
|
--text-primary: #ffffff;
|
||||||
|
--text-secondary: #a0a0a0;
|
||||||
|
--text-muted: #666666;
|
||||||
|
--text-tertiary: #555555;
|
||||||
|
--border-color: rgba(255, 255, 255, 0.08);
|
||||||
|
--border-color-hover: rgba(255, 255, 255, 0.15);
|
||||||
|
--glass-bg: #171717;
|
||||||
|
--glass-bg-solid: #171717;
|
||||||
|
--glass-border: rgba(255, 255, 255, 0.08);
|
||||||
|
--glass-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.15);
|
||||||
|
--card-bg: #1a1a1a;
|
||||||
|
--card-bg-hover: #1e1e1e;
|
||||||
|
--input-bg: #1a1a1a;
|
||||||
|
--glow-color: rgba(214, 48, 49, 0.15);
|
||||||
|
--accent-light: rgba(214, 48, 49, 0.1);
|
||||||
|
--accent-soft: #2a1a1a;
|
||||||
|
--accent-glow: rgba(214, 48, 49, 0.3);
|
||||||
|
--success-light: rgba(34, 197, 94, 0.1);
|
||||||
|
--success-soft: #1a2a1e;
|
||||||
|
--warning-light: rgba(245, 158, 11, 0.1);
|
||||||
|
--warning-soft: #2a2518;
|
||||||
|
--danger-light: rgba(239, 68, 68, 0.1);
|
||||||
|
--danger-soft: #2a1a1a;
|
||||||
|
--info-light: rgba(59, 130, 246, 0.1);
|
||||||
|
--info-soft: #1a1e2a;
|
||||||
|
--muted-light: rgba(107, 114, 128, 0.15);
|
||||||
|
--orb-color-1: rgba(214, 48, 49, 0.2);
|
||||||
|
--orb-color-2: rgba(120, 119, 198, 0.15);
|
||||||
|
--calendar-icon-filter: invert(1);
|
||||||
|
--select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a0a0a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
|
||||||
|
--table-row-hover: rgba(255, 255, 255, 0.02);
|
||||||
|
--row-current: color-mix(in srgb, var(--success) 5%, transparent);
|
||||||
|
--row-current-hover: color-mix(in srgb, var(--success) 8%, transparent);
|
||||||
|
--row-draft: color-mix(in srgb, var(--warning) 6%, transparent);
|
||||||
|
--row-expired: color-mix(in srgb, var(--danger) 5%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- Light theme ---- */
|
||||||
|
[data-theme="light"] {
|
||||||
|
--success: #15803d;
|
||||||
|
--warning: #b45309;
|
||||||
|
--danger: #b91c1c;
|
||||||
|
--info: #1d4ed8;
|
||||||
|
--accent-color: #c73030;
|
||||||
|
--accent-hover: #b52828;
|
||||||
|
--muted: #6b7280;
|
||||||
|
--bg-primary: #f5f4f2;
|
||||||
|
--bg-secondary: #ffffff;
|
||||||
|
--bg-tertiary: #eeecea;
|
||||||
|
--text-primary: #1a1a1a;
|
||||||
|
--text-secondary: #555555;
|
||||||
|
--text-muted: #717180;
|
||||||
|
--text-tertiary: #8a8a96;
|
||||||
|
--border-color: rgba(0, 0, 0, 0.1);
|
||||||
|
--border-color-hover: rgba(0, 0, 0, 0.18);
|
||||||
|
--glass-bg: #ffffff;
|
||||||
|
--glass-bg-solid: #ffffff;
|
||||||
|
--glass-border: rgba(0, 0, 0, 0.08);
|
||||||
|
--glass-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
|
||||||
|
--card-bg: #ffffff;
|
||||||
|
--card-bg-hover: #ffffff;
|
||||||
|
--input-bg: #ffffff;
|
||||||
|
--glow-color: rgba(222, 58, 58, 0.08);
|
||||||
|
--accent-light: rgba(222, 58, 58, 0.08);
|
||||||
|
--accent-soft: #fff0f0;
|
||||||
|
--accent-glow: rgba(222, 58, 58, 0.15);
|
||||||
|
--success-light: rgba(34, 197, 94, 0.1);
|
||||||
|
--success-soft: #e8fbf7;
|
||||||
|
--warning-light: rgba(245, 158, 11, 0.1);
|
||||||
|
--warning-soft: #fef9ec;
|
||||||
|
--danger-light: rgba(239, 68, 68, 0.1);
|
||||||
|
--danger-soft: #fef2f2;
|
||||||
|
--info-light: rgba(59, 130, 246, 0.1);
|
||||||
|
--info-soft: #ebf3fd;
|
||||||
|
--muted-light: rgba(107, 114, 128, 0.12);
|
||||||
|
--calendar-icon-filter: none;
|
||||||
|
--select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23555555' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
|
||||||
|
--table-row-hover: rgba(0, 0, 0, 0.03);
|
||||||
|
--row-current: var(--success-soft);
|
||||||
|
--row-current-hover: color-mix(in srgb, var(--success) 12%, transparent);
|
||||||
|
--row-draft: var(--warning-soft);
|
||||||
|
--row-expired: var(--danger-soft);
|
||||||
|
--orb-color-1: rgba(214, 48, 49, 0.12);
|
||||||
|
--orb-color-2: rgba(120, 119, 198, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Light mode - jemnejsi stiny */
|
||||||
|
[data-theme="light"] .admin-toast {
|
||||||
|
box-shadow:
|
||||||
|
0 2px 8px rgba(0, 0, 0, 0.08),
|
||||||
|
0 1px 3px rgba(0, 0, 0, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="light"] .react-datepicker {
|
||||||
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="light"] .admin-rich-editor .ql-snow .ql-picker-options,
|
||||||
|
[data-theme="light"] .admin-rich-editor .ql-snow .ql-tooltip {
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="light"] .admin-customer-dropdown,
|
||||||
|
[data-theme="light"] .offers-template-menu {
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="light"] .dash-quick-btn:hover {
|
||||||
|
filter: brightness(0.9);
|
||||||
|
}
|
||||||
@@ -63,7 +63,7 @@ export const config = {
|
|||||||
contactTo: process.env.CONTACT_EMAIL_TO || "",
|
contactTo: process.env.CONTACT_EMAIL_TO || "",
|
||||||
contactFrom: process.env.CONTACT_EMAIL_FROM || "",
|
contactFrom: process.env.CONTACT_EMAIL_FROM || "",
|
||||||
smtpFrom: process.env.SMTP_FROM || "",
|
smtpFrom: process.env.SMTP_FROM || "",
|
||||||
smtpFromName: process.env.SMTP_FROM_NAME || "BOHA Automation",
|
smtpFromName: process.env.SMTP_FROM_NAME || "",
|
||||||
leaveNotify: process.env.LEAVE_NOTIFY_EMAIL || "",
|
leaveNotify: process.env.LEAVE_NOTIFY_EMAIL || "",
|
||||||
invoiceAlert: process.env.INVOICE_ALERT_EMAIL || "",
|
invoiceAlert: process.env.INVOICE_ALERT_EMAIL || "",
|
||||||
},
|
},
|
||||||
@@ -75,8 +75,6 @@ export const config = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
security: {
|
security: {
|
||||||
maxLoginAttempts: 5,
|
|
||||||
lockoutMinutes: 15,
|
|
||||||
bcryptCost: 12,
|
bcryptCost: 12,
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ export async function securityHeaders(
|
|||||||
"Content-Security-Policy",
|
"Content-Security-Policy",
|
||||||
[
|
[
|
||||||
"default-src 'self'",
|
"default-src 'self'",
|
||||||
"script-src 'self' https://unpkg.com",
|
"script-src 'self'",
|
||||||
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://unpkg.com",
|
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
|
||||||
"font-src 'self' https://fonts.gstatic.com",
|
"font-src 'self' https://fonts.gstatic.com",
|
||||||
"img-src 'self' data: blob: https://*.tile.openstreetmap.org",
|
"img-src 'self' data: blob: https://*.tile.openstreetmap.org",
|
||||||
"connect-src 'self' https://nominatim.openstreetmap.org",
|
"connect-src 'self' https://nominatim.openstreetmap.org",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default async function bankAccountsRoutes(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
fastify.get(
|
fastify.get(
|
||||||
"/",
|
"/",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (_request, reply) => {
|
async (_request, reply) => {
|
||||||
const accounts = await prisma.bank_accounts.findMany({
|
const accounts = await prisma.bank_accounts.findMany({
|
||||||
orderBy: { position: "asc" },
|
orderBy: { position: "asc" },
|
||||||
@@ -25,7 +25,7 @@ export default async function bankAccountsRoutes(
|
|||||||
|
|
||||||
fastify.post(
|
fastify.post(
|
||||||
"/",
|
"/",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const parsed = parseBody(CreateBankAccountSchema, request.body);
|
const parsed = parseBody(CreateBankAccountSchema, request.body);
|
||||||
if ("error" in parsed) return error(reply, parsed.error, 400);
|
if ("error" in parsed) return error(reply, parsed.error, 400);
|
||||||
@@ -59,7 +59,7 @@ export default async function bankAccountsRoutes(
|
|||||||
|
|
||||||
fastify.put<{ Params: { id: string } }>(
|
fastify.put<{ Params: { id: string } }>(
|
||||||
"/:id",
|
"/:id",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const id = parseId(request.params.id, reply);
|
const id = parseId(request.params.id, reply);
|
||||||
if (id === null) return;
|
if (id === null) return;
|
||||||
@@ -126,7 +126,7 @@ export default async function bankAccountsRoutes(
|
|||||||
|
|
||||||
fastify.delete<{ Params: { id: string } }>(
|
fastify.delete<{ Params: { id: string } }>(
|
||||||
"/:id",
|
"/:id",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const id = parseId(request.params.id, reply);
|
const id = parseId(request.params.id, reply);
|
||||||
if (id === null) return;
|
if (id === null) return;
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ import { logAudit } from "../../services/audit";
|
|||||||
import { success, error } from "../../utils/response";
|
import { success, error } from "../../utils/response";
|
||||||
import multipart from "@fastify/multipart";
|
import multipart from "@fastify/multipart";
|
||||||
import { parseBody } from "../../schemas/common";
|
import { parseBody } from "../../schemas/common";
|
||||||
import { UpdateCompanySettingsSchema } from "../../schemas/company-settings.schema";
|
import { UpdateCompanySettingsSchema } from "../../schemas/settings.schema";
|
||||||
|
import { invalidateSettingsCache } from "../../services/system-settings";
|
||||||
|
import os from "os";
|
||||||
|
import { config } from "../../config/env";
|
||||||
|
import { NasFileManager } from "../../services/nas-file-manager";
|
||||||
|
import { nasFinancialsManager } from "../../services/nas-financials-manager";
|
||||||
|
import { nasOffersManager } from "../../services/nas-offers-manager";
|
||||||
|
|
||||||
/** Encode custom_fields + supplier_field_order into a single JSON blob (matching PHP format) */
|
/** Encode custom_fields + supplier_field_order into a single JSON blob (matching PHP format) */
|
||||||
function encodeCustomFields(
|
function encodeCustomFields(
|
||||||
@@ -53,27 +59,37 @@ export default async function companySettingsRoutes(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await fastify.register(multipart, { limits: { fileSize: 5 * 1024 * 1024 } });
|
await fastify.register(multipart, { limits: { fileSize: 5 * 1024 * 1024 } });
|
||||||
|
|
||||||
// GET /api/admin/company-settings/logo
|
// GET /api/admin/company-settings/logo?variant=light|dark
|
||||||
fastify.get("/logo", { preHandler: requireAuth }, async (_request, reply) => {
|
fastify.get("/logo", { preHandler: requireAuth }, async (request, reply) => {
|
||||||
const settings = await prisma.company_settings.findFirst({
|
const query = request.query as Record<string, string>;
|
||||||
select: { logo_data: true },
|
const variant = query.variant === "dark" ? "dark" : "light";
|
||||||
});
|
const column = variant === "dark" ? "logo_data_dark" : "logo_data";
|
||||||
if (!settings?.logo_data) return error(reply, "Logo nenalezeno", 404);
|
|
||||||
|
const settings = await prisma.company_settings.findFirst({
|
||||||
|
select: { [column]: true },
|
||||||
|
});
|
||||||
|
const buf = settings?.[column] as unknown as Buffer | null;
|
||||||
|
if (!buf) return error(reply, "Logo nenalezeno", 404);
|
||||||
|
|
||||||
// Detect image type from magic bytes
|
|
||||||
const buf = settings.logo_data;
|
|
||||||
let mime = "image/png";
|
let mime = "image/png";
|
||||||
if (buf[0] === 0xff && buf[1] === 0xd8) mime = "image/jpeg";
|
if (buf[0] === 0xff && buf[1] === 0xd8) mime = "image/jpeg";
|
||||||
else if (buf[0] === 0x47 && buf[1] === 0x49) mime = "image/gif";
|
else if (buf[0] === 0x47 && buf[1] === 0x49) mime = "image/gif";
|
||||||
|
|
||||||
return reply.type(mime).send(buf);
|
return reply
|
||||||
|
.type(mime)
|
||||||
|
.header("Cache-Control", "public, max-age=3600")
|
||||||
|
.send(buf);
|
||||||
});
|
});
|
||||||
|
|
||||||
// POST /api/admin/company-settings/logo
|
// POST /api/admin/company-settings/logo?variant=light|dark
|
||||||
fastify.post(
|
fastify.post(
|
||||||
"/logo",
|
"/logo",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
|
const query = request.query as Record<string, string>;
|
||||||
|
const variant = query.variant === "dark" ? "dark" : "light";
|
||||||
|
const column = variant === "dark" ? "logo_data_dark" : "logo_data";
|
||||||
|
|
||||||
const file = await request.file();
|
const file = await request.file();
|
||||||
if (!file) return error(reply, "Nebyl nahrán žádný soubor", 400);
|
if (!file) return error(reply, "Nebyl nahrán žádný soubor", 400);
|
||||||
|
|
||||||
@@ -92,7 +108,7 @@ export default async function companySettingsRoutes(
|
|||||||
|
|
||||||
await prisma.company_settings.update({
|
await prisma.company_settings.update({
|
||||||
where: { id: existing.id },
|
where: { id: existing.id },
|
||||||
data: { logo_data: new Uint8Array(buffer), modified_at: new Date() },
|
data: { [column]: new Uint8Array(buffer), modified_at: new Date() },
|
||||||
});
|
});
|
||||||
|
|
||||||
await logAudit({
|
await logAudit({
|
||||||
@@ -101,7 +117,7 @@ export default async function companySettingsRoutes(
|
|||||||
action: "update",
|
action: "update",
|
||||||
entityType: "company_settings",
|
entityType: "company_settings",
|
||||||
entityId: existing.id,
|
entityId: existing.id,
|
||||||
description: "Nahráno logo",
|
description: `Nahráno logo (${variant})`,
|
||||||
});
|
});
|
||||||
return success(reply, null, 200, "Logo nahráno");
|
return success(reply, null, 200, "Logo nahráno");
|
||||||
},
|
},
|
||||||
@@ -129,6 +145,22 @@ export default async function companySettingsRoutes(
|
|||||||
order_type_code: true,
|
order_type_code: true,
|
||||||
invoice_type_code: true,
|
invoice_type_code: true,
|
||||||
require_2fa: true,
|
require_2fa: true,
|
||||||
|
break_threshold_hours: true,
|
||||||
|
break_duration_short: true,
|
||||||
|
break_duration_long: true,
|
||||||
|
clock_rounding_minutes: true,
|
||||||
|
invoice_alert_email: true,
|
||||||
|
leave_notify_email: true,
|
||||||
|
max_login_attempts: true,
|
||||||
|
lockout_minutes: true,
|
||||||
|
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,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -160,32 +192,156 @@ export default async function companySettingsRoutes(
|
|||||||
order_type_code: true,
|
order_type_code: true,
|
||||||
invoice_type_code: true,
|
invoice_type_code: true,
|
||||||
require_2fa: true,
|
require_2fa: true,
|
||||||
|
break_threshold_hours: true,
|
||||||
|
break_duration_short: true,
|
||||||
|
break_duration_long: true,
|
||||||
|
clock_rounding_minutes: true,
|
||||||
|
invoice_alert_email: true,
|
||||||
|
leave_notify_email: true,
|
||||||
|
max_login_attempts: true,
|
||||||
|
lockout_minutes: true,
|
||||||
|
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
|
// Check if logo exists
|
||||||
const logoCheck = await prisma.company_settings.findFirst({
|
const logoCheck = await prisma.company_settings.findFirst({
|
||||||
where: { id: settings.id },
|
where: { id: settings.id },
|
||||||
select: { logo_data: true },
|
select: { logo_data: true, logo_data_dark: true },
|
||||||
});
|
});
|
||||||
const has_logo = !!logoCheck?.logo_data;
|
const has_logo = !!logoCheck?.logo_data;
|
||||||
|
const has_logo_dark = !!logoCheck?.logo_data_dark;
|
||||||
|
|
||||||
const { custom_fields, supplier_field_order } = decodeCustomFields(
|
const { custom_fields, supplier_field_order } = decodeCustomFields(
|
||||||
settings.custom_fields as string | null,
|
settings.custom_fields as string | null,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
const raw = settings.available_vat_rates as string | null;
|
||||||
|
if (raw) {
|
||||||
|
const parsed = JSON.parse(raw);
|
||||||
|
if (Array.isArray(parsed) && parsed.length > 0)
|
||||||
|
available_vat_rates = parsed;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
|
||||||
|
let available_currencies: string[] = ["CZK", "EUR", "USD", "GBP"];
|
||||||
|
try {
|
||||||
|
const raw = settings.available_currencies as string | null;
|
||||||
|
if (raw) {
|
||||||
|
const parsed = JSON.parse(raw);
|
||||||
|
if (Array.isArray(parsed) && parsed.length > 0)
|
||||||
|
available_currencies = parsed;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
|
||||||
return success(reply, {
|
return success(reply, {
|
||||||
...settings,
|
...settings,
|
||||||
custom_fields,
|
custom_fields,
|
||||||
supplier_field_order,
|
supplier_field_order,
|
||||||
|
available_vat_rates,
|
||||||
|
available_currencies,
|
||||||
has_logo,
|
has_logo,
|
||||||
|
has_logo_dark,
|
||||||
|
app_version: pkg.version,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// GET /api/admin/company-settings/system-info
|
||||||
|
fastify.get(
|
||||||
|
"/system-info",
|
||||||
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
|
async (request, reply) => {
|
||||||
|
// 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);
|
||||||
|
const mins = Math.floor((uptimeSec % 3600) / 60);
|
||||||
|
const uptimeStr =
|
||||||
|
days > 0
|
||||||
|
? `${days}d ${hours}h ${mins}m`
|
||||||
|
: hours > 0
|
||||||
|
? `${hours}h ${mins}m`
|
||||||
|
: `${mins}m`;
|
||||||
|
|
||||||
|
const mem = process.memoryUsage();
|
||||||
|
const totalMem = os.totalmem();
|
||||||
|
const freeMem = os.freemem();
|
||||||
|
|
||||||
|
// DB connection check
|
||||||
|
let dbStatus = "ok";
|
||||||
|
let migrationCount = 0;
|
||||||
|
try {
|
||||||
|
const result = await prisma.$queryRaw<[{ cnt: bigint }]>`
|
||||||
|
SELECT COUNT(*) as cnt FROM _prisma_migrations WHERE finished_at IS NOT NULL
|
||||||
|
`;
|
||||||
|
migrationCount = Number(result[0]?.cnt ?? 0);
|
||||||
|
} catch (err) {
|
||||||
|
dbStatus = "error";
|
||||||
|
request.log.error(err, "DB health check failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// NAS status
|
||||||
|
const projectNas = new NasFileManager();
|
||||||
|
|
||||||
|
return success(reply, {
|
||||||
|
app_version: pkg.version,
|
||||||
|
node_version: process.version,
|
||||||
|
platform: `${os.type()} ${os.release()}`,
|
||||||
|
uptime: uptimeStr,
|
||||||
|
environment: config.appEnv,
|
||||||
|
timezone:
|
||||||
|
process.env.TZ || Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||||
|
memory: {
|
||||||
|
rss: `${Math.round(mem.rss / 1024 / 1024)} MB`,
|
||||||
|
heap_used: `${Math.round(mem.heapUsed / 1024 / 1024)} MB`,
|
||||||
|
heap_total: `${Math.round(mem.heapTotal / 1024 / 1024)} MB`,
|
||||||
|
system_total: `${Math.round(totalMem / 1024 / 1024)} MB`,
|
||||||
|
system_free: `${Math.round(freeMem / 1024 / 1024)} MB`,
|
||||||
|
},
|
||||||
|
database: {
|
||||||
|
status: dbStatus,
|
||||||
|
migrations_applied: migrationCount,
|
||||||
|
},
|
||||||
|
nas: {
|
||||||
|
projects: {
|
||||||
|
configured: projectNas.isConfigured(),
|
||||||
|
path: config.nas.path || "—",
|
||||||
|
},
|
||||||
|
financials: {
|
||||||
|
configured: nasFinancialsManager.isConfigured(),
|
||||||
|
path: config.nas.financialsPath || "—",
|
||||||
|
},
|
||||||
|
offers: {
|
||||||
|
configured: nasOffersManager.isConfigured(),
|
||||||
|
path: config.nas.offersPath || "—",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
fastify.put(
|
fastify.put(
|
||||||
"/",
|
"/",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const parsed = parseBody(UpdateCompanySettingsSchema, request.body);
|
const parsed = parseBody(UpdateCompanySettingsSchema, request.body);
|
||||||
if ("error" in parsed) return error(reply, parsed.error, 400);
|
if ("error" in parsed) return error(reply, parsed.error, 400);
|
||||||
@@ -207,6 +363,13 @@ export default async function companySettingsRoutes(
|
|||||||
"default_currency",
|
"default_currency",
|
||||||
"order_type_code",
|
"order_type_code",
|
||||||
"invoice_type_code",
|
"invoice_type_code",
|
||||||
|
"invoice_alert_email",
|
||||||
|
"leave_notify_email",
|
||||||
|
"smtp_from",
|
||||||
|
"smtp_from_name",
|
||||||
|
"offer_number_pattern",
|
||||||
|
"order_number_pattern",
|
||||||
|
"invoice_number_pattern",
|
||||||
];
|
];
|
||||||
const bodyRec = body as Record<string, unknown>;
|
const bodyRec = body as Record<string, unknown>;
|
||||||
for (const f of strFields) {
|
for (const f of strFields) {
|
||||||
@@ -216,6 +379,24 @@ export default async function companySettingsRoutes(
|
|||||||
if (body.default_vat_rate !== undefined)
|
if (body.default_vat_rate !== undefined)
|
||||||
data.default_vat_rate = Number(body.default_vat_rate);
|
data.default_vat_rate = Number(body.default_vat_rate);
|
||||||
if (body.require_2fa !== undefined) data.require_2fa = !!body.require_2fa;
|
if (body.require_2fa !== undefined) data.require_2fa = !!body.require_2fa;
|
||||||
|
|
||||||
|
const numFields = [
|
||||||
|
"break_threshold_hours",
|
||||||
|
"break_duration_short",
|
||||||
|
"break_duration_long",
|
||||||
|
"clock_rounding_minutes",
|
||||||
|
"max_login_attempts",
|
||||||
|
"lockout_minutes",
|
||||||
|
"max_requests_per_minute",
|
||||||
|
] as const;
|
||||||
|
for (const f of numFields) {
|
||||||
|
if (bodyRec[f] !== undefined) data[f] = Number(bodyRec[f]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.available_vat_rates !== undefined)
|
||||||
|
data.available_vat_rates = JSON.stringify(body.available_vat_rates);
|
||||||
|
if (body.available_currencies !== undefined)
|
||||||
|
data.available_currencies = JSON.stringify(body.available_currencies);
|
||||||
if (
|
if (
|
||||||
body.custom_fields !== undefined ||
|
body.custom_fields !== undefined ||
|
||||||
body.supplier_field_order !== undefined
|
body.supplier_field_order !== undefined
|
||||||
@@ -247,6 +428,8 @@ export default async function companySettingsRoutes(
|
|||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
invalidateSettingsCache();
|
||||||
|
|
||||||
await logAudit({
|
await logAudit({
|
||||||
request,
|
request,
|
||||||
authData: request.authData,
|
authData: request.authData,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import prisma from "../../config/database";
|
|||||||
import { requireAuth } from "../../middleware/auth";
|
import { requireAuth } from "../../middleware/auth";
|
||||||
import { success } from "../../utils/response";
|
import { success } from "../../utils/response";
|
||||||
import { localTimeStr } from "../../utils/date";
|
import { localTimeStr } from "../../utils/date";
|
||||||
|
import { toCzk } from "../../services/exchange-rates";
|
||||||
|
|
||||||
export default async function dashboardRoutes(
|
export default async function dashboardRoutes(
|
||||||
fastify: FastifyInstance,
|
fastify: FastifyInstance,
|
||||||
@@ -206,10 +207,13 @@ export default async function dashboardRoutes(
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
unpaid_count: unpaidCount,
|
unpaid_count: unpaidCount,
|
||||||
revenue_czk:
|
revenue_czk: await (async () => {
|
||||||
revenueByCurrency["CZK"] != null
|
let total = 0;
|
||||||
? Math.round(revenueByCurrency["CZK"] * 100) / 100
|
for (const [cur, amount] of Object.entries(revenueByCurrency)) {
|
||||||
: null,
|
total += await toCzk(Math.round(amount * 100) / 100, cur);
|
||||||
|
}
|
||||||
|
return Math.round(total * 100) / 100;
|
||||||
|
})(),
|
||||||
};
|
};
|
||||||
result.unpaid_invoices = unpaidCount;
|
result.unpaid_invoices = unpaidCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { requirePermission } from "../../middleware/auth";
|
|||||||
import { localDateCzStr } from "../../utils/date";
|
import { localDateCzStr } from "../../utils/date";
|
||||||
import { nasFinancialsManager } from "../../services/nas-financials-manager";
|
import { nasFinancialsManager } from "../../services/nas-financials-manager";
|
||||||
import { htmlToPdf } from "../../utils/html-to-pdf";
|
import { htmlToPdf } from "../../utils/html-to-pdf";
|
||||||
|
import { getRate } from "../../services/exchange-rates";
|
||||||
|
import { localDateStr } from "../../utils/date";
|
||||||
|
|
||||||
/* ── Helpers ─────────────────────────────────────────────────────── */
|
/* ── Helpers ─────────────────────────────────────────────────────── */
|
||||||
|
|
||||||
@@ -358,9 +360,12 @@ export default async function invoicesPdfRoutes(
|
|||||||
// QR generation failed — leave empty
|
// QR generation failed — leave empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// VAT recapitulation (always in CZK)
|
// VAT recapitulation (always in CZK — Czech tax requirement)
|
||||||
const isForeign = currency.toUpperCase() !== "CZK";
|
const isForeign = currency.toUpperCase() !== "CZK";
|
||||||
const cnbRate = 1.0; // Skip CNB rate conversion
|
const issueDateStr = invoice.issue_date
|
||||||
|
? localDateStr(new Date(invoice.issue_date))
|
||||||
|
: undefined;
|
||||||
|
const cnbRate = isForeign ? await getRate(currency, issueDateStr) : 1.0;
|
||||||
const vatRates = [21, 12, 0];
|
const vatRates = [21, 12, 0];
|
||||||
const vatRecap: Array<{
|
const vatRecap: Array<{
|
||||||
rate: number;
|
rate: number;
|
||||||
@@ -1007,6 +1012,17 @@ ${indentCSS}
|
|||||||
<tbody>
|
<tbody>
|
||||||
${vatRecapHtml}
|
${vatRecapHtml}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
${
|
||||||
|
isForeign
|
||||||
|
? `<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="4" style="font-size:0.7em; color:#666; padding-top:6px; text-align:left;">
|
||||||
|
Přepočet kurzem ČNB ke dni ${formatDate(invoice.issue_date)}: 1 ${escapeHtml(currency)} = ${cnbRate.toFixed(3).replace(".", ",")} CZK
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>`
|
||||||
|
: ""
|
||||||
|
}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
UpdateReceivedInvoiceSchema,
|
UpdateReceivedInvoiceSchema,
|
||||||
} from "../../schemas/received-invoices.schema";
|
} from "../../schemas/received-invoices.schema";
|
||||||
import { nasFinancialsManager } from "../../services/nas-financials-manager";
|
import { nasFinancialsManager } from "../../services/nas-financials-manager";
|
||||||
|
import { toCzk } from "../../services/exchange-rates";
|
||||||
|
|
||||||
const VALID_STATUSES = ["unpaid", "paid"] as const;
|
const VALID_STATUSES = ["unpaid", "paid"] as const;
|
||||||
const ALLOWED_SORT_FIELDS = [
|
const ALLOWED_SORT_FIELDS = [
|
||||||
@@ -108,12 +109,15 @@ export default async function receivedInvoicesRoutes(
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const sumCzk = (
|
const sumCzk = async (
|
||||||
invs: typeof monthInvoices,
|
invs: typeof monthInvoices,
|
||||||
field: "amount" | "vat_amount",
|
field: "amount" | "vat_amount",
|
||||||
) => {
|
) => {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
for (const inv of invs) total += Number(inv[field]) || 0;
|
for (const inv of invs) {
|
||||||
|
const amount = Number(inv[field]) || 0;
|
||||||
|
total += await toCzk(amount, inv.currency);
|
||||||
|
}
|
||||||
return Math.round(total * 100) / 100;
|
return Math.round(total * 100) / 100;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -124,11 +128,11 @@ export default async function receivedInvoicesRoutes(
|
|||||||
|
|
||||||
return success(reply, {
|
return success(reply, {
|
||||||
total_month: aggregateByCurrency(monthInvoices, "amount"),
|
total_month: aggregateByCurrency(monthInvoices, "amount"),
|
||||||
total_month_czk: sumCzk(monthInvoices, "amount"),
|
total_month_czk: await sumCzk(monthInvoices, "amount"),
|
||||||
vat_month: aggregateByCurrency(monthInvoices, "vat_amount"),
|
vat_month: aggregateByCurrency(monthInvoices, "vat_amount"),
|
||||||
vat_month_czk: sumCzk(monthInvoices, "vat_amount"),
|
vat_month_czk: await sumCzk(monthInvoices, "vat_amount"),
|
||||||
unpaid: aggregateByCurrency(allUnpaid, "amount"),
|
unpaid: aggregateByCurrency(allUnpaid, "amount"),
|
||||||
unpaid_czk: sumCzk(allUnpaid, "amount"),
|
unpaid_czk: await sumCzk(allUnpaid, "amount"),
|
||||||
unpaid_count: allUnpaid.length,
|
unpaid_count: allUnpaid.length,
|
||||||
month_count: monthInvoices.length,
|
month_count: monthInvoices.length,
|
||||||
});
|
});
|
||||||
@@ -236,7 +240,7 @@ export default async function receivedInvoicesRoutes(
|
|||||||
try {
|
try {
|
||||||
invoicesMeta = JSON.parse(part.value as string);
|
invoicesMeta = JSON.parse(part.value as string);
|
||||||
} catch {
|
} catch {
|
||||||
/* ignore parse error */
|
// Malformed invoices metadata — ignore, use defaults
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default async function rolesRoutes(
|
|||||||
// GET /api/admin/roles
|
// GET /api/admin/roles
|
||||||
fastify.get(
|
fastify.get(
|
||||||
"/",
|
"/",
|
||||||
{ preHandler: requirePermission("settings.roles") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const roles = await prisma.roles.findMany({
|
const roles = await prisma.roles.findMany({
|
||||||
include: {
|
include: {
|
||||||
@@ -35,7 +35,7 @@ export default async function rolesRoutes(
|
|||||||
// GET /api/admin/roles/permissions
|
// GET /api/admin/roles/permissions
|
||||||
fastify.get(
|
fastify.get(
|
||||||
"/permissions",
|
"/permissions",
|
||||||
{ preHandler: requirePermission("settings.roles") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (_request, reply) => {
|
async (_request, reply) => {
|
||||||
const permissions = await prisma.permissions.findMany({
|
const permissions = await prisma.permissions.findMany({
|
||||||
orderBy: { module: "asc" },
|
orderBy: { module: "asc" },
|
||||||
@@ -47,7 +47,7 @@ export default async function rolesRoutes(
|
|||||||
// POST /api/admin/roles
|
// POST /api/admin/roles
|
||||||
fastify.post(
|
fastify.post(
|
||||||
"/",
|
"/",
|
||||||
{ preHandler: requirePermission("settings.roles") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const parsed = parseBody(CreateRoleSchema, request.body);
|
const parsed = parseBody(CreateRoleSchema, request.body);
|
||||||
if ("error" in parsed) return error(reply, parsed.error, 400);
|
if ("error" in parsed) return error(reply, parsed.error, 400);
|
||||||
@@ -86,7 +86,7 @@ export default async function rolesRoutes(
|
|||||||
// PUT /api/admin/roles/:id
|
// PUT /api/admin/roles/:id
|
||||||
fastify.put<{ Params: { id: string } }>(
|
fastify.put<{ Params: { id: string } }>(
|
||||||
"/:id",
|
"/:id",
|
||||||
{ preHandler: requirePermission("settings.roles") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const id = parseId(request.params.id, reply);
|
const id = parseId(request.params.id, reply);
|
||||||
if (id === null) return;
|
if (id === null) return;
|
||||||
@@ -136,7 +136,7 @@ export default async function rolesRoutes(
|
|||||||
// DELETE /api/admin/roles/:id
|
// DELETE /api/admin/roles/:id
|
||||||
fastify.delete<{ Params: { id: string } }>(
|
fastify.delete<{ Params: { id: string } }>(
|
||||||
"/:id",
|
"/:id",
|
||||||
{ preHandler: requirePermission("settings.roles") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const id = parseId(request.params.id, reply);
|
const id = parseId(request.params.id, reply);
|
||||||
if (id === null) return;
|
if (id === null) return;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default async function scopeTemplatesRoutes(
|
|||||||
// Legacy ?action= dispatcher for item templates
|
// Legacy ?action= dispatcher for item templates
|
||||||
fastify.get(
|
fastify.get(
|
||||||
"/",
|
"/",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const query = request.query as Record<string, unknown>;
|
const query = request.query as Record<string, unknown>;
|
||||||
const action = query.action ? String(query.action) : null;
|
const action = query.action ? String(query.action) : null;
|
||||||
@@ -53,7 +53,7 @@ export default async function scopeTemplatesRoutes(
|
|||||||
// Item template CRUD via ?action=item
|
// Item template CRUD via ?action=item
|
||||||
fastify.post(
|
fastify.post(
|
||||||
"/",
|
"/",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const query = request.query as Record<string, unknown>;
|
const query = request.query as Record<string, unknown>;
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ export default async function scopeTemplatesRoutes(
|
|||||||
// Item template delete via DELETE ?action=item&id=X
|
// Item template delete via DELETE ?action=item&id=X
|
||||||
fastify.delete(
|
fastify.delete(
|
||||||
"/",
|
"/",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const query = request.query as Record<string, unknown>;
|
const query = request.query as Record<string, unknown>;
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ export default async function scopeTemplatesRoutes(
|
|||||||
|
|
||||||
fastify.get<{ Params: { id: string } }>(
|
fastify.get<{ Params: { id: string } }>(
|
||||||
"/:id",
|
"/:id",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const id = parseId(request.params.id, reply);
|
const id = parseId(request.params.id, reply);
|
||||||
if (id === null) return;
|
if (id === null) return;
|
||||||
@@ -161,7 +161,7 @@ export default async function scopeTemplatesRoutes(
|
|||||||
|
|
||||||
fastify.put<{ Params: { id: string } }>(
|
fastify.put<{ Params: { id: string } }>(
|
||||||
"/:id",
|
"/:id",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const id = parseId(request.params.id, reply);
|
const id = parseId(request.params.id, reply);
|
||||||
if (id === null) return;
|
if (id === null) return;
|
||||||
@@ -208,7 +208,7 @@ export default async function scopeTemplatesRoutes(
|
|||||||
|
|
||||||
fastify.delete<{ Params: { id: string } }>(
|
fastify.delete<{ Params: { id: string } }>(
|
||||||
"/:id",
|
"/:id",
|
||||||
{ preHandler: requirePermission("offers.settings") },
|
{ preHandler: requirePermission("settings.manage") },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const id = parseId(request.params.id, reply);
|
const id = parseId(request.params.id, reply);
|
||||||
if (id === null) return;
|
if (id === null) return;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import prisma from "../../config/database";
|
|||||||
import { requireAuth, requirePermission } from "../../middleware/auth";
|
import { requireAuth, requirePermission } from "../../middleware/auth";
|
||||||
import { success, error } from "../../utils/response";
|
import { success, error } from "../../utils/response";
|
||||||
import { encrypt } from "../../utils/encryption";
|
import { encrypt } from "../../utils/encryption";
|
||||||
|
import { getSystemSettings } from "../../services/system-settings";
|
||||||
import { OTPAuth } from "../../utils/totp";
|
import { OTPAuth } from "../../utils/totp";
|
||||||
import * as OTPAuthLib from "otpauth";
|
import * as OTPAuthLib from "otpauth";
|
||||||
import { logAudit } from "../../services/audit";
|
import { logAudit } from "../../services/audit";
|
||||||
@@ -16,9 +17,18 @@ export default async function totpRoutes(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// GET - generate new TOTP secret
|
// GET - generate new TOTP secret
|
||||||
fastify.get("/setup", { preHandler: requireAuth }, async (request, reply) => {
|
fastify.get("/setup", { preHandler: requireAuth }, async (request, reply) => {
|
||||||
|
const settings = await getSystemSettings();
|
||||||
|
const companyName =
|
||||||
|
(
|
||||||
|
await prisma.company_settings.findFirst({
|
||||||
|
select: { company_name: true },
|
||||||
|
})
|
||||||
|
)?.company_name ||
|
||||||
|
settings.smtp_from_name ||
|
||||||
|
"System";
|
||||||
const secret = new OTPAuthLib.Secret();
|
const secret = new OTPAuthLib.Secret();
|
||||||
const totp = new OTPAuthLib.TOTP({
|
const totp = new OTPAuthLib.TOTP({
|
||||||
issuer: "BOHA Automation",
|
issuer: companyName,
|
||||||
label: request.authData!.email,
|
label: request.authData!.email,
|
||||||
secret,
|
secret,
|
||||||
algorithm: "SHA1",
|
algorithm: "SHA1",
|
||||||
@@ -153,7 +163,7 @@ export default async function totpRoutes(
|
|||||||
// GET - check if 2FA is required company-wide
|
// GET - check if 2FA is required company-wide
|
||||||
fastify.get(
|
fastify.get(
|
||||||
"/required",
|
"/required",
|
||||||
{ preHandler: [requireAuth, requirePermission("settings.security")] },
|
{ preHandler: [requireAuth, requirePermission("settings.manage")] },
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const settings = await prisma.company_settings.findFirst({
|
const settings = await prisma.company_settings.findFirst({
|
||||||
select: { require_2fa: true },
|
select: { require_2fa: true },
|
||||||
@@ -167,7 +177,7 @@ export default async function totpRoutes(
|
|||||||
fastify.post(
|
fastify.post(
|
||||||
"/required",
|
"/required",
|
||||||
{
|
{
|
||||||
preHandler: [requireAuth, requirePermission("settings.security")],
|
preHandler: [requireAuth, requirePermission("settings.manage")],
|
||||||
bodyLimit: 10240,
|
bodyLimit: 10240,
|
||||||
},
|
},
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
export const UpdateCompanySettingsSchema = z.object({
|
|
||||||
company_name: z.string().nullish(),
|
|
||||||
street: z.string().nullish(),
|
|
||||||
city: z.string().nullish(),
|
|
||||||
postal_code: z.string().nullish(),
|
|
||||||
country: z.string().nullish(),
|
|
||||||
company_id: z.string().nullish(),
|
|
||||||
vat_id: z.string().nullish(),
|
|
||||||
quotation_prefix: z.string().nullish(),
|
|
||||||
default_currency: z.string().nullish(),
|
|
||||||
order_type_code: z.string().nullish(),
|
|
||||||
invoice_type_code: z.string().nullish(),
|
|
||||||
default_vat_rate: z
|
|
||||||
.union([z.number(), z.string()])
|
|
||||||
.transform((v) => Number(v))
|
|
||||||
.optional(),
|
|
||||||
require_2fa: z
|
|
||||||
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
|
|
||||||
.optional(),
|
|
||||||
custom_fields: z.array(z.any()).optional(),
|
|
||||||
supplier_field_order: z.array(z.any()).optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type UpdateCompanySettingsInput = z.infer<
|
|
||||||
typeof UpdateCompanySettingsSchema
|
|
||||||
>;
|
|
||||||
65
src/schemas/settings.schema.ts
Normal file
65
src/schemas/settings.schema.ts
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
export const UpdateCompanySettingsSchema = z.object({
|
||||||
|
company_name: z.string().nullish(),
|
||||||
|
street: z.string().nullish(),
|
||||||
|
city: z.string().nullish(),
|
||||||
|
postal_code: z.string().nullish(),
|
||||||
|
country: z.string().nullish(),
|
||||||
|
company_id: z.string().nullish(),
|
||||||
|
vat_id: z.string().nullish(),
|
||||||
|
quotation_prefix: z.string().nullish(),
|
||||||
|
default_currency: z.string().nullish(),
|
||||||
|
order_type_code: z.string().nullish(),
|
||||||
|
invoice_type_code: z.string().nullish(),
|
||||||
|
default_vat_rate: z
|
||||||
|
.union([z.number(), z.string()])
|
||||||
|
.transform((v) => Number(v))
|
||||||
|
.optional(),
|
||||||
|
require_2fa: z
|
||||||
|
.preprocess((v) => v === true || v === 1 || v === "1", z.boolean())
|
||||||
|
.optional(),
|
||||||
|
break_threshold_hours: z
|
||||||
|
.union([z.number(), z.string()])
|
||||||
|
.transform((v) => Number(v))
|
||||||
|
.optional(),
|
||||||
|
break_duration_short: z
|
||||||
|
.union([z.number(), z.string()])
|
||||||
|
.transform((v) => Number(v))
|
||||||
|
.optional(),
|
||||||
|
break_duration_long: z
|
||||||
|
.union([z.number(), z.string()])
|
||||||
|
.transform((v) => Number(v))
|
||||||
|
.optional(),
|
||||||
|
clock_rounding_minutes: z
|
||||||
|
.union([z.number(), z.string()])
|
||||||
|
.transform((v) => Number(v))
|
||||||
|
.optional(),
|
||||||
|
invoice_alert_email: z.string().nullish(),
|
||||||
|
leave_notify_email: z.string().nullish(),
|
||||||
|
smtp_from: z.string().nullish(),
|
||||||
|
smtp_from_name: z.string().nullish(),
|
||||||
|
offer_number_pattern: z.string().nullish(),
|
||||||
|
order_number_pattern: z.string().nullish(),
|
||||||
|
invoice_number_pattern: z.string().nullish(),
|
||||||
|
max_login_attempts: z
|
||||||
|
.union([z.number(), z.string()])
|
||||||
|
.transform((v) => Number(v))
|
||||||
|
.optional(),
|
||||||
|
lockout_minutes: z
|
||||||
|
.union([z.number(), z.string()])
|
||||||
|
.transform((v) => Number(v))
|
||||||
|
.optional(),
|
||||||
|
max_requests_per_minute: z
|
||||||
|
.union([z.number(), z.string()])
|
||||||
|
.transform((v) => Number(v))
|
||||||
|
.optional(),
|
||||||
|
available_vat_rates: z.array(z.number()).optional(),
|
||||||
|
available_currencies: z.array(z.string()).optional(),
|
||||||
|
custom_fields: z.array(z.any()).optional(),
|
||||||
|
supplier_field_order: z.array(z.any()).optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UpdateCompanySettingsInput = z.infer<
|
||||||
|
typeof UpdateCompanySettingsSchema
|
||||||
|
>;
|
||||||
@@ -58,7 +58,7 @@ async function start() {
|
|||||||
await app.register(cookie);
|
await app.register(cookie);
|
||||||
|
|
||||||
await app.register(rateLimit, {
|
await app.register(rateLimit, {
|
||||||
max: 100,
|
max: 300,
|
||||||
timeWindow: "1 minute",
|
timeWindow: "1 minute",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -189,14 +189,14 @@ async function start() {
|
|||||||
app.log.error(err, "Invoice alert cron failed");
|
app.log.error(err, "Invoice alert cron failed");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log("Invoice alert cron scheduled (daily 8:00)");
|
app.log.info("Invoice alert cron scheduled (daily 8:00)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Start ---
|
// --- Start ---
|
||||||
const port = config.isProduction ? config.port : 3000;
|
const port = config.isProduction ? config.port : 3000;
|
||||||
try {
|
try {
|
||||||
await app.listen({ port, host: config.host });
|
await app.listen({ port, host: config.host });
|
||||||
console.log(`Server running on http://${config.host}:${port}`);
|
app.log.info(`Server running on http://${config.host}:${port}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
app.log.error(err);
|
app.log.error(err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { attendance_leave_type, Prisma } from "@prisma/client";
|
|||||||
import prisma from "../config/database";
|
import prisma from "../config/database";
|
||||||
import { getBusinessDaysInMonth } from "../utils/czech-holidays";
|
import { getBusinessDaysInMonth } from "../utils/czech-holidays";
|
||||||
import { localDateStr } from "../utils/date";
|
import { localDateStr } from "../utils/date";
|
||||||
|
import { getSystemSettings } from "./system-settings";
|
||||||
|
|
||||||
type AttendanceWithRelations = Prisma.attendanceGetPayload<{
|
type AttendanceWithRelations = Prisma.attendanceGetPayload<{
|
||||||
include: {
|
include: {
|
||||||
@@ -48,13 +49,13 @@ function calcWorkedHours(
|
|||||||
return Math.max(0, mins) / 60;
|
return Math.max(0, mins) / 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
const roundUp15 = (d: Date) => {
|
const roundUp = (d: Date, minutes: number) => {
|
||||||
const ms = 15 * 60 * 1000;
|
const ms = minutes * 60 * 1000;
|
||||||
return new Date(Math.ceil(d.getTime() / ms) * ms);
|
return new Date(Math.ceil(d.getTime() / ms) * ms);
|
||||||
};
|
};
|
||||||
|
|
||||||
const roundDown15 = (d: Date) => {
|
const roundDown = (d: Date, minutes: number) => {
|
||||||
const ms = 15 * 60 * 1000;
|
const ms = minutes * 60 * 1000;
|
||||||
return new Date(Math.floor(d.getTime() / ms) * ms);
|
return new Date(Math.floor(d.getTime() / ms) * ms);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1189,6 +1190,7 @@ export async function createLeave(data: LeaveData, authUserId: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function punchAction(userId: number, data: PunchData) {
|
export async function punchAction(userId: number, data: PunchData) {
|
||||||
|
const settings = await getSystemSettings();
|
||||||
const action = data.punch_action;
|
const action = data.punch_action;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const y = now.getFullYear(),
|
const y = now.getFullYear(),
|
||||||
@@ -1223,7 +1225,7 @@ export async function punchAction(userId: number, data: PunchData) {
|
|||||||
return { error: "Máte již aktivní směnu. Nejdříve zaznamenejte odchod." };
|
return { error: "Máte již aktivní směnu. Nejdříve zaznamenejte odchod." };
|
||||||
}
|
}
|
||||||
|
|
||||||
const arrivalTime = roundUp15(now);
|
const arrivalTime = roundUp(now, settings.clock_rounding_minutes);
|
||||||
const record = await prisma.attendance.create({
|
const record = await prisma.attendance.create({
|
||||||
data: {
|
data: {
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
@@ -1257,7 +1259,7 @@ export async function punchAction(userId: number, data: PunchData) {
|
|||||||
return { error: "Nemáte aktivní směnu." };
|
return { error: "Nemáte aktivní směnu." };
|
||||||
}
|
}
|
||||||
|
|
||||||
const departureTime = roundDown15(now);
|
const departureTime = roundDown(now, settings.clock_rounding_minutes);
|
||||||
|
|
||||||
const updateData: Record<string, unknown> = {
|
const updateData: Record<string, unknown> = {
|
||||||
departure_time: departureTime,
|
departure_time: departureTime,
|
||||||
@@ -1270,9 +1272,12 @@ export async function punchAction(userId: number, data: PunchData) {
|
|||||||
if (!ongoing.break_start && ongoing.arrival_time) {
|
if (!ongoing.break_start && ongoing.arrival_time) {
|
||||||
const shiftMs = departureTime.getTime() - ongoing.arrival_time.getTime();
|
const shiftMs = departureTime.getTime() - ongoing.arrival_time.getTime();
|
||||||
const shiftHours = shiftMs / (1000 * 60 * 60);
|
const shiftHours = shiftMs / (1000 * 60 * 60);
|
||||||
if (shiftHours > 6) {
|
if (shiftHours > settings.break_threshold_hours) {
|
||||||
const midpoint = new Date(ongoing.arrival_time.getTime() + shiftMs / 2);
|
const midpoint = new Date(ongoing.arrival_time.getTime() + shiftMs / 2);
|
||||||
const breakMins = shiftHours > 12 ? 30 : 15;
|
const breakMins =
|
||||||
|
shiftHours > settings.break_threshold_hours * 2
|
||||||
|
? settings.break_duration_long
|
||||||
|
: settings.break_duration_short;
|
||||||
updateData.break_start = midpoint;
|
updateData.break_start = midpoint;
|
||||||
updateData.break_end = new Date(
|
updateData.break_end = new Date(
|
||||||
midpoint.getTime() + breakMins * 60 * 1000,
|
midpoint.getTime() + breakMins * 60 * 1000,
|
||||||
@@ -1311,9 +1316,11 @@ export async function punchAction(userId: number, data: PunchData) {
|
|||||||
return { error: "Nemáte aktivní směnu bez přestávky." };
|
return { error: "Nemáte aktivní směnu bez přestávky." };
|
||||||
}
|
}
|
||||||
|
|
||||||
const ms10 = 10 * 60 * 1000;
|
const msRound = settings.clock_rounding_minutes * 60 * 1000;
|
||||||
const breakStart = new Date(Math.round(now.getTime() / ms10) * ms10);
|
const breakStart = new Date(Math.round(now.getTime() / msRound) * msRound);
|
||||||
const breakEnd = new Date(breakStart.getTime() + 30 * 60 * 1000);
|
const breakEnd = new Date(
|
||||||
|
breakStart.getTime() + settings.break_duration_long * 60 * 1000,
|
||||||
|
);
|
||||||
|
|
||||||
await prisma.attendance.update({
|
await prisma.attendance.update({
|
||||||
where: { id: ongoing.id },
|
where: { id: ongoing.id },
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { FastifyRequest, FastifyReply } from "fastify";
|
|||||||
import prisma from "../config/database";
|
import prisma from "../config/database";
|
||||||
import { config } from "../config/env";
|
import { config } from "../config/env";
|
||||||
import { AuthData, JwtPayload } from "../types";
|
import { AuthData, JwtPayload } from "../types";
|
||||||
|
import { getSystemSettings } from "./system-settings";
|
||||||
|
|
||||||
// Pre-computed bcrypt hash for timing-safe comparison when user not found
|
// Pre-computed bcrypt hash for timing-safe comparison when user not found
|
||||||
const DUMMY_HASH =
|
const DUMMY_HASH =
|
||||||
@@ -121,14 +122,15 @@ export async function login(
|
|||||||
|
|
||||||
const passwordValid = await bcrypt.compare(password, user.password_hash);
|
const passwordValid = await bcrypt.compare(password, user.password_hash);
|
||||||
if (!passwordValid) {
|
if (!passwordValid) {
|
||||||
|
const settings = await getSystemSettings();
|
||||||
const attempts = (user.failed_login_attempts ?? 0) + 1;
|
const attempts = (user.failed_login_attempts ?? 0) + 1;
|
||||||
const updateData: Record<string, unknown> = {
|
const updateData: Record<string, unknown> = {
|
||||||
failed_login_attempts: attempts,
|
failed_login_attempts: attempts,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (attempts >= config.security.maxLoginAttempts) {
|
if (attempts >= settings.max_login_attempts) {
|
||||||
updateData.locked_until = new Date(
|
updateData.locked_until = new Date(
|
||||||
Date.now() + config.security.lockoutMinutes * 60_000,
|
Date.now() + settings.lockout_minutes * 60_000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
src/services/exchange-rates.ts
Normal file
65
src/services/exchange-rates.ts
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* Czech National Bank (ČNB) exchange rate service.
|
||||||
|
* Fetches daily rates and caches them.
|
||||||
|
* API: https://api.cnb.cz/cnbapi/exrates/daily
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface CnbRate {
|
||||||
|
currencyCode: string;
|
||||||
|
rate: number;
|
||||||
|
amount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rateCache: Record<string, Record<string, number>> = {};
|
||||||
|
|
||||||
|
async function fetchRatesForDate(
|
||||||
|
date?: string,
|
||||||
|
): Promise<Record<string, number>> {
|
||||||
|
const key = date || "today";
|
||||||
|
if (rateCache[key]) return rateCache[key];
|
||||||
|
|
||||||
|
try {
|
||||||
|
let url = "https://api.cnb.cz/cnbapi/exrates/daily?lang=EN";
|
||||||
|
if (date) url += `&date=${date}`;
|
||||||
|
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) throw new Error(`CNB API: ${response.status}`);
|
||||||
|
|
||||||
|
const data = (await response.json()) as { rates: CnbRate[] };
|
||||||
|
const rates: Record<string, number> = { CZK: 1 };
|
||||||
|
|
||||||
|
for (const r of data.rates) {
|
||||||
|
rates[r.currencyCode] = r.rate / r.amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
rateCache[key] = rates;
|
||||||
|
return rates;
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to fetch CNB exchange rates:", err);
|
||||||
|
if (rateCache["today"]) return rateCache["today"];
|
||||||
|
return { CZK: 1, EUR: 25, USD: 22, GBP: 28 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convert an amount from a given currency to CZK using CNB rates */
|
||||||
|
export async function toCzk(
|
||||||
|
amount: number,
|
||||||
|
currency: string,
|
||||||
|
date?: string,
|
||||||
|
): Promise<number> {
|
||||||
|
if (currency === "CZK") return amount;
|
||||||
|
const rates = await fetchRatesForDate(date);
|
||||||
|
const rate = rates[currency];
|
||||||
|
if (!rate) return amount;
|
||||||
|
return Math.round(amount * rate * 100) / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get CNB rate for a currency (CZK per 1 unit), optionally for a specific date */
|
||||||
|
export async function getRate(
|
||||||
|
currency: string,
|
||||||
|
date?: string,
|
||||||
|
): Promise<number> {
|
||||||
|
if (currency === "CZK") return 1;
|
||||||
|
const rates = await fetchRatesForDate(date);
|
||||||
|
return rates[currency] || 1;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import prisma from "../config/database";
|
|||||||
import { config } from "../config/env";
|
import { config } from "../config/env";
|
||||||
import { sendMail } from "./mailer";
|
import { sendMail } from "./mailer";
|
||||||
import { localDateCzStr, localDateStr } from "../utils/date";
|
import { localDateCzStr, localDateStr } from "../utils/date";
|
||||||
|
import { getSystemSettings } from "./system-settings";
|
||||||
|
|
||||||
interface AlertInvoice {
|
interface AlertInvoice {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -31,7 +32,8 @@ function formatAmount(n: number | { toNumber?: () => number }): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function checkInvoiceAlerts(): Promise<void> {
|
export async function checkInvoiceAlerts(): Promise<void> {
|
||||||
const alertEmail = config.email.invoiceAlert;
|
const settings = await getSystemSettings();
|
||||||
|
const alertEmail = settings.invoice_alert_email || config.email.invoiceAlert;
|
||||||
if (!alertEmail) return;
|
if (!alertEmail) return;
|
||||||
|
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import prisma from "../config/database";
|
import prisma from "../config/database";
|
||||||
|
import { toCzk } from "./exchange-rates";
|
||||||
|
|
||||||
// Status transition rules matching PHP
|
// Status transition rules matching PHP
|
||||||
const VALID_TRANSITIONS: Record<string, string[]> = {
|
const VALID_TRANSITIONS: Record<string, string[]> = {
|
||||||
@@ -69,8 +70,8 @@ export async function markOverdueInvoices() {
|
|||||||
where: { status: "issued", due_date: { lt: new Date() } },
|
where: { status: "issued", due_date: { lt: new Date() } },
|
||||||
data: { status: "overdue" },
|
data: { status: "overdue" },
|
||||||
});
|
});
|
||||||
} catch {
|
} catch (err) {
|
||||||
/* silent */
|
console.error("markOverdueInvoices failed:", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,26 +142,7 @@ export async function listInvoices(params: ListInvoicesParams) {
|
|||||||
return { data: enriched, total, page, limit };
|
return { data: enriched, total, page, limit };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getNextInvoiceNumberFormatted() {
|
export { generateInvoiceNumber as getNextInvoiceNumberFormatted } from "./numbering.service";
|
||||||
const settings = await prisma.company_settings.findFirst({
|
|
||||||
select: { invoice_type_code: true },
|
|
||||||
});
|
|
||||||
const typeCode = settings?.invoice_type_code || "81";
|
|
||||||
const yy = String(new Date().getFullYear()).slice(-2);
|
|
||||||
const prefix = `${yy}${typeCode}`;
|
|
||||||
const prefixLen = prefix.length;
|
|
||||||
const likePattern = `${prefix}%`;
|
|
||||||
|
|
||||||
// MAX from existing invoices — same approach as offers/orders
|
|
||||||
const result = await prisma.$queryRaw<[{ max_num: bigint | null }]>`
|
|
||||||
SELECT COALESCE(MAX(CAST(SUBSTRING(invoice_number, ${prefixLen} + 1) AS UNSIGNED)), 0) as max_num
|
|
||||||
FROM invoices
|
|
||||||
WHERE invoice_number LIKE ${likePattern}
|
|
||||||
`;
|
|
||||||
const nextNum = Number(result[0]?.max_num ?? 0) + 1;
|
|
||||||
const number = `${prefix}${String(nextNum).padStart(4, "0")}`;
|
|
||||||
return { number, next_number: number };
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getInvoiceStats(queryMonth?: number, queryYear?: number) {
|
export async function getInvoiceStats(queryMonth?: number, queryYear?: number) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
@@ -205,10 +187,11 @@ export async function getInvoiceStats(queryMonth?: number, queryYear?: number) {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const sumCzk = (invoices: typeof allInvoices) => {
|
const sumCzk = async (invoices: typeof allInvoices) => {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
for (const inv of invoices) {
|
for (const inv of invoices) {
|
||||||
total += invoiceTotalWithVat(inv); // Simplified: no real FX conversion
|
const amount = invoiceTotalWithVat(inv);
|
||||||
|
total += await toCzk(amount, inv.currency || "CZK");
|
||||||
}
|
}
|
||||||
return Math.round(total * 100) / 100;
|
return Math.round(total * 100) / 100;
|
||||||
};
|
};
|
||||||
@@ -243,18 +226,24 @@ export async function getInvoiceStats(queryMonth?: number, queryYear?: number) {
|
|||||||
let vatCzk = 0;
|
let vatCzk = 0;
|
||||||
for (const [, v] of Object.entries(vatMap)) vatCzk += v;
|
for (const [, v] of Object.entries(vatMap)) vatCzk += v;
|
||||||
|
|
||||||
|
// VAT also needs conversion
|
||||||
|
let vatCzkConverted = 0;
|
||||||
|
for (const [cur, amount] of Object.entries(vatMap)) {
|
||||||
|
vatCzkConverted += await toCzk(amount, cur);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
paid_month: aggregateByCurrency(paidInvoices),
|
paid_month: aggregateByCurrency(paidInvoices),
|
||||||
paid_month_czk: sumCzk(paidInvoices),
|
paid_month_czk: await sumCzk(paidInvoices),
|
||||||
paid_month_count: paidInvoices.length,
|
paid_month_count: paidInvoices.length,
|
||||||
awaiting: aggregateByCurrency(awaitingInvoices),
|
awaiting: aggregateByCurrency(awaitingInvoices),
|
||||||
awaiting_czk: sumCzk(awaitingInvoices),
|
awaiting_czk: await sumCzk(awaitingInvoices),
|
||||||
awaiting_count: awaitingInvoices.length,
|
awaiting_count: awaitingInvoices.length,
|
||||||
overdue: aggregateByCurrency(overdueInvoices),
|
overdue: aggregateByCurrency(overdueInvoices),
|
||||||
overdue_czk: sumCzk(overdueInvoices),
|
overdue_czk: await sumCzk(overdueInvoices),
|
||||||
overdue_count: overdueInvoices.length,
|
overdue_count: overdueInvoices.length,
|
||||||
vat_month: vatAmounts,
|
vat_month: vatAmounts,
|
||||||
vat_month_czk: Math.round(vatCzk * 100) / 100,
|
vat_month_czk: Math.round(vatCzkConverted * 100) / 100,
|
||||||
month,
|
month,
|
||||||
year,
|
year,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { sendMail } from "./mailer";
|
import { sendMail } from "./mailer";
|
||||||
import { config } from "../config/env";
|
import { config } from "../config/env";
|
||||||
import { localDateCzStr, localDateTimeCzStr } from "../utils/date";
|
import { localDateCzStr, localDateTimeCzStr } from "../utils/date";
|
||||||
|
import { getSystemSettings } from "./system-settings";
|
||||||
|
|
||||||
const LEAVE_TYPE_LABELS: Record<string, string> = {
|
const LEAVE_TYPE_LABELS: Record<string, string> = {
|
||||||
vacation: "Dovolená",
|
vacation: "Dovolená",
|
||||||
@@ -38,7 +39,8 @@ export async function notifyNewLeaveRequest(
|
|||||||
request: LeaveRequestData,
|
request: LeaveRequestData,
|
||||||
employeeName: string,
|
employeeName: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const notifyEmail = config.email.leaveNotify;
|
const settings = await getSystemSettings();
|
||||||
|
const notifyEmail = settings.leave_notify_email || config.email.leaveNotify;
|
||||||
if (!notifyEmail) return;
|
if (!notifyEmail) return;
|
||||||
|
|
||||||
const leaveType = LEAVE_TYPE_LABELS[request.leave_type] || request.leave_type;
|
const leaveType = LEAVE_TYPE_LABELS[request.leave_type] || request.leave_type;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import nodemailer from "nodemailer";
|
import nodemailer from "nodemailer";
|
||||||
import { config } from "../config/env";
|
import { config } from "../config/env";
|
||||||
|
import { getSystemSettings } from "./system-settings";
|
||||||
|
|
||||||
const transporter = nodemailer.createTransport({
|
const transporter = nodemailer.createTransport({
|
||||||
sendmail: true,
|
sendmail: true,
|
||||||
@@ -12,14 +13,18 @@ export async function sendMail(
|
|||||||
subject: string,
|
subject: string,
|
||||||
html: string,
|
html: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
|
const settings = await getSystemSettings();
|
||||||
const from =
|
const from =
|
||||||
|
settings.smtp_from ||
|
||||||
config.email.smtpFrom ||
|
config.email.smtpFrom ||
|
||||||
config.email.contactFrom ||
|
config.email.contactFrom ||
|
||||||
"web@boha-automation.cz";
|
"noreply@example.com";
|
||||||
|
const fromName =
|
||||||
|
settings.smtp_from_name || config.email.smtpFromName || "System";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await transporter.sendMail({
|
await transporter.sendMail({
|
||||||
from: { name: config.email.smtpFromName, address: from },
|
from: { name: fromName, address: from },
|
||||||
to,
|
to,
|
||||||
subject,
|
subject,
|
||||||
html,
|
html,
|
||||||
|
|||||||
@@ -1,19 +1,122 @@
|
|||||||
import prisma from "../config/database";
|
import prisma from "../config/database";
|
||||||
|
|
||||||
|
// Default patterns (backward compatible with existing numbers)
|
||||||
|
const DEFAULT_OFFER_PATTERN = "{YYYY}/{PREFIX}/{NNN}";
|
||||||
|
const DEFAULT_ORDER_PATTERN = "{YY}{CODE}{NNNN}";
|
||||||
|
const DEFAULT_INVOICE_PATTERN = "{YY}{CODE}{NNNN}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared number generator for orders and projects.
|
* Apply a numbering pattern template.
|
||||||
* Format: YYtypeCode + 4-digit sequence (e.g., 26710003)
|
* Placeholders: {YYYY}, {YY}, {PREFIX}, {CODE}, {N+} (padding = count of N's)
|
||||||
* Queries MAX from both orders and projects tables.
|
*/
|
||||||
|
function applyPattern(
|
||||||
|
pattern: string,
|
||||||
|
vars: { year: number; prefix: string; code: string; seq: number },
|
||||||
|
): string {
|
||||||
|
const yyyy = String(vars.year);
|
||||||
|
const yy = yyyy.slice(-2);
|
||||||
|
|
||||||
|
return pattern.replace(/\{(\w+)\}/g, (match, key: string) => {
|
||||||
|
if (key === "YYYY") return yyyy;
|
||||||
|
if (key === "YY") return yy;
|
||||||
|
if (key === "PREFIX") return vars.prefix;
|
||||||
|
if (key === "CODE") return vars.code;
|
||||||
|
if (/^N+$/.test(key)) return String(vars.seq).padStart(key.length, "0");
|
||||||
|
return match;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the static prefix and sequence position from a pattern.
|
||||||
|
* Used to build SQL LIKE patterns for MAX(seq) queries.
|
||||||
|
*/
|
||||||
|
function buildLikePattern(
|
||||||
|
pattern: string,
|
||||||
|
vars: { year: number; prefix: string; code: string },
|
||||||
|
): { likePattern: string; prefixLen: number } {
|
||||||
|
const yyyy = String(vars.year);
|
||||||
|
const yy = yyyy.slice(-2);
|
||||||
|
|
||||||
|
let staticPrefix = "";
|
||||||
|
let foundSeq = false;
|
||||||
|
const parts = pattern.split(/(\{[^}]+\})/);
|
||||||
|
|
||||||
|
for (const part of parts) {
|
||||||
|
const m = part.match(/^\{(\w+)\}$/);
|
||||||
|
if (!m) {
|
||||||
|
staticPrefix += part;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const key = m[1];
|
||||||
|
if (/^N+$/.test(key)) {
|
||||||
|
foundSeq = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (key === "YYYY") staticPrefix += yyyy;
|
||||||
|
else if (key === "YY") staticPrefix += yy;
|
||||||
|
else if (key === "PREFIX") staticPrefix += vars.prefix;
|
||||||
|
else if (key === "CODE") staticPrefix += vars.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundSeq) {
|
||||||
|
return { likePattern: staticPrefix + "%", prefixLen: staticPrefix.length };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { likePattern: staticPrefix + "%", prefixLen: staticPrefix.length };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getSettings() {
|
||||||
|
return prisma.company_settings.findFirst({
|
||||||
|
select: {
|
||||||
|
quotation_prefix: true,
|
||||||
|
order_type_code: true,
|
||||||
|
invoice_type_code: true,
|
||||||
|
offer_number_pattern: true,
|
||||||
|
order_number_pattern: true,
|
||||||
|
invoice_number_pattern: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Next offer/quotation number.
|
||||||
|
*/
|
||||||
|
export async function generateOfferNumber(): Promise<string> {
|
||||||
|
const settings = await getSettings();
|
||||||
|
const pattern = settings?.offer_number_pattern || DEFAULT_OFFER_PATTERN;
|
||||||
|
const prefix = settings?.quotation_prefix || "NA";
|
||||||
|
const year = new Date().getFullYear();
|
||||||
|
|
||||||
|
const { likePattern, prefixLen } = buildLikePattern(pattern, {
|
||||||
|
year,
|
||||||
|
prefix,
|
||||||
|
code: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await prisma.$queryRaw<[{ max_seq: bigint | null }]>`
|
||||||
|
SELECT COALESCE(MAX(CAST(SUBSTRING(quotation_number, ${prefixLen} + 1) AS UNSIGNED)), 0) as max_seq
|
||||||
|
FROM quotations
|
||||||
|
WHERE quotation_number LIKE ${likePattern}
|
||||||
|
`;
|
||||||
|
const nextNum = Number(result[0]?.max_seq ?? 0) + 1;
|
||||||
|
|
||||||
|
return applyPattern(pattern, { year, prefix, code: "", seq: nextNum });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared number for orders and projects.
|
||||||
*/
|
*/
|
||||||
export async function generateSharedNumber(): Promise<string> {
|
export async function generateSharedNumber(): Promise<string> {
|
||||||
const settings = await prisma.company_settings.findFirst({
|
const settings = await getSettings();
|
||||||
select: { order_type_code: true },
|
const pattern = settings?.order_number_pattern || DEFAULT_ORDER_PATTERN;
|
||||||
|
const code = settings?.order_type_code || "71";
|
||||||
|
const year = new Date().getFullYear();
|
||||||
|
|
||||||
|
const { likePattern, prefixLen } = buildLikePattern(pattern, {
|
||||||
|
year,
|
||||||
|
prefix: "",
|
||||||
|
code,
|
||||||
});
|
});
|
||||||
const typeCode = settings?.order_type_code || "71";
|
|
||||||
const yy = String(new Date().getFullYear()).slice(-2);
|
|
||||||
const prefix = `${yy}${typeCode}`;
|
|
||||||
const prefixLen = prefix.length;
|
|
||||||
const likePattern = `${prefix}%`;
|
|
||||||
|
|
||||||
const result = await prisma.$queryRaw<[{ max_seq: bigint | null }]>`
|
const result = await prisma.$queryRaw<[{ max_seq: bigint | null }]>`
|
||||||
SELECT COALESCE(MAX(seq), 0) as max_seq FROM (
|
SELECT COALESCE(MAX(seq), 0) as max_seq FROM (
|
||||||
@@ -25,51 +128,53 @@ export async function generateSharedNumber(): Promise<string> {
|
|||||||
) combined
|
) combined
|
||||||
`;
|
`;
|
||||||
const nextNum = Number(result[0]?.max_seq ?? 0) + 1;
|
const nextNum = Number(result[0]?.max_seq ?? 0) + 1;
|
||||||
return `${prefix}${String(nextNum).padStart(4, "0")}`;
|
|
||||||
|
return applyPattern(pattern, { year, prefix: "", code, seq: nextNum });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Next offer number. Queries MAX from quotations table.
|
* Next invoice number.
|
||||||
* Format: YEAR/PREFIX/NNN (e.g., 2026/NA/008)
|
|
||||||
*/
|
*/
|
||||||
export async function generateOfferNumber(): Promise<string> {
|
export async function generateInvoiceNumber(
|
||||||
const settings = await prisma.company_settings.findFirst({
|
_year?: number,
|
||||||
select: { quotation_prefix: true },
|
): Promise<{ number: string; next_number: string }> {
|
||||||
});
|
const settings = await getSettings();
|
||||||
const prefix = settings?.quotation_prefix || "NA";
|
const pattern = settings?.invoice_number_pattern || DEFAULT_INVOICE_PATTERN;
|
||||||
const year = new Date().getFullYear();
|
const code = settings?.invoice_type_code || "81";
|
||||||
const likePattern = `${year}/${prefix}/%`;
|
const year = _year || new Date().getFullYear();
|
||||||
|
|
||||||
const result = await prisma.$queryRaw<[{ max_num: bigint | null }]>`
|
const { likePattern, prefixLen } = buildLikePattern(pattern, {
|
||||||
SELECT COALESCE(MAX(CAST(SUBSTRING_INDEX(quotation_number, '/', -1) AS UNSIGNED)), 0) as max_num
|
year,
|
||||||
FROM quotations
|
prefix: "",
|
||||||
WHERE quotation_number LIKE ${likePattern}
|
code,
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await prisma.$queryRaw<[{ max_seq: bigint | null }]>`
|
||||||
|
SELECT COALESCE(MAX(CAST(SUBSTRING(invoice_number, ${prefixLen} + 1) AS UNSIGNED)), 0) as max_seq
|
||||||
|
FROM invoices
|
||||||
|
WHERE invoice_number LIKE ${likePattern}
|
||||||
`;
|
`;
|
||||||
const nextNum = Number(result[0]?.max_num ?? 0) + 1;
|
const nextNum = Number(result[0]?.max_seq ?? 0) + 1;
|
||||||
return `${year}/${prefix}/${String(nextNum).padStart(3, "0")}`;
|
|
||||||
|
const number = applyPattern(pattern, {
|
||||||
|
year,
|
||||||
|
prefix: "",
|
||||||
|
code,
|
||||||
|
seq: nextNum,
|
||||||
|
});
|
||||||
|
return { number, next_number: number };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Preview what a pattern would produce (for settings UI) */
|
||||||
* Next invoice number via atomic sequence table.
|
export function previewPattern(
|
||||||
*/
|
pattern: string,
|
||||||
export async function generateInvoiceNumber(year: number): Promise<number> {
|
prefix: string,
|
||||||
return prisma.$transaction(async (tx) => {
|
code: string,
|
||||||
const existing = await tx.number_sequences.findFirst({
|
): string {
|
||||||
where: { type: "invoice", year },
|
return applyPattern(pattern, {
|
||||||
});
|
year: new Date().getFullYear(),
|
||||||
|
prefix,
|
||||||
if (existing) {
|
code,
|
||||||
const nextNum = (existing.last_number ?? 0) + 1;
|
seq: 1,
|
||||||
await tx.number_sequences.update({
|
|
||||||
where: { id: existing.id },
|
|
||||||
data: { last_number: nextNum },
|
|
||||||
});
|
|
||||||
return nextNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
await tx.number_sequences.create({
|
|
||||||
data: { type: "invoice", year, last_number: 1 },
|
|
||||||
});
|
|
||||||
return 1;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
97
src/services/system-settings.ts
Normal file
97
src/services/system-settings.ts
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import prisma from "../config/database";
|
||||||
|
|
||||||
|
interface SystemSettings {
|
||||||
|
break_threshold_hours: number;
|
||||||
|
break_duration_short: number;
|
||||||
|
break_duration_long: number;
|
||||||
|
clock_rounding_minutes: number;
|
||||||
|
invoice_alert_email: string;
|
||||||
|
leave_notify_email: string;
|
||||||
|
max_login_attempts: number;
|
||||||
|
lockout_minutes: number;
|
||||||
|
max_requests_per_minute: number;
|
||||||
|
default_currency: string;
|
||||||
|
default_vat_rate: number;
|
||||||
|
available_vat_rates: number[];
|
||||||
|
available_currencies: string[];
|
||||||
|
smtp_from: string;
|
||||||
|
smtp_from_name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DEFAULTS: SystemSettings = {
|
||||||
|
break_threshold_hours: 6,
|
||||||
|
break_duration_short: 15,
|
||||||
|
break_duration_long: 30,
|
||||||
|
clock_rounding_minutes: 15,
|
||||||
|
invoice_alert_email: "",
|
||||||
|
leave_notify_email: "",
|
||||||
|
max_login_attempts: 5,
|
||||||
|
lockout_minutes: 15,
|
||||||
|
max_requests_per_minute: 300,
|
||||||
|
default_currency: "CZK",
|
||||||
|
default_vat_rate: 21,
|
||||||
|
available_vat_rates: [0, 10, 12, 15, 21],
|
||||||
|
available_currencies: ["CZK", "EUR", "USD", "GBP"],
|
||||||
|
smtp_from: "",
|
||||||
|
smtp_from_name: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
let cache: SystemSettings | null = null;
|
||||||
|
let cacheTime = 0;
|
||||||
|
const CACHE_TTL = 60_000; // 60 seconds
|
||||||
|
|
||||||
|
export async function getSystemSettings(): Promise<SystemSettings> {
|
||||||
|
if (cache && Date.now() - cacheTime < CACHE_TTL) return cache;
|
||||||
|
|
||||||
|
const row = await prisma.company_settings.findFirst();
|
||||||
|
if (!row) {
|
||||||
|
cache = { ...DEFAULTS };
|
||||||
|
cacheTime = Date.now();
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
let vatRates = DEFAULTS.available_vat_rates;
|
||||||
|
let currencies = DEFAULTS.available_currencies;
|
||||||
|
try {
|
||||||
|
if (row.available_vat_rates) vatRates = JSON.parse(row.available_vat_rates);
|
||||||
|
} catch {
|
||||||
|
/* keep default */
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (row.available_currencies)
|
||||||
|
currencies = JSON.parse(row.available_currencies);
|
||||||
|
} catch {
|
||||||
|
/* keep default */
|
||||||
|
}
|
||||||
|
|
||||||
|
cache = {
|
||||||
|
break_threshold_hours: Number(
|
||||||
|
row.break_threshold_hours ?? DEFAULTS.break_threshold_hours,
|
||||||
|
),
|
||||||
|
break_duration_short:
|
||||||
|
row.break_duration_short ?? DEFAULTS.break_duration_short,
|
||||||
|
break_duration_long:
|
||||||
|
row.break_duration_long ?? DEFAULTS.break_duration_long,
|
||||||
|
clock_rounding_minutes:
|
||||||
|
row.clock_rounding_minutes ?? DEFAULTS.clock_rounding_minutes,
|
||||||
|
invoice_alert_email: row.invoice_alert_email || "",
|
||||||
|
leave_notify_email: row.leave_notify_email || "",
|
||||||
|
max_login_attempts: row.max_login_attempts ?? DEFAULTS.max_login_attempts,
|
||||||
|
lockout_minutes: row.lockout_minutes ?? DEFAULTS.lockout_minutes,
|
||||||
|
max_requests_per_minute:
|
||||||
|
row.max_requests_per_minute ?? DEFAULTS.max_requests_per_minute,
|
||||||
|
default_currency: row.default_currency || DEFAULTS.default_currency,
|
||||||
|
default_vat_rate: Number(row.default_vat_rate ?? DEFAULTS.default_vat_rate),
|
||||||
|
available_vat_rates: vatRates,
|
||||||
|
available_currencies: currencies,
|
||||||
|
smtp_from: row.smtp_from || "",
|
||||||
|
smtp_from_name: row.smtp_from_name || DEFAULTS.smtp_from_name,
|
||||||
|
};
|
||||||
|
cacheTime = Date.now();
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function invalidateSettingsCache(): void {
|
||||||
|
cache = null;
|
||||||
|
cacheTime = 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user