import { Box, Radio, RadioGroup, Typography } from '@mui/material'; import { Dialogue } from 'component/common/Dialogue/Dialogue'; import { LegalValueLabel } from 'component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/LegalValueLabel/LegalValueLabel'; import { useState } from 'react'; import useFeatureLifecycleApi from 'hooks/api/actions/useFeatureLifecycleApi/useFeatureLifecycleApi'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { SingleVariantOptions } from './SingleVariantOptions'; import { useParentVariantOptions } from 'hooks/api/getters/useFeatureDependencyOptions/useFeatureDependencyOptions'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; interface IMarkCompletedDialogueProps { isOpen: boolean; setIsOpen: (open: boolean) => void; onComplete: () => void; projectId: string; featureId: string; } type Status = 'kept' | 'discarded' | 'kept-with-variant'; export const MarkCompletedDialogue = ({ projectId, featureId, isOpen, setIsOpen, onComplete, }: IMarkCompletedDialogueProps) => { const { markFeatureCompleted } = useFeatureLifecycleApi(); const { parentVariantOptions: variantOptions } = useParentVariantOptions( projectId, featureId, ); const [status, setStatus] = useState('kept'); const [variant, setVariant] = useState(undefined); const { trackEvent } = usePlausibleTracker(); const onClick = async () => { const sentStatus = status === 'kept-with-variant' ? 'kept' : status; await markFeatureCompleted(featureId, projectId, { status: sentStatus, statusValue: variant, }); setIsOpen(false); onComplete(); trackEvent('feature-lifecycle', { props: { eventType: 'complete', status: sentStatus, }, }); }; return ( { setIsOpen(false); }} disabledPrimaryButton={ status === 'kept-with-variant' && variant === null } onClick={onClick} primaryButtonText={'Mark completed'} secondaryButtonText='Cancel' > Marking the feature toggle as complete does not affect any configuration, but it moves the feature toggle into it’s next life cycle stage and is an indication that you have learned what you needed in order to progress with the feature. It serves as a reminder to start cleaning up the feature toggle and removing it from the code. What was the outcome of this feature? theme.spacing(0.5) }} onChange={(e, value) => { setStatus(value as Status); }} > } /> } /> 0} show={ } /> } /> 0 && status === 'kept-with-variant' } show={ { setVariant(variant); }} /> } /> ); };