Как отправить письмо на email@somedomain.com в react frontend при обновлении значения столбца базы данных (django+react+Mysql)

export class Employee extends Component{

constructor(props){
    super(props);

    this.state={
        
        employees:[],
        modalTitle:"",
        EmployeeId:0,
        EmployeeName:"",
        EmployeeEmail:"",
        Department:"",
        DateOfJoining:"",
        
    }
}

refreshList(){

    fetch(variables.API_URL+'employee')
    .then(response=>response.json())
    .then(data=>{
        this.setState({employees:data});
    });

 
}

componentDidMount(){
    this.refreshList();
}

changeEmployeeName =(e)=>{
    this.setState({EmployeeName:e.target.value});
}
changeDepartment =(e)=>{
    this.setState({Department:e.target.value});
}
changeDateOfJoining =(e)=>{
    this.setState({DateOfJoining:e.target.value});
}


updateClick(){
    fetch(variables.API_URL+'employee',{
        method:'PUT',
        headers:{
            'Accept':'application/json',
            'Content-Type':'application/json'
        },
        body:JSON.stringify({
            EmployeeId:this.state.EmployeeId,
            EmployeeName:this.state.EmployeeName,
            EmployeeEmail:this.state.EmployeeEmail,
            Department:this.state.Department,
            DateOfJoining:this.state.DateOfJoining,
            
        })
    })
    .then(res=>res.json())
    .then((result)=>{
        alert(result);
        this.refreshList();
    },(error)=>{
        alert('Failed');
    })
}


render(){
    const {
        
        employees,
        modalTitle,
        EmployeeId,
        EmployeeName,
        EmployeeEmail,
        Department,
        DateOfJoining,
        
    }=this.state;

    return(

    {EmployeeId!=0?
    <button type="button"
    className="btn btn-primary float-start"
    onClick={()=>this.updateClick()}
    >Update</button>
    :null}

    )
}

}

Я могу обновить данные сотрудника в вышеуказанном "updateClick()". Я обновляю "Department" в front end и он обновляется. как вызвать автоматическое письмо на "EmployeeEmail" с обновленным значением Department внутри "updateClick()"

может ли кто-нибудь помочь здесь, пожалуйста... Я изучаю разработку полного стека

Вернуться на верх