hurt-tomatoH
Refine3y ago
4 replies
hurt-tomato

Change object in edit form

Hi everyone,
i have a endpoint offers in which i have a field ski_resort. I have an other endpoint ski_resorts which return all the ski resort available. I display the all the ski resort in edit offer form with the useSelect() hook. I would like to change all the field ski_resort in the obejct with with ski_resorts endpoint response. How can I do that ?
Here is my useSelect hook
 const {options} = useSelect<ISkiResorts>({
        hasPagination: false,
        resource: "all_ski_resorts",
        optionLabel: "name",
        optionValue: "id"
    });

Here is an Offer object
 {
        "id": 1,
        "main_picture_url": "",
        "ski_resort": {
            "id": 2,
            "name": "Test",
            "short_name": "Test",
            "active": true
        },
        "date_from": "2021-12-27T00:00:00+00:00",
        "date_to": "2022-04-23T00:00:00+00:00",
        "from_price": 4000,
        "promo_price": 3000,
        "active": true,
        "rank": 2,
        "title": "Here is the title",
        "description": "Here is the description",
        "discount_amount": 5000,
        "validity_period": "Test"
    },

Here is a ski_resort object return by the ski_resorts endpoint
{
        "id": 1,
        "name": "Chamonix",
        "short_name": "CHAM",
        "contractor_id": 105,
        "longitude": 6.86889,
        "latitude": 45.9222,
        "active": true,
        "domains": [
           // all domains 
        ],
        "consumercategories": [],
        "active_sales": false,
        "keycard_provider": "TA",
        "is_skiogrande": false,
        "offers": []
}
Was this page helpful?