|
| 1 | +"use client"; |
| 2 | + |
1 | 3 | import { observer } from "mobx-react"; |
2 | 4 | // plane ui |
3 | 5 | import { StateGroupIcon } from "@plane/propel/icons"; |
4 | 6 | import { Tooltip } from "@plane/propel/tooltip"; |
| 7 | +import type { TStateGroups } from "@plane/types"; |
5 | 8 | // plane utils |
6 | 9 | import { cn } from "@plane/utils"; |
7 | 10 | //hooks |
8 | 11 | import { useStates } from "@/hooks/store/use-state"; |
9 | 12 |
|
10 | 13 | type Props = { |
11 | | - stateId: string | undefined; |
12 | 14 | shouldShowBorder?: boolean; |
13 | | -}; |
14 | | -export const IssueBlockState = observer(function IssueBlockState({ stateId, shouldShowBorder = true }: Props) { |
15 | | - const { getStateById } = useStates(); |
| 15 | +} & ( |
| 16 | + | { |
| 17 | + stateDetails: { |
| 18 | + name: string; |
| 19 | + group: TStateGroups; |
| 20 | + }; |
| 21 | + } |
| 22 | + | { |
| 23 | + stateId: string; |
| 24 | + } |
| 25 | +); |
16 | 26 |
|
17 | | - const state = getStateById(stateId); |
| 27 | +export const IssueBlockState: React.FC<Props> = observer((props) => { |
| 28 | + const { shouldShowBorder = true } = props; |
| 29 | + // store hooks |
| 30 | + const { getStateById } = useStates(); |
| 31 | + // derived values |
| 32 | + const state = "stateId" in props ? getStateById(props.stateId) : props.stateDetails; |
| 33 | + if (!state) return null; |
18 | 34 |
|
19 | 35 | return ( |
20 | | - <Tooltip tooltipHeading="State" tooltipContent={state?.name ?? "State"}> |
| 36 | + <Tooltip tooltipHeading="State" tooltipContent={state.name}> |
21 | 37 | <div |
22 | 38 | className={cn("flex h-full w-full items-center justify-between gap-1 rounded px-2.5 py-1 text-xs", { |
23 | 39 | "border-[0.5px] border-custom-border-300": shouldShowBorder, |
24 | 40 | })} |
25 | 41 | > |
26 | 42 | <div className="flex w-full items-center gap-1.5"> |
27 | | - <StateGroupIcon stateGroup={state?.group ?? "backlog"} color={state?.color} /> |
28 | | - <div className="text-xs">{state?.name ?? "State"}</div> |
| 43 | + <StateGroupIcon stateGroup={state.group} /> |
| 44 | + <div className="text-xs">{state.name}</div> |
29 | 45 | </div> |
30 | 46 | </div> |
31 | 47 | </Tooltip> |
|
0 commit comments