I'm trying to update a state variable (message) after onStartingAcw event listener, but this not works (I don't have error menssages of the intent of update), I have a console.log on the handlerCallDestroyed and this works fine when the agent enters on ACW (after the call ends), but I can't update the value of message. This is a 3p App working on Amazon Connect Agent Workspace, I'm running my App on localhost:3000 (attached to Amazon Connect Agent Workspace) Am I doing somethis wrong? This is my code:
import { useState, useEffect } from "react";
import { AmazonConnectApp } from "@amazon-connect/app";
import { ContactClient, AgentClient, ContactStartingAcwEventData } from "@amazon-connect/contact";
import './App.css';
const provider = AmazonConnectApp.init({
onCreate: (event) => {
const { appInstanceId, appConfig } = event.context;
console.log('App initialized:', appInstanceId);
console.log("Permissions:", appConfig.permissions);
},
onDestroy: (event) => {
console.log('App being destroyed', event);
}
});
function App() {
const [message, setMessage] = useState("Esperando eventos...");
useEffect(() => {
const agentClient = new AgentClient();
const contactClient = new ContactClient();
const handlerCallDestroyed = (ContactStartingAcwEventData) => {
console.log("test", ContactStartingAcwEventData);
setMessage("Llamada finalizada - ACW completado");
};
contactClient.onStartingAcw(handlerCallDestroyed);
}, []);
return (
<div className="App">
<p className="message">Mensaje: {message}</p>
</div>
);
}
export default App;