mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-19 01:17:18 +02:00
feat: prompt for feedback after second flag created (#8467)
This commit is contained in:
parent
2ec575b85c
commit
793221524c
@ -2,20 +2,13 @@ import { formatUnknownError } from 'utils/formatUnknownError';
|
|||||||
import useToast from 'hooks/useToast';
|
import useToast from 'hooks/useToast';
|
||||||
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
import FormTemplate from 'component/common/FormTemplate/FormTemplate';
|
||||||
import { CREATE_FEATURE } from 'component/providers/AccessProvider/permissions';
|
import { CREATE_FEATURE } from 'component/providers/AccessProvider/permissions';
|
||||||
import {
|
import { type ReactNode, useState, type FormEvent, useMemo } from 'react';
|
||||||
type ReactNode,
|
|
||||||
useState,
|
|
||||||
useContext,
|
|
||||||
type FormEvent,
|
|
||||||
useMemo,
|
|
||||||
} from 'react';
|
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Dialog, styled } from '@mui/material';
|
import { Dialog, styled } from '@mui/material';
|
||||||
import useProjects from 'hooks/api/getters/useProjects/useProjects';
|
import useProjects from 'hooks/api/getters/useProjects/useProjects';
|
||||||
import { Limit } from 'component/common/Limit/Limit';
|
import { Limit } from 'component/common/Limit/Limit';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import UIContext from 'contexts/UIContext';
|
|
||||||
import useFeatureForm from 'component/feature/hooks/useFeatureForm';
|
import useFeatureForm from 'component/feature/hooks/useFeatureForm';
|
||||||
import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi';
|
import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi';
|
||||||
import FlagIcon from '@mui/icons-material/Flag';
|
import FlagIcon from '@mui/icons-material/Flag';
|
||||||
@ -36,6 +29,7 @@ import { MultiSelectConfigButton } from 'component/common/DialogFormTemplate/Con
|
|||||||
import type { ITag } from 'interfaces/tags';
|
import type { ITag } from 'interfaces/tags';
|
||||||
import { ToggleConfigButton } from 'component/common/DialogFormTemplate/ConfigButtons/ToggleConfigButton';
|
import { ToggleConfigButton } from 'component/common/DialogFormTemplate/ConfigButtons/ToggleConfigButton';
|
||||||
import { useFlagLimits } from './useFlagLimits';
|
import { useFlagLimits } from './useFlagLimits';
|
||||||
|
import { useFeatureCreatedFeedback } from './hooks/useFeatureCreatedFeedback';
|
||||||
|
|
||||||
interface ICreateFeatureDialogProps {
|
interface ICreateFeatureDialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -104,9 +98,9 @@ const CreateFeatureDialogContent = ({
|
|||||||
onSuccess,
|
onSuccess,
|
||||||
}: ICreateFeatureDialogProps) => {
|
}: ICreateFeatureDialogProps) => {
|
||||||
const { setToastData, setToastApiError } = useToast();
|
const { setToastData, setToastApiError } = useToast();
|
||||||
const { setShowFeedback } = useContext(UIContext);
|
|
||||||
const { uiConfig, isOss } = useUiConfig();
|
const { uiConfig, isOss } = useUiConfig();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const openFeatureCreatedFeedback = useFeatureCreatedFeedback();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
type,
|
type,
|
||||||
@ -177,7 +171,7 @@ const CreateFeatureDialogContent = ({
|
|||||||
});
|
});
|
||||||
onClose();
|
onClose();
|
||||||
onSuccess?.();
|
onSuccess?.();
|
||||||
setShowFeedback(true);
|
openFeatureCreatedFeedback();
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
setToastApiError(formatUnknownError(error));
|
setToastApiError(formatUnknownError(error));
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
import { useCallback, useContext } from 'react';
|
||||||
|
import UIContext from 'contexts/UIContext';
|
||||||
|
import { createLocalStorage } from 'utils/createLocalStorage';
|
||||||
|
|
||||||
|
export const useFeatureCreatedFeedback = () => {
|
||||||
|
const { setShowFeedback } = useContext(UIContext);
|
||||||
|
|
||||||
|
return useCallback(() => {
|
||||||
|
const { value, setValue } = createLocalStorage<string>(
|
||||||
|
'flagsCreated',
|
||||||
|
'0',
|
||||||
|
);
|
||||||
|
const flagsCount = Number.parseInt(value) + 1;
|
||||||
|
|
||||||
|
setValue(`${flagsCount}`);
|
||||||
|
|
||||||
|
if (flagsCount > 1) {
|
||||||
|
setShowFeedback(true);
|
||||||
|
}
|
||||||
|
}, [setShowFeedback]);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user