Callback
The Callback prop is a function called whenever the user changes any form values in the AccessoryForm
component. The Callback function receives an object containing the accessories request data, which can be used to add an accessories array to the calculation request that will be send to the backend.
To ensure the calc request functions properly, it is essential to add the callback data to the accessories
array of the requestBody
, that is provided by the CalcGatewayForm
callback.
Usage
To use the Callback prop, you need to pass a function to the Callback
prop of the AccessoryForm
component. This function will be called whenever the user changes any form values.
import {AccessoryForm} from 'kampmann-calcgateway-frontend'
function App() {
//This state is passed as a callback to the AccessoryForm component and will store the selected accessories data
const [accessoriesCallback, setAccessoriesCallback] = useState()
return (
<AccessoryForm
...
callback={setAccessoriesCallback}
/>
)
}
Non-calculable Accessories
Non-calculable accessories are returned via the “nonCalculableCallback” prop.
Example callback:
[
{
"id": 63878,
"articleNumber": "196000030058",
"inputCategories": [],
"count": 2
}
]