mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix: segment delete confirmation double dialog flash (#2819)
This commit is contained in:
		
							parent
							
								
									4005bb8a8b
								
							
						
					
					
						commit
						f2eb96000e
					
				@ -1,7 +1,7 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
 | 
			
		||||
import { useStrategiesBySegment } from 'hooks/api/getters/useStrategiesBySegment/useStrategiesBySegment';
 | 
			
		||||
import { ISegment } from 'interfaces/segment';
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import { SegmentDeleteConfirm } from './SegmentDeleteConfirm/SegmentDeleteConfirm';
 | 
			
		||||
import { SegmentDeleteUsedSegment } from './SegmentDeleteUsedSegment/SegmentDeleteUsedSegment';
 | 
			
		||||
 | 
			
		||||
@ -11,14 +11,20 @@ interface ISegmentDeleteProps {
 | 
			
		||||
    onClose: () => void;
 | 
			
		||||
    onRemove: () => void;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const SegmentDelete = ({
 | 
			
		||||
    segment,
 | 
			
		||||
    open,
 | 
			
		||||
    onClose,
 | 
			
		||||
    onRemove,
 | 
			
		||||
}: ISegmentDeleteProps) => {
 | 
			
		||||
    const { strategies } = useStrategiesBySegment(segment.id);
 | 
			
		||||
    const { strategies, loading } = useStrategiesBySegment(segment.id);
 | 
			
		||||
    const canDeleteSegment = strategies?.length === 0;
 | 
			
		||||
 | 
			
		||||
    if (loading) {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <ConditionallyRender
 | 
			
		||||
            condition={canDeleteSegment}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user