1import{a as $}from"./chunk-BODP6TFB.js";import"./chunk-VCCX4LAP.js";import"./chunk-J3A2U6TM.js";import"./chunk-JZGI6YNS.js";import{n as f}from"./chunk-X4IAFPSU.js";import"./chunk-ZC5BAMLL.js";import{a as B}from"./chunk-LY5JTRYZ.js";import"./chunk-STFKJH6K.js";import"./chunk-2JXRFME3.js";import"./chunk-JYQLOY3X.js";import"./chunk-ALB7G2L3.js";import"./chunk-WTW27ATQ.js";import{a as I}from"./chunk-EZD3Q7NT.js";import{a as b,b as T,c as E,d as A,o as O}from"./chunk-EI5WCKEE.js";import{a as g,b as z,c as r,d as u}from"./chunk-642GPQRI.js";import"./chunk-NDQJV6AA.js";import{a as M}from"./chunk-EBWQIPI5.js";import{a as n}from"./chunk-74QXIXOR.js";import"./chunk-UWPN3ANA.js";import"./chunk-URZACWAH.js";import"./chunk-WYWQVVYV.js";import{b as w}from"./chunk-ECDAGYRA.js";import"./chunk-CAZKNYQG.js";import"./chunk-OSCIAXER.js";import{Ca as R}from"./chunk-3MZHKN66.js";import"./chunk-LWGF47UP.js";import"./chunk-CGXKU5IM.js";import"./chunk-KPTJW7ID.js";import{a as S}from"./chunk-KQCPDZJS.js";import{e as N}from"./chunk-Q3T7WDEA.js";import{a as x}from"./chunk-WKJHVILU.js";import"./chunk-3IIZIPSQ.js";import{Ab as _,Ec as C,Fc as h,Xb as P,Yb as c,Zb as l,aa as p,f as D,ib as m,na as o,oc as L}from"./chunk-4P6GBCAD.js";import{a as d,b as v}from"./chunk-MG3ERZGY.js";var U=class y{router=o(N);modal=o(M);service=o(I);tablePreference=o(B);Icons=n;CompanyConstants=O;$onDestroy=new D;moreVerticalSVG=R;gridData=[];createCompanyButton={name:b,url:T};companyColumnConfig=[{type:"dark-text",field:"companyName",title:"Company Name",filter:"text"},{type:"text",field:"email",title:"Email ID",filter:"text"},{type:"text",field:"phoneNumber",title:"Phone",filter:"text"},{type:"image",field:"logo",title:"Logo",filter:"text"},{type:"status",field:"status",title:"Status",filter:"text"},{type:"action",field:"actions",title:"Actions",filter:"text"}];companyListResponse={hasNext:!1,hasPrevious:!1,items:[],pageNumber:1,pageSize:10,totalPages:0,totalRecords:0};pageSize=10;pageNumber=1;searchTerm="";userPermissionList=[];notification=o(w);ngOnInit(){this.pageSize=this.tablePreference.getPageSizeForTable(f.COMPANY,10),this.getCompanyList(),this.userPermissionList=JSON.parse(localStorage.getItem("permissions")||"[]"),this.userPermissionList=this.userPermissionList.filter(t=>t.startsWith("Company")),this.userPermissionList.includes(z)||(this.createCompanyButton={})}getStatusClass(t){if(!t)return"default";switch(t.toLowerCase()){case"active":return"success";case"inactive":return"error";default:return"default"}}onActionClick(t){t.action.text==="Delete"&&this.userPermissionList.includes(u)&&this.modal.deleteConfirm(E,A).subscribe(s=>{s&&this.service.deleteCompany(t.item.id).pipe(p(this.$onDestroy)).subscribe(e=>{this.notification.success(e.statusMessage),this.getCompanyList()})}),t.action.text==="View"&&this.userPermissionList.includes(g)&&this.router.navigate(["company/view",t.item.id]),t.action.text==="Edit"&&this.userPermissionList.includes(r)&&this.router.navigate(["/company/edit",t.item.id]),t.action.text==="Activate"&&this.userPermissionList.includes(r)&&this.service.activateCompany(t.item.id).pipe(p(this.$onDestroy)).subscribe(s=>{this.notification.success(s.statusMessage),this.getCompanyList()}),t.action.text==="Deactivate"&&this.userPermissionList.includes(r)&&this.service.deactivateCompany(t.item.id).pipe(p(this.$onDestroy)).subscribe(s=>{this.notification.success(s.statusMessage),this.getCompanyList()})}actionsData=[{text:"View",svgIcon:n.eyeReadOutlined},{text:"Edit",svgIcon:n.editOutlined},{text:"Activate",svgIcon:n.activeOutlined},{text:"Deactivate",svgIcon:n.closeOutlined},{text:"Delete",svgIcon:n.deleteOutlined,disabled:!1}];getCompanyList(){this.service.getCompanyList(this.pageNumber,this.pageSize,this.searchTerm).pipe(p(this.$onDestroy)).subscribe(t=>{let s=t.result;this.companyListResponse=s,this.gridData=s.items.map(e=>v(d({},e),{logo:e.logoDataUrl?`${S.apiHost}${e.logoDataUrl}`:"../../../../assets/images/app-logo.svg",status:e.isActive?"Active":"Inactive",actions:this.actionsData.filter(i=>!(e.isActive&&i.text==="Activate"||!e.isActive&&i.text==="Deactivate"))})),this.gridData=this.gridData.map(e=>(this.userPermissionList.includes(r)||(e.actions=e.actions?.filter(i=>i.text!=="Edit"&&i.text!=="Activate"&&i.text!=="Deactivate")),this.userPermissionList.includes(g)||(e.actions=e.actions?.filter(i=>i.text!=="View")),this.userPermissionList.includes(u)||(e.actions=e.actions?.filter(i=>i.text!=="Delete")),e)),this.userPermissionList.filter(e=>[g,r,u].includes(e)).length===0&&(this.companyColumnConfig=this.companyColumnConfig.filter(e=>e.field!=="actions"))})}onPageChange(t){this.pageNumber=t,this.getCompanyList()}onPageSizeChange(t){this.pageSize=t.newPageSize,this.pageNumber=1,this.tablePreference.savePageSize(f.COMPANY,t.newPageSize).subscribe(),this.getCompanyList()}onSearchTermChange(t){this.searchTerm=t,this.pageNumber=1,this.getCompanyList()}ngOnDestroy(){this.$onDestroy.next(),this.$onDestroy.complete()}static \u0275fac=function(s){return new(s||y)};static \u0275cmp=_({type:y,selectors:[["app-company"]],decls:7,vars:12,consts:[[1,"title-section"],["kendoTypography","","fontSize","lg","fontWeight","bold","themeColor","dark"],["kendoTypography","","fontSize","sm","themeColor","secondary"],[1,"page-wrapper"],[3,"actionChange","pageChange","pageSizeChange","searchTermChange","data","columnConfig","actionsData","navigateButtonDetails","hasNext","hasPrevious","total","pageSize","totalPages","pageNumber"]],template:function(s,e){s&1&&(c(0,"section",0)(1,"h3",1),C(2),l(),c(3,"p",2),C(4),l()(),c(5,"section",3)(6,"app-dynamic-grid",4),L("actionChange",function(a){return e.onActionClick(a)})("pageChange",function(a){return e.onPageChange(a)})("pageSizeChange",function(a){return e.onPageSizeChange(a)})("searchTermChange",function(a){return e.onSearchTermChange(a)}),l()()),s&2&&(m(2),h(e.CompanyConstants.TITLE),m(2),h(e.CompanyConstants.SUB_TITLE),m(2),P("data",e.gridData)("columnConfig",e.companyColumnConfig)("actionsData",e.actionsData)("navigateButtonDetails",e.createCompanyButton)("hasNext",e.companyListResponse.hasNext)("hasPrevious",e.companyListResponse.hasPrevious)("total",e.companyListResponse.totalRecords)("pageSize",e.companyListResponse.pageSize)("totalPages",e.companyListResponse.totalPages)("pageNumber",e.companyListResponse.pageNumber))},dependencies:[x,$],encapsulation:2})};export{U as Company};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.