import { setCookie } from "@insite/client-framework/Common/Cookies";
import { createHandlerChainRunner, Handler } from "@insite/client-framework/HandlerCreator";

export const ShowPricingCookieName = "ShowPricing";

interface Parameter {
    showPricing: boolean;
}

type HandlerType = Handler<Parameter>;

export const SetCookie: HandlerType = props => {
    setCookie(ShowPricingCookieName, props.parameter.showPricing.toString());
};

export const DispatchSetShowPricing: HandlerType = props => {
    props.dispatch({
        type: "Context/SetShowPricing",
        showPricing: props.parameter.showPricing,
    });
};

export const chain = [SetCookie, DispatchSetShowPricing];

const setShowPricing = createHandlerChainRunner(chain, "setShowPricing");
export default setShowPricing;
