import{j as y}from"./chunk-JBNKEIUX.js";import"./chunk-5SW267PH.js";import"./chunk-PU7DBJLZ.js";import"./chunk-3DDBG3AR.js";import"./chunk-5MLUVH77.js";import"./chunk-SMMBZMNL.js";import"./chunk-S5GA3KRV.js";import"./chunk-EFONMPAR.js";import"./chunk-YQXLYYOT.js";import"./chunk-6RITFGP2.js";import"./chunk-HGXDKXJP.js";import"./chunk-WQUXAKOL.js";import"./chunk-LYNKRDJC.js";import"./chunk-SKY4LXUD.js";import"./chunk-BZT47AWD.js";import"./chunk-5WQBRAHK.js";import"./chunk-4FTRQKHH.js";import"./chunk-TTWRMELT.js";import"./chunk-EMJ4QQUL.js";import"./chunk-QPCAJSKO.js";import"./chunk-QV67LFVX.js";import"./chunk-4O3FVBGX.js";import{b as v}from"./chunk-TGWIHQDX.js";import{d as a}from"./chunk-Q5KZV54I.js";import{a as h}from"./chunk-YHVRQUSB.js";import"./chunk-3Z7PXZF3.js";import{a as S}from"./chunk-43BLBOSI.js";import"./chunk-IWSLIKCG.js";import"./chunk-2DXJE6G7.js";import"./chunk-7RP244JU.js";import"./chunk-LHGSJXTX.js";import"./chunk-ZKNPBXGB.js";import{b as m}from"./chunk-S3ADKFO2.js";import{E as f}from"./chunk-I5MYHHJE.js";import{Fb as s,Ib as c,S as l,Wa as d,Xc as p,f as n,gb as r,lb as u}from"./chunk-CKLXM6EG.js";import"./chunk-TSRGIXR5.js";var g=class o{constructor(i,e,t,w,A){this.apiService=i;this.route=e;this.translate=t;this.cdr=w;this.toast=A}title;urlApi;translationPrefix="reasons";fullWidthFields=["select","input","date","table","radio","textarea"];values;isEdit=!1;isShowMode=!1;fields;destroy$=new n;titleOfButton;ngOnInit(){this.route.paramMap.subscribe(i=>{let e=i.get("id");this.isShowMode=this.route.snapshot.routeConfig?.path?.includes("show")??!1,e?(this.getDetails(e),this.urlApi=`procurement/return-reason/${e}`,this.isShowMode?this.title="show-return-reason":(this.isEdit=!0,this.titleOfButton="edit-return-reason",this.title="edit-return-reason")):(this.isEdit=!1,this.titleOfButton="add",this.title="add-return-reason",this.urlApi="procurement/return-reason")}),this.fields=[{type:"textarea",title:"return-reason_ar",class:"col-6",controlName:"name_ar",validators:[a.required],readOnly:this.isShowMode},{type:"textarea",title:"return-reason_en",class:"col-6",controlName:"name_en",validators:[a.required],readOnly:this.isShowMode},{type:"radio",title:"is_active",controlName:"is_active",class:"col-12",RadioDefaultValue:1,options:[{name:this.translate.instant("yes"),id:1},{name:this.translate.instant("no"),id:0}],validators:[a.required],readOnly:this.isShowMode}]}getDetails(i){this.apiService.Get(`procurement/return-reason/${i}`).pipe(l(this.destroy$)).subscribe({next:e=>{this.values=e.data,this.isShowMode&&this.fields.push({type:"input",title:"created_at",class:"col-6",controlName:"created_at",readOnly:!0,value:this.values.created_at},{type:"input",title:"updated_at",class:"col-6",controlName:"updated_at",readOnly:!0,value:this.values.updated_at})},error:e=>{console.error(e)}})}static \u0275fac=function(e){return new(e||o)(r(h),r(f),r(m),r(p),r(v))};static \u0275cmp=u({type:o,selectors:[["app-return-reason-actions"]],decls:2,vars:11,consts:[[3,"title","Translationprefix","showTitle","showBreadcrumb"],["titleOfButton2","cancel",3,"fields","url","formValues","routeAfterSuccess","fullWidthFields","readOnly","titleOfButton"]],template:function(e,t){e&1&&c(0,"app-page-title",0)(1,"app-main-form",1),e&2&&(s("title",t.title)("Translationprefix",t.translationPrefix)("showTitle",!0)("showBreadcrumb",!0),d(),s("fields",t.fields)("url",t.urlApi)("formValues",t.values)("routeAfterSuccess","/settings/reasons?tab=2")("fullWidthFields",t.fullWidthFields)("readOnly",t.isShowMode)("titleOfButton",t.titleOfButton))},dependencies:[S,y],encapsulation:2})};export{g as ReturnReasonActions};
