import React from "react";
import CreateTaskTemplate from "./CreateTaskTemplate";
import { fetchAllTasks, fetchTaskTemplateDetail } from "@/app/api/tasks";
import { fetchGrades } from "@/app/api/grades";

interface Props {
  taskTemplateId?: string;
}

const CreateTaskTemplateWrapper: React.FC<Props> = async (props) => {
  const [tasks, grades] = await Promise.all([
    fetchAllTasks(),
    fetchGrades(),
  ]);

  const taskTemplateInfo = props.taskTemplateId ? await fetchTaskTemplateDetail(props.taskTemplateId) : undefined
  return <CreateTaskTemplate tasks={tasks} grades={grades} defaultInputs={taskTemplateInfo}/>;
};

export default CreateTaskTemplateWrapper;
