forked from github/plane
chore: module and cycle sidebar date mutation fix (#2986)
This commit is contained in:
parent
e05a6e34c8
commit
baa3669a19
@ -52,7 +52,10 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, projectId, peekCycle } = router.query;
|
const { workspaceSlug, projectId, peekCycle } = router.query;
|
||||||
|
|
||||||
const { cycle: cycleDetailsStore, trackEvent: { setTrackElement, postHogEventTracker } } = useMobxStore();
|
const {
|
||||||
|
cycle: cycleDetailsStore,
|
||||||
|
trackEvent: { setTrackElement, postHogEventTracker },
|
||||||
|
} = useMobxStore();
|
||||||
|
|
||||||
const cycleDetails = cycleDetailsStore.cycle_details[cycleId] ?? undefined;
|
const cycleDetails = cycleDetailsStore.cycle_details[cycleId] ?? undefined;
|
||||||
|
|
||||||
@ -70,31 +73,7 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {
|
|||||||
const submitChanges = (data: Partial<ICycle>) => {
|
const submitChanges = (data: Partial<ICycle>) => {
|
||||||
if (!workspaceSlug || !projectId || !cycleId) return;
|
if (!workspaceSlug || !projectId || !cycleId) return;
|
||||||
|
|
||||||
mutate<ICycle>(CYCLE_DETAILS(cycleId as string), (prevData) => ({ ...(prevData as ICycle), ...data }), false);
|
cycleDetailsStore.patchCycle(workspaceSlug.toString(), projectId.toString(), cycleId.toString(), data);
|
||||||
|
|
||||||
cycleService
|
|
||||||
.patchCycle(workspaceSlug as string, projectId as string, cycleId as string, data)
|
|
||||||
.then((res) => {
|
|
||||||
mutate(CYCLE_DETAILS(cycleId as string));
|
|
||||||
postHogEventTracker(
|
|
||||||
"CYCLE_UPDATE",
|
|
||||||
{
|
|
||||||
...res,
|
|
||||||
state: "SUCCESS"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.catch((e) => {
|
|
||||||
console.log(e);
|
|
||||||
postHogEventTracker(
|
|
||||||
"CYCLE_UPDATE",
|
|
||||||
{
|
|
||||||
state: "FAILED"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCopyText = () => {
|
const handleCopyText = () => {
|
||||||
@ -304,10 +283,10 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {
|
|||||||
cycleDetails.total_issues === 0
|
cycleDetails.total_issues === 0
|
||||||
? "0 Issue"
|
? "0 Issue"
|
||||||
: cycleDetails.total_issues === cycleDetails.completed_issues
|
: cycleDetails.total_issues === cycleDetails.completed_issues
|
||||||
? cycleDetails.total_issues > 1
|
? cycleDetails.total_issues > 1
|
||||||
? `${cycleDetails.total_issues}`
|
? `${cycleDetails.total_issues}`
|
||||||
: `${cycleDetails.total_issues}`
|
: `${cycleDetails.total_issues}`
|
||||||
: `${cycleDetails.completed_issues}/${cycleDetails.total_issues}`;
|
: `${cycleDetails.completed_issues}/${cycleDetails.total_issues}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -337,11 +316,12 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {
|
|||||||
</button>
|
</button>
|
||||||
{!isCompleted && (
|
{!isCompleted && (
|
||||||
<CustomMenu width="lg" placement="bottom-end" ellipsis>
|
<CustomMenu width="lg" placement="bottom-end" ellipsis>
|
||||||
<CustomMenu.MenuItem onClick={() => {
|
<CustomMenu.MenuItem
|
||||||
setTrackElement("CYCLE_PAGE_SIDEBAR");
|
onClick={() => {
|
||||||
setCycleDeleteModal(true)
|
setTrackElement("CYCLE_PAGE_SIDEBAR");
|
||||||
}
|
setCycleDeleteModal(true);
|
||||||
}>
|
}}
|
||||||
|
>
|
||||||
<span className="flex items-center justify-start gap-2">
|
<span className="flex items-center justify-start gap-2">
|
||||||
<Trash2 className="h-3 w-3" />
|
<Trash2 className="h-3 w-3" />
|
||||||
<span>Delete cycle</span>
|
<span>Delete cycle</span>
|
||||||
|
@ -75,20 +75,7 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {
|
|||||||
|
|
||||||
const submitChanges = (data: Partial<IModule>) => {
|
const submitChanges = (data: Partial<IModule>) => {
|
||||||
if (!workspaceSlug || !projectId || !moduleId) return;
|
if (!workspaceSlug || !projectId || !moduleId) return;
|
||||||
|
moduleStore.updateModuleDetails(workspaceSlug.toString(), projectId.toString(), moduleId, data);
|
||||||
mutate<IModule>(
|
|
||||||
MODULE_DETAILS(moduleId as string),
|
|
||||||
(prevData) => ({
|
|
||||||
...(prevData as IModule),
|
|
||||||
...data,
|
|
||||||
}),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
moduleService
|
|
||||||
.patchModule(workspaceSlug as string, projectId as string, moduleId as string, data)
|
|
||||||
.then(() => mutate(MODULE_DETAILS(moduleId as string)))
|
|
||||||
.catch((e) => console.log(e));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCreateLink = async (formData: ModuleLink) => {
|
const handleCreateLink = async (formData: ModuleLink) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user