/**
 * Copyright (c) 2023-present Pi Dash Software, Inc. and contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 * See the LICENSE file for details.
 */

import { observer } from "mobx-react";
import { useTranslation } from "@pi-dash/i18n";
import type { TQuickAddIssueForm } from "../root";

export const SpreadsheetQuickAddIssueForm = observer(function SpreadsheetQuickAddIssueForm(props: TQuickAddIssueForm) {
  const { ref, projectDetail, register, onSubmit, isEpic } = props;
  const { t } = useTranslation();
  return (
    <div className="pb-2">
      <form
        ref={ref}
        onSubmit={onSubmit}
        className="z-10 flex items-center gap-x-5 border-[0.5px] border-t-0 border-subtle bg-surface-1 px-4 shadow-raised-200"
      >
        <h4 className="w-20 text-11 leading-5 text-placeholder">{projectDetail?.identifier ?? "..."}</h4>
        <input
          type="text"
          autoComplete="off"
          placeholder={isEpic ? t("Epic Title") : t("Work item title")}
          {...register("name", {
            required: isEpic ? t("Epic title is required.") : t("Work item title is required."),
          })}
          className="w-full rounded-md bg-transparent py-3 text-13 leading-5 text-secondary outline-none"
        />
      </form>
      <p className="mt-3 ml-3 text-11 text-secondary italic">
        {isEpic ? t("Press 'Enter' to add another epic") : t("Press 'Enter' to add another work item")}
      </p>
    </div>
  );
});
