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-04-11 12:24:01 +00:00
|
|
|
import { CustomSelect } from "components/ui";
|
2023-04-06 09:39:24 +00:00
|
|
|
// icons
|
2023-04-17 06:00:48 +00:00
|
|
|
import { PlayIcon } from "@heroicons/react/24/outline";
|
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-04-06 09:39:24 +00:00
|
|
|
return (
|
2023-08-25 12:11:23 +00:00
|
|
|
<CustomSelect
|
|
|
|
value={value}
|
|
|
|
customButton={
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="flex items-center gap-1.5 !text-sm bg-custom-background-80 rounded px-2.5 py-0.5"
|
2023-04-11 12:24:01 +00:00
|
|
|
>
|
2023-08-25 12:11:23 +00:00
|
|
|
<PlayIcon
|
|
|
|
className={`h-4 w-4 -rotate-90 ${
|
|
|
|
value !== null ? "text-custom-text-100" : "text-custom-text-200"
|
|
|
|
}`}
|
|
|
|
/>
|
|
|
|
{estimatePoints?.find((e) => e.key === value)?.value ?? "No estimate"}
|
|
|
|
</button>
|
|
|
|
}
|
|
|
|
onChange={onChange}
|
|
|
|
disabled={disabled}
|
|
|
|
>
|
|
|
|
<CustomSelect.Option value={null}>
|
|
|
|
<>
|
|
|
|
<span>
|
|
|
|
<PlayIcon className="h-4 w-4 -rotate-90" />
|
|
|
|
</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>
|
|
|
|
<PlayIcon className="h-4 w-4 -rotate-90" />
|
|
|
|
</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
|
|
|
};
|