diff --git a/apps/web/core/components/automation/auto-archive-automation.tsx b/apps/web/core/components/automation/auto-archive-automation.tsx index 91c7bd62cb1..e83c1965117 100644 --- a/apps/web/core/components/automation/auto-archive-automation.tsx +++ b/apps/web/core/components/automation/auto-archive-automation.tsx @@ -1,6 +1,6 @@ "use client"; -import React, { useState } from "react"; +import React, { useMemo, useState } from "react"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; import { ArchiveRestore } from "lucide-react"; @@ -48,6 +48,11 @@ export const AutoArchiveAutomation: React.FC = observer((props) => { currentProjectDetails?.id ); + const autoArchiveStatus = useMemo(() => { + if (currentProjectDetails?.archive_in === undefined) return false; + return currentProjectDetails.archive_in !== 0; + }, [currentProjectDetails]); + return ( <> = observer((props) => { { if (currentProjectDetails?.archive_in === 0) { await handleChange({ archive_in: 1 }); @@ -94,7 +99,7 @@ export const AutoArchiveAutomation: React.FC = observer((props) => { {currentProjectDetails ? ( - currentProjectDetails.archive_in !== 0 && ( + autoArchiveStatus && (
diff --git a/apps/web/core/components/automation/auto-close-automation.tsx b/apps/web/core/components/automation/auto-close-automation.tsx index 736abbc24e0..44c8b76713c 100644 --- a/apps/web/core/components/automation/auto-close-automation.tsx +++ b/apps/web/core/components/automation/auto-close-automation.tsx @@ -1,6 +1,6 @@ "use client"; -import React, { useState } from "react"; +import React, { useMemo, useState } from "react"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; // icons @@ -75,6 +75,11 @@ export const AutoCloseAutomation: React.FC = observer((props) => { currentProjectDetails?.id ); + const autoCloseStatus = useMemo(() => { + if (currentProjectDetails?.close_in === undefined) return false; + return currentProjectDetails.close_in !== 0; + }, [currentProjectDetails]); + return ( <> = observer((props) => {
{ if (currentProjectDetails?.close_in === 0) { await handleChange({ close_in: 1, default_state: defaultState }); @@ -121,7 +126,7 @@ export const AutoCloseAutomation: React.FC = observer((props) => {
{currentProjectDetails ? ( - currentProjectDetails.close_in !== 0 && ( + autoCloseStatus && (