Authors:
Cameron Johns, Cille Schliebitz, Anita Gu
Changed on:
3 Feb 2025
`locationRef` and `quantity` and outputs a JSON object structured as required by the Ruleset. The lesson covers configuring the user action button, creating the custom field component using React Function Components and the `FormFieldProps` interface, registering the field, and updating the workflow definition to use the new custom field type.`StockReservation` Data Structure: The custom field will capture data in a specific JSON format: { "locationRef": "F_NSYD", "quantity": 1 }.`FormFieldProps` Interface: The component uses the `FormFieldProps` interface from the UX Framework, typed with the output payload structure.`onChange` Handler: The `onChange` property of `FormFieldProps` is used to capture user input.`FieldRegistry` using a specific name.`stockReservation`" containing 2 fields: `locationRef` and `quantity. `It also expects a JSON value with a similar structure to the one below:`{`` "locationRef": "F_NSYD",`` "quantity": 1``}`You will build a field to produce this value for the "`stockReservation`" attribute on the posted Event.`actions` property to the `props` for the Product Availability Detail Page:`"props": {`` "title": "Product Availability",`` "actions": {`` "enabled": true`` }``}``StockReservation.tsx` and define the interface for the outgoing payload. [0:50]`FC` (FunctionComponent) component from React as the base, and typing it to the UX Framework `FormFieldProps` — which in turn requires another generic for the output, in our case we will define it to be our payload structure `StockReservationPayload`. [1:43]`onChange` since this will allow us to capture the user input. [2:36]`FieldRegistry`, and take note of the name. This will be used to configure the workflow later. [3:29]`'./fields/StockReservation';` [4:02]`STRING` to `stockReservation`. [4:13]
Once complete, open the user action form, and you should see the "Hello Form" text, indicating that the UX Framework has successfully mapped your custom field component to the attribute type defined in the workflow.