// @flow
import * as React from 'react';
import {
	Badge,
} from 'reactstrap';

import Validate, { VALIDATORS } from '@helpers/schema';
import type { BeatObject, BeatEntity } from '@helpers/beat';

type Props = {
	entity: BeatEntity,
	obj: BeatObject,
};

const ValidSchemaBadge = (props: Props) => {
	const errs = Validate(VALIDATORS[props.entity], props.obj);
	const isValid = !errs;

	if(!isValid){
		//console.log(errs);
	}

	return (
		<Badge className='ml-1' color={isValid ? 'success' : 'danger'}>
			{isValid ? 'Valid' : 'Invalid'}
		</Badge>
	);
};

export default ValidSchemaBadge;
