import * as React from 'react';
import { Step } from '../../models/step';
import { Colors } from '../../models/colors';

export interface LoaderProps {
	automationName?: string;
}

type LoaderContainer = LoaderProps & {
	step?: Step;
	palette?: Colors;
	removeErrorMessage?: () => void;
	render: (palette: Colors) => JSX.Element;
};

class Loader extends React.PureComponent<LoaderContainer> {
	render() {
		if (!this.props.step.loading) return null;
		return this.props.render(this.props.palette);
	}
}

export default Loader;
