shelcia / mocker

Mocker can generate mock data with API endpoints, powered by faker.js
https://mocker-gen.netlify.app/
GNU General Public License v3.0
17 stars 29 forks source link

Set filed's option problem #117

Open yangwawa0323 opened 1 year ago

yangwawa0323 commented 1 year ago

There has a problem that is to set some optional field. I was debug by using the browser's develop tool , there is no any option field in the modified schema send to BE. By reading the source code , I found the problem where is.

In the FE SchemaOptionModal.jsx file. the 4th parameter of the useEffect which call name is missed.

  useEffect(() => {
        - handleSchema(fieldInfo.id, fieldInfo.label, fieldInfo.field, option);
        +  handleSchema(fieldInfo.id, fieldInfo.label, fieldInfo.field, fieldInfo.name, option);

console.log('Im', option);
  }, [option]);

const handleSchema = (id, label, field, name, option) => {            
    // ...
}

WeChat Screenshot_20230203214027

yangwawa0323 commented 1 year ago

When change the has optional attribute filed, the old option is keepped. In CommonResourceModal.jsx

<FormControl fullWidth>
    <InputLabel id='resource-label'>Field</InputLabel>
    <Select
    labelId='resource-label'
        id='resource-id'
     sx={{ mb: 0 }}
     size='small'
     label='Field'
     name='field'
     value={item.field}
     onChange={(e) => {
         handleSchema(
             item.id,
             item.label,
             e.target.value,
            - e.target.value
            + e.target.name,
            + {}               // For the beginning, reset the option
    );
}}
>
Girishbari commented 9 months ago

problem has solved or not then, seems issues was already assigned to @yangwawa0323

Bayyana-kiran commented 9 months ago

Can u assign me i can work on this?

Bayyana-kiran commented 9 months ago

@yangwawa0323 In the above image only male is occuring ....so should i change that to male and female ???right??