{"size": 13673, "ext": "js", "max_stars_repo_path": "public/build/assets/create.5c145d67.js", "max_stars_repo_name": "althafn96/lms", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/build/assets/create.5c145d67.js", "max_issues_repo_name": "althafn96/lms", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/build/assets/create.5c145d67.js", "max_forks_repo_name": "althafn96/lms", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 525.8846153846, "max_line_length": 9601, "alphanum_fraction": 0.67607694}
var B=Object.defineProperty,A=Object.defineProperties;var q=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var S=(t,n,s)=>n in t?B(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,j=(t,n)=>{for(var s in n||(n={}))M.call(n,s)&&S(t,s,n[s]);if(C)for(var s of C(n))P.call(n,s)&&S(t,s,n[s]);return t},D=(t,n)=>A(t,q(n));import{u as K,y as p,N as Q,a0 as G,k as z,g as L,r as Y,i as H,l as J,m as e,O as I,P as g,Q as W,q as l,n as $,R as h,x as k}from"./vendor.9ac200cc.js";import{d as X}from"./getCategoriesToSelect.55e6b6b8.js";import"./getCategories.466bbd81.js";import{u as Z,K as ee,a as te}from"./app.52277fe1.js";import"./sweetalert2.1b53689f.js";import{C as ae}from"./ckeditor.80e0daed.js";import{s as ie}from"./vue-multiselect.esm.f7127d48.js";import{v as ne}from"./useValidator.4107c1a7.js";import"./Bootstrap5.88c59918.js";var y={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"addCategory"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"name"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"description"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"icon"}},type:{kind:"NamedType",name:{kind:"Name",value:"Upload"}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"image"}},type:{kind:"NamedType",name:{kind:"Name",value:"Upload"}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"status"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"is_featured"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"parent_id"}},type:{kind:"NamedType",name:{kind:"Name",value:"ID"}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createCategory"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"name"},value:{kind:"Variable",name:{kind:"Name",value:"name"}}},{kind:"ObjectField",name:{kind:"Name",value:"description"},value:{kind:"Variable",name:{kind:"Name",value:"description"}}},{kind:"ObjectField",name:{kind:"Name",value:"icon"},value:{kind:"Variable",name:{kind:"Name",value:"icon"}}},{kind:"ObjectField",name:{kind:"Name",value:"image"},value:{kind:"Variable",name:{kind:"Name",value:"image"}}},{kind:"ObjectField",name:{kind:"Name",value:"status"},value:{kind:"Variable",name:{kind:"Name",value:"status"}}},{kind:"ObjectField",name:{kind:"Name",value:"is_featured"},value:{kind:"Variable",name:{kind:"Name",value:"is_featured"}}},{kind:"ObjectField",name:{kind:"Name",value:"parent_id"},value:{kind:"Variable",name:{kind:"Name",value:"parent_id"}}}]}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:503}};y.loc.source={body:`mutation addCategory (\r
    $name: String!,\r
    $description: String,\r
    $icon: Upload,\r
    $image: Upload,\r
    $status: Int!,\r
    $is_featured: Int,\r
    $parent_id: ID\r
) {\r
    createCategory (\r
        input: {\r
            name: $name,\r
            description: $description,\r
            icon: $icon,\r
            image: $image,\r
            status: $status,\r
            is_featured: $is_featured,\r
            parent_id: $parent_id\r
        }\r
    ) {\r
        id\r
        name\r
    }\r
}\r
`,name:"GraphQL request",locationOffset:{line:1,column:1}};function x(t,n){if(t.kind==="FragmentSpread")n.add(t.name.value);else if(t.kind==="VariableDefinition"){var s=t.type;s.kind==="NamedType"&&n.add(s.name.value)}t.selectionSet&&t.selectionSet.selections.forEach(function(d){x(d,n)}),t.variableDefinitions&&t.variableDefinitions.forEach(function(d){x(d,n)}),t.definitions&&t.definitions.forEach(function(d){x(d,n)})}var N={};(function(){y.definitions.forEach(function(n){if(n.name){var s=new Set;x(n,s),N[n.name.value]=s}})})();function F(t,n){for(var s=0;s<t.definitions.length;s++){var d=t.definitions[s];if(d.name&&d.name.value==n)return d}}function se(t,n){var s={kind:t.kind,definitions:[F(t,n)]};t.hasOwnProperty("loc")&&(s.loc=t.loc);var d=N[n]||new Set,r=new Set,u=new Set;for(d.forEach(function(c){u.add(c)});u.size>0;){var o=u;u=new Set,o.forEach(function(c){if(!r.has(c)){r.add(c);var m=N[c]||new Set;m.forEach(function(b){u.add(b)})}})}return r.forEach(function(c){var m=F(t,c);m&&s.definitions.push(m)}),s}se(y,"addCategory");const oe={class:"content d-flex flex-column flex-column-fluid",id:"kt_content"},le={class:"container-xxl",id:"kt_content_container"},de=["onSubmit"],re={class:"d-flex flex-column gap-7 gap-lg-10 w-100 w-lg-300px mb-7 me-lg-10"},ce={class:"card card-flush py-4"},ue=e("div",{class:"card-header"},[e("div",{class:"card-title"},[e("h2",null,"Icon")])],-1),me={class:"card-body text-center pt-0"},pe={class:"image-input image-input-empty image-input-outline mb-3","data-kt-image-input":"true",style:{"background-image":"url(/media/svg/files/blank-image.svg)"}},be=e("div",{class:"image-input-wrapper w-150px h-150px"},null,-1),ve={class:"btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow","data-kt-image-input-action":"change","data-bs-toggle":"tooltip",title:"Change Icon"},fe=e("i",{class:"bi bi-pencil-fill fs-7"},null,-1),ge=e("span",{class:"btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow","data-kt-image-input-action":"cancel","data-bs-toggle":"tooltip",title:"Cancel Icon"},[e("i",{class:"bi bi-x fs-2"})],-1),ke=e("span",{class:"btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow","data-kt-image-input-action":"remove","data-bs-toggle":"tooltip",title:"Remove Icon"},[e("i",{class:"bi bi-x fs-2"})],-1),_e=e("div",{class:"text-muted fs-7"},"Set the category icon. Only *.png, *.jpg and *.jpeg image files are accepted",-1),he={class:"card card-flush py-4"},ye=e("div",{class:"card-header"},[e("div",{class:"card-title"},[e("h2",null,"Image")])],-1),xe={class:"card-body text-center pt-0"},we={class:"image-input image-input-empty image-input-outline mb-3","data-kt-image-input":"true",style:{"background-image":"url(/media/svg/files/blank-image.svg)"}},Ne=e("div",{class:"image-input-wrapper w-150px h-150px"},null,-1),Ve={class:"btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow","data-kt-image-input-action":"change","data-bs-toggle":"tooltip",title:"Change Image"},Ce=e("i",{class:"bi bi-pencil-fill fs-7"},null,-1),Se=e("span",{class:"btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow","data-kt-image-input-action":"cancel","data-bs-toggle":"tooltip",title:"Cancel Image"},[e("i",{class:"bi bi-x fs-2"})],-1),je=e("span",{class:"btn btn-icon btn-circle btn-active-color-primary w-25px h-25px bg-body shadow","data-kt-image-input-action":"remove","data-bs-toggle":"tooltip",title:"Remove Image"},[e("i",{class:"bi bi-x fs-2"})],-1),De=e("div",{class:"text-muted fs-7"},"Set the category image. Only *.png, *.jpg and *.jpeg image files are accepted",-1),Ie={class:"d-flex flex-column flex-row-fluid gap-7 gap-lg-10"},$e={class:"d-flex flex-column gap-7 gap-lg-10"},Fe={class:"card card-flush py-4"},Oe=e("div",{class:"card-header"},[e("div",{class:"card-title"},[e("h2",null,"General")])],-1),Te={class:"card-body pt-0"},Ee={class:"mb-10 fv-row"},Ue=e("label",{class:"required form-label"},"Category Name",-1),Re={class:"mb-10 fv-row"},Be=e("label",{class:"form-label"},"Parent",-1),Ae={class:"mb-10 fv-row"},qe=e("label",{class:"form-label"},"Description",-1),Me={class:"mb-10 fv-row d-flex flex-column"},Pe=e("label",{class:"form-label"},"Featured",-1),Ke={class:"btn-group w-50","data-kt-buttons":"true","data-kt-buttons-target":"[data-kt-button]"},Qe={class:"btn btn-outline-secondary text-muted text-hover-white text-active-white btn-outline btn-active-success","data-kt-button":"true"},Ge=k(" Yes "),ze={class:"btn btn-outline-secondary text-muted text-hover-white text-active-white btn-outline btn-active-danger active","data-kt-button":"true"},Le=k(" No "),Ye={class:"mb-10 fv-row d-flex flex-column"},He=e("label",{class:"form-label"},"Status",-1),Je={class:"btn-group w-50","data-kt-buttons":"true","data-kt-buttons-target":"[data-kt-button]"},We={class:"btn btn-outline-secondary text-muted text-hover-white text-active-white btn-outline btn-active-success active","data-kt-button":"true"},Xe=k(" Enabled "),Ze={class:"btn btn-outline-secondary text-muted text-hover-white text-active-white btn-outline btn-active-danger","data-kt-button":"true"},et=k(" Disabled "),tt={class:"d-flex justify-content-end"},at=e("span",{class:"indicator-label"},"Save Changes",-1),it=e("span",{class:"indicator-progress"},[k("Please wait... "),e("span",{class:"spinner-border spinner-border-sm align-middle ms-2"})],-1),nt=[at,it],gt={setup(t){const n=Z();n.title="Add Category",n.breadcrumbs=[{link:"/dashboard",title:"Dashboard"},{link:"/categories",title:"Categories"},{link:"",title:"Add Category"}];const s=K();let d=p(null),r=p(null),u=p(null),o=Q({name:"",description:"",image:null,icon:null,status:1,is_featured:0,parent:null}),c=ae,m={},b=p(null),w=p(null),V=p([]);const{resolveClient:O}=G(),T=O(),{mutate:E,onDone:st,onError:ot}=z(y),U=()=>{u.validate().then(async function(v){if(v=="Valid"){r.value.setAttribute("data-kt-indicator","on"),r.value.disabled=!0;try{const a=await E(D(j({},o),{parent_id:o.parent?o.parent.id:null}),{context:{hasUpload:!0}});alert("category added successfully"),s.push("/categories"),r.value.removeAttribute("data-kt-indicator"),r.value.disabled=!1}catch(a){alert("error occurred. please try again later."),console.log(a),alert("error occurred. please try again later."),r.value.removeAttribute("data-kt-indicator"),r.value.disabled=!1}}else alert("Sorry, looks like there are some errors detected, please try again.")})},_=(v,a,f)=>{if(a=="icon")if(f=="set"){let i=new Blob(w.value.files,{type:"image/*"});i.name=w.value.files[0].name,o.icon=i}else o.icon=null;if(a=="image")if(f=="set"){let i=new Blob(b.value.files,{type:"image/*"});i.name=b.value.files[0].name,o.image=i}else o.image=null},R=async()=>{const{data:v,loading:a,fetch:f}=await T.query({query:X});V.value=v.categories.data.map(function(i){return{id:i.id,name:i.name}})};return L(()=>{u=ne(d.value,{category_name:{validators:{notEmpty:{message:"Category Name is required"}}},parent:{validators:{notEmpty:{message:"Parent is required"}}}}),ee.init(),te.initButtons()}),(v,a)=>{const f=Y("ckeditor");return H(),J("div",oe,[e("div",le,[e("form",{onSubmit:I(U,["prevent"]),ref_key:"form",ref:d,class:"form fv-plugins-bootstrap5 fv-plugins-framework d-flex flex-column flex-lg-row"},[e("div",re,[e("div",ce,[ue,e("div",me,[e("div",pe,[be,e("label",ve,[fe,e("input",{ref_key:"icon",ref:w,onChange:a[0]||(a[0]=i=>_(i,"icon","set")),type:"file",name:"icon",accept:".png, .jpg, .jpeg"},null,544),e("input",{type:"hidden",onClick:a[1]||(a[1]=i=>_(i,"icon","remove")),name:"icon_remove"})]),ge,ke]),_e])]),e("div",he,[ye,e("div",xe,[e("div",we,[Ne,e("label",Ve,[Ce,e("input",{ref_key:"image",ref:b,onChange:a[2]||(a[2]=i=>_(i,"image","set")),type:"file",name:"image",accept:".png, .jpg, .jpeg"},null,544),e("input",{type:"hidden",onClick:a[3]||(a[3]=i=>_(i,"image","remove")),name:"image_remove"})]),Se,je]),De])])]),e("div",Ie,[e("div",$e,[e("div",Fe,[Oe,e("div",Te,[e("div",Ee,[Ue,g(e("input",{"onUpdate:modelValue":a[4]||(a[4]=i=>l(o).name=i),type:"text",name:"category_name",class:"form-control mb-2",placeholder:"Category Name"},null,512),[[W,l(o).name]])]),e("div",Re,[Be,$(l(ie),{modelValue:l(o).parent,"onUpdate:modelValue":a[5]||(a[5]=i=>l(o).parent=i),onSearchChange:R,"track-by":"id",label:"name",options:l(V)},null,8,["modelValue","options"])]),e("div",Ae,[qe,$(f,{editor:l(c),modelValue:l(o).description,"onUpdate:modelValue":a[6]||(a[6]=i=>l(o).description=i),config:l(m)},null,8,["editor","modelValue","config"])]),e("div",Me,[Pe,e("div",Ke,[e("label",Qe,[g(e("input",{"onUpdate:modelValue":a[7]||(a[7]=i=>l(o).is_featured=i),class:"btn-check",type:"radio",name:"is_featured",value:1},null,512),[[h,l(o).is_featured]]),Ge]),e("label",ze,[g(e("input",{"onUpdate:modelValue":a[8]||(a[8]=i=>l(o).is_featured=i),class:"btn-check",type:"radio",name:"is_featured",checked:"checked",value:0},null,512),[[h,l(o).is_featured]]),Le])])]),e("div",Ye,[He,e("div",Je,[e("label",We,[g(e("input",{"onUpdate:modelValue":a[9]||(a[9]=i=>l(o).status=i),class:"btn-check",type:"radio",name:"status",checked:"checked",value:1},null,512),[[h,l(o).status]]),Xe]),e("label",Ze,[g(e("input",{"onUpdate:modelValue":a[10]||(a[10]=i=>l(o).status=i),class:"btn-check",type:"radio",name:"status",value:0},null,512),[[h,l(o).status]]),et])])])])])]),e("div",tt,[e("button",{onClick:a[11]||(a[11]=I(i=>l(s).go(-1),["prevent"])),id:"category_create_cancel",class:"btn btn-light me-5"},"Cancel"),e("button",{ref_key:"submitButton",ref:r,type:"submit",id:"submitButton",class:"btn btn-primary"},nt,512)])])],40,de)])])}}};export{gt as default};
