2023-04-06 09:39:24 +00:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
// ui
|
|
|
|
import { CustomSelect } from "components/ui";
|
|
|
|
// icons
|
2023-04-11 12:24:01 +00:00
|
|
|
import { PlayIcon } from "@heroicons/react/24/outline";
|
2023-04-06 09:39:24 +00:00
|
|
|
// fetch-keys
|
2023-04-11 12:24:01 +00:00
|
|
|
import useEstimateOption from "hooks/use-estimate-option";
|
2023-04-06 09:39:24 +00:00
|
|
|
|
|
|
|
type Props = {
|
2023-04-17 06:00:48 +00:00
|
|
|
value: number | null;
|
|
|
|
onChange: (value: number | null) => void;
|
2023-04-06 09:39:24 +00:00
|
|
|
};
|
|
|
|
|
2023-04-11 12:24:01 +00:00
|
|
|
export const IssueEstimateSelect: React.FC<Props> = ({ value, onChange }) => {
|
|
|
|
const { isEstimateActive, estimatePoints } = useEstimateOption();
|
2023-04-06 09:39:24 +00:00
|
|
|
|
2023-04-11 12:24:01 +00:00
|
|
|
if (!isEstimateActive) return null;
|
2023-04-06 09:39:24 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<CustomSelect
|
|
|
|
value={value}
|
|
|
|
label={
|
2023-04-11 12:24:01 +00:00
|
|
|
<div className="flex items-center gap-2 text-xs">
|
2023-04-21 19:29:57 +00:00
|
|
|
<PlayIcon className="h-4 w-4 -rotate-90 text-gray-500" />
|
2023-04-06 09:39:24 +00:00
|
|
|
<span className={`${value ? "text-gray-600" : "text-gray-500"}`}>
|
2023-04-17 06:00:48 +00:00
|
|
|
{estimatePoints?.find((e) => e.key === value)?.value ?? "Estimate"}
|
2023-04-06 09:39:24 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
onChange={onChange}
|
|
|
|
position="right"
|
2023-04-17 06:00:48 +00:00
|
|
|
width="w-full min-w-[8rem]"
|
2023-04-11 12:24:01 +00:00
|
|
|
noChevron
|
2023-04-06 09:39:24 +00:00
|
|
|
>
|
2023-04-17 06:00:48 +00:00
|
|
|
<CustomSelect.Option value={null}>
|
|
|
|
<>
|
|
|
|
<span>
|
|
|
|
<PlayIcon className="h-4 w-4 -rotate-90" />
|
|
|
|
</span>
|
|
|
|
None
|
|
|
|
</>
|
|
|
|
</CustomSelect.Option>
|
2023-04-06 09:39:24 +00:00
|
|
|
{estimatePoints &&
|
|
|
|
estimatePoints.map((point) => (
|
2023-04-17 06:00:48 +00:00
|
|
|
<CustomSelect.Option key={point.key} value={point.key}>
|
2023-04-08 08:25:30 +00:00
|
|
|
<>
|
|
|
|
<span>
|
|
|
|
<PlayIcon className="h-4 w-4 -rotate-90" />
|
|
|
|
</span>
|
|
|
|
{point.value}
|
|
|
|
</>
|
2023-04-06 09:39:24 +00:00
|
|
|
</CustomSelect.Option>
|
|
|
|
))}
|
|
|
|
</CustomSelect>
|
|
|
|
);
|
|
|
|
};
|