MCPcopy Create free account
hub / github.com/FeatureProbe/FeatureProbe / Serve

Function Serve

ui/src/components/Serve/index.tsx:31–325  ·  view source on GitHub ↗
(props: IProps)

Source from the content-addressed store, hash-verified

29const MIN = 0;
30
31const Serve = (props: IProps) => {
32 const {
33 id,
34 index,
35 serve,
36 disabled,
37 variations,
38 customStyle,
39 hooksFormContainer,
40 handleChangeServe,
41 } = props;
42
43 const [ value, saveValue ] = useState<string | number | boolean | (string | number | boolean)[] | undefined>(-1);
44 const [ percentageShow, setPercentageShow ] = useState<boolean>(false);
45 const [ variationsInUse, setVariationsInUse ] = useState<IVariation[]>([]);
46 const [ variationsOptions, setVariatiosOptions ] = useState<IDropItemProps[]>([]);
47 const [ total, setTotal ] = useState<number>(0);
48 const intl = useIntl();
49
50 const {
51 formState: { errors },
52 setValue,
53 trigger,
54 register,
55 setError,
56 clearErrors,
57 } = hooksFormContainer.useContainer();
58 const { registerErrorName } = useFormErrorScrollIntoView();
59
60 useEffect(() => {
61 setVariationsInUse(cloneDeep(variations));
62 }, [variations]);
63
64 useEffect(() => {
65 if (id) {
66 register(`rule_${id}_serve`, {
67 required: true,
68 });
69 } else {
70 register('defaultServe', {
71 required: true,
72 });
73 }
74 }, [id, intl, register]);
75
76 useEffect(() => {
77 const options: IDropItemProps[] = variationsInUse.map((item: IDropItemProps, index: number) => {
78 return {
79 value: index,
80 text: item.name || item.value,
81 content: (
82 <div className={styles['dropdown-variation']}>
83 <span style={{background: VariationColors[index % 20]}} className={styles['dropdown-variation-color']}></span>
84 <span className={styles['dropdown-variation-text']}>
85 { item.name || item.value }
86 </span>
87 </div>
88 ),

Callers

nothing calls this directly

Calls 6

setValueFunction · 0.85
pushMethod · 0.65
handleChangeServeFunction · 0.50
handleChangeFunction · 0.50
handleAddFunction · 0.50

Tested by

no test coverage detected