Spaces:
Sleeping
Sleeping
lakshmisravya123
Major upgrade: comprehensive negotiation coaching with EQ scoring and detailed reports
dad7400 | const API = "/api/negotiate"; | |
| export async function getScenarios() { | |
| const res = await fetch(API + "/scenarios"); | |
| if (!res.ok) throw new Error("Failed to fetch scenarios"); | |
| return res.json(); | |
| } | |
| export async function startNegotiation(data) { | |
| const res = await fetch(API + "/start", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify(data), | |
| }); | |
| if (!res.ok) throw new Error((await res.json()).error); | |
| return res.json(); | |
| } | |
| export async function sendResponse(sessionId, response) { | |
| const res = await fetch(API + "/respond", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify({ sessionId, response }), | |
| }); | |
| if (!res.ok) throw new Error((await res.json()).error); | |
| return res.json(); | |
| } | |
| export async function acceptOffer(sessionId) { | |
| const res = await fetch(API + "/accept", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify({ sessionId }), | |
| }); | |
| if (!res.ok) throw new Error((await res.json()).error); | |
| return res.json(); | |
| } | |