import React from "react";
import { withJsonFormsControlProps } from "@jsonforms/react";
import {
	rankWith,
	scopeEndsWith,
	isStringControl,
	RankedTester,
	ControlProps
} from "@jsonforms/core";

interface RatingControlProps {
	data: any;
	handleChange(path: string, value: any): void;
	path: string;
	schema: any;
}

const TestControl = ({
	data,
	handleChange,
	path,
	schema
}: RatingControlProps) => {
	return (
		//   <Rating
		//     value={data}
		//     updateValue={(newValue: number) => handleChange(path, newValue)}
		//   />
		<div className="my-4">
			<input
				type="boolean"
				value={data}
				onChange={(event) => handleChange(path, event.target.value)}
				name={"Test control"}
				placeholder="Type something here..."
				className="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
			/>
		</div>
	);
};

export const testControlTester: RankedTester = rankWith(
	3, //increase rank as needed
	isStringControl
);

export default withJsonFormsControlProps(TestControl);
