mirror of
https://github.com/makeplane/plane.git
synced 2026-07-14 14:31:37 +02:00
* chore: return estimate type for estimate activities * chore: return estimate type for estimate activities in epics * chore: update activity components for epics and work items * chore: adde estimate formatting for notification * fix: incorrect estimate type * fix: remove unwanted changes * fix: remove unwanted changes * feat: added render for time estimate activity * chore: time estimate text update * feat: addded time estimate activtiy for epics * feat: added estimate time activity * chore: removed unwanted changes * fix: reverted feature flag changes * fix: handle None estimate_type --------- Co-authored-by: vamsikrishnamathala <matalav55@gmail.com>
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
import { FC, useState } from "react";
|
|
import { setToast, TOAST_TYPE } from "@plane/ui";
|
|
// plane web components
|
|
import { WorklogFormRoot } from "@/plane-web/components/issues/worklog";
|
|
// plane web hooks
|
|
import { useWorkspaceWorklogs } from "@/plane-web/hooks/store";
|
|
// plane web types
|
|
import { TWorklog } from "@/plane-web/types";
|
|
|
|
type TWorklogCreate = {
|
|
workspaceSlug: string;
|
|
projectId: string;
|
|
issueId: string;
|
|
handleClose?: () => void;
|
|
};
|
|
|
|
export const WorklogCreate: FC<TWorklogCreate> = (props) => {
|
|
const { workspaceSlug, projectId, issueId, handleClose } = props;
|
|
// hooks
|
|
const { createWorklog } = useWorkspaceWorklogs();
|
|
// states
|
|
const [loader, setLoader] = useState(false);
|
|
|
|
const onCancel = () => {
|
|
setLoader(false);
|
|
handleClose && handleClose();
|
|
};
|
|
|
|
const onSubmit = async (payload: Partial<TWorklog>) => {
|
|
if (!workspaceSlug || !projectId || !issueId) return { status: "error" };
|
|
|
|
try {
|
|
setLoader(true);
|
|
await createWorklog(workspaceSlug, projectId, issueId, payload);
|
|
setToast({
|
|
type: TOAST_TYPE.SUCCESS,
|
|
title: "Success!",
|
|
message: "Worklog created successfully.",
|
|
});
|
|
setLoader(false);
|
|
handleClose && handleClose();
|
|
return { status: "success" };
|
|
} catch (error: any) {
|
|
setLoader(false);
|
|
const errorMessage = error?.duration
|
|
? "Please use hours and minutes together for longer durations."
|
|
: "Something went wrong. please try again.";
|
|
setToast({
|
|
type: TOAST_TYPE.ERROR,
|
|
title: "Error!",
|
|
message: errorMessage,
|
|
});
|
|
return { status: "error" };
|
|
}
|
|
};
|
|
|
|
return (
|
|
<WorklogFormRoot
|
|
data={{ hours: "", minutes: "", description: "" }}
|
|
onSubmit={onSubmit}
|
|
onCancel={onCancel}
|
|
buttonDisabled={loader}
|
|
buttonTitle={loader ? `Saving` : `Save`}
|
|
/>
|
|
);
|
|
};
|