diff --git a/frontend/web/components/modals/CreateSegment.tsx b/frontend/web/components/modals/CreateSegment.tsx index 81b0d86d1aa3..6d7a544201cc 100644 --- a/frontend/web/components/modals/CreateSegment.tsx +++ b/frontend/web/components/modals/CreateSegment.tsx @@ -125,6 +125,16 @@ const CreateSegment: FC = ({ ], } const [segment, setSegment] = useState(_segment || defaultSegment) + const [description, setDescription] = useState(segment.description) + const [name, setName] = useState(segment.name) + const [rules, setRules] = useState(segment.rules) + useEffect(() => { + if (segment) { + setRules(segment.rules) + setDescription(segment.description) + setName(segment.name) + } + }, [segment]) const isEdit = !!segment.id const [ createSegment, @@ -147,9 +157,6 @@ const CreateSegment: FC = ({ const isSaving = creating || updating const [showDescriptions, setShowDescriptions] = useState(false) - const [description, setDescription] = useState(segment.description) - const [name, setName] = useState(segment.name) - const [rules, setRules] = useState(segment.rules) const [tab, setTab] = useState(0) const [metadata, setMetadata] = useState( segment.metadata, @@ -157,7 +164,6 @@ const CreateSegment: FC = ({ const metadataEnable = Utils.getPlansPermission('METADATA') && Utils.getFlagsmithHasFeature('enable_metadata') - const error = createError || updateError const totalSegments = ProjectStore.getTotalSegments() ?? 0 const maxSegmentsAllowed = ProjectStore.getMaxSegmentsAllowed() ?? 0 @@ -284,6 +290,7 @@ const CreateSegment: FC = ({ }, [createSuccess]) useEffect(() => { if (updateSuccess && updateSegmentData) { + setSegment(updateSegmentData) onComplete?.(updateSegmentData) } //eslint-disable-next-line diff --git a/frontend/web/components/pages/SegmentsPage.tsx b/frontend/web/components/pages/SegmentsPage.tsx index 89ece6ddbcf4..53cef1cfc359 100644 --- a/frontend/web/components/pages/SegmentsPage.tsx +++ b/frontend/web/components/pages/SegmentsPage.tsx @@ -50,7 +50,6 @@ const SegmentsPage: FC = (props) => { params.featureSpecific === 'true', ) - console.log('id is', id) useEffect(() => { if (id) { editSegment(id, !manageSegmentsPermission)