import{a as Z}from"./chunk-DM34UTHR.js";import{e as B}from"./chunk-XZELSHJP.js";import{c as A,h as Q,i as H,k as O,m as k,n as q,x as G,y as L}from"./chunk-AUG6ZMIQ.js";import{a as K}from"./chunk-IQYEAILM.js";import"./chunk-3NZUMR4F.js";import{c as J}from"./chunk-JQJV7TYV.js";import{c as $,f as z}from"./chunk-YM543BQE.js";import{a as V,m as M,o as N,p as U}from"./chunk-STBSUBIU.js";import{Ac as R,Ba as v,Ca as g,Cb as x,Hb as j,Jc as c,Kc as f,Ob as S,Tb as n,Ub as p,Vb as I,Zb as C,_,ac as F,cc as w,jc as E,kb as o,kc as P,lb as d,lc as D,oc as T,qa as b,qc as m,rc as u,sc as h,xb as y}from"./chunk-NW2U37DI.js";import{h as Y}from"./chunk-TWZW5B45.js";var W=Y(Z());var ee=["uploadFile"];function te(a,X){if(a&1&&(n(0,"div",5)(1,"p"),m(2),p()()),a&2){let r=w();o(2),u(r.ErrorMessage)}}function ie(a,X){a&1&&I(0,"i",19)}var ve=(()=>{class a extends U{constructor(r,e,i,s,t,l){super(l),this.fb=r,this.adminService=e,this.toastr=i,this.router=s,this.translate=t,this.sendingResponse={},this.Error=!1,this.form=this.fb.group({file:null})}ngOnInit(){}File(r){let e=r.target?.files?.[0];this.form.patchValue({file:e})}UploadProjects(r,e){let i=new FormData;i.append("file",this.form.controls.file.value);let s={headers:new V({Accept:"application/json"})};this.sendingResponse[e]=!0,r.value.file.includes(".csv")||r.value.file.includes(".xlsx")?this.adminService.uploadProjects(i,s).pipe(_(this.unSubscribe$)).subscribe({next:t=>{if(this.sendingResponse[e]=!1,this.Error=!1,t?.success&&(W.default.fire({title:this.translate.transform("Imported Successfully"),text:this.translate.transform(t.success),icon:"success",confirmButtonColor:"#6259ca"}),this.form.reset({}),this.router.navigate(["/admin/projects"])),t.error){if(this.form.reset({}),this.uploadFile.nativeElement.value="",typeof t.error=="string")this.toastr.error(this.translate.transform(t.error));else if(typeof t.error=="object"){this.Error=!0;for(let l in t.errors)this.ErrorMessage=t.errors[l],this.toastr.error(this.translate.transform(t.errors[l]))}}},error:()=>{this.uploadFile.nativeElement.value="",this.form.reset({}),this.sendingResponse[e]=!1}}):(this.Error=!0,this.ErrorMessage=this.translate.transform("The File Type Is Not Supported"),this.sendingResponse[e]=!1)}static{this.\u0275fac=function(e){return new(e||a)(d(G),d(z),d(M),d(B),d($),d(N))}}static{this.\u0275cmp=b({type:a,selectors:[["app-projects-import"]],viewQuery:function(e,i){if(e&1&&E(ee,5),e&2){let s;P(s=D())&&(i.uploadFile=s.first)}},standalone:!0,features:[y,R],decls:34,vars:22,consts:[["FormData","ngForm"],["uploadFile",""],[3,"title"],[1,"col-xl-12","col-lg-12","col-md-12"],[1,"card"],[1,"alert","alert-danger"],[1,"card-header","border-0"],[1,"card-title"],[3,"ngSubmit"],[1,"card-body"],[1,"row"],[1,"form-group"],[1,"form-label"],[1,"input-group","file-browser"],["ngModel","","name","file","type","file",1,"form-control",3,"change"],[1,"text-muted"],["href","./download/projectsample.csv","download","",1,"text-primary"],[1,"card-footer"],["type","submit",1,"btn","btn-secondary","float-end","mb-2",3,"disabled"],[1,"fa","fa-spinner","fa-spin","mx-1"]],template:function(e,i){if(e&1){let s=C();I(0,"admin-page-header",2),n(1,"div",3)(2,"div",4),x(3,te,3,1,"div",5),n(4,"div",6)(5,"h4",7),m(6),c(7,"translate"),p()(),n(8,"form",8,0),F("ngSubmit",function(){v(s);let l=T(9);return g(i.UploadProjects(l,"uploadprojects"))}),n(10,"div",9)(11,"div",10)(12,"div",11)(13,"label",12),m(14),c(15,"translate"),p(),n(16,"div",13)(17,"input",14,1),F("change",function(l){return v(s),g(i.File(l))}),p()(),n(19,"small",15)(20,"i"),m(21),c(22,"translate"),p()(),n(23,"p"),m(24),c(25,"translate"),n(26,"a",16),m(27),c(28,"translate"),p()()()()(),n(29,"div",17)(30,"button",18),m(31),c(32,"translate"),x(33,ie,1,0,"i",19),p()()()()()}e&2&&(j("title","Projects Import"),o(3),S(i.Error?3:-1),o(3),u(f(7,10,"Import Projects")),o(8),h("",f(15,12,"Upload File")," "),o(7),u(f(22,14,"File Format: .xlsx and .csv")),o(3),h("",f(25,16,"Download")," "),o(3),u(f(28,18,"Sample File")),o(3),j("disabled",i.sendingResponse.uploadprojects),o(),h(" ",f(32,20,"Import Data"),""),o(2),S(i.sendingResponse.uploadprojects?33:-1))},dependencies:[K,J,L,q,A,Q,H,k,O]})}}return a})();export{ve as ProjectsImportComponent};
