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

Function VariationItem

ui/src/components/VariationItem/index.tsx:36–346  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

34}
35
36const VariationItem: React.FC<IProps> = (props) => {
37 const [ open, setOpen ] = useState<boolean>(false);
38 const [ canSave, setCanSave ] = useState<boolean>(true);
39 const [ jsonValue, setJsonValue ] = useState<string>('');
40 const intl = useIntl();
41
42 const {
43 disabled,
44 total,
45 returnType,
46 item: {
47 value,
48 name,
49 description,
50 index,
51 id,
52 },
53 prefix,
54 handleInput,
55 handleDelete,
56 handleChangeVariation,
57 hooksFormContainer,
58 ruleContainer,
59 defaultServeContainer
60 } = props;
61
62 const { rules, saveRules } = ruleContainer.useContainer();
63 const { defaultServe, saveDefaultServe } = defaultServeContainer.useContainer();
64
65 const {
66 formState: { errors },
67 register,
68 unregister,
69 setValue,
70 trigger,
71 } = hooksFormContainer.useContainer();
72
73 useEffect(() => {
74 register(`variation_${id}_name`, {
75 required: {
76 value: true,
77 message: intl.formatMessage({id: 'common.input.placeholder'})
78 }
79 });
80
81 if (returnType !== 'boolean') {
82 unregister(`variation_${id}_normal`);
83 register(`variation_${id}`, {
84 required: {
85 value: true,
86 message: intl.formatMessage({id: 'common.input.placeholder'})
87 },
88 validate: {
89 isNumber: (v: string) => {
90 const reg = /^(-?\d+)(\.\d+)?$/i;
91 if (v && returnType === 'number' && !reg.test(v)) {
92 return intl.formatMessage({id: 'common.number.invalid'});
93 }

Callers

nothing calls this directly

Calls 5

isJSONFunction · 0.90
setValueFunction · 0.85
handleChangeVariationFunction · 0.50
handleDeleteFunction · 0.50
handleInputFunction · 0.50

Tested by

no test coverage detected