src/components/addLocation/AddLocation.js
// when the save changes button is clicked, the new data is sent to the server via put request
when the save changes button is clicked, the new data is sent to the server via put request
when the save changes button is clicked the new data is sent to the server via put request
async saveChangesBench() {
        try {
            this.setState({savingLocation: true});
            const requestBody = JSON.stringify({
                locationType: "BENCH",
                longitude: this.state.longitude,
                latitude: this.state.latitude,
                view: this.state.view,
                peace: this.state.peace,
                romantics: this.state.romantics,
                comfort: this.state.comfort
            });
            const url = '/locations';
            const response = await api.post(url, requestBody);
            const location = new Location(response.data);
            const locationUrl = '/map/informationpage/' + location.id;
            this.props.history.push(locationUrl);
        } catch (e) {
            alert(`Something went wrong while adding the new location: \n${handleError(e)}`);
        }
    }
async saveChangesBench ( ) { try { this . setState ( { savingLocation : true } ) ; const requestBody = JSON . stringify ( { locationType : "BENCH" , longitude : this . state . longitude , latitude : this . state . latitude , view : this . state . view , peace : this . state . peace , romantics : this . state . romantics , comfort : this . state . comfort } ) ; const url = '/locations' ; const response = await api . post ( url , requestBody ) ; const location = new Location ( response . data ) ; const locationUrl = '/map/informationpage/' + location . id ; this . props . history . push ( locationUrl ) ; } catch ( e ) { alert ( ` \n ${ handleError ( e ) } ` ) ; } }
when the save changes button is clicked, the new data is sent to the server via put request
when the save changes button is clicked the new data is sent to the server via put request
// after successfully saving the changes, the user is redirected to the information page