import{_t as e,lt as r,n as t,yt as s}from"./render-cqdoDfd9.js";import{t as o}from"./Box-pvlRBLzs.js";import{t as n}from"./Typography-8v555lWC.js";import{t as a}from"./Button-D-nJohaT.js";import{t as i}from"./Alert-BpUkH7Nx.js";import{t as l}from"./DialogActions-IskUXpPi.js";import{n as c,t as d}from"./DialogTitle-HCb6VQhm.js";import{t as m}from"./DialogContentText-EZ4FAf5e.js";import{t as h}from"./Warning-CywfiYbG.js";import{t as j}from"./utils-C0ZHLGh_.js";var p=s(e(),1),u=r(),x=({courseId:e,courseTitle:r,handleClose:s,handleSuccess:x})=>{const{localeMessages:f,apiBaseUrl:g}=t(),E=localStorage.getItem("activeOrganizationId"),[C,k]=(0,p.useState)(!1),[y,S]=(0,p.useState)("");return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(d,{id:"alert-dialog-title",children:[C&&(0,u.jsx)(i,{severity:"error",children:y}),(0,u.jsxs)(n,{variant:"h6",component:"span",children:[(0,u.jsx)(o,{sx:{display:"inline-block",alignItems:"center",mr:1,mt:1,pt:1},children:(0,u.jsx)(h,{color:"warning"})}),(0,u.jsx)(o,{sx:{display:"inline-block"},children:f.delete_course.replace("COURSE_NAME",r)})]})]}),(0,u.jsx)(c,{children:(0,u.jsx)(m,{id:"alert-dialog-description",children:f.course_delete_confirmation.replace("COURSE_NAME",r)})}),(0,u.jsxs)(l,{children:[(0,u.jsx)(a,{onClick:s,children:f.cancel}),(0,u.jsx)(a,{onClick:()=>{fetch(`${g}/organizations/${E}/courses/${e}/`,{method:"DELETE",headers:{"Content-Type":"application/json","X-CSRFToken":j("csrftoken")}}).then(e=>{if(200!=e.status&&409!=e.status)throw new Error("Unhandled network Error! course is not deleted");return e.json()}).then(e=>{if(e.error)throw new Error(e.error);x(),s()}).catch(e=>{S(e.message),k(!0)})},autoFocus:!0,variant:"contained",children:(0,u.jsx)(n,{children:f.delete})})]})]})};export{x as default};