diff --git a/web/components/cycles/sidebar.tsx b/web/components/cycles/sidebar.tsx index 924faf455..890a09f49 100644 --- a/web/components/cycles/sidebar.tsx +++ b/web/components/cycles/sidebar.tsx @@ -52,7 +52,10 @@ export const CycleDetailsSidebar: React.FC = observer((props) => { const router = useRouter(); 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; @@ -70,31 +73,7 @@ export const CycleDetailsSidebar: React.FC = observer((props) => { const submitChanges = (data: Partial) => { if (!workspaceSlug || !projectId || !cycleId) return; - mutate(CYCLE_DETAILS(cycleId as string), (prevData) => ({ ...(prevData as ICycle), ...data }), false); - - 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" - } - ); - } - ); + cycleDetailsStore.patchCycle(workspaceSlug.toString(), projectId.toString(), cycleId.toString(), data); }; const handleCopyText = () => { @@ -304,10 +283,10 @@ export const CycleDetailsSidebar: React.FC = observer((props) => { cycleDetails.total_issues === 0 ? "0 Issue" : cycleDetails.total_issues === cycleDetails.completed_issues - ? cycleDetails.total_issues > 1 - ? `${cycleDetails.total_issues}` - : `${cycleDetails.total_issues}` - : `${cycleDetails.completed_issues}/${cycleDetails.total_issues}`; + ? cycleDetails.total_issues > 1 + ? `${cycleDetails.total_issues}` + : `${cycleDetails.total_issues}` + : `${cycleDetails.completed_issues}/${cycleDetails.total_issues}`; return ( <> @@ -337,11 +316,12 @@ export const CycleDetailsSidebar: React.FC = observer((props) => { {!isCompleted && ( - { - setTrackElement("CYCLE_PAGE_SIDEBAR"); - setCycleDeleteModal(true) - } - }> + { + setTrackElement("CYCLE_PAGE_SIDEBAR"); + setCycleDeleteModal(true); + }} + > Delete cycle diff --git a/web/components/modules/sidebar.tsx b/web/components/modules/sidebar.tsx index a525124ee..f8813b80b 100644 --- a/web/components/modules/sidebar.tsx +++ b/web/components/modules/sidebar.tsx @@ -75,20 +75,7 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => { const submitChanges = (data: Partial) => { if (!workspaceSlug || !projectId || !moduleId) return; - - mutate( - 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)); + moduleStore.updateModuleDetails(workspaceSlug.toString(), projectId.toString(), moduleId, data); }; const handleCreateLink = async (formData: ModuleLink) => {