2022-12-22 16:19:46 +00:00
|
|
|
// react
|
|
|
|
import React from "react";
|
|
|
|
// react-hook-form
|
|
|
|
import { Control, Controller, UseFormWatch } from "react-hook-form";
|
|
|
|
// ui
|
2023-10-19 09:54:51 +00:00
|
|
|
import { CustomSelect, DoubleCircleIcon } from "@plane/ui";
|
2022-12-22 16:19:46 +00:00
|
|
|
// types
|
|
|
|
import { IModule } from "types";
|
|
|
|
// common
|
|
|
|
// constants
|
2023-02-08 04:45:18 +00:00
|
|
|
import { MODULE_STATUS } from "constants/module";
|
2022-12-22 16:19:46 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
control: Control<Partial<IModule>, any>;
|
|
|
|
submitChanges: (formData: Partial<IModule>) => void;
|
|
|
|
watch: UseFormWatch<Partial<IModule>>;
|
|
|
|
};
|
|
|
|
|
2023-02-08 04:45:18 +00:00
|
|
|
export const SidebarStatusSelect: React.FC<Props> = ({ control, submitChanges, watch }) => (
|
2023-01-26 18:12:20 +00:00
|
|
|
<div className="flex flex-wrap items-center py-2">
|
|
|
|
<div className="flex items-center gap-x-2 text-sm sm:basis-1/2">
|
2023-10-16 14:57:22 +00:00
|
|
|
<DoubleCircleIcon className="h-4 w-4 flex-shrink-0" />
|
2023-01-26 18:12:20 +00:00
|
|
|
<p>Status</p>
|
|
|
|
</div>
|
|
|
|
<div className="sm:basis-1/2">
|
|
|
|
<Controller
|
|
|
|
control={control}
|
|
|
|
name="status"
|
|
|
|
render={({ field: { value } }) => (
|
|
|
|
<CustomSelect
|
|
|
|
label={
|
2023-10-16 14:57:22 +00:00
|
|
|
<span className={`flex items-center gap-2 text-left capitalize ${value ? "" : "text-custom-text-100"}`}>
|
2022-12-22 16:19:46 +00:00
|
|
|
<span
|
2023-01-26 18:12:20 +00:00
|
|
|
className="h-2 w-2 flex-shrink-0 rounded-full"
|
|
|
|
style={{
|
|
|
|
backgroundColor: MODULE_STATUS?.find((option) => option.value === value)?.color,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{watch("status")}
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
value={value}
|
|
|
|
onChange={(value: any) => {
|
|
|
|
submitChanges({ status: value });
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{MODULE_STATUS.map((option) => (
|
|
|
|
<CustomSelect.Option key={option.value} value={option.value}>
|
|
|
|
<>
|
2023-10-16 14:57:22 +00:00
|
|
|
<span className="h-2 w-2 flex-shrink-0 rounded-full" style={{ backgroundColor: option.color }} />
|
2023-01-26 18:12:20 +00:00
|
|
|
{option.label}
|
|
|
|
</>
|
|
|
|
</CustomSelect.Option>
|
|
|
|
))}
|
|
|
|
</CustomSelect>
|
|
|
|
)}
|
|
|
|
/>
|
2022-12-22 16:19:46 +00:00
|
|
|
</div>
|
2023-01-26 18:12:20 +00:00
|
|
|
</div>
|
|
|
|
);
|