"use client";

import React from "react";
import { AutoRegisteringComponentRenderer } from "../../AutoRegisteringComponentRenderer";
import { V2ProcessWorkStandardDefinition } from "./index";
import { ProcessWorkStandardComponent } from "./ProcessWorkStandardComponent";

export class ProcessWorkStandardRenderer extends AutoRegisteringComponentRenderer {
  static componentDefinition = V2ProcessWorkStandardDefinition;

  render(): React.ReactElement {
    const { formData, isPreview, config, tableName, screenId } = this.props as Record<
      string,
      unknown
    >;

    return (
      <ProcessWorkStandardComponent
        config={(config as object) || {}}
        formData={formData as Record<string, unknown>}
        tableName={tableName as string}
        isPreview={isPreview as boolean}
        screenId={screenId as number | string}
      />
    );
  }
}

ProcessWorkStandardRenderer.registerSelf();

if (process.env.NODE_ENV === "development") {
  ProcessWorkStandardRenderer.enableHotReload();
}
