feat: add default label template setting and apply it to print dialog selection
Build and Push Multi-Platform Images / build-and-push (push) Successful in 35s
Build and Push Multi-Platform Images / build-and-push (push) Successful in 35s
This commit is contained in:
@@ -36,6 +36,7 @@ import type { ColumnsType } from 'antd/es/table';
|
||||
import { inboxApi, type InboxBarcode, type InboxFile } from '../api/inbox';
|
||||
import { barcodeTemplatesApi, type BarcodeTemplate } from '../api/barcode-templates';
|
||||
import { labelPrintAgentApi } from '../api/labelPrintAgent';
|
||||
import { userSettingsApi } from '../api/userSettings';
|
||||
|
||||
const { Title } = Typography;
|
||||
|
||||
@@ -150,14 +151,22 @@ export default function InboxPage() {
|
||||
|
||||
const openPrintDialog = async () => {
|
||||
try {
|
||||
const all = await barcodeTemplatesApi.list();
|
||||
setLabelTemplates(all.filter((t) => t.LabelEnabled));
|
||||
const [all, settings] = await Promise.all([
|
||||
barcodeTemplatesApi.list(),
|
||||
userSettingsApi.get(),
|
||||
]);
|
||||
const enabled = all.filter((t) => t.LabelEnabled);
|
||||
setLabelTemplates(enabled);
|
||||
const defaultId = settings.defaultLabelTemplateId;
|
||||
const defaultTemplate = defaultId != null
|
||||
? (enabled.find((t) => t.Id === defaultId) ?? null)
|
||||
: null;
|
||||
setSelectedTemplate(defaultTemplate);
|
||||
setFieldValues(buildInitialFieldValues(defaultTemplate));
|
||||
} catch {
|
||||
message.error('Vorlagen konnten nicht geladen werden');
|
||||
return;
|
||||
}
|
||||
setSelectedTemplate(null);
|
||||
setFieldValues({});
|
||||
setLabelCount(1);
|
||||
setPrintDialogOpen(true);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user