plane/apps/app/components/project/issues/issue-detail/issue-detail-sidebar/select-priority.tsx

59 lines
1.8 KiB
TypeScript
Raw Normal View History

2022-12-15 04:17:56 +00:00
// react
import React from "react";
// react-hook-form
import { Control, Controller, UseFormWatch } from "react-hook-form";
2022-12-15 04:17:56 +00:00
// headless ui
import { Listbox, Transition } from "@headlessui/react";
// icons
import { ChevronDownIcon, ChartBarIcon } from "@heroicons/react/24/outline";
// types
import { IIssue } from "types";
// constants
import { classNames } from "constants/common";
import { PRIORITIES } from "constants/";
import CustomSelect from "ui/custom-select";
2022-12-15 04:17:56 +00:00
type Props = {
control: Control<IIssue, any>;
submitChanges: (formData: Partial<IIssue>) => void;
watch: UseFormWatch<IIssue>;
2022-12-15 04:17:56 +00:00
};
const SelectPriority: React.FC<Props> = ({ control, submitChanges, watch }) => {
2022-12-15 04:17:56 +00:00
return (
<div className="flex items-center py-2 flex-wrap">
<div className="flex items-center gap-x-2 text-sm sm:basis-1/2">
<ChartBarIcon className="flex-shrink-0 h-4 w-4" />
<p>Priority</p>
</div>
<div className="sm:basis-1/2">
<Controller
control={control}
name="state"
render={({ field: { value } }) => (
<CustomSelect
label={
<span className={classNames(value ? "" : "text-gray-900", "text-left capitalize")}>
{watch("priority") && watch("priority") !== "" ? watch("priority") : "None"}
</span>
}
2022-12-15 04:17:56 +00:00
value={value}
onChange={(value: any) => {
submitChanges({ priority: value });
}}
>
{PRIORITIES.map((option) => (
<CustomSelect.Option key={option} value={option} className="capitalize">
{option}
</CustomSelect.Option>
))}
</CustomSelect>
2022-12-15 04:17:56 +00:00
)}
/>
</div>
</div>
);
};
export default SelectPriority;