import React, { useState } from 'react';
import axios from 'axios';

const UserProfile = () => {
    const [formData, setFormData] = useState({
        phone_number: '',
        email: '',
        // Добавьте другие поля, которые хотите редактировать
    });

    const handleChange = (e) => {
        setFormData({ ...formData, [e.target.name]: e.target.value });
    };

    const handleSubmit = async (e) => {
        e.preventDefault();
        try {
            const response = await axios.put('http://127.0.0.1:8000/users/update', formData);
            console.log('User  profile updated:', response.data);
        } catch (error) {
            console.error('Error updating user profile:', error);
        }
    };

    return (
        <form onSubmit={handleSubmit}>
            <input type="text" name="phone_number" placeholder="Phone Number" onChange={handleChange} required />
            <input type="email" name="email" placeholder="Email" onChange={handleChange} required />
            <button type="submit">Update Profile</button>
        </form>
    );
};

export default UserProfile;