v1.6.9: cleanup offer dead columns, add item template picker to offer form

- Remove dead DB columns: uuid, sync_version from quotations/quotation_items/scope_sections; is_deleted from quotation_items/scope_sections; content_editor_height from scope_sections
- Remove unused scope_title/scope_description from offer form state
- Remove dead CSS: offers-template-menu, offers-draft-indicator, exchange-rate
- Remove dead scope_title translation key from offers PDF
- Fix duplicate Customer interface in OfferDetail.tsx (use shared type)
- Add missing title field to ScopeTemplate interface
- Add item template picker dropdown next to "Přidat položku" button

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-05-28 13:20:22 +02:00
parent 0330453ad6
commit 705f58e3d1
6 changed files with 71 additions and 85 deletions

View File

@@ -16,12 +16,15 @@ import {
offerCustomersOptions,
scopeTemplatesOptions,
offerNextNumberOptions,
itemTemplatesOptions,
type ItemTemplate,
type OfferDetailData,
type OfferItemData,
type OfferSectionData,
type OfferLockInfo,
type OfferOrderInfo,
type ScopeTemplate,
type Customer,
} from "../lib/queries/offers";
import {
@@ -90,14 +93,6 @@ interface OfferForm {
language: string;
vat_rate: number;
apply_vat: boolean;
scope_title: string;
scope_description: string;
}
interface Customer {
id: number;
name: string;
city?: string;
}
const emptyForm: OfferForm = {
@@ -111,8 +106,6 @@ const emptyForm: OfferForm = {
language: "EN",
vat_rate: 21,
apply_vat: false,
scope_title: "",
scope_description: "",
};
const emptyScopeSection = (): ScopeSection => ({
@@ -319,6 +312,7 @@ export default function OfferDetail() {
enabled: !isEdit,
});
const { data: templatesData } = useQuery(scopeTemplatesOptions());
const { data: itemTemplates } = useQuery(itemTemplatesOptions());
const { data: nextNumberData } = useQuery({
...offerNextNumberOptions(),
enabled: !isEdit,
@@ -350,11 +344,6 @@ export default function OfferDetail() {
language: (draft.form.language as string) || emptyForm.language,
vat_rate: (draft.form.vat_rate as number) ?? emptyForm.vat_rate,
apply_vat: (draft.form.apply_vat as boolean) ?? emptyForm.apply_vat,
scope_title:
(draft.form.scope_title as string) || emptyForm.scope_title,
scope_description:
(draft.form.scope_description as string) ||
emptyForm.scope_description,
};
}
return emptyForm;
@@ -445,8 +434,6 @@ export default function OfferDetail() {
language: d.language || "EN",
vat_rate: d.vat_rate ?? companySettings?.default_vat_rate ?? 21,
apply_vat: !!d.apply_vat,
scope_title: d.scope_title || "",
scope_description: d.scope_description || "",
};
setForm(formData);
const mappedItems =
@@ -1252,12 +1239,59 @@ export default function OfferDetail() {
<div className="admin-card-header flex-between">
<h3 className="admin-card-title">Položky</h3>
{!readOnly && (
<button
onClick={addItem}
className="admin-btn admin-btn-secondary admin-btn-sm"
<div
style={{
display: "flex",
gap: "0.5rem",
alignItems: "center",
}}
>
+ Přidat položku
</button>
{itemTemplates && itemTemplates.length > 0 && (
<select
className="admin-form-select"
style={{ width: "auto", minWidth: "160px" }}
defaultValue=""
onChange={(e) => {
const templateId = Number(e.target.value);
if (!templateId) return;
const template = itemTemplates.find(
(t: ItemTemplate) => t.id === templateId,
);
if (template) {
setItems((prev) => [
...prev,
{
_key: `item-${++itemKeyCounter.current}`,
description: template.name || "",
item_description: template.description || "",
quantity: 1,
unit: "ks",
unit_price: template.default_price || 0,
is_included_in_total: true,
},
]);
alert.success(
`Načtena šablona položky "${template.name}"`,
);
}
e.target.value = "";
}}
>
<option value="">Ze šablony...</option>
{itemTemplates.map((t: ItemTemplate) => (
<option key={t.id} value={t.id}>
{t.name}
</option>
))}
</select>
)}
<button
onClick={addItem}
className="admin-btn admin-btn-secondary admin-btn-sm"
>
+ Přidat položku
</button>
</div>
)}
</div>
{errors.items && (
@@ -1408,13 +1442,6 @@ export default function OfferDetail() {
content: s.content || "",
}));
setSections((prev) => [...prev, ...newSections]);
if (template.description) {
setForm((prev) => ({
...prev,
scope_description:
template.description || prev.scope_description,
}));
}
alert.success(`Načtena šablona "${template.name}"`);
}
e.target.value = "";