import{_t as e,lt as r,n as t,yt as s}from"./render-C1-Vvny8.js";import{t as o}from"./Box-BbbSuncO.js";import{t as n}from"./Typography-CZowogrb.js";import{t as a}from"./Button-DTVoBv0Y.js";import{t as i}from"./Alert-C8jEdKQG.js";import{t as l}from"./DialogActions-CSfNi6Fl.js";import{n as c,t as d}from"./DialogTitle-3xkF2gTa.js";import{t as m}from"./DialogContentText-B3tPnlAQ.js";import{t as h}from"./Warning-DC_j4KpI.js";import{t as j}from"./utils-CF94S7_6.js";var p=s(e(),1),u=r(),x=({courseId:e,courseTitle:r,handleClose:s,handleSuccess:x})=>{const{localeMessages:g,apiBaseUrl:f}=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:g.delete_course.replace("COURSE_NAME",r)})]})]}),(0,u.jsx)(c,{children:(0,u.jsx)(m,{id:"alert-dialog-description",children:g.course_delete_confirmation.replace("COURSE_NAME",r)})}),(0,u.jsxs)(l,{children:[(0,u.jsx)(a,{onClick:s,children:g.cancel}),(0,u.jsx)(a,{onClick:()=>{fetch(`${f}/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:g.delete})})]})]})};export{x as default};