plane/web/components/modules/select/status.tsx
Anmol Singh Bhatia 0f99fb302b chore: modal and dropdown improvement (#3332)
* dev: dropdown key down custom hook added

* chore: plane ui dropdowns updated

* chore: cycle and module tab index added in modals

* chore: view and page tab index added in modals

* chore: issue modal tab indexing added

* chore: project modal tab indexing added

* fix: build fix

* build-error: build error in pages new structure and reverted back to old page structure

---------

Co-authored-by: gurusainath <gurusainath007@gmail.com>
2024-01-22 13:19:43 +05:30

54 lines
1.6 KiB
TypeScript

import React from "react";
// react hook form
import { Controller, FieldError, Control } from "react-hook-form";
// ui
import { CustomSelect, DoubleCircleIcon, ModuleStatusIcon } from "@plane/ui";
// types
import type { IModule } from "@plane/types";
// constants
import { MODULE_STATUS } from "constants/module";
type Props = {
control: Control<IModule, any>;
error?: FieldError;
tabIndex?: number;
};
export const ModuleStatusSelect: React.FC<Props> = ({ control, error, tabIndex }) => (
<Controller
control={control}
rules={{ required: true }}
name="status"
render={({ field: { value, onChange } }) => (
<CustomSelect
value={value}
label={
<div className={`flex items-center justify-center gap-2 text-xs ${error ? "text-red-500" : ""}`}>
{value ? (
<ModuleStatusIcon status={value} />
) : (
<DoubleCircleIcon className={`h-3 w-3 ${error ? "text-red-500" : "text-custom-text-200"}`} />
)}
{MODULE_STATUS.find((s) => s.value === value)?.label ?? (
<span className={`${error ? "text-red-500" : "text-custom-text-200"}`}>Status</span>
)}
</div>
}
onChange={onChange}
tabIndex={tabIndex}
noChevron
>
{MODULE_STATUS.map((status) => (
<CustomSelect.Option key={status.value} value={status.value}>
<div className="flex items-center gap-2">
<ModuleStatusIcon status={status.value} />
{status.label}
</div>
</CustomSelect.Option>
))}
</CustomSelect>
)}
/>
);