import{u as f,r as n,j as e,T as i,B as a}from"./render-D1ZqzUbP.js";import{g as E}from"./utils-VIUIl18e.js";import{W as C}from"./Base-Qt2-pbvB.js";import{D,a as k}from"./DialogTitle-J__fqFcw.js";import{A as w}from"./Alert-M7jUzTjE.js";import{D as y}from"./DialogContentText-BSyscD7T.js";import{D as S}from"./DialogActions-JiHQNj-t.js";import{B as l}from"./Button-DJ_uYab0.js";import"./formControlState-C1XOL3mQ.js";import"./Select-Ht3nAO4Q.js";import"./Link-4dUp4u44.js";import"./Grid-BihMtcd8.js";import"./isMuiElement-BcEQvMml.js";import"./Dialog-aanaDG86.js";const N=({courseId:c,courseTitle:t,handleClose:s,handleSuccess:p})=>{const{localeMessages:o,apiBaseUrl:d}=f(),m=localStorage.getItem("activeOrganizationId"),[h,u]=n.useState(!1),[g,x]=n.useState(""),j=()=>{fetch(`${d}/organizations/${m}/courses/${c}/`,{method:"DELETE",headers:{"Content-Type":"application/json","X-CSRFToken":E("csrftoken")}}).then(r=>{if(r.status!=200&&r.status!=409)throw new Error("Unhandled network Error! course is not deleted");return r.json()}).then(r=>{if(r.error)throw new Error(r.error);console.log("Course state deleted successfully:",r),p(),s()}).catch(r=>{x(r.message),u(!0)})};return e.jsxs(e.Fragment,{children:[e.jsxs(D,{id:"alert-dialog-title",children:[h&&e.jsx(w,{severity:"error",children:g}),e.jsxs(i,{variant:"h6",component:"span",children:[e.jsx(a,{sx:{display:"inline-block",alignItems:"center",mr:1,mt:1,pt:1},children:e.jsx(C,{color:"warning"})}),e.jsx(a,{sx:{display:"inline-block"},children:o.delete_course.replace("COURSE_NAME",t)})]})]}),e.jsx(k,{children:e.jsx(y,{id:"alert-dialog-description",children:o.course_delete_confirmation.replace("COURSE_NAME",t)})}),e.jsxs(S,{children:[e.jsx(l,{onClick:s,children:o.cancel}),e.jsx(l,{onClick:j,autoFocus:!0,variant:"contained",children:e.jsx(i,{children:o.delete})})]})]})};export{N as default};
//# sourceMappingURL=DeleteCoursePopup-BEQqWV2R.js.map
