import { ComponentProps, ComponentType, JSX, PureComponent } from "react";

import { SvgConstantDisabledTheme } from "../SvgConstants";
import { InjectedSvgProps } from "./hocTypings";
import { getDisplayName } from "./utils";

export function asDisabledSvg<
  C extends ComponentType<ComponentProps<C> & InjectedSvgProps>,
  ResolvedProps = JSX.LibraryManagedAttributes<C, ComponentProps<C>>
>(WrappedComponent: C) {
  return class AsDisabledSvg extends PureComponent<
    ResolvedProps & InjectedSvgProps
  > {
    static displayName = `asDisabledSvg(${getDisplayName(WrappedComponent)})`;

    static defaultProps = {
      fillColor: SvgConstantDisabledTheme.fill,
      secondaryFillColor: SvgConstantDisabledTheme.secondaryFill,
      className: "ddbc-svg--disabled",
    };

    render() {
      return <WrappedComponent {...(this.props as any)} />;
    }
  };
}
