2023-05-16 09:41:40 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
2023-05-16 05:11:37 +00:00
|
|
|
// ui
|
|
|
|
import { CustomSelect } from "components/ui";
|
|
|
|
// types
|
2023-05-16 09:41:40 +00:00
|
|
|
import { TXAxisValues } from "types";
|
2023-05-16 05:11:37 +00:00
|
|
|
// constants
|
2023-05-16 09:41:40 +00:00
|
|
|
import { ANALYTICS_X_AXIS_VALUES } from "constants/analytics";
|
2023-05-16 05:11:37 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
value: TXAxisValues;
|
|
|
|
onChange: (val: string) => void;
|
|
|
|
};
|
|
|
|
|
2023-05-16 09:41:40 +00:00
|
|
|
export const SelectXAxis: React.FC<Props> = ({ value, onChange }) => {
|
|
|
|
const router = useRouter();
|
|
|
|
const { cycleId, moduleId } = router.query;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CustomSelect
|
|
|
|
value={value}
|
|
|
|
label={<span>{ANALYTICS_X_AXIS_VALUES.find((v) => v.value === value)?.label}</span>}
|
|
|
|
onChange={onChange}
|
|
|
|
width="w-full"
|
|
|
|
maxHeight="lg"
|
|
|
|
>
|
|
|
|
{ANALYTICS_X_AXIS_VALUES.map((item) => {
|
|
|
|
if (cycleId && item.value === "issue_cycle__cycle__name") return null;
|
|
|
|
if (moduleId && item.value === "issue_module__module__name") return null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CustomSelect.Option key={item.value} value={item.value}>
|
|
|
|
{item.label}
|
|
|
|
</CustomSelect.Option>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</CustomSelect>
|
|
|
|
);
|
|
|
|
};
|