Initial commit: core-prestashop module v1.1.1

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
fatequod
2026-07-07 14:30:30 +02:00
co-authored by Cursor
commit f163100ad4
33 changed files with 2605 additions and 0 deletions
+135
View File
@@ -0,0 +1,135 @@
const { Log, Core, Utils, Pages } = require('@orbito/api-lib');
const ShopConfig = require('../src/models/ShopConfig');
module.exports = async function(companyId, instanceId, body, params) {
const configId = params.shopId;
const isEdit = !!configId;
let config = null;
if (isEdit) {
config = await ShopConfig.findOne({ _id: configId, companyId, isRemoved: { $ne: true } });
if (!config) throw new Error('Config not found');
}
const res = await Core.callModule(companyId, 'core/orders', 'status.search', {});
const orderStatuses = res.results || [];
return {
type: 'ove',
template: {
type: 'card',
title: isEdit ? `Edytuj konfigurację: ${config.shopName || configId}` : 'Nowa konfiguracja sklepu',
description: isEdit
? 'Zaktualizuj dane połączenia ze sklepem Prestashop.'
: 'Uzupełnij dane połączenia z nowym sklepem Prestashop.',
content: [
{
type: 'row',
cols: [
{
size: 6,
childs: [
{
type: 'input',
name: 'shopName',
inputType: 'text',
label: 'Nazwa sklepu',
value: config?.shopName || '',
groups: ['config-data']
}
]
},
{
size: 6,
childs: [
{
type: 'select',
name: 'versionCode',
label: 'Wersja sklepu',
value: config?.versionCode || '',
options: [
{ id: '9', label: 'PrestaShop 9' },
{ id: '8', label: 'PrestaShop 8' },
{ id: '1.7', label: 'PrestaShop 1.7' },
{ id: '1.6', label: 'PrestaShop 1.6 lub starsze' }
],
groups: ['config-data']
}
]
},
{
size: 12,
childs: [
{
type: 'input',
name: 'apiUrl',
inputType: 'text',
label: 'API URL',
placeholder: 'https://sklep.pl/api',
value: config?.apiUrl || '',
groups: ['config-data']
},
{
type: 'input',
name: 'apiKey',
inputType: 'text',
label: 'API Key',
placeholder: 'Klucz API Prestashop',
value: config?.apiKey || '',
groups: ['config-data']
},
{
type: 'select',
name: 'orderStatus',
label: 'Domyślny status zamówienia po pobraniu z Prestashop',
value: config?.orderStatus || '',
options: orderStatuses.map(status => ({ id: status._id, label: status.name })),
groups: ['config-data']
}
]
}
]
}
],
footer: [
{
type: 'button',
label: 'Wróć do listy',
variant: 'secondary',
outline: true,
icon: 'arrow-left',
onClick: {
action: 'emit',
event: 'generatePage',
data: {
module: 'core/prestashop',
page: 'config'
}
}
},
{
type: 'button',
label: isEdit ? 'Zapisz zmiany' : 'Utwórz konfigurację',
variant: 'primary',
icon: 'device-floppy',
groups: ['config-data'],
onClick: {
action: 'callMethod',
module: 'core/prestashop',
method: 'updateConfig',
params: isEdit ? { _id: configId } : {},
withData: ['#config-data'],
then: {
action: 'emit',
event: 'generatePage',
data: {
module: 'core/prestashop',
page: 'config'
}
}
}
}
]
}
};
}