import TextWidget from "@rjsf/core/lib/components/widgets/TextWidget";
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from "@rjsf/utils";

import { ForeignKeyWidget } from "./foreign-key";
import {BgfcPriceWidget} from "./bgfc-price";

export default function CrudTextWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
  props: WidgetProps<T, S, F>
) {
  if (props.schema.hasOwnProperty("foreign_key")) {
    return (<ForeignKeyWidget {...props} />);
  } else if (props.schema.hasOwnProperty("format") && props.schema.format == "price-bgdc") {
    return (<BgfcPriceWidget {...props} />);
  } else {
    return (<TextWidget {...props} />);
  }
}
