2023-02-08 04:43:07 +00:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
// ui
|
2023-02-22 06:12:17 +00:00
|
|
|
import { CustomSelect, Tooltip } from "components/ui";
|
2023-02-08 04:43:07 +00:00
|
|
|
// icons
|
|
|
|
import { getPriorityIcon } from "components/icons/priority-icon";
|
|
|
|
// types
|
|
|
|
import { IIssue } from "types";
|
|
|
|
// constants
|
|
|
|
import { PRIORITIES } from "constants/project";
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
issue: IIssue;
|
|
|
|
partialUpdateIssue: (formData: Partial<IIssue>) => void;
|
2023-03-05 14:52:01 +00:00
|
|
|
position?: "left" | "right";
|
2023-02-23 17:04:36 +00:00
|
|
|
selfPositioned?: boolean;
|
2023-02-08 04:43:07 +00:00
|
|
|
isNotAllowed: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ViewPrioritySelect: React.FC<Props> = ({
|
|
|
|
issue,
|
|
|
|
partialUpdateIssue,
|
2023-03-05 14:52:01 +00:00
|
|
|
position = "left",
|
2023-02-23 17:04:36 +00:00
|
|
|
selfPositioned = false,
|
2023-02-08 04:43:07 +00:00
|
|
|
isNotAllowed,
|
|
|
|
}) => (
|
2023-02-16 06:33:52 +00:00
|
|
|
<CustomSelect
|
2023-03-15 06:14:44 +00:00
|
|
|
value={issue.priority}
|
|
|
|
onChange={(data: string) =>
|
|
|
|
partialUpdateIssue({ priority: data, state: issue.state, target_date: issue.target_date })
|
|
|
|
}
|
2023-02-16 06:33:52 +00:00
|
|
|
maxHeight="md"
|
2023-02-28 09:12:46 +00:00
|
|
|
customButton={
|
|
|
|
<button
|
|
|
|
type="button"
|
2023-03-05 14:52:01 +00:00
|
|
|
className={`grid h-6 w-6 place-items-center rounded ${
|
2023-02-28 09:12:46 +00:00
|
|
|
isNotAllowed ? "cursor-not-allowed" : "cursor-pointer"
|
|
|
|
} items-center shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 ${
|
|
|
|
issue.priority === "urgent"
|
|
|
|
? "bg-red-100 text-red-600 hover:bg-red-100"
|
|
|
|
: issue.priority === "high"
|
|
|
|
? "bg-orange-100 text-orange-500 hover:bg-orange-100"
|
|
|
|
: issue.priority === "medium"
|
|
|
|
? "bg-yellow-100 text-yellow-500 hover:bg-yellow-100"
|
|
|
|
: issue.priority === "low"
|
|
|
|
? "bg-green-100 text-green-500 hover:bg-green-100"
|
|
|
|
: "bg-gray-100"
|
|
|
|
} border-none`}
|
|
|
|
>
|
|
|
|
<Tooltip tooltipHeading="Priority" tooltipContent={issue.priority ?? "None"}>
|
|
|
|
<span>
|
|
|
|
{getPriorityIcon(
|
|
|
|
issue.priority && issue.priority !== "" ? issue.priority ?? "" : "None",
|
|
|
|
"text-sm"
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
</Tooltip>
|
|
|
|
</button>
|
|
|
|
}
|
2023-02-16 06:33:52 +00:00
|
|
|
noChevron
|
2023-02-08 04:43:07 +00:00
|
|
|
disabled={isNotAllowed}
|
2023-03-05 14:52:01 +00:00
|
|
|
position={position}
|
2023-02-23 17:04:36 +00:00
|
|
|
selfPositioned={selfPositioned}
|
2023-02-08 04:43:07 +00:00
|
|
|
>
|
2023-02-16 06:33:52 +00:00
|
|
|
{PRIORITIES?.map((priority) => (
|
|
|
|
<CustomSelect.Option key={priority} value={priority} className="capitalize">
|
|
|
|
<>
|
|
|
|
{getPriorityIcon(priority, "text-sm")}
|
|
|
|
{priority ?? "None"}
|
|
|
|
</>
|
|
|
|
</CustomSelect.Option>
|
|
|
|
))}
|
|
|
|
</CustomSelect>
|
2023-02-08 04:43:07 +00:00
|
|
|
);
|