diff --git a/web/ce/components/estimates/index.ts b/web/ce/components/estimates/index.ts index 2dc47bba6..918b72d8d 100644 --- a/web/ce/components/estimates/index.ts +++ b/web/ce/components/estimates/index.ts @@ -1,3 +1,3 @@ export * from "./estimate-list-item-buttons"; - export * from "./update"; +export * from "./points"; diff --git a/web/ce/components/estimates/points/delete.tsx b/web/ce/components/estimates/points/delete.tsx new file mode 100644 index 000000000..08dd605e4 --- /dev/null +++ b/web/ce/components/estimates/points/delete.tsx @@ -0,0 +1,17 @@ +"use client"; + +import { FC } from "react"; + +import { TEstimateTypeErrorObject } from "@plane/types"; + +type TEstimatePointDelete = { + workspaceSlug: string; + projectId: string; + estimateId: string; + estimatePointId: string; + callback: () => void; + estimatePointError?: TEstimateTypeErrorObject | undefined; + handleEstimatePointError?: (newValue: string, message: string | undefined, mode?: "add" | "delete") => void; +}; + +export const EstimatePointDelete: FC = () => <>; diff --git a/web/ce/components/estimates/points/index.ts b/web/ce/components/estimates/points/index.ts new file mode 100644 index 000000000..fe722bd23 --- /dev/null +++ b/web/ce/components/estimates/points/index.ts @@ -0,0 +1 @@ +export * from "./delete"; diff --git a/web/core/components/estimates/points/delete.tsx b/web/core/components/estimates/points/delete.tsx deleted file mode 100644 index fd11c414e..000000000 --- a/web/core/components/estimates/points/delete.tsx +++ /dev/null @@ -1,120 +0,0 @@ -"use client"; - -import { FC, useState } from "react"; -import { observer } from "mobx-react"; -import { MoveRight, Trash2, X } from "lucide-react"; -import { TEstimatePointsObject } from "@plane/types"; -import { Spinner, TOAST_TYPE, setToast } from "@plane/ui"; -// components -import { EstimatePointDropdown } from "@/components/estimates/points"; -// hooks -import { useEstimate, useEstimatePoint } from "@/hooks/store"; - -type TEstimatePointDelete = { - workspaceSlug: string; - projectId: string; - estimateId: string; - estimatePointId: string; - callback: () => void; -}; - -export const EstimatePointDelete: FC = observer((props) => { - const { workspaceSlug, projectId, estimateId, estimatePointId, callback } = props; - // hooks - const { estimatePointIds, estimatePointById, deleteEstimatePoint } = useEstimate(estimateId); - const { asJson: estimatePoint } = useEstimatePoint(estimateId, estimatePointId); - // states - const [loader, setLoader] = useState(false); - const [estimateInputValue, setEstimateInputValue] = useState(undefined); - const [error, setError] = useState(undefined); - - const handleClose = () => { - setEstimateInputValue(""); - callback(); - }; - - const handleDelete = async () => { - if (!workspaceSlug || !projectId || !projectId) return; - - setError(undefined); - - if (estimateInputValue) - try { - setLoader(true); - - await deleteEstimatePoint( - workspaceSlug, - projectId, - estimatePointId, - estimateInputValue === "none" ? undefined : estimateInputValue - ); - - setLoader(false); - setError(undefined); - setToast({ - type: TOAST_TYPE.SUCCESS, - title: "Estimate point updated", - message: "The estimate point has been updated successfully.", - }); - handleClose(); - } catch { - setLoader(false); - setError("something went wrong. please try again later"); - setToast({ - type: TOAST_TYPE.ERROR, - title: "Estimate point failed to updated", - message: "We are unable to process your request, please try again.", - }); - } - else setError("please select option"); - }; - - // derived values - const selectDropdownOptionIds = estimatePointIds?.filter((pointId) => pointId != estimatePointId) as string[]; - const selectDropdownOptions = (selectDropdownOptionIds || []) - ?.map((pointId) => { - const estimatePoint = estimatePointById(pointId); - if (estimatePoint && estimatePoint?.id) - return { id: estimatePoint.id, key: estimatePoint.key, value: estimatePoint.value }; - }) - .filter((estimatePoint) => estimatePoint != undefined) as TEstimatePointsObject[]; - - return ( -
-
-
- {estimatePoint?.value} -
-
- Mark as -
- { - setEstimateInputValue(estimateId); - setError(undefined); - }} - /> -
- {loader ? ( -
- -
- ) : ( -
- -
- )} -
- -
-
- ); -}); diff --git a/web/core/components/estimates/points/index.ts b/web/core/components/estimates/points/index.ts index d696a7f97..1a7c5501c 100644 --- a/web/core/components/estimates/points/index.ts +++ b/web/core/components/estimates/points/index.ts @@ -1,7 +1,6 @@ export * from "./preview"; export * from "./create"; export * from "./update"; -export * from "./delete"; export * from "./select-dropdown"; export * from "./create-root"; diff --git a/web/core/components/estimates/points/preview.tsx b/web/core/components/estimates/points/preview.tsx index a3e24ff04..7f8f410bb 100644 --- a/web/core/components/estimates/points/preview.tsx +++ b/web/core/components/estimates/points/preview.tsx @@ -3,7 +3,9 @@ import { observer } from "mobx-react"; import { GripVertical, Pencil, Trash2 } from "lucide-react"; import { TEstimatePointsObject, TEstimateSystemKeys, TEstimateTypeErrorObject } from "@plane/types"; // components -import { EstimatePointUpdate, EstimatePointDelete } from "@/components/estimates/points"; +import { EstimatePointUpdate } from "@/components/estimates/points"; +// plane web components +import { EstimatePointDelete } from "@/plane-web/components/estimates"; // plane web constants import { estimateCount } from "@/plane-web/constants/estimates"; @@ -49,7 +51,7 @@ export const EstimatePointItemPreview: FC = observer( return (
{!estimatePointEditToggle && !estimatePointDeleteToggle && ( -
+
@@ -106,6 +108,8 @@ export const EstimatePointItemPreview: FC = observer( estimateId={estimateId} estimatePointId={estimatePointId} callback={() => estimateId && setEstimatePointDeleteToggle(false)} + estimatePointError={estimatePointError} + handleEstimatePointError={handleEstimatePointError} /> )}
diff --git a/web/ee/components/estimates/index.ts b/web/ee/components/estimates/index.ts index 4ad250c45..918b72d8d 100644 --- a/web/ee/components/estimates/index.ts +++ b/web/ee/components/estimates/index.ts @@ -1,2 +1,3 @@ export * from "./estimate-list-item-buttons"; export * from "./update"; +export * from "./points"; diff --git a/web/ee/components/estimates/points/delete.tsx b/web/ee/components/estimates/points/delete.tsx new file mode 100644 index 000000000..6cebb5646 --- /dev/null +++ b/web/ee/components/estimates/points/delete.tsx @@ -0,0 +1 @@ +export * from "ce/components/estimates/points/delete"; diff --git a/web/ee/components/estimates/points/index.ts b/web/ee/components/estimates/points/index.ts new file mode 100644 index 000000000..fe722bd23 --- /dev/null +++ b/web/ee/components/estimates/points/index.ts @@ -0,0 +1 @@ +export * from "./delete";