diff --git a/packages/types/src/issues/issue.d.ts b/packages/types/src/issues/issue.d.ts index 42c95dc4e..990b308e7 100644 --- a/packages/types/src/issues/issue.d.ts +++ b/packages/types/src/issues/issue.d.ts @@ -15,7 +15,7 @@ export type TIssue = { priority: TIssuePriorities; label_ids: string[]; assignee_ids: string[]; - estimate_point: number | null; + estimate_point: string | null; sub_issues_count: number; attachment_count: number; diff --git a/web/components/core/modals/gpt-assistant-popover.tsx b/web/components/core/modals/gpt-assistant-popover.tsx index 9843124e4..04d696790 100644 --- a/web/components/core/modals/gpt-assistant-popover.tsx +++ b/web/components/core/modals/gpt-assistant-popover.tsx @@ -5,7 +5,7 @@ import { Controller, useForm } from "react-hook-form"; // services import { usePopper } from "react-popper"; // ui import { AlertCircle } from "lucide-react"; -import { Popover, PopoverButton, PopoverPanel, Transition } from "@headlessui/react"; +import { Popover, Transition } from "@headlessui/react"; import { Button, Input, TOAST_TYPE, setToast } from "@plane/ui"; import { RichTextReadOnlyEditor } from "@/components/editor/rich-text-editor/rich-text-read-only-editor"; // icons @@ -178,9 +178,9 @@ export const GptAssistantPopover: React.FC = (props) => { return ( - + - + = (props) => { leaveFrom="transform opacity-100 scale-100" leaveTo="transform opacity-0 scale-95" > - } @@ -261,7 +261,7 @@ export const GptAssistantPopover: React.FC = (props) => { - + ); diff --git a/web/components/dropdowns/estimate.tsx b/web/components/dropdowns/estimate.tsx index da0c77d9b..99e8106de 100644 --- a/web/components/dropdowns/estimate.tsx +++ b/web/components/dropdowns/estimate.tsx @@ -1,5 +1,4 @@ import { Fragment, ReactNode, useRef, useState } from "react"; -import sortBy from "lodash/sortBy"; import { observer } from "mobx-react"; import { usePopper } from "react-popper"; import { Check, ChevronDown, Search, Triangle } from "lucide-react"; @@ -9,6 +8,8 @@ import { cn } from "@/helpers/common.helper"; // hooks import { useAppRouter, + useEstimate, + useProjectEstimates, // useEstimate } from "@/hooks/store"; import { useDropdown } from "@/hooks/use-dropdown"; @@ -22,15 +23,15 @@ type Props = TDropdownProps & { button?: ReactNode; dropdownArrow?: boolean; dropdownArrowClassName?: string; - onChange: (val: number | null) => void; + onChange: (val: string | undefined) => void; onClose?: () => void; projectId: string; - value: number | null; + value: string | undefined; }; type DropdownOptions = | { - value: number | null; + value: string | null; query: string; content: JSX.Element; }[] @@ -79,23 +80,29 @@ export const EstimateDropdown: React.FC = observer((props) => { }); // store hooks const { workspaceSlug } = useAppRouter(); - console.log("workspaceSlug", workspaceSlug); - console.log("projectId", projectId); - // const { fetchProjectEstimates, getProjectActiveEstimateDetails, getEstimatePointValue } = useEstimate(); - // const activeEstimate = getProjectActiveEstimateDetails(projectId); - const activeEstimate: any = undefined; + const { currentActiveEstimateId, getProjectEstimates } = useProjectEstimates(); + const { estimatePointIds, estimatePointById } = useEstimate( + currentActiveEstimateId ? currentActiveEstimateId : undefined + ); - const options: DropdownOptions = sortBy(activeEstimate?.points ?? [], "key")?.map((point) => ({ - value: point.key, - query: `${point?.value}`, - content: ( -
- - {point.value} -
- ), - })); + const options: DropdownOptions = (estimatePointIds ?? []) + ?.map((estimatePoint) => { + const currentEstimatePoint = estimatePointById(estimatePoint); + if (currentEstimatePoint) + return { + value: currentEstimatePoint.id, + query: `${currentEstimatePoint?.value}`, + content: ( +
+ + {currentEstimatePoint.value} +
+ ), + }; + else undefined; + }) + .filter((estimatePointDropdownOption) => estimatePointDropdownOption != undefined) as DropdownOptions; options?.unshift({ value: null, query: "No estimate", @@ -110,14 +117,10 @@ export const EstimateDropdown: React.FC = observer((props) => { const filteredOptions = query === "" ? options : options?.filter((o) => o.query.toLowerCase().includes(query.toLowerCase())); - const selectedEstimate = - value !== null - ? // getEstimatePointValue(value, projectId) - null - : null; + const selectedEstimate = value && estimatePointById ? estimatePointById(value) : undefined; const onOpen = async () => { - // if (!activeEstimate && workspaceSlug) await fetchProjectEstimates(workspaceSlug, projectId); + if (!currentActiveEstimateId && workspaceSlug) await getProjectEstimates(workspaceSlug, projectId); }; const { handleClose, handleKeyDown, handleOnClick, searchInputKeyDown } = useDropdown({ @@ -131,7 +134,7 @@ export const EstimateDropdown: React.FC = observer((props) => { setQuery, }); - const dropdownOnChange = (val: number | null) => { + const dropdownOnChange = (val: string | undefined) => { onChange(val); handleClose(); }; @@ -175,13 +178,13 @@ export const EstimateDropdown: React.FC = observer((props) => { className={buttonClassName} isActive={isOpen} tooltipHeading="Estimate" - tooltipContent={selectedEstimate !== null ? selectedEstimate : placeholder} + tooltipContent={selectedEstimate ? selectedEstimate?.value : placeholder} showTooltip={showTooltip} variant={buttonVariant} > {!hideIcon && } {(selectedEstimate || placeholder) && BUTTON_VARIANTS_WITH_TEXT.includes(buttonVariant) && ( - {selectedEstimate !== null ? selectedEstimate : placeholder} + {selectedEstimate ? selectedEstimate?.value : placeholder} )} {dropdownArrow && (