2023-04-06 09:39:24 +00:00
|
|
|
import React from "react";
|
2023-12-18 10:56:17 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
import { Triangle } from "lucide-react";
|
|
|
|
// store hooks
|
|
|
|
import { useEstimate } from "hooks/store";
|
2023-04-06 09:39:24 +00:00
|
|
|
// ui
|
2023-10-19 09:54:51 +00:00
|
|
|
import { CustomSelect } from "@plane/ui";
|
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-12-18 10:56:17 +00:00
|
|
|
export const IssueEstimateSelect: React.FC<Props> = observer((props) => {
|
|
|
|
const { value, onChange } = props;
|
2023-04-06 09:39:24 +00:00
|
|
|
|
2023-12-18 10:56:17 +00:00
|
|
|
const { areEstimatesEnabledForCurrentProject, activeEstimateDetails } = useEstimate();
|
|
|
|
|
|
|
|
if (!areEstimatesEnabledForCurrentProject) return null;
|
2023-04-06 09:39:24 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<CustomSelect
|
|
|
|
value={value}
|
|
|
|
label={
|
2023-11-08 12:21:32 +00:00
|
|
|
<div className="flex items-center justify-center gap-1 text-xs">
|
|
|
|
<Triangle className={`h-3 w-3 ${value !== null ? "text-custom-text-200" : "text-custom-text-300"}`} />
|
|
|
|
<span className={value !== null ? "text-custom-text-200" : "text-custom-text-300"}>
|
2023-12-18 10:56:17 +00:00
|
|
|
{activeEstimateDetails?.points?.find((e) => e.key === value)?.value ?? "Estimate"}
|
2023-04-06 09:39:24 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
onChange={onChange}
|
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>
|
2023-10-16 14:57:22 +00:00
|
|
|
<Triangle className="h-4 w-4" />
|
2023-04-17 06:00:48 +00:00
|
|
|
</span>
|
|
|
|
None
|
|
|
|
</>
|
|
|
|
</CustomSelect.Option>
|
2023-12-18 10:56:17 +00:00
|
|
|
{activeEstimateDetails?.points &&
|
|
|
|
activeEstimateDetails.points?.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>
|
2023-10-16 14:57:22 +00:00
|
|
|
<Triangle className="h-4 w-4" />
|
2023-04-08 08:25:30 +00:00
|
|
|
</span>
|
|
|
|
{point.value}
|
|
|
|
</>
|
2023-04-06 09:39:24 +00:00
|
|
|
</CustomSelect.Option>
|
|
|
|
))}
|
|
|
|
</CustomSelect>
|
|
|
|
);
|
2023-12-18 10:56:17 +00:00
|
|
|
});
|