diff --git a/src/components/Projects/StatusStepper/ProjectStepper.tsx b/src/components/Projects/StatusStepper/ProjectStepper.tsx index f4c4d3b02..be7d8eaf9 100644 --- a/src/components/Projects/StatusStepper/ProjectStepper.tsx +++ b/src/components/Projects/StatusStepper/ProjectStepper.tsx @@ -1,11 +1,11 @@ -import { Flag, Play, Send, Share } from 'lucide-react'; +import { Flag, Play, Send, Share, X } from 'lucide-react'; import { useEffect, useRef, useState } from 'react'; import { cn } from '../../../lib/classname.ts'; import { useStickyStuck } from '../../../hooks/use-sticky-stuck.tsx'; import { StepperAction } from './StepperAction.tsx'; import { StepperStepSeparator } from './StepperStepSeparator.tsx'; import { MilestoneStep } from './MilestoneStep.tsx'; -import { httpGet } from '../../../lib/http.ts'; +import { httpGet, httpPost } from '../../../lib/http.ts'; import { StartProjectModal } from '../StartProjectModal.tsx'; import { getRelativeTimeString } from '../../../lib/date.ts'; import { getUser, isLoggedIn } from '../../../lib/jwt.ts'; @@ -40,6 +40,8 @@ export function ProjectStepper(props: ProjectStepperProps) { const [isSubmittingProject, setIsSubmittingProject] = useState(false); const { copyText, isCopied } = useCopyText(); + const [isStoppingProject, setIsStoppingProject] = useState(false); + const [error, setError] = useState(null); const [activeStep, setActiveStep] = useState(0); const [isLoadingStatus, setIsLoadingStatus] = useState(true); @@ -78,6 +80,22 @@ export function ProjectStepper(props: ProjectStepperProps) { setIsLoadingStatus(false); } + const stopProject = async () => { + setIsStoppingProject(true); + const { response, error } = await httpPost( + `${import.meta.env.PUBLIC_API_URL}/v1-stop-project/${projectId}`, + {}, + ); + + if (error || !response) { + setIsStoppingProject(false); + setError(error?.message || 'Error stopping project'); + return; + } + + window.location.reload(); + }; + useEffect(() => { loadProjectStatus().finally(() => {}); }, []); @@ -189,6 +207,20 @@ export function ProjectStepper(props: ProjectStepperProps) { )} + {projectStatus.startedAt && !projectStatus.submittedAt && ( + + )} + {activeStep >= 2 && (