248 lines · 9.5 KB
import { useState } from "react";
import { Link, useNavigate } from "@tanstack/react-router";
import { listTransferTargets, setIssuePinned, setIssuePlanning, setSubIssue, transferIssueTo } from "~/fns/planning";
import { convertIssueToDiscussion } from "~/fns/discussion-admin";
import { useAction } from "~/hooks/use-action";
import type { getIssuePlanning } from "~/fns/planning";
import { ProgressBar } from "./ProgressBar";
import { Button } from "~/ui/Button";
import { InlineSelect, inputClass } from "~/ui/Field";
import { LabelChip } from "~/ui/LabelChip";
import { cn } from "~/utils/cn";
import { SidebarSection } from "~/ui/Heading";

type Planning = Awaited<ReturnType<typeof getIssuePlanning>>;
type Props = { owner: string; repo: string; number: number; planning: Planning };

function Choice({
  label,
  value,
  options,
  disabled,
  onChange,
}: {
  label: string;
  value: string;
  options: Array<{ id: string; name: string }>;
  disabled: boolean;
  onChange: (value: string | null) => void;
}) {
  return (
    <InlineSelect
      label={label}
      value={value}
      disabled={disabled}
      onValueChange={(next) => onChange(next || null)}
      className="w-full"
      options={[{ value: "", label: "None" }, ...options.map((option) => ({ value: option.id, label: option.name }))]}
    />
  );
}