import dayjs from 'dayjs';
import _ from 'lodash';

export default {
    filesFormatter(arr) {
        if (!arr || !arr.length) return [];
        return arr.map((item) => item);
    },
    imageFormatter(arr) {
        if (!arr || !arr.length) return []
        return arr.map(item => ({
            publicUrl: item.publicUrl || ''
        }))
    },
    oneImageFormatter(arr) {
        if (!arr || !arr.length) return ''
        return arr[0].publicUrl || ''
    },
    dateFormatter(date) {
        if (!date) return ''
        return dayjs(date).format('YYYY-MM-DD')
    },
    dateTimeFormatter(date) {
        if (!date) return ''
        return dayjs(date).format('YYYY-MM-DD HH:mm')
    },
    booleanFormatter(val) {
        return val ? 'Yes' : 'No'
    },
    dataGridEditFormatter(obj) {
        return _.transform(obj, (result, value, key) => {
            if (_.isArray(value)) {
                result[key] = _.map(value, 'id');
            } else if (_.isObject(value)) {
                result[key] = value.id;
            } else {
                result[key] = value;
            }
        });
    },
    
        
        usersManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.firstName)
        },
        usersOneListFormatter(val) {
            if (!val) return ''
            return val.firstName
        },
        usersManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.firstName}
            });
        },
        usersOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.firstName, id: val.id}
        },
        
    
        
        rolesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        rolesOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        rolesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        rolesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        permissionsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        permissionsOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        permissionsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        permissionsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        organizationsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        organizationsOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        organizationsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        organizationsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        tenantsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        tenantsOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        tenantsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        tenantsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        membershipsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.status)
        },
        membershipsOneListFormatter(val) {
            if (!val) return ''
            return val.status
        },
        membershipsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.status}
            });
        },
        membershipsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.status, id: val.id}
        },
        
    
        
        role_assignmentsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.assigned_at)
        },
        role_assignmentsOneListFormatter(val) {
            if (!val) return ''
            return val.assigned_at
        },
        role_assignmentsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.assigned_at}
            });
        },
        role_assignmentsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.assigned_at, id: val.id}
        },
        
    
        
        approval_workflowsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        approval_workflowsOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        approval_workflowsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        approval_workflowsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        approval_stepsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.approver_type)
        },
        approval_stepsOneListFormatter(val) {
            if (!val) return ''
            return val.approver_type
        },
        approval_stepsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.approver_type}
            });
        },
        approval_stepsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.approver_type, id: val.id}
        },
        
    
        
        approval_requestsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.object_ref)
        },
        approval_requestsOneListFormatter(val) {
            if (!val) return ''
            return val.object_ref
        },
        approval_requestsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.object_ref}
            });
        },
        approval_requestsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.object_ref, id: val.id}
        },
        
    
        
        approval_decisionsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.decision)
        },
        approval_decisionsOneListFormatter(val) {
            if (!val) return ''
            return val.decision
        },
        approval_decisionsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.decision}
            });
        },
        approval_decisionsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.decision, id: val.id}
        },
        
    
        
    
        
        customersManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        customersOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        customersManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        customersOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        suppliersManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        suppliersOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        suppliersManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        suppliersOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        uomsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        uomsOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        uomsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        uomsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        item_categoriesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        item_categoriesOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        item_categoriesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        item_categoriesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        itemsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        itemsOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        itemsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        itemsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        warehousesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        warehousesOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        warehousesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        warehousesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        locationsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        locationsOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        locationsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        locationsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        lotsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.lot_number)
        },
        lotsOneListFormatter(val) {
            if (!val) return ''
            return val.lot_number
        },
        lotsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.lot_number}
            });
        },
        lotsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.lot_number, id: val.id}
        },
        
    
        
        serial_numbersManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.serial_number)
        },
        serial_numbersOneListFormatter(val) {
            if (!val) return ''
            return val.serial_number
        },
        serial_numbersManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.serial_number}
            });
        },
        serial_numbersOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.serial_number, id: val.id}
        },
        
    
        
        inventory_transfersManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.transfer_number)
        },
        inventory_transfersOneListFormatter(val) {
            if (!val) return ''
            return val.transfer_number
        },
        inventory_transfersManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.transfer_number}
            });
        },
        inventory_transfersOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.transfer_number, id: val.id}
        },
        
    
        
        inventory_transfer_linesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.memo)
        },
        inventory_transfer_linesOneListFormatter(val) {
            if (!val) return ''
            return val.memo
        },
        inventory_transfer_linesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.memo}
            });
        },
        inventory_transfer_linesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.memo, id: val.id}
        },
        
    
        
    
        
        quotationsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.quote_number)
        },
        quotationsOneListFormatter(val) {
            if (!val) return ''
            return val.quote_number
        },
        quotationsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.quote_number}
            });
        },
        quotationsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.quote_number, id: val.id}
        },
        
    
        
        quotation_linesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.description)
        },
        quotation_linesOneListFormatter(val) {
            if (!val) return ''
            return val.description
        },
        quotation_linesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.description}
            });
        },
        quotation_linesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.description, id: val.id}
        },
        
    
        
        sales_ordersManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.order_number)
        },
        sales_ordersOneListFormatter(val) {
            if (!val) return ''
            return val.order_number
        },
        sales_ordersManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.order_number}
            });
        },
        sales_ordersOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.order_number, id: val.id}
        },
        
    
        
        sales_order_linesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.description)
        },
        sales_order_linesOneListFormatter(val) {
            if (!val) return ''
            return val.description
        },
        sales_order_linesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.description}
            });
        },
        sales_order_linesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.description, id: val.id}
        },
        
    
        
        sales_allocationsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.quantity)
        },
        sales_allocationsOneListFormatter(val) {
            if (!val) return ''
            return val.quantity
        },
        sales_allocationsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.quantity}
            });
        },
        sales_allocationsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.quantity, id: val.id}
        },
        
    
        
        invoicesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.invoice_number)
        },
        invoicesOneListFormatter(val) {
            if (!val) return ''
            return val.invoice_number
        },
        invoicesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.invoice_number}
            });
        },
        invoicesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.invoice_number, id: val.id}
        },
        
    
        
        invoice_linesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.description)
        },
        invoice_linesOneListFormatter(val) {
            if (!val) return ''
            return val.description
        },
        invoice_linesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.description}
            });
        },
        invoice_linesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.description, id: val.id}
        },
        
    
        
        customer_returnsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.return_number)
        },
        customer_returnsOneListFormatter(val) {
            if (!val) return ''
            return val.return_number
        },
        customer_returnsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.return_number}
            });
        },
        customer_returnsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.return_number, id: val.id}
        },
        
    
        
        customer_return_linesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.condition_notes)
        },
        customer_return_linesOneListFormatter(val) {
            if (!val) return ''
            return val.condition_notes
        },
        customer_return_linesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.condition_notes}
            });
        },
        customer_return_linesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.condition_notes, id: val.id}
        },
        
    
        
        purchase_ordersManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.po_number)
        },
        purchase_ordersOneListFormatter(val) {
            if (!val) return ''
            return val.po_number
        },
        purchase_ordersManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.po_number}
            });
        },
        purchase_ordersOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.po_number, id: val.id}
        },
        
    
        
        purchase_order_linesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.description)
        },
        purchase_order_linesOneListFormatter(val) {
            if (!val) return ''
            return val.description
        },
        purchase_order_linesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.description}
            });
        },
        purchase_order_linesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.description, id: val.id}
        },
        
    
        
        receiptsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.receipt_number)
        },
        receiptsOneListFormatter(val) {
            if (!val) return ''
            return val.receipt_number
        },
        receiptsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.receipt_number}
            });
        },
        receiptsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.receipt_number, id: val.id}
        },
        
    
        
        receipt_linesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.memo)
        },
        receipt_linesOneListFormatter(val) {
            if (!val) return ''
            return val.memo
        },
        receipt_linesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.memo}
            });
        },
        receipt_linesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.memo, id: val.id}
        },
        
    
        
        vendor_billsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.bill_number)
        },
        vendor_billsOneListFormatter(val) {
            if (!val) return ''
            return val.bill_number
        },
        vendor_billsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.bill_number}
            });
        },
        vendor_billsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.bill_number, id: val.id}
        },
        
    
        
        vendor_bill_linesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.description)
        },
        vendor_bill_linesOneListFormatter(val) {
            if (!val) return ''
            return val.description
        },
        vendor_bill_linesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.description}
            });
        },
        vendor_bill_linesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.description, id: val.id}
        },
        
    
        
        chart_of_accountsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        chart_of_accountsOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        chart_of_accountsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        chart_of_accountsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        fiscal_periodsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        fiscal_periodsOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        fiscal_periodsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        fiscal_periodsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        journal_entriesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.journal_number)
        },
        journal_entriesOneListFormatter(val) {
            if (!val) return ''
            return val.journal_number
        },
        journal_entriesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.journal_number}
            });
        },
        journal_entriesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.journal_number, id: val.id}
        },
        
    
        
        journal_linesManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.reference)
        },
        journal_linesOneListFormatter(val) {
            if (!val) return ''
            return val.reference
        },
        journal_linesManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.reference}
            });
        },
        journal_linesOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.reference, id: val.id}
        },
        
    
        
    
        
    
        
        webhooksManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        webhooksOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        webhooksManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        webhooksOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        webhook_subscriptionsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.event_type)
        },
        webhook_subscriptionsOneListFormatter(val) {
            if (!val) return ''
            return val.event_type
        },
        webhook_subscriptionsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.event_type}
            });
        },
        webhook_subscriptionsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.event_type, id: val.id}
        },
        
    
        
    
        
    
        
    
        
    
        
        dashboardsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.name)
        },
        dashboardsOneListFormatter(val) {
            if (!val) return ''
            return val.name
        },
        dashboardsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.name}
            });
        },
        dashboardsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.name, id: val.id}
        },
        
    
        
        dashboard_widgetsManyListFormatter(val) {
            if (!val || !val.length) return []
            return val.map((item) => item.title)
        },
        dashboard_widgetsOneListFormatter(val) {
            if (!val) return ''
            return val.title
        },
        dashboard_widgetsManyListFormatterEdit(val) {
            if (!val || !val.length) return []
            return val.map((item) => {
              return {id: item.id, label: item.title}
            });
        },
        dashboard_widgetsOneListFormatterEdit(val) {
            if (!val) return ''
            return {label: val.title, id: val.id}
        },
        
    
}
