2023-04-06 09:39:24 +00:00
|
|
|
import React from "react";
|
|
|
|
|
2023-04-17 06:00:48 +00:00
|
|
|
// hooks
|
|
|
|
import useEstimateOption from "hooks/use-estimate-option";
|
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
|
|
|
// icons
|
2023-10-16 14:57:22 +00:00
|
|
|
import { Triangle } from "lucide-react";
|
2023-04-06 09:39:24 +00:00
|
|
|
|
|
|
|
type Props = {
|
2023-04-17 06:00:48 +00:00
|
|
|
value: number | null;
|
|
|
|
onChange: (val: number | null) => void;
|
2023-07-13 06:04:37 +00:00
|
|
|
disabled?: boolean;
|
2023-04-06 09:39:24 +00:00
|
|
|
};
|
|
|
|
|
2023-08-25 12:11:23 +00:00
|
|
|
export const SidebarEstimateSelect: React.FC<Props> = ({ value, onChange, disabled = false }) => {
|
2023-08-29 14:45:12 +00:00
|
|
|
const { estimatePoints } = useEstimateOption();
|
2023-04-11 12:24:01 +00:00
|
|
|
|
2023-11-01 08:52:29 +00:00
|
|
|
const currentEstimate = estimatePoints?.find((e) => e.key === value)?.value;
|
2023-04-06 09:39:24 +00:00
|
|
|
return (
|
2023-08-25 12:11:23 +00:00
|
|
|
<CustomSelect
|
|
|
|
value={value}
|
|
|
|
customButton={
|
2023-11-01 08:52:29 +00:00
|
|
|
<div className="flex items-center gap-1.5 text-xs bg-custom-background-80 rounded px-2.5 py-0.5">
|
|
|
|
{currentEstimate ? (
|
|
|
|
<>
|
|
|
|
<Triangle className={`h-3 w-3 ${value !== null ? "text-custom-text-100" : "text-custom-text-200"}`} />
|
|
|
|
{currentEstimate}
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
"No Estimate"
|
|
|
|
)}
|
2023-10-11 06:35:53 +00:00
|
|
|
</div>
|
2023-08-25 12:11:23 +00:00
|
|
|
}
|
|
|
|
onChange={onChange}
|
|
|
|
disabled={disabled}
|
|
|
|
>
|
|
|
|
<CustomSelect.Option value={null}>
|
|
|
|
<>
|
|
|
|
<span>
|
2023-11-01 08:52:29 +00:00
|
|
|
<Triangle className="h-3.5 w-3" />
|
2023-08-25 12:11:23 +00:00
|
|
|
</span>
|
|
|
|
None
|
|
|
|
</>
|
|
|
|
</CustomSelect.Option>
|
|
|
|
{estimatePoints &&
|
|
|
|
estimatePoints.map((point) => (
|
|
|
|
<CustomSelect.Option key={point.key} value={point.key}>
|
2023-04-17 06:00:48 +00:00
|
|
|
<>
|
|
|
|
<span>
|
2023-11-01 08:52:29 +00:00
|
|
|
<Triangle className="h-3.5 w-3.5" />
|
2023-04-17 06:00:48 +00:00
|
|
|
</span>
|
2023-08-25 12:11:23 +00:00
|
|
|
{point.value}
|
2023-04-17 06:00:48 +00:00
|
|
|
</>
|
|
|
|
</CustomSelect.Option>
|
2023-08-25 12:11:23 +00:00
|
|
|
))}
|
|
|
|
</CustomSelect>
|
2023-04-06 09:39:24 +00:00
|
|
|
);
|
2023-04-11 12:24:01 +00:00
|
|
|
};
|