import { AXPWidgetsList } from '@acorex/modules/common';
import { createAllQueryView } from '@acorex/platform/common';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { RootConfig } from './acorex-modules-customer-management.mjs';
import { entityMasterCrudActions } from '@acorex/platform/layout/entity';

async function leadFactory(injector) {
    const i18n = RootConfig.config.i18n + ':leads.entities.lead';
    const entityName = 'lead';
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.lead.name,
        title: RootConfig.entities.lead.title,
        icon: RootConfig.entities.lead.icon,
        formats: {
            individual: RootConfig.entities.lead.title,
            plural: RootConfig.entities.lead.titlePlural,
            searchResult: { title: '{{ name }}', description: RootConfig.module.title },
        },
        groups: [
            { id: 'basic-info', title: `@${i18n}.groups.basic-info` },
            { id: 'additional', title: '@general:terms.interface.additional-info' },
        ],
        properties: [
            { name: 'name', title: `@${i18n}.fields.name.title`, groupId: 'basic-info', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } }, validations: [{ rule: 'required' }] },
            { name: 'status', title: `@${i18n}.fields.status.title`, groupId: 'basic-info', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.select, options: { valueField: 'id', dataSource: [{ id: 'new', title: 'New' }, { id: 'working', title: 'Working' }, { id: 'qualified', title: 'Qualified' }, { id: 'unqualified', title: 'Unqualified' }] } } } },
            { name: 'lifecycleStageId', title: `@${i18n}.fields.lifecycle-stage.title`, groupId: 'basic-info', schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.LookupBox, options: { entity: 'BusinessCore.LifecycleStage', textField: 'title', valueField: 'id', look: 'select', expose: [{ source: 'id', target: 'lifecycleStage.id' }, { source: 'title', target: 'lifecycleStage.title' }] } } } },
            { name: 'source', title: `@${i18n}.fields.source.title`, groupId: 'basic-info', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } } },
            { name: 'email', title: `@${i18n}.fields.email.title`, groupId: 'additional', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.contact, options: { type: 'email' } } } },
            { name: 'phone', title: `@${i18n}.fields.phone.title`, groupId: 'additional', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.contact, options: { type: 'phone' } } } },
            { name: 'company', title: `@${i18n}.fields.company.title`, groupId: 'additional', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } } },
        ],
        columns: [{ name: 'name' }, { name: 'email' }, { name: 'phone' }, { name: 'company' }, { name: 'status' }, { name: 'lifecycleStageId', options: { dataPath: 'lifecycleStage.title' } }],
        interfaces: {
            master: {
                create: {
                    sections: [
                        { id: 'basic-info' },
                        { id: 'additional' },
                    ],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'status', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'lifecycleStageId', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'source', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'email', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'phone', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                        { name: 'company', layout: { positions: { lg: { colSpan: 12, order: 7 } } } },
                    ],
                },
                update: {
                    sections: [
                        { id: 'basic-info' },
                        { id: 'additional' },
                    ],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'status', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'lifecycleStageId', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'source', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'email', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'phone', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                        { name: 'company', layout: { positions: { lg: { colSpan: 12, order: 7 } } } },
                    ],
                },
                single: {
                    title: '{{name}}',
                    sections: [
                        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'additional', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'status', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'lifecycleStageId', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'source', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'email', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'phone', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                        { name: 'company', layout: { positions: { lg: { colSpan: 12, order: 7 } } } },
                    ],
                    actions: [],
                },
                list: { actions: [...entityMasterCrudActions()], views: [createAllQueryView({ sorts: [{ name: 'name', dir: 'asc' }] })] },
            },
        },
    };
    return entityDef;
}

export { leadFactory };
//# sourceMappingURL=acorex-modules-customer-management-lead.entity-C-juNxOd.mjs.map
