Introduce initial version of the Lonc app with core features, styling, and configurations.
- Add base app structure, including Bootstrap setup and Alpine.js integration. - Implement authentication flow with session handling. - Integrate stock management and label creation functionalities. - Include responsive styling and theme using CSS variables and custom components. - Add API clients for Tryton-based backend. - Set up kitchen and dashboard navigation workflows. - Configure service worker for PWA support.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { apiRequest, getPath } from './client.js';
|
||||
|
||||
export function normalizeLabelImagePayload(payload) {
|
||||
if (!payload) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (payload instanceof Blob) {
|
||||
return {
|
||||
objectUrl: URL.createObjectURL(payload),
|
||||
contentType: payload.type,
|
||||
};
|
||||
}
|
||||
|
||||
if (payload?.imageUrl) {
|
||||
return {
|
||||
objectUrl: payload.imageUrl,
|
||||
contentType: payload.contentType || 'image/png',
|
||||
};
|
||||
}
|
||||
|
||||
if (payload?.imageSvg) {
|
||||
const blob = new Blob([payload.imageSvg], { type: 'image/svg+xml' });
|
||||
return {
|
||||
objectUrl: URL.createObjectURL(blob),
|
||||
contentType: 'image/svg+xml',
|
||||
};
|
||||
}
|
||||
|
||||
if (payload?.label) {
|
||||
return {
|
||||
objectUrl: `data:image/png;base64,${payload.label}`,
|
||||
contentType: 'image/png',
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function previewLabel(store, body) {
|
||||
const payload = await apiRequest(store, getPath('items'), {
|
||||
method: 'POST',
|
||||
body,
|
||||
accept: 'image/svg+xml, image/png, application/json',
|
||||
includeKitchen: false,
|
||||
query: { label: 1, preview: 1 },
|
||||
});
|
||||
|
||||
const image = normalizeLabelImagePayload(payload);
|
||||
if (image) {
|
||||
return image;
|
||||
}
|
||||
|
||||
throw new Error('Label preview response did not include an image.');
|
||||
}
|
||||
Reference in New Issue
Block a user