eunzzang's picture
Fix learning route build and restore word learning layout
11ab88a verified
Raw
History Blame Contribute Delete
775 Bytes
export async function requestJson(path, options = {}) {
const response = await fetch(path, options);
const contentType = response.headers.get("content-type") || "";
const data = contentType.includes("application/json") ? await response.json() : null;
if (!response.ok) {
const message = data?.detail?.message || data?.detail || "์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.";
throw new Error(message);
}
return data;
}
export function getConfidenceState(confidence) {
if (confidence >= 0.9) {
return { label: "์•ˆ์ •", className: "confidence-stable" };
}
if (confidence >= 0.7) {
return { label: "ํ™•์ธ ํ•„์š”", className: "confidence-review" };
}
return { label: "๋‹ค์‹œ ๋ณด๊ธฐ", className: "confidence-retry" };
}