import { __ } from '../../globals';
import Condition from '../Condition';
import { invert } from 'lodash';

export default class CustomerType extends Condition
{
    static TYPE =window.CouponsPlus.components.conditions.CustomerType.type;
    
    getComponent() 
    {
        return window.CouponsPlus.components.conditions.CustomerType;       
    }

    getTitle() 
    {
        return window.CouponsPlus.components.conditions.CustomerType.name;
    }

    getDescription() 
    {
        return window.CouponsPlus.components.conditions.CustomerType.description;
    }

    getDefaultValueLabel()
    {
        return __('Guests & W/Account')
    }
    
    getIcon()
{
        return (<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4" />
                </svg>);
    }

    getFields() 
    {
        return [
            {
                type: 'select',
                width: 'auto',
                options:window.CouponsPlus.components.conditions.CustomerType.fields.type.meta['_allowed'],
                labels: {
                },
                temporaryID: this.data.temporaryID,
                propertyName: 'options.type',
                getValue: () => {
                    return invert(CouponsPlus.components.conditions.CustomerType.fields.type.meta['_allowed'])[this.data.options.type]
                },
            },
        ]
    }

    getDefaultOptions()
{
        return window.CouponsPlus.components.conditions.CustomerType.defaultOptions;
    }
}