@djb25/digit-ui-module-vendor 1.0.32 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var e,t=require("react"),l=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=require("react-router-dom"),a=require("@djb25/digit-ui-react-components"),i=require("react-i18next"),o=require("react-hook-form"),r=require("react-query");function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var n in l)({}).hasOwnProperty.call(l,n)&&(e[n]=l[n])}return e}).apply(null,arguments)}const d=e=>{let{path:t}=e;const{t:o}=i.useTranslation(),r=n.useLocation();sessionStorage.removeItem("revalidateddone");const d=Digit.ComponentRegistryService.getComponent("AddVendor"),u=Digit.ComponentRegistryService.getComponent("SearchVendor"),c=Digit.ComponentRegistryService.getComponent("SearchApp"),E=Digit.ComponentRegistryService.getComponent("AddDriver"),m=Digit.ComponentRegistryService.getComponent("EditVendorDetails"),v=Digit.ComponentRegistryService.getComponent("AddVehicle"),S=Digit.ComponentRegistryService.getComponent("VENDORCreate"),p=Digit.ComponentRegistryService.getComponent("DriverDetails"),_=Digit.ComponentRegistryService.getComponent("VehicleDetails"),D=Digit.ComponentRegistryService.getComponent("AddSupervisor"),R=Digit.ComponentRegistryService.getComponent("SupervisorDetails"),N=Digit.ComponentRegistryService.getComponent("AddSurveyor"),g=Digit.ComponentRegistryService.getComponent("SurveyorDetails");return l.createElement(n.Switch,null,l.createElement(a.AppContainer,null,l.createElement(l.Fragment,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(a.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(a.ArrowLeft,{className:"icon"}),"Back"),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const e=r.pathname;let t=[{icon:a.HomeIcon,path:"/digit-ui/employee"},{label:o("TITLE_VENDOR_MANAGEMENT"),path:"/digit-ui/employee/vendor/search-vendor"}];return e.includes("/registry/new-vendor")?t.push({label:o("ES_FSM_REGISTRY_TITLE_NEW_VENDOR")}):e.includes("/search-vendor")?t.push({label:o("SEARCH_VENDOR")}):e.includes("/registry/new-driver")?t.push({label:o("ES_FSM_REGISTRY_TITLE_NEW_DRIVER")}):e.includes("/registry/vendor-details")||e.includes("/registry/modify-vendor/")?t.push({label:o("VENDOR_VENDOR_DETAILS")}):e.includes("/registry/vehicle-details")||e.includes("/registry/modify-vehicle/")?t.push({label:o("VENDOR_VEHICLE_DETAILS")}):e.includes("/registry/new-vehicle")?t.push({label:o("ES_FSM_REGISTRY_TITLE_NEW_VEHICLE")}):e.includes("/registry/driver-details")||e.includes("/registry/modify-driver/")?t.push({label:o("VENDOR_DRIVER_DETAILS")}):e.includes("/registry/additionaldetails")?t.push({label:o("VENDOR_ADDITIONAL_DETAILS")}):e.includes("/registry/new-supervisor")?t.push({label:o("ES_FSM_REGISTRY_TITLE_NEW_SUPERVISOR")}):e.includes("/registry/supervisor-details")||e.includes("/registry/modify-supervisor/")?t.push({label:o("VENDOR_SUPERVISOR_DETAILS")}):e.includes("/registry/new-surveyor")?t.push({label:o("ES_FSM_REGISTRY_TITLE_NEW_SURVEYOR")}):(e.includes("/registry/surveyor-details")||e.includes("/registry/modify-surveyor/"))&&t.push({label:o("VENDOR_SURVEYOR_DETAILS")}),t})()}),l.createElement(a.PrivateRoute,{path:t+"/search-vendor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"normal"},l.createElement(u,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/new-driver",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(E,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/new-vehicle",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(v,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/additionaldetails",component:e=>{const n=e.location.pathname.includes("/info");return l.createElement(a.LayoutWrapper,{layoutClass:n?"action":"normal"},l.createElement(S,s({},e,{parentRoute:t})))}}),l.createElement(a.PrivateRoute,{path:t+"/registry/driver-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(p,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/common-search/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"normal"},l.createElement(c,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/new-vendor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(d,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/vendor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(m,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/vehicle-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(_,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/new-supervisor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(D,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/supervisor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(R,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/new-surveyor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(N,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/surveyor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(g,s({},e,{parentRoute:t})))})))))};function u(e,t){try{var l=e()}catch(e){return t(e)}return l&&l.then?l.then(void 0,t):l}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));const c=function(e){return void 0===e&&(e=""),function(e){return void 0===e&&(e=""),!(!e||null==e||void 0===e||""===e)}(e)?e:"NA"},E=function(e,t,l){if(void 0===e&&(e=""),void 0===t&&(t=""),void 0===l&&(l=""),""===t)return e;for(;e.includes(t);)e=e.replace(t,l);return e},m=e=>{var n,i;let{isLoading:r,t:s,onSubmit:d,data:u,count:c,setShowToast:E,vendorData:m}=e;const v=window.Digit.Utils.browser.isMobile(),S=new Date,p=S.toISOString().split("T")[0],_=new Date(S);_.setDate(S.getDate()-7);const D=_.toISOString().split("T")[0],{register:R,control:N,handleSubmit:g,setValue:y,getValues:T,reset:I,formState:C}=o.useForm({defaultValues:{offset:0,limit:!v&&10,sortBy:"commencementDate",sortOrder:"DESC",fromDate:D,toDate:p}});t.useEffect(()=>{R("offset",0),R("limit",10),R("sortBy","commencementDate"),R("sortOrder","DESC"),y("fromDate",D),y("toDate",p)},[R,g,y,p,D]),t.useEffect(()=>{var e;if(console.log("Fetched Vendor Data:"),null!=m&&null!==(e=m.vendor)&&void 0!==e&&e.length){const e=m.vendor.map(e=>e.name);console.log("Vendor Names:",e)}},[m]);const O=t.useMemo(()=>[{Header:s("VENDOR_REGISTRATION_NO"),accessor:"requestId",disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const a=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.registrationNo;return l.createElement("div",null,a||"N/A")}},{Header:s("CONTACT_PERSON_NAME"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const a=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.contactPerson;return l.createElement("div",null,a||"N/A")}},{Header:s("VENDOR_MOBILE_NUMBER"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const a=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.vendorMobileNumber;return l.createElement("div",null,a||"N/A")}},{Header:s("VENDOR_BANK_NAME"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const a=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.bank;return l.createElement("div",null,a||"N/A")}},{Header:s("VENDOR_STATUS"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const a=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.status;return l.createElement("div",null,a||"N/A")}}],[]),A=t.useCallback(e=>{0!==e.length&&(y("sortBy",e.id),y("sortOrder",e.desc?"DESC":"ASC"))},[]);function f(){y("offset",T("offset")-T("limit")),g(d)()}return l.createElement(l.Fragment,null,l.createElement("div",null,l.createElement(a.Header,null,s("VENDOR_COMMON_SEARCH_ADDITIONAL_DETAILS")),l.createElement(a.SearchForm,{onSubmit:d,handleSubmit:g},l.createElement(a.SearchField,null,l.createElement("label",null,s("VENDOR_NAME")),l.createElement(o.Controller,{control:N,name:"vendorName",render:e=>{var t;return l.createElement(a.Dropdown,{selected:e.value||"",select:e.onChange,onBlur:e.onBlur,option:(null==m||null===(t=m.vendor)||void 0===t?void 0:t.map(e=>({name:e.name,i18nKey:e.name})))||[],optionKey:"i18nKey",t:s,disable:!1})}})),l.createElement(a.SearchField,null,l.createElement("label",null,s("VENDOR_MOBILE_NO")),l.createElement(a.MobileNumber,{name:"mobileNumber",inputRef:R({minLength:{value:10,message:s("CORE_COMMON_MOBILE_ERROR")},maxLength:{value:10,message:s("CORE_COMMON_MOBILE_ERROR")},pattern:{value:/[6789][0-9]{9}/,message:s("CORE_COMMON_MOBILE_ERROR")}}),type:"number",componentInFront:l.createElement("div",{className:"employee-card-input employee-card-input--front"},"+91")}),l.createElement(a.CardLabelError,null,null==C||null===(n=C.errors)||void 0===n||null===(i=n.mobileNumber)||void 0===i?void 0:i.message)),l.createElement(a.SearchField,null,l.createElement("label",null,s("VENDOR_FROM_DATE")),l.createElement(o.Controller,{render:e=>l.createElement(a.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"fromDate",control:N})),l.createElement(a.SearchField,null,l.createElement("label",null,s("VENDOR_TO_DATE")),l.createElement(o.Controller,{render:e=>l.createElement(a.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"toDate",control:N})),l.createElement(a.SearchField,{className:"submit"},l.createElement(a.SubmitBar,{label:s("ES_COMMON_SEARCH"),submit:!0}),l.createElement("p",{style:{marginTop:"10px"},onClick:()=>{I({fromDate:D,toDate:"",mobileNumber:"",vendorName:"",offset:0,limit:10,sortBy:"commencementDate",sortOrder:"DESC"}),E(null),f()}},s("ES_COMMON_CLEAR_ALL")))),!r&&null!=u&&u.display?l.createElement(a.Card,{style:{marginTop:20}},s(u.display).split("\\n").map((e,t)=>l.createElement("p",{key:t,style:{textAlign:"center"}},e))):r||""===u?""!==u||r&&l.createElement(a.Loader,null):l.createElement(a.Table,{t:s,data:u,totalRecords:c,columns:O,getCellProps:e=>({style:{minWidth:e.column.Header===s("EW_INBOX_APPLICATION_NO")?"240px":"",padding:"20px 18px",fontSize:"16px"}}),onPageSizeChange:function(e){y("limit",Number(e.target.value)),g(d)()},currentPage:T("offset")/T("limit"),onNextPage:function(){y("offset",T("offset")+T("limit")),g(d)()},onPrevPage:f,pageSizeLimit:T("limit"),onSort:A,disableSort:!1,sortParams:[{id:T("sortBy"),desc:"DESC"===T("sortOrder")}]})))},v=e=>{let{parentRoute:o}=e;const{t:r}=i.useTranslation(),s=[{text:r("ES_TITLE_NEW_DESULDGING_APPLICATION"),link:"/digit-ui/employee/fsm/new-application",roles:["FSM_CREATOR_EMP"]},{text:r("ES_TITILE_SEARCH_APPLICATION"),link:o+"/search"},{text:r("ES_TITLE_REPORTS"),link:"/employee/report/fsm/FSMDailyDesludingReport",roles:["FSM_ADMIN"],hyperlink:!0}],[d,u]=t.useState([]),{roles:c}=Digit.UserService.getUser().info;return t.useEffect(()=>{let e=s.filter(e=>{let{roles:t}=e;return(null==t?void 0:t.some(e=>null==c?void 0:c.map(e=>{let{code:t}=e;return t}).includes(e)))||!(null!=t&&t.length)});u(e)},[]),l.createElement(a.Card,{className:"employeeCard inboxLinksFSM"},l.createElement("div",{className:"complaint-links-container"},l.createElement("div",{className:"header"},l.createElement("span",{className:"logo"},l.createElement(a.ShippingTruck,null))," ",l.createElement("span",{className:"text"},r("ES_TITLE_FAECAL_SLUDGE_MGMT"))),l.createElement("div",{className:"body"},d.map((e,t)=>{let{link:a,text:i,hyperlink:o=!1,accessTo:s=[]}=e;return l.createElement("span",{className:"link",key:t},o?l.createElement("a",{href:a},r(i)):l.createElement(n.Link,{to:a},r(i)))}))))},S=e=>{let{className:t="table",t:n,currentPage:i,columns:o,data:r,getCellProps:d,disableSort:u,onSort:c,onNextPage:E,onPrevPage:m,onPageSizeChange:v,pageSizeLimit:S,sortParams:p,totalRecords:_,isPaginationRequired:D,showCSVExport:R,csvExportFileName:N,csvExportData:g,getCSVExportData:y,csvExportColumns:T,csvExportButtonLabel:I,...C}=e;return l.createElement(a.Table,s({className:t,t:n,data:r,currentPage:i,columns:o,getCellProps:d,onNextPage:E,onPrevPage:m,pageSizeLimit:S,disableSort:u,onPageSizeChange:v,onSort:c,sortParams:p,totalRecords:_,isPaginationRequired:D,showCSVExport:R,csvExportFileName:N,csvExportData:g,getCSVExportData:y,csvExportColumns:T,csvExportButtonLabel:I},C))},p=e=>{var t;let{status:n,searchParams:o,onAssignmentChange:r,statusMap:s}=e;return i.useTranslation(),l.createElement(a.CheckBox,{styles:{height:"unset"},onChange:e=>r({...e,state:n.state},n),checked:null==o?void 0:o.applicationStatus.some(e=>e.uuid===n.uuid),label:`${n.name} (${(null==s||null===(t=s.find(e=>e.statusid===n.uuid))||void 0===t?void 0:t.count)||"-"})`})},_=e=>{var n,o,r,s,d;let{onAssignmentChange:u,searchParams:c,businessServices:E,statusMap:m}=e;const{t:v}=i.useTranslation(),[S,_]=t.useState(!1),{data:D,isLoading:R}=Digit.Hooks.useApplicationStatusGeneral({businessServices:E},{}),{userRoleStates:N}=D||{},g=(e,t)=>t(map[e.stateBusinessService])+" - "+t("ES_PTR_COMMON_STATUS_"+(e.state||"CREATED"));return R?l.createElement(a.Loader,null):null!=N&&N.filter(e=>!e.isTerminateState).length?l.createElement("div",{className:"status-container"},l.createElement("div",{className:"filter-label",style:{fontWeight:"normal"}},v("ES_INBOX_STATUS")),null==N||null===(n=N.filter(e=>!e.isTerminateState))||void 0===n||null===(o=n.slice(0,4))||void 0===o?void 0:o.map((e,t)=>l.createElement(p,{businessServices:E,key:t,onAssignmentChange:u,status:{name:g(e,v),code:e.applicationStatus,...e},searchParams:c,statusMap:m})),(null==N||null===(r=N.filter(e=>!e.isTerminateState))||void 0===r?void 0:r.slice(4).length)>0?l.createElement(l.Fragment,null,S&&(null==N||null===(s=N.filter(e=>!e.isTerminateState))||void 0===s||null===(d=s.slice(4))||void 0===d?void 0:d.map((e,t)=>l.createElement(p,{businessServices:E,key:e.uuid,onAssignmentChange:u,status:{name:g(e,v),code:e.applicationStatus,...e},searchParams:c,statusMap:m}))),l.createElement("div",{className:"filter-button",onClick:()=>_(!S)}," ",v(S?"ES_COMMON_LESS":"ES_COMMON_MORE")," ")):null):null},D=e=>{let{onFilterChange:t,searchParams:n,paginationParms:i,tenantId:o,t:r}=e;const{data:s}=Digit.Hooks.fsm.useInbox(o,{...n,...i,fromDate:null!=n&&n.fromDate?new Date(null==n?void 0:n.fromDate).getTime():void 0,toDate:null!=n&&n.toDate?new Date(null==n?void 0:n.toDate).getTime():void 0,total:!0,uuid:{code:"ASSIGNED_TO_ALL",name:r("ES_INBOX_ASSIGNED_TO_ALL")}}),d=[{code:"ASSIGNED_TO_ME",name:r("ES_INBOX_ASSIGNED_TO_ME")+" (0)"},{code:"ASSIGNED_TO_ALL",name:`${r("ES_INBOX_ASSIGNED_TO_ALL")} (${(null==s?void 0:s.totalCount)||0})`}];return l.createElement(l.Fragment,null,l.createElement(a.RadioButtons,{onSelect:e=>t({uuid:{code:e.code}}),selectedOption:d.filter(e=>{var t;return e.code===(null==n||null===(t=n.uuid)||void 0===t?void 0:t.code)})[0],optionsKey:"name",options:d}))},R=e=>{var t,o,r,s;let{searchParams:d,paginationParms:u,onFilterChange:c,onSearch:E,...m}=e;const{t:v}=i.useTranslation(),S=n.useLocation(),p=Digit.UserService.hasAccess(["FSM_DSO"])||!1,R=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1,N=Digit.UserService.hasAccess("FSM_EMP_FSTPO")&&S.pathname.includes("fstp-fsm-request")||!1,g=Digit.ULBService.getCurrentTenantId(),y=Digit.ULBService.getStateId(),{data:T,isFetched:I}=Digit.Hooks.fsm.useMDMS(y,"DIGIT-UI","RoleStatusMapping"),C=Digit.UserService.getUser().info.roles.map(e=>e.code),O=null==T?void 0:T.filter(e=>C.filter(t=>t===e.userRole)[0]),A=null==O?void 0:O.reduce((e,t)=>({fixed:(null==t?void 0:t.fixed)&&(null==e?void 0:e.fixed),statuses:[...null==e?void 0:e.statuses,...null==t?void 0:t.statuses].filter((e,t,l)=>l.indexOf(e)==t),zeroCheck:(null==t?void 0:t.zeroCheck)||(null==e?void 0:e.zeroCheck)}),{statuses:[]}),f=()=>{if(R)return c()};return l.createElement(l.Fragment,null,(!p&&!R&&d||(null==A||null===(t=A.statuses)||void 0===t?void 0:t.length)>0||N)&&l.createElement("div",{className:"filter",style:{marginTop:R?"-0px":"revert"}},l.createElement("div",{className:"filter-card"},l.createElement("div",{className:"heading"},l.createElement("div",{className:"filter-label"},v("ES_COMMON_FILTER_BY"),":"),l.createElement("div",{className:"clearAll",onClick:f},v("ES_COMMON_CLEAR_ALL")),"desktop"===m.type&&l.createElement("span",{className:"clear-search",onClick:f},v("ES_COMMON_CLEAR_ALL")),"mobile"===m.type&&l.createElement("span",{onClick:m.onClose},l.createElement(a.CloseSvg,null))),l.createElement("div",null,!p&&!R&&d&&l.createElement(D,{onFilterChange:c,searchParams:d,paginationParms:u,tenantId:g,t:v}),l.createElement("div",null)),(null==A||null===(o=A.statuses)||void 0===o?void 0:o.length)>0||N?l.createElement("div",null,l.createElement("div",{className:"filter-label"},v("ES_INBOX_LOCALITY")),l.createElement(a.Localities,{selectLocality:e=>{c(R?{locality:[e]}:{locality:[...null==d?void 0:d.locality,e]})},tenantId:g,boundaryType:"revenue"}),l.createElement("div",{className:"tag-container"},null==d?void 0:d.locality.map((e,t)=>l.createElement(a.RemoveableTag,{key:t,text:e.i18nkey,onClick:()=>{c({locality:null==d?void 0:d.locality.filter(t=>t.code!==e.code)})}})))):null,l.createElement("div",null,I&&A&&null!=m&&null!==(r=m.applications)&&void 0!==r&&r.statuses?l.createElement(_,{onAssignmentChange:(e,t)=>{c(e.target.checked?{applicationStatus:[...null==d?void 0:d.applicationStatus,t]}:{applicationStatus:null==d?void 0:d.applicationStatus.filter(e=>t.name!==e.name)})},fsmfilters:d,mergedRoleDetails:A,statusMap:null==m||null===(s=m.applications)||void 0===s?void 0:s.statuses}):S.pathname.includes("fstp-fsm-request")?"":l.createElement(a.Loader,null)))),"mobile"===m.type&&m.onClose&&l.createElement(a.ActionBar,null,l.createElement(a.ApplyFilterBar,{submit:!1,labelLink:v("ES_COMMON_CLEAR_ALL"),buttonLink:v("ES_COMMON_FILTER"),onClear:f,onSubmit:()=>{"mobile"===m.type?E({delete:["applicationNos"]}):E()},style:{flex:1}})))},N=e=>{let{onAssignmentChange:t,value:n,applicationStatuses:i,areApplicationStatus:o}=e;return o?l.createElement(a.Dropdown,{option:i,optionKey:"name",selected:n,select:t}):l.createElement(a.Loader,null)},g=e=>{var r,d,u,c,E,m,v,S,p,_,D;let{onSearch:R,type:g,onClose:y,onTabChange:T,searchFields:I,searchParams:C,isInboxPage:O,selectedTab:A,matchedRoles:f}=e;const b=O?Digit.SessionStorage.get("vendor/inbox/searchParams"):Digit.SessionStorage.get("vendor/search/searchParams"),{t:h}=i.useTranslation(),V=n.useHistory(),{register:M,handleSubmit:L,reset:w,watch:k,control:P}=o.useForm({defaultValues:b||C}),[F,x]=t.useState(!1),H=window.Digit.Utils.browser.isMobile(),B=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1;function U(){const e=I.reduce((e,t)=>({...e,[null==t?void 0:t.name]:""}),{});w(e),O?Digit.SessionStorage.del("fsm/inbox/searchParams"):Digit.SessionStorage.del("fsm/search/searchParams"),R({})}const Y=e=>null,G=[..."EMPLOYEE"===Digit.SessionStorage.get("User").info.type&&null!=f&&null!==(r=f.wt)&&void 0!==r&&r.includes("WT_VENDOR")?["VENDOR"]:[],...null!=f&&null!==(d=f.wt)&&void 0!==d&&d.includes("WT_VENDOR")?["DRIVER","VEHICLE"]:[],...null!=f&&null!==(u=f.ekyc)&&void 0!==u&&u.includes("EKYC-VENDOR")?["SUPERVISOR"]:[],...null!=f&&null!==(c=f.ekyc)&&void 0!==c&&c.includes("EKYC_SUPERVISOR")||null!=f&&null!==(E=f.ekyc)&&void 0!==E&&E.includes("EKYC-VENDOR")?["SURVEYOR"]:[]];return l.createElement(l.Fragment,null,l.createElement("div",{className:"search-container",style:{width:"auto"}},l.createElement("div",{className:"search-complaint-container"},("mobile"===g||H)&&l.createElement("div",{className:"complaint-header"},l.createElement("h2",null,h("ES_COMMON_SEARCH_BY")),l.createElement("span",{style:{position:"absolute",top:"2%",right:"8px"},onClick:y},l.createElement(a.CloseSvg,null))),l.createElement("div",{className:"search-tabs-container"},l.createElement("div",null,(null==f||null===(m=f.wt)||void 0===m?void 0:m.includes("WT_VENDOR"))&&l.createElement("button",{className:"VENDOR"===A?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),T("VENDOR")}},h("ES_FSM_REGISTRY_INBOX_TAB_VENDOR")),(null==f||null===(v=f.wt)||void 0===v?void 0:v.includes("WT_VENDOR"))&&l.createElement("button",{className:"VEHICLE"===A?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),T("VEHICLE")}},h("ES_FSM_REGISTRY_INBOX_TAB_VEHICLE")),(null==f||null===(S=f.wt)||void 0===S?void 0:S.includes("WT_VENDOR"))&&l.createElement("button",{className:"DRIVER"===A?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),T("DRIVER")}},h("ES_FSM_REGISTRY_INBOX_TAB_DRIVER")),(null==f||null===(p=f.ekyc)||void 0===p?void 0:p.includes("EKYC-VENDOR"))&&l.createElement("button",{className:"SUPERVISOR"===A?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),T("SUPERVISOR")}},h("ES_FSM_REGISTRY_INBOX_TAB_SUPERVISOR")),((null==f||null===(_=f.ekyc)||void 0===_?void 0:_.includes("EKYC_SUPERVISOR"))||(null==f||null===(D=f.ekyc)||void 0===D?void 0:D.includes("EKYC-VENDOR")))&&l.createElement("button",{className:"SURVEYOR"===A?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),T("SURVEYOR")}},h("ES_FSM_REGISTRY_INBOX_TAB_SURVEYOR"))),l.createElement("div",{className:"action-bar-wrap-registry"},l.createElement("div",{className:"search-add",onClick:()=>{x(!F)}},h("ES_VENDOR_REGISTRY_INBOX_HEADER_ADD"),l.createElement("div",{className:"search-add-icon"},l.createElement(a.AddIcon,{className:""}))),F&&l.createElement(a.Menu,{localeKeyPrefix:"ES_FSM_ACTION_CREATE",options:G,t:h,onSelect:function(e){switch(e){case"VENDOR":return V.push("/digit-ui/employee/vendor/registry/new-vendor");case"VEHICLE":return V.push("/digit-ui/employee/vendor/registry/new-vehicle");case"DRIVER":return V.push("/digit-ui/employee/vendor/registry/new-driver");case"SUPERVISOR":return V.push("/digit-ui/employee/vendor/registry/new-supervisor");case"SURVEYOR":return V.push("/digit-ui/employee/vendor/registry/new-surveyor")}}}))),l.createElement("form",{onSubmit:L(e=>{e.mobileNumber||delete e.mobileNumber,R(e),"mobile"===g&&y()})},l.createElement("div",{className:B?"for-pt for-search flex-box":"flex-box",style:{gap:"16px"}},null==I?void 0:I.map((e,t)=>l.createElement("span",{key:t,className:0===t?"finance-mainlayout-col1 complaint-input":"finance-mainlayout-col1 mobile-input"},(e=>{switch(e.type){case"date":return l.createElement(o.Controller,{render:e=>l.createElement(a.DatePicker,{date:e.value,onChange:e.onChange}),name:e.name,control:P,defaultValue:null});case"status":return l.createElement(o.Controller,{render:e=>l.createElement(N,{onAssignmentChange:e.onChange,value:e.value}),name:e.name,control:P,defaultValue:null});case"dropdown":return l.createElement(o.Controller,{render:t=>l.createElement(a.Dropdown,{option:e.options,optionKey:e.optionsKey,value:t.value,selected:t.value,select:t.onChange,t:h,placeholder:e.label}),name:e.name,control:P,defaultValue:null});default:return l.createElement(a.TextInput,s({},e,{inputRef:M},M(e.name,{validate:Y}),{watch:k,shouldUpdate:!0,placeholder:e.label}))}})(e))),l.createElement("div",{style:{display:"flex",justifyContent:"end",gap:"16px",alignItems:"center"}},"desktop"===g&&!H&&l.createElement("span",{className:"clear-search generic-button"},l.createElement(a.LinkLabel,{style:{},onClick:U},h("ES_COMMON_CLEAR_SEARCH"))),"desktop"===g&&!H&&l.createElement(a.SubmitBar,{className:"submit-bar-search",label:h("ES_COMMON_SEARCH"),submit:!0})))))))},y=e=>{if(!e)return{};if("object"==typeof e)return e;if("string"!=typeof e)return{};try{return JSON.parse(e)}catch(e){return{}}},T=e=>{var t;return e?"string"==typeof e||"number"==typeof e?[String(e)]:[null==e?void 0:e.id,null==e?void 0:e.fillingStationId,null==e?void 0:e.bookingId,null==e?void 0:e.fillingPointId,null==e?void 0:e.uuid,null==e||null===(t=e.fillingpointmetadata)||void 0===t?void 0:t.fillingPointId].filter(e=>null!=e&&""!==e).map(String):[]},I=function(e,t){void 0===t&&(t=[]);const l=function(e){var t,l,n,a,i,o,r,s,d,u,c,E,m;void 0===e&&(e={});const v=e=>Array.isArray(e)?e.flatMap(T):T(e);return Array.from(new Set([...[null===(t=e)||void 0===t?void 0:t.fillingPointId,null===(l=e)||void 0===l||null===(n=l.dsoDetails)||void 0===n?void 0:n.fillingPointId,null===(a=e)||void 0===a||null===(i=a.fillingpointmetadata)||void 0===i?void 0:i.fillingPointId,null===(o=e)||void 0===o?void 0:o.fillingPtName,null===(r=e)||void 0===r?void 0:r.filling_pt_name,null===(s=e)||void 0===s||null===(d=s.fillingPoint)||void 0===d?void 0:d.fillingPointId].filter(e=>null!=e&&""!==e).map(String),...v(null===(u=e)||void 0===u?void 0:u.fillingPoint),...v(null===(c=e)||void 0===c||null===(E=c.dsoDetails)||void 0===E?void 0:E.fillingPoint),...v(null===(m=e)||void 0===m?void 0:m.fillingPointDetail)]))}(e);return l.length&&t.find(e=>T(e).some(e=>l.includes(e)))||null},C=function(e){var t,l,n,a,i,o,r,s,d,u,c,E,m,v,S,p,_,D,R,N,g,y;if(void 0===e&&(e={}),Array.isArray(null===(t=e)||void 0===t?void 0:t.fillingPoint)){const t=e.fillingPoint.map(e=>(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.fillingPointId)).filter(Boolean);if(t.length>0)return t.join(", ")}return(null===(l=e)||void 0===l||null===(n=l.fillingPoint)||void 0===n?void 0:n.fillingPointName)||(null===(a=e)||void 0===a||null===(i=a.dsoDetails)||void 0===i||null===(o=i.fillingPoint)||void 0===o?void 0:o.fillingPointName)||(null===(r=e)||void 0===r?void 0:r.fillingPointName)||(null===(s=e)||void 0===s||null===(d=s.dsoDetails)||void 0===d?void 0:d.fillingPointName)||(null===(u=e)||void 0===u?void 0:u.fillingPointId)||(null===(c=e)||void 0===c||null===(E=c.dsoDetails)||void 0===E?void 0:E.fillingPointId)||("string"==typeof(null===(m=e)||void 0===m?void 0:m.fillingPoint)?null===(v=e)||void 0===v?void 0:v.fillingPoint:null)||("string"==typeof(null===(S=e)||void 0===S||null===(p=S.dsoDetails)||void 0===p?void 0:p.fillingPoint)?null===(_=e)||void 0===_||null===(D=_.dsoDetails)||void 0===D?void 0:D.fillingPoint:null)||(null===(R=e)||void 0===R||null===(N=R.fillingpointmetadata)||void 0===N?void 0:N.fillingPointId)||(null===(g=e)||void 0===g?void 0:g.filling_pt_name)||(null===(y=e)||void 0===y?void 0:y.fillingPtName)||"NA"},O=function(e,t){var l,n,a,i,o,r,s;void 0===e&&(e={}),void 0===t&&(t=[]);const d=(null===(l=e)||void 0===l||null===(n=l.vendor)||void 0===n?void 0:n.id)||(null===(a=e)||void 0===a||null===(i=a.vendorData)||void 0===i?void 0:i.id)||(null===(o=e)||void 0===o?void 0:o.vendorId);return d&&(t.find(e=>(null==e?void 0:e.id)===d)||(null===(r=e)||void 0===r?void 0:r.vendor)||(null===(s=e)||void 0===s?void 0:s.vendorData))||null},A=function(e){var t,l,n,a;void 0===e&&(e={});const i=[...Array.isArray(null===(t=e)||void 0===t?void 0:t.fillingPoint)?e.fillingPoint:[null===(l=e)||void 0===l?void 0:l.fillingPoint],...Array.isArray(null===(n=e)||void 0===n?void 0:n.fillingPoints)?e.fillingPoints:[null===(a=e)||void 0===a?void 0:a.fillingPoints]].filter(Boolean),o=new Map;return i.forEach(e=>{const t=T(e)[0]||(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.id);t&&!o.has(t)&&o.set(t,e)}),Array.from(o.values())},f=(e,t)=>{const l=Array.isArray(null==e?void 0:e.drivers)?e.drivers.filter(Boolean).map(e=>{var t;return{...e,displayName:`${e.name} (${(null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"N/A"})`}}):[];if(!t)return[];const n=T(t);return n.length?l.filter(e=>{const t=function(e){var t,l,n,a,i,o,r,s,d,u,c;return void 0===e&&(e={}),Array.from(new Set([null===(t=e)||void 0===t?void 0:t.fillingPointId,null===(l=e)||void 0===l?void 0:l.fillingStationId,null===(n=e)||void 0===n||null===(a=n.additionalDetails)||void 0===a?void 0:a.fillingPointId,null===(i=e)||void 0===i||null===(o=i.additionalDetails)||void 0===o?void 0:o.fillingStationId,null===(r=e)||void 0===r||null===(s=r.fillingpointmetadata)||void 0===s?void 0:s.fillingPointId].filter(e=>null!=e&&""!==e).map(String).concat(T(null===(d=e)||void 0===d?void 0:d.fillingPoint),T(null===(u=e)||void 0===u?void 0:u.fillingPointDetail),T(null===(c=e)||void 0===c?void 0:c.fillingPointDetails))))}(e);return!t.length||t.some(e=>n.includes(e))}):l},b=function(e,t){var l,n,a,i;void 0===e&&(e={}),void 0===t&&(t=[]);const o=(null===(l=e)||void 0===l||null===(n=l.driverData)||void 0===n?void 0:n.id)||(null===(a=e)||void 0===a||null===(i=a.driver)||void 0===i?void 0:i.id);return o&&t.find(e=>(null==e?void 0:e.id)===o)||null},h=e=>{if(!e||"object"!=typeof e)return e;const{id:t,...l}=e;return{...l,fillingStationId:(null==e?void 0:e.fillingStationId)||t||(null==e?void 0:e.bookingId)||(null==e?void 0:e.uuid)||(null==e?void 0:e.fillingPointId)}},V=e=>{var o,s,d;const c=Digit.ULBService.getCurrentTenantId(),{t:E}=i.useTranslation(),m=n.useHistory(),p=e=>l.createElement("span",{className:"cell-text"},e),_=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1,[D,N]=t.useState([]),[T,V]=t.useState(null),[M,L]=t.useState([]),[w,k]=t.useState([]),[P,F]=t.useState(!1),[x,H]=t.useState(null),B=Digit.SessionStorage.get("User"),U=B.info.roles,Y=null===(o=B.info.type)||void 0===o?void 0:o.toLowerCase(),G=()=>{H(null),F(!1)},K=l.useMemo(()=>[{Header:E("WT_NAME"),accessor:"name",Cell:e=>{let{row:t}=e;return p(t.original.name)}},{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{let{row:t}=e;return p(t.original.mobileNumber)}},{Header:E("WT_EMAIL_ID"),accessor:"emailId",Cell:e=>{let{row:t}=e;return p(t.original.emailId)}},{Header:E("WT_VALID_FROM"),accessor:"validFrom",Cell:e=>{let{row:t}=e;return t.original.validFrom?Digit.DateUtils.ConvertEpochToDate(t.original.validFrom):E("CS_NA")}},{Header:E("WT_VALID_TO"),accessor:"validTo",Cell:e=>{let{row:t}=e;return t.original.validTo?Digit.DateUtils.ConvertEpochToDate(t.original.validTo):E("CS_NA")}},{Header:E("WT_DOCUMENT"),accessor:"fileStoreId",Cell:e=>{let{row:t}=e;return t.original.fileStoreId?l.createElement("div",{style:{color:"#f47738",cursor:"pointer",textDecoration:"underline"},onClick:()=>function(e){try{if(!e)return Promise.resolve();const t=u(function(){return Promise.resolve(Digit.UploadServices.Filefetch([e],"dl")).then(function(t){var l;if(null!=t&&null!==(l=t.data)&&void 0!==l&&l[e]){const l=t.data[e].split(",")[0];window.open(l,"_blank")}})},function(e){console.error(e),V({key:"error",action:"Failed to fetch document."}),setTimeout(J,5e3)});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}(t.original.fileStoreId)},l.createElement(a.ViewsIcon,null)):E("CS_NA")}}],[E]),W=r.useQueryClient(),{data:$,refetch:z}=Digit.Hooks.fsm.useDsoSearch(c,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{enabled:!1}),{data:X,refetch:q}=Digit.Hooks.fsm.useDriverSearch({tenantId:c,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"}}),{mutate:j}=Digit.Hooks.fsm.useVendorUpdate(c),{mutate:Q}=Digit.Hooks.fsm.useUpdateVehicle(c),{mutate:Z}=Digit.Hooks.fsm.useDriverUpdate(c);t.useEffect(()=>{var t;N((null==e||null===(t=e.data)||void 0===t?void 0:t.table)||[])},[e]),t.useEffect(()=>{"DRIVER"!==e.selectedTab&&"VEHICLE"!==e.selectedTab||(z(),q())},[e.selectedTab]),t.useEffect(()=>{if($){let e=$.map(e=>{var t;return{...e.dsoDetails,displayName:`${e.dsoDetails.name} (${e.dsoDetails.mobileNumber||(null===(t=e.dsoDetails.owner)||void 0===t?void 0:t.mobileNumber)||"N/A"})`}});L(e)}},[$]),t.useEffect(()=>{X&&k((X.driver||[]).map(e=>{var t;return{...e,displayName:`${e.name} (${(null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"N/A"})`}}))},[X]);const J=()=>{V(null)},ee=(e,t)=>{N(l=>l.map(l=>(null==l?void 0:l.id)===e?{...l,...t}:l))},te=function(e,t){var l;void 0===t&&(t={});const n={...e,...t,driverData:(null===(l=t)||void 0===l?void 0:l.driverData)||(null==e?void 0:e.driverData)||(null==e?void 0:e.driver),fillingPoint:h(Object.prototype.hasOwnProperty.call(t,"fillingPoint")?t.fillingPoint:null==e?void 0:e.fillingPoint)};return delete n.vendor,delete n.popup,delete n.driver,{vehicle:n}},le=(e,t)=>{var l;return{vendor:{...e,owner:{...null==e?void 0:e.owner,gender:(null==e||null===(l=e.owner)||void 0===l?void 0:l.gender)||"OTHERS"},vehicles:t}}},ne=()=>{switch(e.selectedTab){case"VENDOR":return m.push(`/digit-ui/${Y}/vendor/registry/new-vendor`);case"VEHICLE":return m.push(`/digit-ui/${Y}/fsm/registry/new-vehicle`);case"DRIVER":return m.push(`/digit-ui/${Y}/fsm/registry/new-driver`);case"SUPERVISOR":return m.push(`/digit-ui/${Y}/vendor/registry/new-supervisor`);case"SURVEYOR":return m.push(`/digit-ui/${Y}/vendor/registry/new-surveyor`)}},ae=l.useMemo(()=>"VENDOR"===e.selectedTab?(null==D?void 0:D.map(e=>e.id))||[]:(null==$?void 0:$.map(e=>{var t;return null===(t=e.dsoDetails)||void 0===t?void 0:t.id}))||[],[e.selectedTab,D,$]),{data:ie}=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:c,filters:{vendorIds:null==ae?void 0:ae.join(","),vendorId:null==ae?void 0:ae.join(",")}},{enabled:(null==ae?void 0:ae.length)>0}),{data:oe,isLoading:re}=Digit.Hooks.wt.useFillPointSearch({tenantId:c,filters:{limit:1e3}},{enabled:!0}),se=l.useMemo(()=>{switch(e.selectedTab){case"VENDOR":return[{Header:E("ES_VENDOR_INBOX_VENDOR_NAME"),accessor:"name",Cell:e=>{let{row:t}=e;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/vendor-details/`+t.original.id},l.createElement("div",null,t.original.name))))}},{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{let{row:t}=e;return l.createElement("div",null,t.original.mobileNumber)}},{Header:E("ES_VENDOR_INBOX_DATE_VENDOR_CREATION"),accessor:"createdTime",Cell:e=>{var t,l,n,a;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(a=n.auditDetails)||void 0===a?void 0:a.createdTime):"")}},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),id:"serviceType",accessor:e=>{var t,l;let n=null===(t=e.dsoDetails)||void 0===t?void 0:t.additionalDetails;if("string"==typeof n)try{n=JSON.parse(n)}catch(e){n={}}return(null===(l=n)||void 0===l?void 0:l.serviceType)||"N/A"},Cell:e=>{var t,n;let{row:a}=e,i=null===(t=a.original.dsoDetails)||void 0===t?void 0:t.additionalDetails;if("string"==typeof i)try{i=JSON.parse(i)}catch(e){console.error("Error parsing additionalDetails:",e),i={}}const o=(null===(n=i)||void 0===n?void 0:n.serviceType)||"N/A";return l.createElement("div",null,o)}},{Header:E("ES_VENDOR_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>{var t;return(null===(t=e.dsoDetails)||void 0===t?void 0:t.status)||""},Cell:t=>{var n,i;let{row:o}=t;return l.createElement(a.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=o.original)||void 0===n||null===(i=n.dsoDetails)||void 0===i?void 0:i.status),onChange:()=>(t=>{var l,n,a,i;let o=t.original.dsoDetails;const r={vendor:{...o,status:"ACTIVE"===(null==o?void 0:o.status)?"DISABLED":"ACTIVE",owner:{...o.owner,gender:(null==o||null===(l=o.owner)||void 0===l?void 0:l.gender)||"OTHER",dob:(null==o||null===(n=o.owner)||void 0===n?void 0:n.dob)||new Date("1/1/1970").getTime(),emailId:(null==o||null===(a=o.owner)||void 0===a?void 0:a.emailId)||"abc@egov.com",relationship:(null==o||null===(i=o.owner)||void 0===i?void 0:i.relationship)||"OTHER"}}};j(r,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"VENDOR"}),W.invalidateQueries("DSO_SEARCH"),e.refetchData(),setTimeout(J,3e3)}})})(o),name:"switch-"+o.id})}},{Header:E("ES_VENDOR_ADDITIONAL_DETAILS"),disableSortBy:!0,Cell:e=>{var t,a;let{row:i}=e;const o=null===(t=i.original)||void 0===t?void 0:t.id;if(!ie)return l.createElement("span",null,"Loading...");const r=null!==(null===(a=i.original)||void 0===a?void 0:a.vendorAdditionalDetails);return l.createElement(n.Link,{to:r?`/digit-ui/${Y}/vendor/registry/additionaldetails/info?vendorId=`+o:`/digit-ui/${Y}/vendor/registry/additionaldetails/vendor-details?vendorId=`+o},l.createElement("button",{className:"submit-bar",style:{backgroundColor:r?"#417505":"#3A8DCC",color:"white"}},r?"View Details":"Add Details"))}},{Header:E("VIEW_WORKORDER_DETAILS"),disableSortBy:!0,Cell:e=>{let{row:t}=e;return l.createElement("button",{className:"submit-bar",style:{backgroundColor:"#417505",color:"white"},onClick:()=>(H(t.original),void F(!0))},E("VIEW_WORKORDER_DETAILS"))}}];case"VEHICLE":return[{Header:E("ES_FSM_REGISTRY_INBOX_VEHICLE_NAME"),accessor:"registrationNumber",Cell:e=>{let{row:t}=e;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/vehicle-details/`+t.original.registrationNumber},l.createElement("div",null,t.original.registrationNumber))))}},{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{var t,n;let{row:a}=e;return l.createElement("div",null,(null===(t=a.original)||void 0===t||null===(n=t.owner)||void 0===n?void 0:n.mobileNumber)||"N/A")}},{Header:E("ES_FSM_REGISTRY_INBOX_DATE_VEHICLE_CREATION"),accessor:"createdTime",Cell:e=>{var t,l,n,a;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(a=n.auditDetails)||void 0===a?void 0:a.createdTime):"")}},{Header:"Map Vendor",id:"mapVendor",accessor:e=>{var t,l;return(null===(t=e.vendor)||void 0===t?void 0:t.name)||(null===(l=e.vendorData)||void 0===l?void 0:l.name)||"NA"},Cell:t=>{let{row:n}=t;return l.createElement(a.Dropdown,{className:"fsm-registry-dropdown",selected:O(n.original,M),option:M,select:t=>((t,l)=>{const n=t.original,a=null==n?void 0:n.vendor;if(null==l||!l.id||(null==a?void 0:a.id)===(null==l?void 0:l.id))return;const i={...n,vendorVehicleStatus:"ACTIVE",fillingPoint:null,driverData:null,driver:null};delete i.vendor,delete i.popup,delete i.driver;const o=()=>{const t=Array.isArray(null==l?void 0:l.vehicles)?[...l.vehicles]:[],a=t.findIndex(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id));a>-1?t[a]={...t[a],...i,vendorVehicleStatus:"ACTIVE"}:t.push(i);const o={...l,vehicles:t};j(le(l,t),{onError:e=>{V({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:()=>{ee(null==n?void 0:n.id,{vendor:o,fillingPoint:null,driverData:null,driver:null}),V({key:"success",action:"VEHICLE"}),W.invalidateQueries("DSO_SEARCH"),W.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchData(),e.refetchVendor&&e.refetchVendor(),setTimeout(J,3e3)}})};if(null!=a&&a.id){const e=Array.isArray(null==a?void 0:a.vehicles)?a.vehicles.map(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id)?{...e,vendorVehicleStatus:"INACTIVE"}:e):[];j(le(a,e),{onError:e=>{V({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:o})}else o()})(n,t),style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"displayName",t:E})}},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),id:"serviceType",accessor:e=>{var t;let l=e.additionalDetails;if("string"==typeof l)try{l=JSON.parse(l)}catch(e){l={}}return(null===(t=l)||void 0===t?void 0:t.serviceType)||"N/A"},Cell:e=>{var t;let{row:n}=e,a=n.original.additionalDetails;if("string"==typeof a)try{a=JSON.parse(a)}catch(e){console.error("Error parsing additionalDetails:",e),a={}}const i=(null===(t=a)||void 0===t?void 0:t.serviceType)||"N/A";return l.createElement("div",null,i)}},{Header:E("WT_FILLING_POINT"),accessor:e=>C(e),id:"fillingPoint",minWidth:250,Cell:t=>{let{row:n}=t;const i=O(n.original,M),o=A(i);return l.createElement(a.Dropdown,{className:"fsm-registry-dropdown",selected:I(n.original,o),option:o,select:t=>((t,l)=>{const n=te(t.original,{fillingPoint:l});Q(n,{onError:e=>{var t,l,n,a;V({key:"error",label:(null==e?void 0:e.message)||(null==e||null===(t=e.response)||void 0===t||null===(l=t.data)||void 0===l||null===(n=l.Errors)||void 0===n||null===(a=n[0])||void 0===a?void 0:a.message)||"Failed to map filling point"}),setTimeout(J,5e3)},onSuccess:()=>{var n;const a=O(t.original,M),i=f(a,l),o=b(t.original,i);ee(null===(n=t.original)||void 0===n?void 0:n.id,{fillingPoint:{...l,fillingStationId:(null==l?void 0:l.fillingStationId)||(null==l?void 0:l.id)||(null==l?void 0:l.bookingId)||(null==l?void 0:l.uuid)||(null==l?void 0:l.fillingPointId)},...o?{}:{driverData:null,driver:null}}),V({key:"success",label:"Filling point mapped successfully"}),W.invalidateQueries("FSM_VEICLES_SEARCH"),W.invalidateQueries("DSO_SEARCH"),e.refetchData(),e.refetchVendor&&e.refetchVendor(),setTimeout(J,3e3)}})})(n,t),style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"fillingPointName",t:E,disable:!i||!o.length})}},{Header:E("ES_FSM_REGISTRY_SELECT_DRIVER"),id:"driver",accessor:e=>{var t,l;return(null===(t=e.driverData)||void 0===t?void 0:t.name)||(null===(l=e.driver)||void 0===l?void 0:l.name)||"NA"},minWidth:250,Cell:t=>{let{row:n}=t;const i=O(n.original,M),o=I(n.original,A(i)),r=f(i,o);return l.createElement(a.Dropdown,{className:"fsm-registry-dropdown",selected:b(n.original,r),option:r,select:t=>((t,l)=>{const n=te(t.original,{driverData:l});Q(n,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(n,a)=>{var i;ee(null===(i=t.original)||void 0===i?void 0:i.id,{driverData:l}),V({key:"success",action:"VEHICLE"}),W.invalidateQueries("FSM_VEICLES_SEARCH"),W.invalidateQueries("DSO_SEARCH"),e.refetchData(),e.refetchVendor(),setTimeout(J,3e3)}})})(n,t),optionKey:"displayName",t:E,style:{textAlign:"left",width:"100%",minWidth:"250px"},disable:!o||!r.length})}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let{row:i}=t;return l.createElement(a.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>(t=>{var l;const n=te(t.original,{status:"ACTIVE"===(null===(l=t.original)||void 0===l?void 0:l.status)?"DISABLED":"ACTIVE"});Q(n,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"VEHICLE"}),W.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(J,3e3)}})})(i),name:"switch-"+i.id})}}];case"DRIVER":return[{Header:E("ES_FSM_REGISTRY_INBOX_USERNAME"),id:"userName",accessor:e=>{var t;return(null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"},Cell:e=>{var t;let{row:a}=e;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/driver-details/`+a.original.id},l.createElement("div",null,(null===(t=a.original.owner)||void 0===t?void 0:t.userName)||"NA"))))}},{Header:E("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),accessor:"name",Cell:e=>{let{row:t}=e;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/driver-details/`+t.original.id},l.createElement("div",null,""+(t.original.name||"N/A")))))}},{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{var t,n;let{row:a}=e;return l.createElement("div",null,(null===(t=a.original)||void 0===t||null===(n=t.owner)||void 0===n?void 0:n.mobileNumber)||"N/A")}},{Header:E("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),accessor:"createdTime",Cell:e=>{var t,l,n,a;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(a=n.auditDetails)||void 0===a?void 0:a.createdTime):"")}},{Header:E("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),id:"vendorName",accessor:e=>{var t,l;return(null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"},minWidth:250,Cell:t=>{let{row:n}=t;return l.createElement(a.Dropdown,{className:"fsm-registry-dropdown",selected:(null==M?void 0:M.find(e=>{var t,l;return((null===(t=n.original.vendorData)||void 0===t?void 0:t.id)||(null===(l=n.original.vendor)||void 0===l?void 0:l.id))===e.id}))||n.original.vendorData||n.original.vendor,option:M,select:t=>((t,l)=>{let n=t.original,a=null==n?void 0:n.vendor,i=l;if(delete n.vendor,n.vendorDriverStatus="ACTIVE",a){const e=null==a?void 0:a.drivers;e.splice(e.findIndex(e=>e.id===n.id),1)}const o={vendor:{...i,drivers:i.drivers?[...i.drivers,n]:[n]}};j(o,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"VENDOR"}),W.invalidateQueries("DSO_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(J,3e3)}})})(n,t),style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"displayName",t:E})}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let{row:i}=t;return l.createElement(a.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>(t=>{var l,n,a,i;let o=t.original;const r={driver:{...o,status:"ACTIVE"===(null==o?void 0:o.status)?"DISABLED":"ACTIVE",owner:{...o.owner,gender:(null==o||null===(l=o.owner)||void 0===l?void 0:l.gender)||"OTHER",dob:(null==o||null===(n=o.owner)||void 0===n?void 0:n.dob)||new Date("1/1/1970").getTime(),emailId:(null==o||null===(a=o.owner)||void 0===a?void 0:a.emailId)||"abc@egov.com",relationship:(null==o||null===(i=o.owner)||void 0===i?void 0:i.relationship)||"OTHER"}}};Z(r,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"DRIVER"}),W.invalidateQueries("FSM_DRIVER_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(J,3e3)}})})(i),name:"switch-"+i.id})}}];case"SUPERVISOR":case"SURVEYOR":return[{Header:E("SUPERVISOR"===e.selectedTab?"Supervisor's Mobile No.":"Surveyor's Mobile No."),id:"userName",accessor:e=>{var t;return(null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"},Cell:t=>{var a;let{row:i}=t;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/${"SUPERVISOR"===e.selectedTab?"supervisor-details":"surveyor-details"}/`+i.original.id},l.createElement("div",null,(null===(a=i.original.owner)||void 0===a?void 0:a.userName)||"NA"))))}},{Header:E("SUPERVISOR"===e.selectedTab?"ES_FSM_REGISTRY_INBOX_SUPERVISOR_NAME":"ES_FSM_REGISTRY_INBOX_SURVEYOR_NAME"),accessor:"name",Cell:t=>{let{row:a}=t;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/${"SUPERVISOR"===e.selectedTab?"supervisor-details":"surveyor-details"}/`+a.original.id},l.createElement("div",null,""+(a.original.name||"N/A")))))}},{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{var t,n;let{row:a}=e;return l.createElement("div",null,(null===(t=a.original)||void 0===t||null===(n=t.owner)||void 0===n?void 0:n.mobileNumber)||"N/A")}},{Header:E("ES_FSM_REGISTRY_INBOX_DATE_CREATION"),accessor:"createdTime",Cell:e=>{var t,l,n,a;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(a=n.auditDetails)||void 0===a?void 0:a.createdTime):"")}},{Header:E("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),id:"vendorName",accessor:e=>{var t,l;return(null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"},minWidth:250,Cell:t=>{let{row:n}=t;return l.createElement(a.Dropdown,{className:"fsm-registry-dropdown",selected:(null==M?void 0:M.find(e=>{var t,l;return((null===(t=n.original.vendorData)||void 0===t?void 0:t.id)||(null===(l=n.original.vendor)||void 0===l?void 0:l.id))===e.id}))||n.original.vendorData||n.original.vendor,option:M,select:t=>{console.log("Updating vendor for",e.selectedTab,t)},style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"displayName",t:E})}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let{row:i}=t;return l.createElement(a.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>{console.log("Updating status for",e.selectedTab,i.original.id)},name:"switch-"+i.id})}}];default:return[]}},[e.selectedTab,M,w,D,ie,(null==oe?void 0:oe.fillingPoints)||[],E]),de=l.useMemo(()=>{switch(e.selectedTab){case"VENDOR":return[{Header:E("ES_VENDOR_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,a,i;return`${(null==e?void 0:e.name)||(null==e||null===(t=e.dsoDetails)||void 0===t?void 0:t.name)||"NA"} (${(null==e?void 0:e.mobileNumber)||(null==e||null===(l=e.owner)||void 0===l?void 0:l.mobileNumber)||(null==e||null===(n=e.dsoDetails)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(a=e.dsoDetails)||void 0===a||null===(i=a.owner)||void 0===i?void 0:i.mobileNumber)||"NA"})`}},{Header:E("ES_VENDOR_INBOX_DATE_VENDOR_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:E("WT_FILLING_POINT"),exportAccessor:e=>C(e)},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t,l;return(null===(t=y(null==e||null===(l=e.dsoDetails)||void 0===l?void 0:l.additionalDetails))||void 0===t?void 0:t.serviceType)||"N/A"}},{Header:E("ES_VENDOR_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>{var t;return(null==e||null===(t=e.dsoDetails)||void 0===t?void 0:t.status)||"NA"}}];case"VEHICLE":return[{Header:E("ES_FSM_REGISTRY_INBOX_VEHICLE_NAME"),exportAccessor:e=>(null==e?void 0:e.registrationNumber)||"NA"},{Header:E("ES_FSM_REGISTRY_INBOX_DATE_VEHICLE_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:"Map Vendor",exportAccessor:e=>{var t,l,n,a,i,o,r,s;return`${(null==e||null===(t=e.vendor)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendorData)||void 0===l?void 0:l.name)||"NA"} (${(null==e||null===(n=e.vendor)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a||null===(i=a.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(o=e.vendorData)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(r=e.vendorData)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"})`}},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t;return(null===(t=y(null==e?void 0:e.additionalDetails))||void 0===t?void 0:t.serviceType)||"N/A"}},{Header:E("WT_FILLING_POINT"),exportAccessor:e=>C(e)},{Header:E("ES_FSM_REGISTRY_SELECT_DRIVER"),exportAccessor:e=>{var t,l,n,a,i,o;return`${(null==e||null===(t=e.driverData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.driver)||void 0===l?void 0:l.name)||"NA"} (${(null==e||null===(n=e.driverData)||void 0===n||null===(a=n.owner)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(i=e.driver)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];case"DRIVER":return[{Header:E("ES_FSM_REGISTRY_INBOX_USERNAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"}},{Header:E("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),exportAccessor:e=>{var t;return`${(null==e?void 0:e.name)||"NA"} (${(null==e||null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:E("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,a,i,o,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} (${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(a=e.vendorData)||void 0===a||null===(i=a.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(o=e.vendor)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];case"SURVEYOR":return[{Header:E("ES_FSM_REGISTRY_INBOX_USERNAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"}},{Header:E("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),exportAccessor:e=>{var t;return`${(null==e?void 0:e.name)||"NA"} (${(null==e||null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:E("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,a,i,o,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} ${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(a=e.vendorData)||void 0===a||null===(i=a.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(o=e.vendor)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"}`}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];case"SUPERVISOR":return[{Header:E("ES_FSM_REGISTRY_INBOX_USERNAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"}},{Header:E("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),exportAccessor:e=>{var t;return`${(null==e?void 0:e.name)||"NA"} (${(null==e||null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:E("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,a,i,o,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} ${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(a=e.vendorData)||void 0===a||null===(i=a.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(o=e.vendor)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"}`}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];default:return[]}},[e.selectedTab,E]),ue=l.useCallback(function(){return Promise.resolve(D)},[D]);let ce;if(e.isLoading||re)ce=l.createElement("div",{style:{zIndex:10,position:"relative",padding:"10px",backgroundColor:"#fff",width:"75px",height:"75px",borderRadius:"12px",display:"flex",justifyContent:"center",alignItems:"center",margin:"auto"}},l.createElement(a.Loader,null));else if(0===D.length){let t="",n="";"VENDOR"===e.selectedTab?(t="ES_FSM_REGISTRY_EMPTY_CARD_VENDOR",n="ES_FSM_REGISTRY_EMPTY_BUTTON_VENDOR"):"VEHICLE"===e.selectedTab?(t="ES_FSM_REGISTRY_EMPTY_CARD_VEHICLE",n="ES_FSM_REGISTRY_EMPTY_BUTTON_VEHICLE"):"SUPERVISOR"===e.selectedTab?(t="ES_FSM_REGISTRY_EMPTY_CARD_SUPERVISOR",n="ES_FSM_REGISTRY_EMPTY_BUTTON_SUPERVISOR"):"SURVEYOR"===e.selectedTab?(t="ES_FSM_REGISTRY_EMPTY_CARD_SURVEYOR",n="ES_FSM_REGISTRY_EMPTY_BUTTON_SURVEYOR"):(t="ES_FSM_REGISTRY_EMPTY_CARD_DRIVER",n="ES_FSM_REGISTRY_EMPTY_BUTTON_DRIVER"),ce=l.createElement(a.Card,{className:"flex-center flex-box"},l.createElement("div",{style:{marginTop:"50px",marginBottom:"25px"}},E(t)),l.createElement(a.SubmitBar,{className:"",label:E(n),onSubmit:ne}))}else D.length>0&&(ce=l.createElement(S,{className:"table registryTable",t:E,data:D,columns:se,getCellProps:()=>({style:{padding:"8px 12px",fontSize:"13.5px"}}),onPageSizeChange:e.onPageSizeChange,currentPage:e.currentPage,onNextPage:e.onNextPage,onPrevPage:e.onPrevPage,pageSizeLimit:e.pageSizeLimit,onSort:e.onSort,disableSort:e.disableSort,sortParams:e.sortParams,totalRecords:e.totalRecords,showCSVExport:!0,getCSVExportData:ue,csvExportColumns:de,csvExportFileName:`vendor-${String(e.selectedTab||"registry").toLowerCase()}-inbox`}));const Ee=U.map(e=>e.code),me={ekyc:Object.values({ekycVendor:"EKYC-VENDOR",supervisor:"EKYC_SUPERVISOR"}).filter(e=>Ee.includes(e)),wt:Object.values({wtVendor:"WT_VENDOR"}).filter(e=>Ee.includes(e))};return me.ekyc.push("EKYC-VENDOR"),l.createElement("div",{className:"inbox-container"},"FSM_EMP_FSTPO"!==e.userRole&&"FSM_ADMIN"!==e.userRole&&!e.isSearch&&l.createElement("div",{className:"filters-container"},l.createElement(v,{parentRoute:e.parentRoute}),l.createElement("div",{style:{marginTop:"24px"}},l.createElement(R,{searchParams:e.searchParams,paginationParms:e.paginationParms,applications:e.data,onFilterChange:e.onFilterChange,type:"desktop"}))),l.createElement("div",{style:{flex:1,width:"100%",marginLeft:"FSM_ADMIN"===e.userRole?"":"24px"}},l.createElement(g,{onSearch:e.onSearch,type:"desktop",searchFields:e.searchFields,isInboxPage:!(null!=e&&e.isSearch),searchParams:e.searchParams,onTabChange:e.onTabChange,selectedTab:e.selectedTab,matchedRoles:me}),l.createElement("div",{className:"result",style:{marginLeft:_||"FSM_ADMIN"===e.userRole||null!=e&&e.isSearch?"":"24px",flex:1}},ce)),T&&l.createElement(a.Toast,{error:"error"===T.key,label:E(T.label?T.label:"success"===T.key?`ES_FSM_REGISTRY_${T.action}_DISABLE_SUCCESS`:T.action),onClose:J}),P&&l.createElement(a.Modal,{headerBarMain:l.createElement("h1",{className:"heading-m",style:{margin:0}},E("ES_VENDOR_WORKORDER_DETAILS_MODAL")),headerBarEnd:l.createElement("div",{className:"icon-bg-secondary",onClick:G,style:{cursor:"pointer"}},l.createElement(a.MdClose,null)),actionCancelLabel:E("CS_COMMON_CLOSE"),actionCancelOnSubmit:G,hideSubmit:!0,formId:"modal-action"},l.createElement("div",{style:{padding:"16px"}},(null==x||null===(s=x.dsoDetails)||void 0===s||null===(d=s.vendorWorkOrder)||void 0===d?void 0:d.length)>0?l.createElement(a.Table,{t:E,data:x.dsoDetails.vendorWorkOrder,columns:K,getCellProps:e=>({style:{minWidth:"150px",padding:"8px 12px",fontSize:"13.5px"}})}):l.createElement("p",{style:{textAlign:"center",marginTop:"20px"}},E("ES_VENDOR_NO_WORKORDERS")))))},M=()=>{const{t:e}=i.useTranslation(),t=n.useLocation(),{path:o}=n.useRouteMatch(),r=Digit.ComponentRegistryService.getComponent("SearchVendor"),d=Digit.ComponentRegistryService.getComponent("EditVendorDetails"),u=Digit.ComponentRegistryService.getComponent("AddSupervisor"),c=Digit.ComponentRegistryService.getComponent("SupervisorDetails"),E=Digit.ComponentRegistryService.getComponent("AddSurveyor"),m=Digit.ComponentRegistryService.getComponent("SurveyorDetails"),v=Digit.ComponentRegistryService.getComponent("VENDORCreate");return l.createElement(n.Switch,null,l.createElement(a.AppContainer,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(a.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(a.ArrowLeft,{className:"icon"}),e("CS_COMMON_BACK")),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const l=t.pathname;let n=[{icon:a.HomeIcon,path:"/digit-ui/citizen"},{label:e("WT_MODULE_NAME"),path:o+"/wt-Vendor"}];if(l.includes("/inbox")){let t="ES_COMMON_INBOX";l.includes("/mt/inbox")&&(n=[{icon:a.HomeIcon,path:"/digit-ui/citizen"},{label:e("ACTION_TEST_MT"),path:o+"/mt-Vendor"}]),n.push({label:e(t)})}else if(l.includes("/my-bookings")){let t="WT_SEARCH_BOOKINGS";l.includes("/mt/my-bookings")&&(t="MT_SEARCH_BOOKINGS"),n.push({label:e(t)})}else l.includes("/status")?n.push({label:e("WT_MY_APPLICATIONS")}):(l.includes("/booking/")||l.includes("/booking-details")||l.includes("/bookingsearch/booking-details"))&&(n.push({label:e("ES_COMMON_INBOX"),path:l.includes("/mt/")?o+"/mt/inbox":o+"/inbox"}),n.push({label:e("WT_BOOKING_DETAILS")}));const i=[{match:"/registry/new-vendor",label:"ES_FSM_REGISTRY_TITLE_NEW_VENDOR"},{match:"/search-vendor",label:"SEARCH_VENDOR"},{match:"/registry/new-driver",label:"ES_FSM_REGISTRY_TITLE_NEW_DRIVER"},{match:["/registry/vendor-details","/registry/modify-vendor/"],label:"VENDOR_VENDOR_DETAILS"},{match:["/registry/vehicle-details","/registry/modify-vehicle/"],label:"VENDOR_VEHICLE_DETAILS"},{match:"/registry/new-vehicle",label:"ES_FSM_REGISTRY_TITLE_NEW_VEHICLE"},{match:["/registry/driver-details","/registry/modify-driver/"],label:"VENDOR_DRIVER_DETAILS"},{match:"/registry/additionaldetails",label:"VENDOR_ADDITIONAL_DETAILS"},{match:"/registry/new-supervisor",label:"ES_FSM_REGISTRY_TITLE_NEW_SUPERVISOR"},{match:["/registry/supervisor-details","/registry/modify-supervisor/"],label:"VENDOR_SUPERVISOR_DETAILS"},{match:"/registry/new-surveyor",label:"ES_FSM_REGISTRY_TITLE_NEW_SURVEYOR"},{match:["/registry/surveyor-details","/registry/modify-surveyor/"],label:"VENDOR_SURVEYOR_DETAILS"}].find(e=>{let{match:t}=e;return Array.isArray(t)?t.some(e=>l.includes(e)):l.includes(t)});return i&&n.push({label:e(i.label)}),n})()}),l.createElement(a.PrivateRoute,{path:o+"/search-vendor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"normal"},l.createElement(r,s({},e,{parentRoute:o}))),exact:!0}),l.createElement(a.PrivateRoute,{path:o+"/registry/vendor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(d,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/new-supervisor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(u,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/additionaldetails",component:e=>{const t=e.location.pathname.includes("/info");return l.createElement(a.LayoutWrapper,{layoutClass:t?"action":"normal"},l.createElement(v,s({},e,{parentRoute:o})))}}),l.createElement(a.PrivateRoute,{path:o+"/registry/supervisor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(c,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/new-surveyor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(E,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/surveyor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(m,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:""+o,component:()=>Digit.UserService.hasAccess(["WT_VENDOR"])?l.createElement("div",{style:{display:"flex",gap:"24px",flexWrap:"wrap",width:"100%",padding:"8px 0"}},l.createElement(a.CitizenHomeCard,{header:e("TITLE_VENDOR_MANAGEMENT"),links:[{i18nKey:e("SEARCH_VENDOR"),link:"/digit-ui/citizen/vendor/search-vendor"}],Icon:()=>l.createElement(a.PropertyHouse,{className:"fill-path-primary-main"})})):l.createElement(n.Redirect,{to:{pathname:"/digit-ui/citizen/login",state:{from:o+"/wt-Vendor",role:"WT_VENDOR"}}}),exact:!0}))))},L=e=>{let{t:t,title:n}=e;return l.createElement("div",{className:"confirmation_box"},l.createElement("span",null,t(""+n)," "))},w=e=>l.createElement("h1",{className:"heading-m"},e.label),k=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),P=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(k,null)),{Dropdown:F}=(require("@djb25/digit-ui-react-components"),require("@djb25/digit-ui-react-components")),{Dropdown:x}=require("@djb25/digit-ui-react-components"),H=e=>l.createElement("h1",{className:"heading-m"},e.label),B=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),U=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(B,null)),Y=e=>l.createElement("h1",{className:"heading-m"},e.label),G=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),K=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(G,null)),W=e=>{let{jumpTo:t}=e;const{t:o}=i.useTranslation(),r=n.useHistory();return l.createElement(a.LinkButton,{label:o("CS_COMMON_CHANGE"),className:"check-page-link-button",onClick:function(){r.push(t)}})},$=e=>{const{t:t}=i.useTranslation();return e.isSuccess?window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_SUCCESS"):t("ES_VENDOR_RESPONSE_CREATE_ACTION"):e.isLoading?window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_PENDING"):t("CS_VENDOR_APPLICATION_PENDING"):e.isSuccess?void 0:window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_FAILED"):t("CS_VENDOR_APPLICATION_FAILED")},z={padding:"4px 0px",justifyContent:"space-between"},X=e=>{var t,n;return l.createElement(a.Banner,{message:$(e),applicationNumber:null===(t=e.data)||void 0===t||null===(n=t.VendorAdditionalDetails)||void 0===n?void 0:n[0].registrationNo,info:e.isSuccess?e.t("ES_VENDOR_RESPONSE_CREATE_LABEL"):"",successful:e.isSuccess,style:{width:"100%"}})},q=[{head:"VENDOR_DETAILS",body:[{route:"info",component:"ServiceDoc",nextStep:"vendor-details",key:"Documents"},{route:"vendor-details",component:"VendorDetails",withoutLabel:!0,key:"vendordet",type:"component",nextStep:"documents",hideInEmployee:!0,isMandatory:!0,texts:{header:"VENDOR_ADDITIONAL_DETAILS",submitBarLabel:"VENDOR_COMMON_NEXT"}}]},{head:"VENDOR_DOCUMENT_DETAILS",body:[{route:"documents",component:"VendorDocuments",withoutLabel:!0,key:"documents",type:"component",nextStep:null,texts:{header:"VENDOR_DOCUMENTS_DETAILS",submitBarLabel:"VENDOR_COMMON_NEXT"}}]}],{DatePicker:j}=require("@djb25/digit-ui-react-components"),Q=e=>l.createElement("h1",{className:"heading-m"},e.label),Z=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),J=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(Z,null)),{DatePicker:ee}=require("@djb25/digit-ui-react-components"),te=e=>l.createElement("h1",{className:"heading-m"},e.label),le=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),ne=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(le,null)),ae={VendorDetails:e=>{var n,i,r,s;let{t:d,config:u,onSelect:c,userType:E,formData:m}=e;const v=Digit.UserService.getUser().info,S=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].applicantName||(null==m||null===(n=m.ownerKey)||void 0===n?void 0:n.applicantName)||"",p=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].emailId||(null==m||null===(i=m.ownerKey)||void 0===i?void 0:i.emailId)||"",_=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].mobileNumber||(null==m||null===(r=m.ownerKey)||void 0===r?void 0:r.mobileNumber)||(null==v?void 0:v.mobileNumber),D=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].altMobileNumber||(null==m||null===(s=m.ownerKey)||void 0===s?void 0:s.altmobileNumber)||"",[R,N]=t.useState(""),[g,y]=t.useState(""),[T,I]=t.useState(""),[C,O]=t.useState(""),[A,f]=t.useState(),[b,h]=t.useState(""),[V,M]=t.useState(""),[L,w]=t.useState(""),[k,P]=t.useState(""),[F,x]=t.useState(""),[H,B]=t.useState(""),[U,Y]=t.useState(""),[G,K]=t.useState(""),[W,$]=t.useState(""),[z,X]=t.useState(""),[q,j]=t.useState(""),[Q,Z]=t.useState(""),[J,ee]=t.useState("");t.useEffect(()=>{11!==b.length||C||A||q?11===b.length&&C&&A?(O(C),f(A),j(q)):(O(""),f(""),j("")):fetch("https://ifsc.razorpay.com/"+b).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH&&e.MICR&&(O(e.BANK),f(e.BRANCH),j(e.MICR))}).catch(()=>{})},[b]);const te=Digit.ULBService.getCurrentTenantId(),{control:le}=o.useForm(),{data:ne}=Digit.Hooks.fsm.useDsoSearch(te,{staleTime:Infinity});t.useEffect(()=>{if(ne){const e=ne.find(e=>e.id);e&&(I(e.name),y(e.id))}},[ne]);const ae=()=>{let e,t=m.ownerKey&&m.ownerKey[0];"citizen"===E?(e={...t,applicantName:S,mobileNumber:_,altMobileNumber:D,emailId:p},c(u.key,{...m[u.key],...e},!1,0)):(e={...t,VendorCategory:R,name:T,VendorId:g,Bank:C,BankbranchName:A,IFSC:b,AccountNo:V,PanNo:L,GstNo:k,GstState:F,RegistrationNo:H,EpfNo:U,EsiNo:G,VendorType:W,Status:z,micrNo:q,PhoneNo:Q,ContactPerson:J},c(u.key,e,!1,0))};return t.useEffect(()=>{"citizen"===E&&ae()},[R,g,T,C,A,b,V,L,k,F,H,U,G,W,z,q,Q,J,E]),l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{timeLine:[{actions:d("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:d("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:d("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormStep,{config:u,onSelect:ae,t:d,className:"formcomposer-grid-container-form"},l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,{className:"card-label-smaller"},l.createElement(a.CustomTooltip,{label:""+d("IFSC_CODE"),isMandatory:!1,message:d("INVALID_IFSC_CODE_ERROR_MESSAGE")})),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"IFSC",value:b,placeholder:"Enter IFSC Code",onChange:function(e){const t=e.target.value.replace(/[^a-zA-Z0-9]/g,"");t.length<=11&&h(t)},style:{width:"100%"},maxLength:11,ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[A-Z]{4}0[A-Z0-9]{6}$",type:"text",title:d("INVALID_IFSC_CODE_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("VENDOR_BANK_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"bankName",placeholder:"Bank Name Auto Select",style:{width:"100%"},value:C,onChange:function(e){O(e.target.value)},disabled:!0})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("VENDOR_BANK_BRANCH_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"BankbranchName",value:A,style:{width:"100%"},placeholder:"Bank Branch Name Auto Select",onChange:function(e){f(e.target.value)},disabled:!1})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("VENDOR_MICR_NO")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"MicrNo",value:q,style:{width:"100%"},placeholder:"MICR No",onChange:j,disabled:!1})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("ACCOUNT_NO")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"AccountNo",value:V,onChange:function(e){M(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"[0-9]{9,18}",type:"text",title:d("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("PHONE_NO")),l.createElement(a.MobileNumber,{value:Q,name:"PhoneNo",onChange:Z,style:{width:"100%"}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("CONTACT_PERSON")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"ContactPerson",value:J,onChange:function(e){ee(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:d("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("PAN_NO")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"PanNo",value:L,onChange:function(e){w(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"[A-Z]{5}[0-9]{4}[A-Z]{1}",type:"text",title:d("INVALID_PAN_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("GST_NO")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"GstNo",value:k,onChange:function(e){P(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[A-Z0-9]{1}[Z]{1}[A-Z0-9]{1}$",type:"text",title:d("INVALID_GST_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("GST_REGISTERED_STATE/UT")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"GstState",value:F,onChange:function(e){x(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:d("PT_NAME_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("REGISTRATION_NO")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"RegistrationNo",value:H,onChange:function(e){B(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:d("INVALID_REGISTRATION_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("EPF_NO")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"EpfNo",value:U,onChange:function(e){Y(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,15}$",type:"text",title:d("INVALID_EPF_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+d("ESI_NO")),l.createElement(a.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"EsiNo",value:G,onChange:function(e){K(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:d("INVALID_ESI_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement("div",null,d("VENDOR_TYPE"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}},""+d("AST_CLASSIFICATION_ASSET")))),l.createElement(o.Controller,{control:le,name:"VendorType",defaultValue:W,rules:{required:d("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(a.Dropdown,{selected:W,select:$,option:[{i18nKey:"Supplier",code:"SUPPLIER"},{i18nKey:"Contractor",code:"CONTRACTOR"}],optionKey:"i18nKey",placeholder:"Select",t:d})})),l.createElement(a.LabelFieldPair,null,l.createElement("div",null,d("VENOR_CATEGORY"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}}))),l.createElement(o.Controller,{control:le,name:"VendorCategory",defaultValue:R,rules:{required:d("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(a.Dropdown,{selected:R,select:N,option:[{i18nKey:"Firm",code:"FIRM"},{i18nKey:"Individual",code:"Individual"}],optionKey:"i18nKey",placeholder:"Select",t:d})})),l.createElement(a.LabelFieldPair,null,l.createElement("div",null,d("STATUS"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}},""+d("AST_CLASSIFICATION_ASSET")))),l.createElement(o.Controller,{control:le,name:"Status",defaultValue:z,rules:{required:d("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(a.Dropdown,{selected:z,select:X,option:[{i18nKey:"Active",code:"ACTIVE"},{i18nKey:"Inactive",code:"INACTIVE"}],optionKey:"i18nKey",placeholder:"Select",t:d})})))))},VendorDocuments:e=>{var n;let{t:i,config:o,onSelect:r,formData:s}=e;const[d,c]=t.useState([null]),[E,m]=t.useState([null]),[v,S]=t.useState(null),[p,_]=t.useState(1),[D,R]=(Digit.ULBService.getStateId(),Digit.ULBService.getStateId(),t.useState((null==s||null===(n=s.documents)||void 0===n?void 0:n.documents)||[]));return t.useEffect(()=>{var e;null!=s&&null!==(e=s.documents)&&void 0!==e&&e.documents&&(m(s.documents.documents),_(s.documents.documents.length),c(new Array(s.documents.documents.length).fill(null)))},[s]),l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{timeLine:[{actions:i("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:i("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:i("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:1,showFinalStep:!1}),l.createElement(a.FormStep,{t:i,config:o,onSelect:()=>{let e;e={...s.documents,documents:E.filter(e=>null!==e)},r(o.key,e)},onSkip:()=>r(),isDisabled:E.some(e=>null===e)&&d.some(e=>null===e)},d.map((e,t)=>l.createElement(a.LabelFieldPair,{key:t},l.createElement(a.CardLabel,{className:"card-label-smaller"},i("VENDOR_ID")+(0!==t?t:"")),l.createElement("div",{className:"field",style:{display:"flex",alignItems:"center",paddingBottom:"10px"}},l.createElement(a.UploadFile,{onUpload:e=>((e,t)=>{const l=e.target.files[0];c(e=>{const n=[...e];return n[t]=l,n}),function(e,t){try{const l=function(){if(e.size>=5242880)S(i("CS_MAXIMUM_UPLOAD_SIZE_EXCEEDED"));else{const l=u(function(){return Promise.resolve(Digit.UploadServices.Filestorage("EWASTE",e,Digit.ULBService.getStateId())).then(function(e){var l,n;if((null==e||null===(l=e.data)||void 0===l||null===(n=l.files)||void 0===n?void 0:n.length)>0){const l=e.data.files[0].fileStoreId;m(e=>{const n=[...e];return n[t]={filestoreId:l,documentuuid:l,documentType:"Photo"+(t+1)},n})}else S(i("CS_FILE_UPLOAD_ERROR"))})},function(){S(i("CS_FILE_UPLOAD_ERROR"))});if(l&&l.then)return l.then(function(){})}}();Promise.resolve(l&&l.then?l.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}(l,t)})(e,t),onDelete:()=>m(e=>{const l=[...e];return l[t]=null,l}),id:"file-upload-"+t,message:E[t]?"1 "+i("CS_ACTION_FILEUPLOADED"):i("CS_ACTION_NO_FILEUPLOADED"),textStyles:{width:"100%"},inputStyles:{width:"280px"},accept:".pdf, .jpeg, .jpg, .png",buttonType:"button",error:!E[t]})))),v&&l.createElement(a.Toast,{label:v,onClose:()=>S(null),error:!0})))},ServiceDoc:e=>{var t;let{t:n,config:i,onSelect:o}=e;const r=Digit.ULBService.getStateId(),s=null!=i&&i.isMutation?["MutationDocuments"]:"Documents",{isLoading:d,data:u={}}=Digit.Hooks.asset.useAssetDocumentsMDMS(r,"ASSET",s);let c=null==u||null===(t=u.ASSET)||void 0===t?void 0:t.Documents;return l.createElement("div",{className:"employee-form-content"},d&&l.createElement(a.Loader,null),Array.isArray(c)&&c.map((e,t)=>{let{code:i,dropdownData:o}=e;return l.createElement(a.Card,{key:t},l.createElement("div",null,l.createElement("h3",{style:{margin:0}},t+1,". ",n(E(i,".","_")))),o.map((e,t)=>l.createElement("div",{key:t,style:{paddingLeft:"10px",marginBottom:"6px",fontSize:"14px"}},t+1,". ",n(E(null==e?void 0:e.code,".","_")))))}),l.createElement(a.ActionBar,null,l.createElement(a.SubmitBar,{label:n("COMMON_NEXT"),onSubmit:o})))},AddVendor:e=>{const o=Digit.ULBService.getCurrentTenantId(),r=Digit.ULBService.getStateId(),{t:s}=i.useTranslation(),d=n.useHistory(),[u,c]=t.useState(1),[E,m]=t.useState(null),[v,S]=t.useState(!1),[,p]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,_]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,D]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),{mutate:R}=Digit.Hooks.fsm.useVendorCreate(o);t.useEffect(()=>{p(!1),D(),_()},[]);const N=function(e,t){return void 0===t&&(t=!1),[{head:"ES_VRNDOR_NEW_VENDOR_DETAILS",body:[{label:"ES_FSM_REGISTRY_NEW_VENDOR_NAME",isMandatory:!0,type:"text",disable:t,populators:{name:"vendorName",validation:{required:!0,pattern:/^[A-Za-z\s.,/]+$/},error:e("FSM_REGISTRY_INVALID_NAME"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_EMAIL",isMandatory:!1,type:"text",key:"emailId",populators:{name:"emailId",validation:{required:!1,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("FSM_REGISTRY_INVALID_EMAIL"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_VENDOR_PHONE",isMandatory:!0,type:"mobileNumber",key:"phone",disable:t,populators:{name:"phone",validation:{required:!0,pattern:/^[6-9]\d{9}$/},labelStyle:{border:"1px solid black",borderRight:"none"},error:e("FSM_REGISTRY_INVALID_PHONE"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_REGISTRY_SERVICE_TYPE",isMandatory:!0,type:"component",key:"serviceType",component:"SelectServiceType",disable:t,populators:{name:"serviceType",defaultValue:{code:"WT",name:"WT",i18nKey:"WT"}},texts:{header:"CS_COMMON_CHOOSE_SERVICE_TYPE",submitBarLabel:"CS_COMMON_NEXT"}}]},{head:"ES_FSM_REGISTRY_NEW_ADDRESS_DETAILS",body:[{label:"HOUSE_NO",isMandatory:!1,type:"text",key:"doorNo",populators:{name:"doorNo",defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_PLOT",isMandatory:!1,type:"text",key:"plotNo",populators:{name:"plotNo",defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_BUILDING_NAME",isMandatory:!1,type:"text",key:"buildingName",populators:{name:"buildingName",defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_STREET",isMandatory:!1,type:"text",key:"street",populators:{name:"street",defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_PINCODE",isMandatory:!1,type:"text",key:"pincode",populators:{name:"pincode",validation:{required:!1,pattern:/^[1-9][0-9]{5}$/},error:e("FSM_REGISTRY_INVALID_PINCODE"),defaultValue:"",className:"payment-form-text-input-correction"}},{route:"address",component:"VendorSelectAddress",withoutLabel:!0,texts:{headerCaption:"CS_FILE_APPLICATION_PROPERTY_LOCATION_LABEL",header:"CS_FILE_APPLICATION_PROPERTY_LOCATION_ADDRESS_TEXT",cardText:"CS_FILE_APPLICATION_PROPERTY_LOCATION_CITY_MOHALLA_TEXT",submitBarLabel:"CS_COMMON_NEXT"},key:"address",isMandatory:!0,type:"component"},{label:"ES_FSM_REGISTRY_NEW_LANDMARK",isMandatory:!1,type:"text",key:"landmark",populators:{name:"landmark",defaultValue:"",className:"payment-form-text-input-correction"}}]}]}(s),g=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{route:"vendor-details",timeLine:[{actions:"New Vendor Details",currentStep:1}]},{route:"address-details",timeLine:[{actions:"Address Details",currentStep:2}]}],currentActiveIndex:u-1,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormComposer,{label:s("ES_COMMON_APPLICATION_SUBMIT"),config:N.filter(e=>!e.hideInEmployee).map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0,body:e.body.filter(e=>!e.hideInEmployee)})),onSubmit:e=>{var t,l,n,a,i,s,u,c,E,v,S,p,_,D,N,y,T,I,C,O,A,f;const b=e,h=null==b?void 0:b.vendorName,V=null==b?void 0:b.pincode,M=null==b||null===(t=b.street)||void 0===t?void 0:t.trim(),L=null==b||null===(l=b.doorNo)||void 0===l?void 0:l.trim(),w=null==b||null===(n=b.plotNo)||void 0===n?void 0:n.trim(),k=null==b||null===(a=b.landmark)||void 0===a?void 0:a.trim(),P=null==b||null===(i=b.address)||void 0===i||null===(s=i.city)||void 0===s?void 0:s.name,F=null==b||null===(u=b.address)||void 0===u||null===(c=u.city)||void 0===c?void 0:c.state,x=null==b||null===(E=b.address)||void 0===E||null===(v=E.city)||void 0===v?void 0:v.name,H=null==b||null===(S=b.address)||void 0===S||null===(p=S.city)||void 0===p?void 0:p.name,B=null==b||null===(_=b.buildingName)||void 0===_?void 0:_.trim(),U=null==b||null===(D=b.address)||void 0===D||null===(N=D.locality)||void 0===N?void 0:N.code,Y=null==b||null===(y=b.address)||void 0===y||null===(T=y.locality)||void 0===T?void 0:T.name,G=null==b||null===(I=b.address)||void 0===I||null===(C=I.locality)||void 0===C?void 0:C.area,K=null==b||null===(O=b.serviceType)||void 0===O?void 0:O.code,W={vendor:{tenantId:o,name:h,agencyType:"ULB",paymentPreference:"post-service",address:{tenantId:o,landmark:k,doorNo:L,plotNo:w,street:M,city:P,district:x,region:H,state:F,country:"in",pincode:V,buildingName:B,locality:{code:U||"",name:Y||"",label:"Locality",area:G||""},geoLocation:{latitude:(null==b||null===(A=b.address)||void 0===A?void 0:A.latitude)||0,longitude:(null==b||null===(f=b.address)||void 0===f?void 0:f.longitude)||0}},owner:{tenantId:r,name:h,fatherOrHusbandName:h,relationship:"OTHER",gender:"MALE",dob:"915148800",emailId:(null==b?void 0:b.emailId)||"abc@egov.com",mobileNumber:null==b?void 0:b.phone},additionalDetails:{serviceType:K},vehicle:[],drivers:[],source:"WhatsApp"}};R(W,{onError:e=>{m({key:"error",action:e}),setTimeout(g,5e3)},onSuccess:(e,t)=>{m({key:"success",action:"ADD_VENDOR"}),setTimeout(()=>{g(),d.push("/digit-ui/employee/vendor/search-vendor")},2e3)}})},defaultValues:{serviceType:{code:"WT",name:"WT",i18nKey:"WT"},tripData:{noOfTrips:1,amountPerTrip:null,amount:null}},onFormValueChange:(e,t)=>{var l,n,a;const i=(null==t?void 0:t.vendorName)&&(null==t?void 0:t.phone)&&(null==t||null===(l=t.serviceType)||void 0===l?void 0:l.code),o=(null==t||null===(n=t.address)||void 0===n?void 0:n.city)&&(null==t||null===(a=t.address)||void 0===a?void 0:a.locality);S(!(!i||!o)),i?1===u&&(c(2),setTimeout(()=>{const e=Array.from(document.querySelectorAll(".collapsible-card-title")).find(e=>e.textContent.includes(s("ES_FSM_REGISTRY_NEW_ADDRESS_DETAILS")));e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100)):2===u&&(c(1),setTimeout(()=>{const e=Array.from(document.querySelectorAll(".collapsible-card-title")).find(e=>e.textContent.includes(s("ES_VRNDOR_NEW_VENDOR_DETAILS")));e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100))},noBreakLine:!0,noCard:!0,isDisabled:!v}),E&&l.createElement(a.Toast,{error:"error"===E.key,label:s("success"===E.key?`ES_FSM_REGISTRY_${E.action}_SUCCESS`:E.action),onClose:g})))},VendorSelectAddress:e=>{var n,i,o;let{t:r,config:s,onSelect:d,userType:u,formData:c}=e;const E=Digit.Hooks.vendor.useTenants();let m=Digit.ULBService.getCurrentTenantId();const{pincode:v}=(null==c?void 0:c.address)||"",S="employee"===u?E.filter(e=>e.code===m):v?E.filter(e=>{var t;return null==e||null===(t=e.pincode)||void 0===t?void 0:t.some(e=>e==v)}):E;let p=null===(n=sessionStorage)||void 0===n?void 0:n.getItem("Digit_FSM_PT");var _;"undefined"!==p&&(p=JSON.parse(null===(_=sessionStorage)||void 0===_?void 0:_.getItem("Digit_FSM_PT")));let D={};p&&(D=S.filter(e=>{var t,l,n;return e.code==(null===(t=p)||void 0===t||null===(l=t.propertyDetails)||void 0===l||null===(n=l.address)||void 0===n?void 0:n.tenantId)}));const[R,N]=t.useState(()=>{var e,t;return(null==c||null===(e=c.address)||void 0===e?void 0:e.city)||(null===(t=D)||void 0===t?void 0:t[0])||null}),{data:g}=Digit.Hooks.useBoundaryLocalities(null==R?void 0:R.code,"revenue",{enabled:!!R},r),[y,T]=t.useState(),[I,C]=t.useState(()=>{var e,t,l,n,a,i,o;return(null===(e=p)||void 0===e||null===(t=e.propertyDetails)||void 0===t||null===(l=t.address)||void 0===l?void 0:l.locality)||(null==c||null===(n=c.cpt)||void 0===n||null===(a=n.details)||void 0===a||null===(i=a.address)||void 0===i?void 0:i.locality)||(null==c||null===(o=c.address)||void 0===o?void 0:o.locality)});function O(e){C(null),T(null),Digit.SessionStorage.set("fsm.file.address.city",e),N(e)}function A(e){C(e),"employee"===u&&d(s.key,{...c[s.key],locality:e})}return t.useEffect(()=>{S&&1===S.length&&N(S[0])},[S]),t.useEffect(()=>{if(R&&g){var e,t,l,n,a,i,o,r;let _=g,D=[];if(null!=c&&null!==(e=c.address)&&void 0!==e&&e.locality)C(c.address.locality);else if(null!=c&&null!==(t=c.cpt)&&void 0!==t&&null!==(l=t.details)&&void 0!==l&&null!==(n=l.address)&&void 0!==n&&n.locality)C(c.cpt.details.address.locality);else if(null!==(a=p)&&void 0!==a&&null!==(i=a.propertyDetails)&&void 0!==i&&null!==(o=i.address)&&void 0!==o&&o.locality){var E,m,v;C(null===(E=p)||void 0===E||null===(m=E.propertyDetails)||void 0===m||null===(v=m.address)||void 0===v?void 0:v.locality)}var S;null!=c&&null!==(r=c.address)&&void 0!==r&&r.pincode&&(D=_.filter(e=>{var t;return null===(t=e.pincode)||void 0===t?void 0:t.find(e=>e==c.address.pincode)}),null!=c&&null!==(S=c.address)&&void 0!==S&&S.locality||C()),"employee"===u&&d(s.key,{...c[s.key],city:R}),T(()=>D.length>0?D:_),1===D.length&&(C(D[0]),"employee"===u&&d(s.key,{...c[s.key],locality:D[0]}))}},[R,null==c||null===(i=c.cpt)||void 0===i||null===(o=i.details)||void 0===o?void 0:o.address,g]),"employee"===u?l.createElement(l.Fragment,null,l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,r("MYCITY_CODE_LABEL"),s.isMandatory?" * ":null),l.createElement(a.Dropdown,{className:"",isMandatory:!0,selected:1===(null==S?void 0:S.length)?S[0]:R,disable:1===(null==S?void 0:S.length),option:S,select:O,optionKey:"code",t:r})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_MOHALLA"),s.isMandatory?" * ":null),l.createElement(a.Dropdown,{className:"",isMandatory:!0,selected:I,option:y,select:A,optionKey:"name",t:r}))):l.createElement(l.Fragment,null,l.createElement(a.FormStep,{config:s,onSelect:function(){d(s.key,{city:R,locality:I})},t:r,isDisabled:!I},l.createElement(a.CardLabel,null,r("MYCITY_CODE_LABEL")+" *"),l.createElement(a.RadioOrSelect,{options:S,selectedOption:R,optionKey:"i18nKey",onSelect:O,t:r}),R&&y&&l.createElement(a.CardLabel,null,r("CS_CREATECOMPLAINT_MOHALLA")+" *"),R&&y&&l.createElement(a.RadioOrSelect,{isMandatory:s.isMandatory,options:y,selectedOption:I,optionKey:"name",onSelect:A,t:r})))},SearchApp:e=>{n.useParams();const{t:o}=i.useTranslation(),r=Digit.ULBService.getCurrentTenantId(),[s,d]=t.useState({}),[u,c]=t.useState(null),E={enabled:!!(s&&Object.keys(s).length>0)},{isLoading:v,isSuccess:S,data:{EwasteApplication:p,Count:_}={}}=Digit.Hooks.ew.useEWSearch({tenantId:r,filters:s},E);return l.createElement(l.Fragment,null,l.createElement(m,{t:o,isLoading:v,tenantId:r,setShowToast:c,onSubmit:function(e){var t=new Date(null==e?void 0:e.fromDate);null==t||t.setSeconds((null==t?void 0:t.getSeconds())-19800);var l=new Date(null==e?void 0:e.toDate);null==l||l.setSeconds((null==l?void 0:l.getSeconds())+86399-19800);let n=Object.keys(data).filter(e=>data[e]).reduce((e,t)=>({...e,[t]:"object"==typeof data[t]?data[t].code:data[t]}),{});!(Object.entries(n).length>0)||n.requestId||n.creationReason||n.fromDate||n.mobileNumber||n.requestId||n.status||n.toDate?!(Object.entries(n).length>0&&(n.creationReason||n.status))||n.requestId||n.fromDate||n.mobileNumber||n.requestId||n.toDate?Object.entries(n).length>0&&n.fromDate&&!n.toDate||!n.fromDate&&n.toDate?c({warning:!0,label:"ERR_PROVIDE_BOTH_FORM_TO_DATE"}):d(n):c({warning:!0,label:"ERR_PROVIDE_MORE_PARAM_WITH_TYPE_STATUS"}):c({warning:!0,label:"ERR_VENDOR_FILL_VALID_FIELDS"})},data:S&&!v?p.length>0?p:{display:"ES_COMMON_NO_DATA"}:"",count:_}),u&&l.createElement(a.Toast,{error:u.error,warning:u.warning,label:o(u.label),isDleteBtn:!0,onClose:()=>{c(null)}}))},SearchVendor:()=>{var e,n,a,o,r,s;const{t:d}=i.useTranslation(),u=Digit.ULBService.getCurrentTenantId(),{selectedTabs:c}=Digit.Hooks.useQueryParams(),[E,m]=t.useState({}),[v,S]=t.useState([{id:"createdTime",desc:!0}]),[p,_]=t.useState(0),[D,R]=t.useState(10),[N,g]=t.useState(c||"VENDOR"),[y,T]=t.useState(""),[I,C]=t.useState(""),[O,A]=t.useState([]),{data:f}=Digit.Hooks.fsm.useDsoSearch(u,{status:"ACTIVE"},{staleTime:Infinity}),{data:b}=Digit.Hooks.wt.useFillPointSearch({tenantId:u,filters:{limit:1e3}},{staleTime:Infinity});let h={limit:D,offset:p,sortBy:null==v||null===(e=v[0])||void 0===e?void 0:e.id,sortOrder:null!=v&&null!==(n=v[0])&&void 0!==n&&n.desc?"DESC":"ASC"};const{data:M,isLoading:L,refetch:w}="VEHICLE"===N?Digit.Hooks.fsm.useVehiclesSearch({tenantId:u,filters:{...h,registrationNumber:null==E?void 0:E.registrationNumber,status:"ACTIVE,DISABLED",vendorId:null==E||null===(a=E.vendor)||void 0===a?void 0:a.id,fillingPointId:null==E||null===(o=E.fillingPoint)||void 0===o?void 0:o.id},config:{enabled:!1}}):"DRIVER"===N?Digit.Hooks.fsm.useDriverSearch({tenantId:u,filters:{...h,name:null==E?void 0:E.name,status:"ACTIVE,DISABLED",vendorId:null==E||null===(r=E.vendor)||void 0===r?void 0:r.id},config:{enabled:!1}}):"SUPERVISOR"===N?Digit.Hooks.fsm.useSupervisorDetails(u,{...h,status:"ACTIVE,DISABLED"},{enabled:!1}):"SURVEYOR"===N?Digit.Hooks.fsm.useSurveyorDetails(u,{...h,status:"ACTIVE,DISABLED"},{enabled:!1}):Digit.Hooks.fsm.useVendorSearch({tenantId:u,filters:{...h,name:null==E?void 0:E.name,status:"ACTIVE,DISABLED"},config:{enabled:!1}});Digit.Hooks.fsm.useVendorSearch({tenantId:u,filters:{...h,name:null==E?void 0:E.name,status:"ACTIVE,DISABLED"},config:{enabled:!1}});const{data:k,isLoading:P,refetch:F}=Digit.Hooks.fsm.useDsoSearch(u,{vehicleIds:y,driverIds:I,status:"ACTIVE"},{enabled:!1}),x=(null==M?void 0:M.totalCount)||50;t.useEffect(()=>{w(),F()},[]),t.useEffect(()=>{w()},[E,v,p,D]),t.useEffect(()=>{if(null!=M&&M.vehicle&&"VEHICLE"===N){const e=M.vehicle.map(e=>e.id).filter(Boolean).join(",");T(e),A(M.vehicle)}if(null!=M&&M.driver&&"DRIVER"===N){const e=M.driver.map(e=>e.id).filter(Boolean).join(",");C(e),A(null==M?void 0:M.driver)}if(null!=M&&M.vendor&&"VENDOR"===N){const e=M.vendor.map(e=>{var t,l,n,a;return{mobileNumber:null===(t=e.owner)||void 0===t?void 0:t.mobileNumber,name:e.name,id:e.id,auditDetails:e.auditDetails,drivers:e.drivers,activeDrivers:null===(l=e.drivers)||void 0===l?void 0:l.filter(e=>"ACTIVE"===e.status),allVehicles:e.vehicles,dsoDetails:e,vendorAdditionalDetails:e.vendorAdditionalDetails,fillingPoint:e.fillingPoint,vehicles:null===(n=e.vehicles)||void 0===n||null===(a=n.filter(e=>"ACTIVE"===e.status))||void 0===a?void 0:a.map(e=>({id:e.id,registrationNumber:null==e?void 0:e.registrationNumber,type:e.type,i18nKey:"FSM_VEHICLE_TYPE_"+e.type,capacity:e.tankCapacity,suctionType:e.suctionType,model:e.model}))}});A(e)}if("SUPERVISOR"===N){const e=[{id:"SUP1",name:"Amit Kumar",employeeId:"EMP001",status:"ACTIVE",owner:{mobileNumber:"9876543210",userName:"9876543210"},auditDetails:{createdTime:(new Date).getTime()},vendorData:{name:"Clean City Agency"}},{id:"SUP2",name:"Rajesh Singh",employeeId:"EMP002",status:"ACTIVE",owner:{mobileNumber:"9876543211",userName:"9876543211"},auditDetails:{createdTime:(new Date).getTime()},vendorData:{name:"Green Environment"}}];A((null==M?void 0:M.supervisor)||e)}if("SURVEYOR"===N){const e=[{id:"SUR1",name:"Suresh Raina",employeeId:"EMP101",status:"ACTIVE",owner:{mobileNumber:"9123456780",userName:"9123456780"},auditDetails:{createdTime:(new Date).getTime()},vendorData:{name:"Clean City Agency"}},{id:"SUR2",name:"Mahesh Babu",employeeId:"EMP102",status:"ACTIVE",owner:{mobileNumber:"9123456781",userName:"9123456781"},auditDetails:{createdTime:(new Date).getTime()},vendorData:{name:"Green Environment"}}];A((null==M?void 0:M.surveyor)||e)}},[M,N]),t.useEffect(()=>{""===y&&""===I||F()},[y,I]),t.useEffect(()=>{let e=!0;if(k&&e){if("VEHICLE"===N){const e=null==M?void 0:M.vehicle.map(e=>{let t=k.find(t=>{var l,n;return null===(l=t.dsoDetails)||void 0===l||null===(n=l.vehicles)||void 0===n?void 0:n.find(t=>t.id===e.id)});if(t){var l,n;let a={...e,vendor:t.dsoDetails};const i=null===(l=t.dsoDetails)||void 0===l||null===(n=l.vehicles)||void 0===n?void 0:n.find(t=>t.id===e.id);return i&&(a.driverData=i.driverData||i.driver||a.driverData),a}return e});A(e),T("")}if("DRIVER"===N){const e=null==M?void 0:M.driver.map(e=>{let t=k.find(t=>{var l,n;return null===(l=t.dsoDetails)||void 0===l||null===(n=l.drivers)||void 0===n?void 0:n.find(t=>t.id===e.id)});return t?{...e,vendor:t.dsoDetails}:e});A(e),C("")}}return()=>{e=!1}},[k,M]);const H="VEHICLE"===N?[{label:d("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==f?void 0:f.map(e=>{var t;return{...e.dsoDetails,displayName:`${e.dsoDetails.name} (${e.dsoDetails.mobileNumber||(null===(t=e.dsoDetails.owner)||void 0===t?void 0:t.mobileNumber)||"N/A"})`}}),optionsKey:"displayName"},{label:d("ES_FSM_REGISTRY_SEARCH_FILLING_POINT"),name:"fillingPoint",type:"dropdown",options:null==b||null===(s=b.fillingPoints)||void 0===s?void 0:s.map(e=>({...e,name:(null==e?void 0:e.name)||(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.fillingStationId)})),optionsKey:"name"},{label:d("ES_VEHICLE_SEARCH_VEHICLE_NUMBER"),name:"registrationNumber",pattern:"[A-Z]{2}[- ]?[0-9]{2}[- ]?[A-Z]{1,2}[- ]?[0-9]{4}",title:d("ES_FSM_VEHICLE_FORMAT_TIP")}]:"DRIVER"===N?[{label:d("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==f?void 0:f.map(e=>{var t;return{...e.dsoDetails,displayName:`${e.dsoDetails.name} (${e.dsoDetails.mobileNumber||(null===(t=e.dsoDetails.owner)||void 0===t?void 0:t.mobileNumber)||"N/A"})`}}),optionsKey:"displayName"},{label:d("ES_DRIVER_SEARCH_DRIVER_NAME"),name:"name"}]:"SUPERVISOR"===N||"SURVEYOR"===N?[{label:d("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==f?void 0:f.map(e=>{var t;return{...e.dsoDetails,displayName:`${e.dsoDetails.name} (${e.dsoDetails.mobileNumber||(null===(t=e.dsoDetails.owner)||void 0===t?void 0:t.mobileNumber)||"N/A"})`}}),optionsKey:"displayName"},{label:d("SUPERVISOR"===N?"ES_SUPERVISOR_SEARCH_NAME":"ES_SURVEYOR_SEARCH_NAME"),name:"name"}]:[{label:d("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"name"}],B=t.useCallback(e=>{0!==(null==e?void 0:e.length)&&S(e)},[]);return l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(V,{data:{table:O},isLoading:L||P,onSort:B,disableSort:!1,sortParams:v,userRole:"FSM_ADMIN",onFilterChange:()=>{},searchFields:H,onSearch:function(e){void 0===e&&(e={}),m({...e})},onNextPage:()=>{_(e=>e+D)},onPrevPage:()=>{_(e=>e-D)},currentPage:Math.floor(p/D),pageSizeLimit:D,onPageSizeChange:e=>{R(Number(e.target.value))},totalRecords:x||0,onTabChange:e=>{g(e)},selectedTab:N,refetchData:()=>{w()},refetchVendor:()=>{F()}})))},SelectServiceType:e=>{let{config:n,onSelect:i,t:o,userType:r,formData:s}=e;const d=Digit.ULBService.getCurrentTenantId(),[u,c]=(Digit.ULBService.getStateId(),t.useState(null==s?void 0:s.serviceType)),[E,m]=t.useState([]),{data:v,isLoading:S}=Digit.Hooks.useCustomMDMS(d,"tenant",[{name:"citymodule"}],{select:e=>{var t;return null==e||null===(t=e.tenant)||void 0===t?void 0:t.citymodule}});return t.useEffect(()=>{if(v){const e=v.map(e=>({i18nKey:""+e.code,code:""+e.code,value:""+e.name}));if(m(e),!u||"WT"===u.code){const t=e.find(e=>"WT"===e.code);t&&(c(t),"employee"===r&&i(n.key,t))}}},[v]),S?l.createElement(a.Loader,null):"employee"===r?l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,o(n.label)),l.createElement(a.Dropdown,{className:"payment-form-text-input-correction",isMandatory:n.isMandatory,selected:u,option:E,select:e=>{c(e),"employee"===r&&i(n.key,e)},optionKey:"i18nKey",disable:n.disable,t:o})):void 0},SelectVehicleType:e=>{var n;let{t:i,config:o,onSelect:r,formData:s}=e;const d=Digit.ULBService.getStateId(),u=Digit.ULBService.getCurrentTenantId(),{data:c,isLoading:E}=Digit.Hooks.wt.useWTMDMS(d,"Vehicle","VehicleMakeModel"),{data:m,isLoading:v}=Digit.Hooks.useCustomMDMS(u,"tenant",[{name:"citymodule"}],{select:e=>{var t;return null==e||null===(t=e.tenant)||void 0===t?void 0:t.citymodule}}),[S,p]=t.useState({}),[_,D]=t.useState([]),[R,N]=t.useState({}),[g,y]=t.useState([]),[T,I]=t.useState({}),[C,O]=t.useState(""),A=(null==s||null===(n=s.serviceType)||void 0===n?void 0:n.code)||(null==s?void 0:s.serviceType),f=t.useMemo(()=>{if(!m||!c)return{};const e={};return m.forEach(t=>{"WT"===t.code?e[t.code]=c.filter(e=>["MAHINDRA","TATA","TRACTOR","TAFE","SONALIKA"].includes(e.code)).map(e=>e.code):"CND"===t.code&&(e[t.code]=c.filter(e=>["MAHINDRA","TATA"].includes(e.code)).map(e=>e.code))}),e},[m,c]);return t.useEffect(()=>{p(f)},[f]),t.useEffect(()=>{if(!c)return;const e=S[A],t=e?c.filter(t=>e.includes(t.code)):c;D(t),N({}),y([]),I({}),O("")},[c,A,S]),t.useEffect(()=>{if(!c||null==R||!R.code)return;const e=c.filter(e=>e.make===R.code);y(e),I({}),O("")},[R,c]),t.useEffect(()=>{null!=T&&T.capacity&&O(T.capacity)},[T]),E||v?l.createElement(a.Loader,null):c&&m?l.createElement(l.Fragment,null,l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_MODEL")),l.createElement(a.Dropdown,{className:"form-field",selected:R,option:_,select:e=>{N(e),r(o.key,{...(null==s?void 0:s[o.key])||{},modal:e,type:""})},optionKey:"name",t:i})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_TYPE")),l.createElement(a.Dropdown,{className:"form-field",selected:T,option:g,select:e=>{I(e),O(e.capacity),r(o.key,{...s[o.key],type:e})},optionKey:"name",t:i})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_CAPACITY")),l.createElement(a.TextInput,{className:"",textInputStyle:{width:"100%"},value:C,disable:!0}))):l.createElement("div",null,i("ERROR_FETCHING_DATA"))},BankDetailsComponent:e=>{let{t:n,config:i,onSelect:o,formData:r,...s}=e;const[d,u]=t.useState((null==r?void 0:r.ifscCode)||""),[c,E]=t.useState((null==r?void 0:r.bankName)||""),[m,v]=t.useState((null==r?void 0:r.branchName)||""),[S,p]=t.useState((null==r?void 0:r.accountNumber)||""),[_,D]=t.useState(null);return t.useEffect(()=>{11===d.length&&fetch("https://ifsc.razorpay.com/"+d).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH?(E(e.BANK),v(e.BRANCH),"function"==typeof o&&o(i.key,{bankName:e.BANK,branchName:e.BRANCH,ifscCode:d,accountNumber:S}),D({error:!1,label:n("VALID_IFSC_CODE")})):D({error:!0,label:n("INVALID_IFSC_CODE")})}).catch(()=>{D({error:!0,label:n("INVALID_IFSC_CODE")})})},[d]),t.useEffect(()=>{"function"==typeof o&&o(i.key,{bankName:c,branchName:m,ifscCode:d,accountNumber:S})},[S,c,m,d]),l.createElement(l.Fragment,null,l.createElement(a.CardLabel,null,n("ES_FSM_REGISTRY_IFSC_CODE")),l.createElement(a.TextInput,{t:n,type:"text",isMandatory:!1,name:"ifscCode",value:d,onChange:e=>{const t=e.target.value.replace(/[^a-zA-Z0-9]/g,"");t.length<=11&&u(t)},style:{width:"100%"},maxLength:11}),l.createElement(a.CardLabel,null,n("ES_FSM_REGISTRY_ACCOUNT_NUMBER")),l.createElement(a.TextInput,{t:n,type:"text",isMandatory:!1,name:"accountNumber",value:S,onChange:e=>p(e.target.value),style:{width:"100%"}}),l.createElement(a.CardLabel,null,n("ES_FSM_REGISTRY_BANK_NAME")),l.createElement(a.TextInput,{t:n,type:"text",isMandatory:!1,name:"bankName",value:c,onChange:e=>E(e.target.value),disabled:11===d.length&&c,style:{width:"100%"}}),l.createElement(a.CardLabel,null,n("ES_FSM_REGISTRY_BRANCH_NAME")),l.createElement(a.TextInput,{t:n,type:"text",isMandatory:!1,name:"branchName",value:m,onChange:e=>v(e.target.value),disabled:11===d.length&&m,style:{width:"100%"}}))},AddDriver:()=>{const e=Digit.ULBService.getCurrentTenantId(),{t:n}=i.useTranslation(),o=Digit.ULBService.getStateId(),[d,u]=t.useState(null),c=r.useQueryClient(),[,E]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,m]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,v]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),{mutate:S}=Digit.Hooks.fsm.useDriverCreate(e);t.useEffect(()=>{E(!1),v(),m()},[]);const p=function(e,t){return void 0===t&&(t=!1),[{head:"ES_FSM_REGISTRY_DRIVER_DETAILS",body:[{label:"ES_FSM_REGISTRY_DRIVER_NAME",isMandatory:!0,type:"text",disable:t,populators:{name:"driverName",validation:{required:!0,pattern:{value:/^[A-Za-z\s]+$/,message:e("FSM_REGISTRY_INVALID_NAME")}},error:e("FSM_REGISTRY_INVALID_NAME"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_DRIVER_LICENSE",isMandatory:!0,type:"text",key:"license",populators:{name:"license",validation:{required:!0,pattern:{value:/^[A-Z]{2}-[0-9]{2}-[0-9]{4}-[0-9]{7}$/,message:e("ES_FSM_REGISTRY_INVALID_LICENSE")}},error:e("ES_FSM_REGISTRY_INVALID_LICENSE"),required:!1,defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_REGISTRY_SERVICE_TYPE",isMandatory:!0,type:"component",route:"select-service",hideInEmployee:!1,key:"serviceType",component:"SelectServiceType",disable:t,populators:{name:"serviceType",defaultValue:{code:"WT",name:"WT",i18nKey:"WT"}},texts:{headerCaption:"",header:"CS_COMMON_CHOOSE_GENDER",cardText:"CS_COMMON_SELECT_GENDER",submitBarLabel:"CS_COMMON_NEXT",skipText:"CORE_COMMON_SKIP_CONTINUE"}}]},{head:"ES_FSM_REGISTRY_PERSONAL_DETAILS",body:[{label:"ES_FSM_REGISTRY_NEW_GENDER",isMandatory:!0,type:"component",route:"select-gender",hideInEmployee:!1,key:"selectGender",component:"SelectGender",texts:{headerCaption:"",header:"CS_COMMON_CHOOSE_GENDER",cardText:"CS_COMMON_SELECT_GENDER",submitBarLabel:"CS_COMMON_NEXT",skipText:"CORE_COMMON_SKIP_CONTINUE"}},{label:e("ES_FSM_REGISTRY_NEW_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(j,s({onChange:e.onChange,date:e.value},t,{max:(()=>{const e=new Date;return e.setFullYear(e.getFullYear()-18),e.toISOString().split("T")[0]})()}))}},{label:"ES_FSM_REGISTRY_NEW_EMAIL",isMandatory:!1,type:"text",key:"emailId",populators:{name:"emailId",validation:{required:!1,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("FSM_REGISTRY_INVALID_EMAIL"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_DRIVER_PHONE",isMandatory:!0,type:"mobileNumber",key:"phone",disable:t,populators:{name:"phone",validation:{required:!0,pattern:/^[6-9]\d{9}$/},error:e("FSM_REGISTRY_INVALID_PHONE"),defaultValue:"",className:"payment-form-text-input-correction",labelStyle:{border:"1px solid black",borderRight:"none"}}}]}]}(n),[_,D]=t.useState(!1),R=()=>{u(null)},N="WT_VENDOR"===Digit.UserService.getType();return console.log(N,"iscitizen"),l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{route:"vendor-details",timeLine:[{actions:n("ES_FSM_REGISTRY_TITLE_NEW_DRIVER"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormComposer,{isDisabled:!_,label:n("ES_COMMON_APPLICATION_SUBMIT"),config:p.filter(e=>!e.hideInEmployee).map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0,body:e.body.filter(e=>!e.hideInEmployee)})),fieldStyle:{marginRight:0},onSubmit:t=>{var l,n;const a=null==t?void 0:t.driverName,i=null==t?void 0:t.license,r=null==t||null===(l=t.selectGender)||void 0===l?void 0:l.code,s=null==t?void 0:t.emailId,d=null==t?void 0:t.phone,E=new Date(""+t.dob).getTime()||new Date("1/1/1970").getTime(),m=null==t||null===(n=t.serviceType)||void 0===n?void 0:n.code;S({driver:{tenantId:N?e:"dl.djb",name:a,licenseNumber:i,status:"ACTIVE",owner:{tenantId:o,name:a,fatherOrHusbandName:a,relationship:"OTHER",gender:r,dob:E,emailId:s||"abc@egov.com",mobileNumber:d},additionalDetails:{serviceType:m},vendorDriverStatus:"ACTIVE"}},{onError:(e,t)=>{u({key:"error",action:e}),setTimeout(R,5e3)},onSuccess:(e,t)=>{u({key:"success",action:"ADD_DRIVER"}),setTimeout(R,5e3),c.invalidateQueries("FSM_DRIVER_SEARCH")}})},defaultValues:{serviceType:{code:"WT",name:"WT",i18nKey:"WT"},tripData:{noOfTrips:1,amountPerTrip:null,amount:null}},onFormValueChange:(e,t)=>{if(null!=t&&t.license){const l=t.license.replace(/[^A-Za-z0-9]/g,"").toUpperCase();let n=l;l.length>2&&(n=l.slice(0,2)+"-"+l.slice(2)),l.length>4&&(n=n.slice(0,5)+"-"+n.slice(5)),l.length>8&&(n=n.slice(0,10)+"-"+n.slice(10));const a=n.slice(0,18);t.license!==a&&e("license",a)}null!=t&&t.driverName&&/^[A-Za-z\s]+$/.test(null==t?void 0:t.driverName)&&null!=t&&t.license&&/^[A-Z]{2}-[0-9]{2}-[0-9]{4}-[0-9]{7}$/.test(null==t?void 0:t.license)&&null!=t&&t.selectGender&&null!=t&&t.dob&&new Date(null==t?void 0:t.dob).getTime()<=(new Date).setFullYear((new Date).getFullYear()-18)?D(!0):D(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),d&&l.createElement(a.Toast,{error:"error"===d.key,label:n("success"===d.key?`ES_FSM_${d.action}_SUCCESS`:d.action),onClose:R})))},EditVendorDetails:e=>{var o,s,d;const u=Digit.ULBService.getCurrentTenantId(),{t:c}=i.useTranslation(),E=n.useHistory(),m=r.useQueryClient();let{id:v}=n.useParams();const[S,p]=t.useState(!1),[_,D]=t.useState(null),[R,N]=t.useState(!1),[g,y]=t.useState(null),[T,I]=t.useState([]),[C,O]=t.useState([]),[A,f]=t.useState({}),{data:b,isLoading:h,refetch:V}=Digit.Hooks.fsm.useDsoSearch(u,{ids:v},{staleTime:Infinity}),{data:M,refetch:k}=Digit.Hooks.fsm.useVehiclesSearch({tenantId:u,filters:{status:"ACTIVE",sortBy:"registrationNumber",sortOrder:"ASC",vehicleWithNoVendor:!0}}),{data:F,refetch:x}=Digit.Hooks.fsm.useDriverSearch({tenantId:u,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE",driverWithNoVendor:!0}}),{data:H,isLoading:B}=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:u,filters:{vendorId:v}},{enabled:!!v}),{mutate:U}=Digit.Hooks.fsm.useVendorUpdate(u);function Y(e){p(!1),D(e)}const G=null===(o=Digit.SessionStorage.get("User").info.type)||void 0===o?void 0:o.toLowerCase();t.useEffect(()=>{switch(_){case"DELETE":case"ADD_VEHICLE":case"ADD_DRIVER":return N(!0);case"EDIT":return E.push(`/digit-ui/${G}/fsm/registry/modify-vendor/dsoId`);case"HOME":return E.push(`/digit-ui/${G}/fsm/registry?selectedTabs=VENDOR`)}},[_]),t.useEffect(()=>{M&&I((null==M?void 0:M.vehicle)||[])},[M]),t.useEffect(()=>{F&&O((null==F?void 0:F.driver)||[])},[F]);const K=()=>{y(null)},W=()=>{D(null),f({}),N(!1)},$=window.Digit.Utils.browser.isMobile();if(h)return l.createElement(a.Loader,null);const z=["vendorAdditionalDetailsId","vendorId","tenantId","code","lastModifiedTime","createdTime","lastModifiedBy","createdBy","active","status","vendorType","vendorGroup","narration","documents"];return l.createElement("div",{className:"employee-form-content"},h?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,l.createElement(a.Card,null,null==b||null===(s=b[0])||void 0===s||null===(d=s.employeeResponse)||void 0===d?void 0:d.map((e,t)=>{var n,i;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(a.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},c(e.title)),l.createElement("div",null,null==e||null===(n=e.values)||void 0===n?void 0:n.map((t,n)=>{var i;if("ES_FSM_REGISTRY_DETAILS_ADDITIONAL_DETAILS"===t.title){var o,r;const e=null==H||null===(o=H.VendorDetails)||void 0===o||null===(r=o[0])||void 0===r?void 0:r.vendorAdditionalDetails,n=Object.entries(e||{}).filter(e=>{let[t]=e;return!z.includes(t)});return l.createElement(l.Fragment,{key:t.title},l.createElement(a.Row,{label:c(t.title),text:"",className:"border-none flex-box"}),B?l.createElement(a.Loader,null):e?l.createElement(a.Card,{className:"card-with-background",style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"additional-grid"},n.map(e=>{let[t,n]=e;if("object"==typeof n&&null!==n)return null;const a=String(t);let i=null!=n&&""!==n?String(n):"N/A";var o,r;return"name"!==t||n&&""!==n||(i=(null==b||null===(o=b[0])||void 0===o||null===(r=o.dsoDetails)||void 0===r?void 0:r.name)||"N/A"),l.createElement(l.Fragment,{key:a},l.createElement("div",{className:"additional-label"},c((e=>{const t=e.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)})(a))),l.createElement("div",{className:"additional-value"},i))})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>E.push(`/digit-ui/${G}/vendor/registry/additionaldetails/info?vendorId=${v}`)},c("Edit Details"))):l.createElement("div",{onClick:()=>E.push(`/digit-ui/${G}/vendor/registry/additionaldetails/vendor-details?vendorId=${v}`),className:"add-details-link hover-button"},c("Add Additional Details")))}return l.createElement(a.Row,{key:c(String(t.title)),label:c(String(t.title)),text:t.value?c(String(t.value)):"N/A",last:n===(null==e||null===(i=e.values)||void 0===i?void 0:i.length)-1,caption:t.caption,className:"border-none flex-box "+($?"":"vendor-details-row")})}),null==e||null===(i=e.child)||void 0===i?void 0:i.map((t,n)=>{var i;return l.createElement(a.Card,{className:"card-with-background",key:t.id||n},l.createElement("div",{className:"card-head"},l.createElement("h2",null,c(e.type)," ",n+1),l.createElement("div",{style:{display:"flex"}},l.createElement("span",{onClick:()=>((e,t,l)=>{if("ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===t)E.push(`/digit-ui/${G}/fsm/registry/modify-driver/${l}`);else{var n,a;let t=null==e||null===(n=e.values)||void 0===n||null===(a=n.find(e=>"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.title))||void 0===a?void 0:a.value;E.push(`/digit-ui/${G}/fsm/registry/modify-vehicle/${t}`)}})(t,e.type,t.id)},l.createElement(a.EditIcon,{style:{cursor:"pointer",marginRight:"20px"},className:"edit",fill:"#a82227"})),l.createElement("span",{onClick:()=>((e,t,l)=>{let n={};if("ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===t){var a,i;let e=null==b||null===(a=b[0])||void 0===a?void 0:a.dsoDetails,t=null==e?void 0:e.drivers;t=t.map(e=>(e.id===l&&(e.vendorDriverStatus="INACTIVE"),e)),n={vendor:{...e,owner:{...e.owner,gender:(null===(i=e.owner)||void 0===i?void 0:i.gender)||"OTHERS"},drivers:t}}}else{var o,r,s,d;let t=null==b||null===(o=b[0])||void 0===o?void 0:o.dsoDetails,l=null==t?void 0:t.vehicles,a=null==e||null===(r=e.values)||void 0===r||null===(s=r.find(e=>"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.title))||void 0===s?void 0:s.value;l=l.map(e=>(e.registrationNumber===a&&(e.vendorVehicleStatus="INACTIVE"),e)),n={vendor:{...t,owner:{...t.owner,gender:(null===(d=t.owner)||void 0===d?void 0:d.gender)||"OTHERS"},vehicles:l}}}U(n,{onError:(e,t)=>{y({key:"error",action:e}),setTimeout(K,5e3)},onSuccess:(e,l)=>{y({key:"success",action:"ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===t?"DELETE_DRIVER":"DELETE_VEHICLE"}),m.invalidateQueries("DSO_SEARCH"),V(),k(),x(),setTimeout(()=>{K()},5e3)}})})(t,e.type,t.id)},l.createElement(a.DeleteIcon,{style:{cursor:"pointer"},className:"delete",fill:"#a82227"})))),l.createElement("div",{className:"additional-grid",style:{padding:"8px 16px"}},null==t||null===(i=t.values)||void 0===i?void 0:i.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},c(String(e.title))),l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},e.value?c(String(e.value)):"N/A")))))}),e.type&&l.createElement("div",{className:"add-details-link hover-button",onClick:()=>Y("ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===e.type?"ADD_DRIVER":"ADD_VEHICLE")},c(e.type+"_ADD"))))})),R&&l.createElement(a.Modal,{headerBarMain:l.createElement(w,{label:c("DELETE"===_?"ES_FSM_REGISTRY_DELETE_POPUP_HEADER":"ADD_VEHICLE"===_?"ES_FSM_REGISTRY_ADD_VEHICLE_POPUP_HEADER":"ES_FSM_REGISTRY_ADD_DRIVER_POPUP_HEADER")}),headerBarEnd:l.createElement(P,{onClick:W}),actionCancelLabel:c("CS_COMMON_CANCEL"),actionCancelOnSubmit:W,actionSaveLabel:c("DELETE"===_?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{var e;let t=null==b||null===(e=b[0])||void 0===e?void 0:e.dsoDetails,l={};if("DELETE"===_&&(l={vendor:{...t,status:"INACTIVE"}}),"ADD_VEHICLE"===_){var n;let e=A;e.vendorVehicleStatus="ACTIVE",l={vendor:{...t,owner:{...t.owner,gender:(null===(n=t.owner)||void 0===n?void 0:n.gender)||"OTHERS"},vehicles:t.vehicles?[...t.vehicles,e]:[e]}}}if("ADD_DRIVER"===_){var a;let e=A;e.vendorDriverStatus="ACTIVE",l={vendor:{...t,owner:{...t.owner,gender:(null===(a=t.owner)||void 0===a?void 0:a.gender)||"OTHERS"},drivers:t.drivers?[...t.drivers,e]:[e]}}}U(l,{onError:(e,t)=>{y({key:"error",action:e}),setTimeout(K,5e3)},onSuccess:(e,t)=>{y({key:"success",action:"DELETE"===_?"DELETE_VENDOR":_}),m.invalidateQueries("DSO_SEARCH"),V(),k(),x(),setTimeout(()=>{K(),"DELETE"===_&&E.push(`/digit-ui/${G}/fsm/registry`)},5e3)}}),N(!1),D(null)}},l.createElement(a.Card,{style:{boxShadow:"none"}},"DELETE"===_?l.createElement(L,{t:c,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VEHICLE"===_?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,c("ES_FSM_REGISTRY_SELECT_VEHICLE")),l.createElement(a.Dropdown,{t:c,option:T,value:A,selected:A,select:f,optionKey:"registrationNumber"})):"ADD_DRIVER"===_?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,c("ES_FSM_REGISTRY_SELECT_DRIVER")),l.createElement(a.Dropdown,{t:c,option:C,value:A,selected:A,select:f,optionKey:"name"})):void 0)),g&&l.createElement(a.Toast,{error:"error"===g.key,label:c("success"===g.key?`ES_FSM_REGISTRY_${g.action}_SUCCESS`:g.action),onClose:K}),l.createElement(a.ActionBar,{style:{zIndex:"19"}},S?l.createElement(a.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE","HOME"],t:c,onSelect:Y}):null,l.createElement(a.SubmitBar,{label:c("ES_COMMON_TAKE_ACTION"),onSubmit:()=>p(!S)}))))},AddVehicle:e=>{const o=Digit.ULBService.getCurrentTenantId(),d=Digit.ULBService.getStateId(),[u,c]=t.useState(null),E=n.useHistory(),{t:m}=i.useTranslation(),v=r.useQueryClient(),[,S]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,p]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,_]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),{mutate:D}=Digit.Hooks.fsm.useVehicleCreate(o);t.useEffect(()=>{S(!1),_(),p()},[]);const R=function(e,t){return void 0===t&&(t=!1),[{head:"ES_FSM_REGISTRY_VEHICLE_DETAILS",body:[{label:"ES_FSM_REGISTRY_VEHICLE_NUMBER",isMandatory:!0,type:"text",disable:t,populators:{name:"registrationNumber",ValidationRequired:!0,validation:{pattern:"^[A-Z]{2}-[0-9]{1,2}[A-Z]{0,2}-(?:[A-Z]{1,2}-)?[0-9]{1,4}$",title:e("ES_FSM_VEHICLE_FORMAT_TIP")},error:e("FSM_REGISTRY_INVALID_REGISTRATION_NUMBER"),defaultValue:""}},{label:"ES_VENDOR_REGISTRY_SERVICE_TYPE",isMandatory:!0,type:"component",key:"serviceType",component:"SelectServiceType",disable:t,populators:{name:"serviceType",defaultValue:{code:"WT",name:"WT",i18nKey:"WT"}},texts:{header:"CS_COMMON_CHOOSE_SERVICE_TYPE",submitBarLabel:"CS_COMMON_NEXT"}},{route:"vehicle",component:"SelectVehicleType",withoutLabel:!0,key:"vehicle",isMandatory:!0,type:"component"},{label:"ES_FSM_REGISTRY_VEHICLE_POLLUTION_CERT",isMandatory:!1,type:"custom",key:"pollutionCert",populators:{name:"pollutionCert",validation:{required:!0},component:(e,t)=>l.createElement(ee,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_VEHICLE_INSURANCE",isMandatory:!1,type:"custom",key:"insurance",populators:{name:"insurance",validation:{required:!0},component:(e,t)=>l.createElement(ee,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_VEHICLE_ROAD_TAX",isMandatory:!1,type:"custom",key:"roadTax",populators:{name:"roadTax",validation:{required:!0},component:(e,t)=>l.createElement(ee,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_NEW_FITNESS",isMandatory:!1,type:"custom",key:"fitnessValidity",populators:{name:"fitnessValidity",validation:{required:!0},component:(e,t)=>l.createElement(ee,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_NEW_VEHICLE_OWNER_NAME",isMandatory:!0,type:"text",disable:t,populators:{name:"ownerName",validation:{required:!0,pattern:{value:/^[A-Za-z\s.,/]+$/,message:e("FSM_REGISTRY_INVALID_NAME")}},error:e("FSM_REGISTRY_INVALID_NAME"),defaultValue:""}},{label:"ES_FSM_REGISTRY_NEW_VEHICLE_OWNER_PHONE",isMandatory:!0,type:"mobileNumber",key:"phone",disable:t,populators:{name:"phone",validation:{required:!0,pattern:/^[6-9]\d{9}$/},error:e("FSM_REGISTRY_INVALID_PHONE"),defaultValue:""}},{label:"ES_FSM_REGISTRY_NEW_GENDER",isMandatory:!0,type:"component",route:"select-gender",hideInEmployee:!1,key:"selectGender",component:"SelectGender"},{label:e("ES_FSM_REGISTRY_NEW_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(ee,s({onChange:e.onChange,date:e.value},t,{max:(()=>{const e=new Date;return e.setFullYear(e.getFullYear()-18),e.toISOString().split("T")[0]})()}))}},{label:"ES_FSM_REGISTRY_NEW_EMAIL",isMandatory:!1,type:"text",key:"emailId",populators:{name:"emailId",validation:{required:!1,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("FSM_REGISTRY_INVALID_EMAIL"),defaultValue:""}}]}]}(m);R[0].body.forEach(e=>{"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.label&&(e.labelChildren=l.createElement("div",{className:"tooltip",style:{paddingLeft:"10px",marginBottom:"-3px"}},l.createElement(a.InfoIcon,null),l.createElement("span",{className:"tooltiptext",style:{width:"320px",left:"230%",fontSize:"14px"}},e.populators.validation.title)))});const[N,g]=t.useState(!1),y=()=>{c(null)};return l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{route:"vendor-details",timeLine:[{actions:m("ES_FSM_REGISTRY_TITLE_NEW_VEHICLE"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormComposer,{isDisabled:!N,label:m("ES_COMMON_APPLICATION_SUBMIT"),config:R.filter(e=>!e.hideInEmployee).map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0,body:e.body.filter(e=>!e.hideInEmployee)})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,a,i,r,s,u;const m=null==e?void 0:e.registrationNumber,S=null==e||null===(t=e.vehicle)||void 0===t||null===(l=t.type)||void 0===l?void 0:l.code,p=null==e||null===(n=e.vehicle)||void 0===n||null===(a=n.modal)||void 0===a?void 0:a.code,_=null==e||null===(i=e.vehicle)||void 0===i||null===(r=i.type)||void 0===r?void 0:r.capacity,R=new Date(""+(null==e?void 0:e.pollutionCert)).getTime(),N=new Date(""+(null==e?void 0:e.insurance)).getTime(),g=new Date(""+(null==e?void 0:e.roadTax)).getTime(),T=new Date(""+(null==e?void 0:e.fitnessValidity)).getTime(),I=null==e?void 0:e.ownerName,C=null==e?void 0:e.phone,O=null==e||null===(s=e.serviceType)||void 0===s?void 0:s.code,A=null==e||null===(u=e.selectGender)||void 0===u?void 0:u.code,f=null==e?void 0:e.emailId,b=new Date(""+e.dob).getTime()||new Date("1/1/1970").getTime(),h="WT_VENDOR"===Digit.UserService.getType();D({vehicle:{tenantId:h?o:"dl.djb",registrationNumber:m,model:p,type:S,tankCapacity:_,suctionType:"SEWER_SUCTION_MACHINE",pollutionCertiValidTill:R,InsuranceCertValidTill:N,fitnessValidTill:T,roadTaxPaidTill:g,gpsEnabled:!0,source:"Municipal records",owner:{tenantId:d,name:I,fatherOrHusbandName:I,relationship:"OTHER",correspondenceAddress:"",mobileNumber:C,gender:A,dob:b,emailId:f||"abc@egov.com"},additionalDetails:{serviceType:O}}},{onError:(e,t)=>{c({key:"error",action:e}),setTimeout(y,5e3)},onSuccess:(e,t)=>{c({key:"success",action:"ADD_VEHICLE"}),v.invalidateQueries("FSM_VEICLES_SEARCH"),setTimeout(()=>{y(),E.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=VEHICLE")},3e3)}})},defaultValues:{serviceType:{code:"WT",name:"WT",i18nKey:"WT"},tripData:{noOfTrips:1,amountPerTrip:null,amount:null}},onFormValueChange:(e,t)=>{var l,n;if(null!=t&&t.registrationNumber){let l=(e=>{const t=e.toUpperCase().replace(/[^A-Z0-9]/g,"");if(t.length<=2)return t;const l=t.slice(0,2),n=t.slice(2);if(!n)return l;const a=n.match(/^(\d{1,2})/);if(!a)return l+"-"+n;const i=a[1],o=n.slice(i.length),r=o.match(/^([A-Z]*)/),s=r?r[1]:"",d=o.slice(s.length);if(!d)return l+"-"+i+s;if(s.length>=3){const e=s.length<=3?1:2;return l+"-"+i+s.slice(0,e)+"-"+s.slice(e)+"-"+d.slice(0,4)}return l+"-"+i+s+"-"+d.slice(0,4)})(t.registrationNumber);l.length>15&&(l=l.slice(0,15)),l!==t.registrationNumber&&e("registrationNumber",l)}null!=t&&t.registrationNumber&&null!=t&&t.ownerName&&null!=t&&t.phone&&null!=t&&null!==(l=t.vehicle)&&void 0!==l&&l.modal&&null!=t&&null!==(n=t.vehicle)&&void 0!==n&&n.type&&null!=t&&t.selectGender&&null!=t&&t.dob&&new Date(null==t?void 0:t.dob).getTime()<=(new Date).setFullYear((new Date).getFullYear()-18)?g(!0):g(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),u&&l.createElement(a.Toast,{error:"error"===u.key,label:m("success"===u.key?`ES_FSM_REGISTRY_${u.action}_SUCCESS`:u.action),onClose:y})))},VENDORCreate:e=>{var t,a,o,s;const d=r.useQueryClient(),u=n.useRouteMatch(),{t:c}=i.useTranslation(),{pathname:E}=n.useLocation(),m=n.useHistory();let v=[];const[S,p,_]=Digit.Hooks.useSessionStorage("VENDOR_Test",{});function D(e,t,l,n,a){if(void 0===a&&(a=!1),"owners"===e){let l=S.owners||[];l[n]=t,p({...S,[e]:[...l]})}else if("units"===e){let e=S.units||[];e=t,p({...S,units:e})}else p({...S,[e]:{...S[e],...t}});((e,t,l,n)=>{let a,i=E.split("/").pop(),o=i.charAt(i.length-1),r=!1;Number(parseInt(i))||"0"===i||"-1"===i?"-1"===i||"-2"===i?(i=E.slice(0,-3),i=i.split("/").pop(),r=!0):(i=E.slice(0,-2),i=i.split("/").pop(),r=!0):r=!1,isNaN(o)||(r=!0);let{nextStep:s={}}=v.find(e=>e.route===(i||"0")),d=m.push;if(e&&(d=m.replace),l&&(s=n),null===s)return console.log("matchhhhh pathhhh",u.path),d(u.path+"/check");a=isNaN(s.split("/").pop())&&r&&"map"!==s?`${u.path}/${s}/${t}`:`${u.path}/${s}`,d(a)})(l,n,a,e)}S&&Object.keys(S).length>0&&window.location.href.includes("/info")&&"true"!==sessionStorage.getItem("docReqScreenByBack")&&(_(),d.invalidateQueries("VENDOR_CREATE"));const R=()=>{},N=()=>{};q.forEach(e=>{v=v.concat(e.body.filter(e=>!e.hideInCitizen))}),v.indexRoute="info";const g=null===(t=Digit)||void 0===t||null===(a=t.ComponentRegistryService)||void 0===a?void 0:a.getComponent("VENDORCheckPage"),y=null===(o=Digit)||void 0===o||null===(s=o.ComponentRegistryService)||void 0===s?void 0:s.getComponent("NewResponse");return l.createElement(l.Fragment,null,l.createElement(n.Switch,null,v.map((e,t)=>{const{component:a,texts:i,inputs:o,key:r}=e,s="string"==typeof a?Digit.ComponentRegistryService.getComponent(a):a;return l.createElement(n.Route,{path:`${u.path}/${e.route}`,key:t},l.createElement(s,{config:{texts:i,inputs:o,key:r},onSelect:D,onSkip:R,t:c,formData:S,onAdd:N}))}),l.createElement(n.Route,{path:u.path+"/check"},l.createElement(g,{onSubmit:function(){try{return m.push(u.path+"/acknowledgement"),Promise.resolve()}catch(e){return Promise.reject(e)}},value:S})),l.createElement(n.Route,{path:u.path+"/acknowledgement"},l.createElement(y,{data:S,onSuccess:()=>{_(),d.invalidateQueries("VENDOR_CREATE")}})),l.createElement(n.Route,null,l.createElement(n.Redirect,{to:`${u.path}/${v.indexRoute}`}))))},VENDORCheckPage:e=>{var n,o,r,s;let{onSubmit:d,value:u={}}=e;const{t:E}=i.useTranslation(),{vendordet:m,documents:v}=u;console.log("vendordetailssppsss",m),console.log("documents",v);const[S,p]=t.useState(!1);return l.createElement(l.Fragment,null,window.location.href.includes("/employee")?l.createElement(a.VerticalTimeline,{config:[{timeLine:[{actions:E("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:E("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:E("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:2,showFinalStep:!1}):null,l.createElement("div",{style:{flex:"1",overflowY:"auto",marginBottom:"20px"}},l.createElement(a.Card,null,l.createElement(a.CardHeader,null,E("VENDOR_CHECK_DETAILS")),l.createElement("div",null,l.createElement("br",null),l.createElement(a.CardSubHeader,null,E("VENDOR_ADDITIONAL_DETAILS")),l.createElement(a.StatusTable,null,l.createElement(l.Fragment,null,l.createElement(a.Row,{label:E("VENDOR_ID"),text:""+E(c(null==m?void 0:m.VendorId)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("VENDOR_BANK_IFSC_CODE"),text:""+E(c(null==m?void 0:m.IFSC)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("VENDOR_BANK_NAME"),text:""+E(c(null==m?void 0:m.Bank)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("VENDOR_BANK_BRANCH"),text:""+E(c(null==m?void 0:m.BankbranchName)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("VENDOR_MICR_NO"),text:""+E(c(null==m?void 0:m.micrNo)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("BANK_ACCONT_NO"),text:""+E(c(null==m?void 0:m.AccountNo)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("PAN_NO"),text:""+E(c(null==m?void 0:m.PanNo)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("GST_NO"),text:""+E(c(null==m?void 0:m.GstNo)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("GST_REGISTERED_STATE/UT"),text:""+E(c(null==m?void 0:m.GstState)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-detailss"})}),l.createElement(a.Row,{label:E("REGISTRATION_NO"),text:""+E(c(null==m?void 0:m.RegistrationNo)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("EPF_NO"),text:""+E(c(null==m?void 0:m.EpfNo)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("ESI_NO"),text:""+E(c(null==m?void 0:m.EsiNo)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("VENDOR_TYPE"),text:""+E(c(null==m||null===(n=m.VendorType)||void 0===n?void 0:n.code)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("VENDOR_CATEGORY"),text:""+E(c(null==m||null===(o=m.VendorCategory)||void 0===o?void 0:o.code)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:E("VENDOR_STATUS"),text:""+E(c(null==m||null===(r=m.Status)||void 0===r?void 0:r.code)),actionButton:l.createElement(W,{jumpTo:"/digit-ui/employee/vendor/registry/additionaldetails/vendor-details"})}))),l.createElement("br",null),l.createElement(a.CardSubHeader,null,E("VENDOR_DOCUMENTS_DETAILS")),l.createElement(a.StatusTable,null,l.createElement(a.StatusTable,null,l.createElement(a.Row,{label:E("VENDOR_DOCUMENTS"),text:(null==v||null===(s=v.documents)||void 0===s?void 0:s.length)>0?v.documents.map((e,t)=>l.createElement("div",{key:t},l.createElement("span",{style:{color:"#5a6ee1",cursor:"pointer",textDecoration:"underline"},onClick:()=>{var t;(t=null==e?void 0:e.filestoreId)?Digit.UploadServices.Filefetch([t],Digit.ULBService.getStateId()).then(e=>{var t,l,n;const a=null==e||null===(t=e.data)||void 0===t||null===(l=t.fileStoreIds)||void 0===l||null===(n=l[0])||void 0===n?void 0:n.url;if(a){const e=a.split(",")[0];if(e){const t=document.createElement("a");t.href=e,t.target="_blank",t.rel="noopener noreferrer",document.body.appendChild(t),t.click(),document.body.removeChild(t)}}else console.error("URL missing in response. Full res:",e)}):console.error("fileId is null or undefined!")}},E(e.documentType)))):E("CS_NA")}))),l.createElement("br",null),l.createElement(a.CheckBox,{label:E("AST_FINAL_DECLARATION_MESSAGE"),onChange:()=>{p(!S)},styles:{height:"auto"},checked:S})),l.createElement("br",null),l.createElement("div",{className:"formcomposer-section-button"},l.createElement(a.SubmitBar,{label:E("COMMON_BUTTON_SUBMIT"),onSubmit:d,disabled:!S})))))},NewResponse:e=>{let{data:o,onSuccess:r}=e;const{t:s}=i.useTranslation(),d=Digit.Hooks.vendor.useVendorAdditionaldetailsAPI(Digit.ULBService.getCurrentTenantId());return t.useEffect(()=>{try{var e,t;o.tenantId=null===(e=o.address)||void 0===e||null===(t=e.city)||void 0===t?void 0:t.code;let l=(e=>{var t,l,n,a,i,o,r,s,d,u,c,E,m,v,S,p,_,D,R,N,g,y,T,I,C;return{VendorAdditionalDetails:{tenantId:Digit.ULBService.getCurrentTenantId(),code:"VENDOR12345454",name:(null==e||null===(t=e.vendordet)||void 0===t?void 0:t.userName)||"N/A",vendorCompany:null==e||null===(l=e.vendordet)||void 0===l?void 0:l.Company,vendorPhone:null==e||null===(n=e.vendordet)||void 0===n?void 0:n.PhoneNo,vendorEmail:"vendor@example.com",contactPerson:null==e||null===(a=e.vendordet)||void 0===a?void 0:a.ContactPerson,vendorMobileNumber:"9876543210",bankAccountNumber:null==e||null===(i=e.vendordet)||void 0===i?void 0:i.AccountNo,bank:null==e||null===(o=e.vendordet)||void 0===o?void 0:o.Bank,bankBranchName:null==e||null===(r=e.vendordet)||void 0===r?void 0:r.BankbranchName,micrNo:null==e||null===(s=e.vendordet)||void 0===s?void 0:s.micrNo,epfNo:null==e||null===(d=e.vendordet)||void 0===d?void 0:d.EpfNo,esiNo:null==e||null===(u=e.vendordet)||void 0===u?void 0:u.EsiNo,gstRegisteredState:null==e||null===(c=e.vendordet)||void 0===c?void 0:c.GstState,ifscCode:null==e||null===(E=e.vendordet)||void 0===E?void 0:E.IFSC,panNo:null==e||null===(m=e.vendordet)||void 0===m?void 0:m.PanNo,registrationNo:null==e||null===(v=e.vendordet)||void 0===v?void 0:v.RegistrationNo,status:null==e||null===(S=e.vendordet)||void 0===S||null===(p=S.Status)||void 0===p?void 0:p.code,vendorCategory:null==e||null===(_=e.vendordet)||void 0===_||null===(D=_.VendorCategory)||void 0===D?void 0:D.code,vendorId:null==e||null===(R=e.vendordet)||void 0===R?void 0:R.VendorId,gstTinNo:null==e||null===(N=e.vendordet)||void 0===N?void 0:N.GstNo,serviceType:null==e||null===(g=e.vendordet)||void 0===g||null===(y=g.VendorType)||void 0===y?void 0:y.code,documents:null==e||null===(T=e.documents)||void 0===T?void 0:T.documents,active:null,vendorAdditionalDetailsId:null,vendorGroup:(null==e||null===(I=e.vendordet)||void 0===I?void 0:I.vendorGroup)||"N/A",vendorType:(null==e||null===(C=e.vendordet)||void 0===C?void 0:C.vendorType)||"N/A"}}})(o);console.log("formdata in acknowejkfdlgi ::: ",l),d.mutate(l,{onSuccess:r}),console.log("mutation in acknowejkfdlgi ::: ",d)}catch(e){}},[]),d.isLoading||d.isIdle?l.createElement(a.Loader,null):l.createElement(a.Card,{className:"vehicle-details-card"},l.createElement(X,{t:s,data:d.data,isSuccess:d.isSuccess,isLoading:d.isIdle||d.isLoading}),l.createElement(a.StatusTable,null,d.isSuccess&&l.createElement(a.Row,{rowContainerStyle:z,last:!0,textStyle:{whiteSpace:"pre",width:"60%"}})),l.createElement(n.Link,{to:"/digit-ui/employee"},l.createElement(a.LinkButton,{label:s("CORE_COMMON_GO_TO_HOME")})))},DriverDetails:()=>{var e,o;const s=Digit.ULBService.getCurrentTenantId(),{t:d}=i.useTranslation(),u=n.useHistory(),c=r.useQueryClient(),{id:E}=n.useParams(),[m,v]=t.useState(!1),[S,p]=t.useState(null),[_,D]=t.useState(!1),[R,N]=t.useState(null),[g,y]=t.useState([]),[T,I]=t.useState({}),{data:C,isLoading:O,refetch:A}=Digit.Hooks.fsm.useDriverDetails(s,{ids:E},{staleTime:Infinity}),{data:f}=Digit.Hooks.fsm.useDsoSearch(s,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{mutate:b}=Digit.Hooks.fsm.useDriverUpdate(s),{mutate:h}=Digit.Hooks.fsm.useVendorUpdate(s);function V(e){p(e),v(!1)}t.useEffect(()=>{if(f){let e=f.map(e=>e.dsoDetails);y(e)}},[f]),t.useEffect(()=>{A()},[]),t.useEffect(()=>{switch(S){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return D(!0);case"EDIT":return u.push("/digit-ui/employee/fsm/registry/modify-driver/"+E);case"HOME":return u.push("/digit-ui/employee/fsm/registry?selectedTabs=DRIVER")}},[S]);const M=()=>{N(null)},w=()=>{p(null),I({}),D(!1)},k=()=>"DELETE"===S||"DELETE_VENDOR"===S?l.createElement(L,{t:d,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===S||"EDIT_VENDOR"===S?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,d("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(a.Dropdown,{t:d,option:g,value:T,selected:T,select:I,optionKey:"name"})):void 0;return O||O?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(a.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==C||null===(e=C[0])||void 0===e||null===(o=e.employeeResponse)||void 0===o?void 0:o.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(a.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},d(e.title)),l.createElement(a.Card,{className:"card-with-background",style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"additional-grid"},null==e||null===(n=e.values)||void 0===n?void 0:n.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},d(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},d(e.value)||"N/A","ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"===e.value&&l.createElement("span",{className:"add-details-link hover-button",onClick:()=>V("ADD_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.AddIcon,{className:"",fill:"#a82227"})),"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"!==e.value&&l.createElement("div",{className:"add-details-link hover-button",onClick:()=>V("EDIT_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.EditIcon,null)),"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"!==e.value&&l.createElement("div",{className:"add-details-link hover-button",onClick:()=>V("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.DeleteIcon,{className:"delete",fill:"#a82227"}))):l.createElement("div",{className:"additional-value"},d(e.value)||"N/A"))))))}))),_&&l.createElement(a.Modal,{headerBarMain:l.createElement(Q,{label:d((()=>{switch(S){case"DELETE":case"DELETE_VENDOR":return"ES_FSM_REGISTRY_DELETE_POPUP_HEADER";case"ADD_VENDOR":case"EDIT_VENDOR":return"ES_FSM_REGISTRY_ADD_VENDOR_POPUP_HEADER"}})())}),headerBarEnd:l.createElement(J,{onClick:w}),actionCancelLabel:d("CS_COMMON_CANCEL"),actionCancelOnSubmit:w,actionSaveLabel:d("DELETE"===S||"DELETE_VENDOR"===S?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(S){case"DELETE":return(()=>{var e;const t={driver:{...null==C||null===(e=C[0])||void 0===e?void 0:e.driverData,status:"INACTIVE"}};b(t,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"DELETE_DRIVER"}),c.invalidateQueries("DSO_SEARCH"),setTimeout(()=>{M(),u.push("/digit-ui/employee/fsm/registry")},5e3)}}),D(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let a={},i=null==C||null===(e=C[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],o=null==i?void 0:i.drivers;o=o.map(e=>(e.id===E&&(e.vendorDriverStatus="INACTIVE"),e)),a={vendor:{...i,owner:{...i.owner,gender:(null===(n=i.owner)||void 0===n?void 0:n.gender)||"OTHERS"},drivers:o}},h(a,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"DELETE_VENDOR"}),c.invalidateQueries("FSM_VENDOR_SEARCH"),A(),setTimeout(M,5e3)}}),D(!1)})();case"ADD_VENDOR":return(()=>{var e,t;let l=T,n=null==C||null===(e=C[0])||void 0===e?void 0:e.driverData;n.vendorDriverStatus="ACTIVE";const a={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},drivers:l.drivers?[...l.drivers,n]:[n]}};h(a,{onError:(e,t)=>{N({key:"error",action:e}),A(),setTimeout(M,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"ADD_VENDOR"}),c.invalidateQueries("DSO_SEARCH"),A(),setTimeout(M,5e3)}}),D(!1),p(null)})();case"EDIT_VENDOR":return(()=>{var e,t;let l=T,n=null==C||null===(e=C[0])||void 0===e?void 0:e.driverData;n.vendorDriverStatus="ACTIVE";const a={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},drivers:l.drivers?[...l.drivers,n]:[n]}};h(a,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"EDIT_VENDOR"}),A(),c.invalidateQueries("DSO_SEARCH"),setTimeout(M,5e3)}}),D(!1),p(null)})()}},formId:"modal-action"},"DELETE"===S||"DELETE_VENDOR"===S?k():l.createElement(a.Card,{style:{boxShadow:"none"}},k())),R&&l.createElement(a.Toast,{error:"error"===R.key,label:d("success"===R.key?`ES_FSM_REGISTRY_${R.action}_SUCCESS`:R.action),onClose:M}),l.createElement(a.ActionBar,{style:{zIndex:"19"}},m?l.createElement(a.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:d,onSelect:V}):null,l.createElement(a.SubmitBar,{label:d("ES_COMMON_TAKE_ACTION"),onSubmit:()=>v(!m)})))},VehicleDetails:e=>{var o,s;const d=Digit.ULBService.getCurrentTenantId(),{t:u}=i.useTranslation(),c=n.useHistory(),E=r.useQueryClient();let{id:m}=n.useParams();const[v,S]=t.useState(!1),[p,_]=t.useState(null),[D,R]=t.useState(!1),[N,g]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),[O,A]=t.useState(null),{data:f,isLoading:b,refetch:h}=Digit.Hooks.fsm.useVehicleDetails(d,{registrationNumber:m},{staleTime:Infinity});t.useEffect(()=>{var e,t;!b&&f&&A(null==f||null===(e=f[0])||void 0===e||null===(t=e.vehicleData)||void 0===t?void 0:t.id)},[f,b]);const{data:V}=Digit.Hooks.fsm.useDsoSearch(d,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{});t.useEffect(()=>{if(V){let e=V.map(e=>e.dsoDetails);T(e)}},[V]);const{mutate:M}=Digit.Hooks.fsm.useUpdateVehicle(d),{mutate:w}=Digit.Hooks.fsm.useVendorUpdate(d);function k(e){S(!1),_(e)}t.useEffect(()=>{h()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return R(!0);case"EDIT":return c.push("/digit-ui/employee/fsm/registry/modify-vehicle/"+m);case"HOME":return c.push("/digit-ui/employee/fsm/registry?selectedTabs=VEHICLE")}},[p]);const P=()=>{g(null)},F=()=>{_(null),C({}),R(!1)},x=()=>"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(L,{t:u,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(a.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0;return b?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,b?l.createElement(a.Loader,null):l.createElement("div",{className:"employee-form-content"},l.createElement(a.Card,{className:"vehicle-details-card",style:{position:"relative"}},null==f||null===(o=f[0])||void 0===o||null===(s=o.employeeResponse)||void 0===s?void 0:s.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(a.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(a.Card,{className:"card-with-background",style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"additional-grid"},null==e||null===(n=e.values)||void 0===n?void 0:n.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},u(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{display:"flex",alignItems:"center",gap:"8px"}},"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"===e.value&&l.createElement("div",{onClick:()=>k("ADD_VENDOR"),style:{color:"#a82227",display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"}},l.createElement(a.AddIcon,{className:"",fill:"#a82227"})," ",u(e.value)||"N/A"),"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"!==e.value&&l.createElement(l.Fragment,null,l.createElement("span",null,e.value),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>k("EDIT_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.EditIcon,{fill:"#a82227"})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>k("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.DeleteIcon,{className:"delete",fill:"#a82227"})))):l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},u(e.value)||"N/A"))))))})),D&&l.createElement(a.Modal,{headerBarMain:l.createElement(te,{label:u((()=>{switch(p){case"DELETE":case"DELETE_VENDOR":return"ES_FSM_REGISTRY_DELETE_POPUP_HEADER";case"ADD_VENDOR":case"EDIT_VENDOR":return"ES_FSM_REGISTRY_ADD_VENDOR_POPUP_HEADER"}})())}),headerBarEnd:l.createElement(ne,{onClick:F}),actionCancelLabel:u("CS_COMMON_CANCEL"),actionCancelOnSubmit:F,actionSaveLabel:u("DELETE"===p||"DELETE_VENDOR"===p?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(p){case"DELETE":return(()=>{var e;const t={vehicle:{...null==f||null===(e=f[0])||void 0===e?void 0:e.vehicleData,status:"INACTIVE"}};M(t,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"DELETE_VEHICLE"}),E.invalidateQueries("FSM_VEICLES_SEARCH"),setTimeout(()=>{P(),c.push("/digit-ui/employee/fsm/registry")},5e3)}}),R(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let a={},i=null==f||null===(e=f[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],o=null==i?void 0:i.vehicles;o=o.map(e=>(e.id===O&&(e.vendorVehicleStatus="INACTIVE"),e)),a={vendor:{...i,owner:{...i.owner,gender:(null===(n=i.owner)||void 0===n?void 0:n.gender)||"OTHERS"},vehicles:o}},w(a,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),h(),setTimeout(P,5e3)}}),R(!1)})();case"ADD_VENDOR":return(()=>{var e,t;let l=I,n=null==f||null===(e=f[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const a={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},vehicles:l.vehicles?[...l.vehicles,n]:[n]}};w(a,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"EDIT_VENDOR"}),h(),E.invalidateQueries("DSO_SEARCH"),setTimeout(P,5e3)}}),R(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e,t;let l=I,n=null==f||null===(e=f[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const a={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},vehicles:l.vehicles?[...l.vehicles,n]:[n]}};w(a,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"EDIT_VENDOR"}),h(),E.invalidateQueries("DSO_SEARCH"),setTimeout(P,5e3)}}),R(!1),_(null)})()}}},"DELETE"===p||"DELETE_VENDOR"===p?x():l.createElement(a.Card,{style:{boxShadow:"none"}},x())),N&&l.createElement(a.Toast,{error:"error"===N.key,label:u("success"===N.key?`ES_FSM_REGISTRY_${N.action}_SUCCESS`:N.action),onClose:P}),l.createElement(a.ActionBar,{style:{zIndex:"19"}},v?l.createElement(a.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:u,onSelect:k}):null,l.createElement(a.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)}))))},AddSupervisor:e=>{var n;const o=Digit.ULBService.getCurrentTenantId(),{t:s}=i.useTranslation(),[d,u]=t.useState(null),c=r.useQueryClient(),[E,m]=t.useState(!1),{mutate:v}=Digit.Hooks.fsm.useSupervisorCreate(o),{data:S}=Digit.Hooks.fsm.useVendorSearch(o,{status:"ACTIVE"}),p=function(e,t,n,a){return void 0===t&&(t=[]),void 0===n&&(n=[]),void 0===a&&(a=!1),[{head:"ES_VENDOR_SUPERVISOR_BASIC_DETAILS",body:[{label:"ES_VENDOR_SUPERVISOR_FULL_NAME",isMandatory:!0,type:"text",disable:a,populators:{name:"fullName",validation:{required:!0,pattern:{value:/^[A-Za-z\s]+$/,message:e("ES_VENDOR_INVALID_NAME")}},error:e("ES_VENDOR_INVALID_NAME"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_SUPERVISOR_MOBILE_NUMBER",isMandatory:!0,type:"mobileNumber",disable:a,populators:{name:"mobileNumber",validation:{required:!0,pattern:/^[6-9]\d{9}$/},error:e("ES_VENDOR_INVALID_MOBILE"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_SUPERVISOR_EMAIL_ID",isMandatory:!0,type:"text",populators:{name:"emailId",validation:{required:!0,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("ES_VENDOR_INVALID_EMAIL"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_SUPERVISOR_EMPLOYEE_ID",isMandatory:!0,type:"text",populators:{name:"employeeId",validation:{required:!0},defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_SUPERVISOR_GENDER",isMandatory:!1,type:"component",key:"gender",component:"SelectGender",texts:{headerCaption:"",header:"CS_COMMON_CHOOSE_GENDER",cardText:"CS_COMMON_SELECT_GENDER",submitBarLabel:"CS_COMMON_NEXT",skipText:"CORE_COMMON_SKIP_CONTINUE"}}]},{head:"ES_VENDOR_SUPERVISOR_ROLE_ACCESS",body:[{label:"ES_VENDOR_SUPERVISOR_ROLE",isMandatory:!0,type:"custom",populators:{name:"role",component:(t,n)=>l.createElement(F,{option:[{code:"SUPERVISOR",name:"Supervisor"}],optionKey:"name",select:t.onChange,selected:t.value,t:e,disable:!0}),defaultValue:{code:"SUPERVISOR",name:"Supervisor"}}},{label:"ES_VENDOR_SUPERVISOR_AGENCY_NAME",isMandatory:!0,type:"custom",populators:{name:"agencyName",component:(n,a)=>l.createElement(F,{option:t,optionKey:"name",select:n.onChange,selected:n.value,t:e})}},{label:"ES_VENDOR_SUPERVISOR_REPORTING_MANAGER",isMandatory:!1,type:"custom",populators:{name:"reportingManager",component:(t,a)=>l.createElement(F,{option:n,optionKey:"name",select:t.onChange,selected:t.value,t:e})}}]},{head:"ES_VENDOR_SUPERVISOR_AREA_ASSIGNMENT",body:[{type:"component",component:"SupervisorAreaAssignment",key:"areaAssignment",withoutLabel:!0}]}]}(s,(null==S||null===(n=S.vendor)||void 0===n?void 0:n.map(e=>({code:e.id,name:e.name,...e})))||[],[{code:"MGR1",name:"John Doe (Agency Admin)"},{code:"MGR2",name:"Jane Smith (Agency Admin)"}]),_=()=>{u(null)};return l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{route:"supervisor-details",timeLine:[{actions:s("ES_VENDOR_SUPERVISOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormComposer,{isDisabled:!E,label:s("ES_COMMON_APPLICATION_SUBMIT"),config:p.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n;const a={supervisor:{tenantId:o,name:null==e?void 0:e.fullName,employeeId:null==e?void 0:e.employeeId,status:"ACTIVE",owner:{tenantId:o,name:null==e?void 0:e.fullName,gender:(null==e||null===(t=e.gender)||void 0===t?void 0:t.code)||"OTHERS",emailId:null==e?void 0:e.emailId,mobileNumber:null==e?void 0:e.mobileNumber},vendorSupervisorStatus:"ACTIVE",additionalDetails:{agencyId:null==e||null===(l=e.agencyName)||void 0===l?void 0:l.code,reportingManager:null==e||null===(n=e.reportingManager)||void 0===n?void 0:n.code,areaAssignment:null==e?void 0:e.areaAssignment}}};v(a,{onError:e=>{u({key:"error",action:e}),setTimeout(_,5e3)},onSuccess:()=>{u({key:"success",action:"ADD_SUPERVISOR"}),c.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(_,5e3)}})},defaultValues:{role:{code:"SUPERVISOR",name:"Supervisor"}},onFormValueChange:(e,t)=>{var l,n,a,i,o;const r=(null==t||null===(l=t.areaAssignment)||void 0===l?void 0:l.zone)&&(null==t||null===(n=t.areaAssignment)||void 0===n?void 0:n.cluster)&&(null==t||null===(a=t.areaAssignment)||void 0===a?void 0:a.ward)&&(null==t||null===(i=t.areaAssignment)||void 0===i||null===(o=i.areas)||void 0===o?void 0:o.length)>0;m(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.employeeId)&&(null==t?void 0:t.agencyName)&&r))},noBreakLine:!0,mode:"onChange",noCard:!0}),d&&l.createElement(a.Toast,{error:"error"===d.key,label:s("success"===d.key?`ES_VENDOR_${d.action}_SUCCESS`:d.action),onClose:_})))},SupervisorDetails:e=>{var o,s;const d=Digit.ULBService.getCurrentTenantId(),{t:u}=i.useTranslation(),c=n.useHistory(),E=r.useQueryClient(),{id:m}=n.useParams(),[v,S]=t.useState(!1),[p,_]=t.useState(null),[D,R]=t.useState(!1),[N,g]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),{data:O,isLoading:A,refetch:f}=Digit.Hooks.fsm.useSupervisorDetails(d,{ids:m},{staleTime:Infinity}),{data:b}=Digit.Hooks.fsm.useDsoSearch(d,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{mutate:h}=Digit.Hooks.fsm.useSupervisorUpdate(d),{mutate:V}=Digit.Hooks.fsm.useVendorUpdate(d);t.useEffect(()=>{if(b){let e=b.map(e=>e.dsoDetails);T(e)}},[b]),t.useEffect(()=>{f()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return R(!0);case"EDIT":return c.push("/digit-ui/employee/vendor/modify-supervisor/"+m);case"HOME":return c.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SUPERVISOR")}},[p]);const M=()=>{g(null)},w=()=>{_(null),C({}),R(!1)};return A?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(a.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==O||null===(o=O[0])||void 0===o||null===(s=o.employeeResponse)||void 0===s?void 0:s.map((e,t)=>{var n,i;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(a.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(a.Card,{className:"card-with-background",style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"additional-grid"},null==e||null===(n=e.values)||void 0===n?void 0:n.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},u(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},u(e.value)||"N/A","ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"===e.value&&l.createElement("span",{className:"add-details-link hover-button",onClick:()=>_("ADD_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.AddIcon,{fill:"#a82227"})),"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"!==e.value&&l.createElement(l.Fragment,null,l.createElement("div",{className:"add-details-link hover-button",onClick:()=>_("EDIT_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>_("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},u(e.value)||"N/A"))))),null==e||null===(i=e.child)||void 0===i?void 0:i.map((t,n)=>{var i;return l.createElement(a.Card,{className:"card-with-background",key:t.id||n,style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"card-head",style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px"}},l.createElement("h2",{style:{fontSize:"18px",fontWeight:"bold"}},u(e.type)," ",n+1),l.createElement("div",{style:{display:"flex",gap:"15px"}},l.createElement("span",{onClick:()=>c.push("/digit-ui/employee/vendor/registry/modify-surveyor/"+t.id)},l.createElement(a.EditIcon,{fill:"#a82227",style:{cursor:"pointer"}})))),l.createElement("div",{className:"additional-grid"},null==t||null===(i=t.values)||void 0===i?void 0:i.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},u(e.title)),l.createElement("div",{className:"additional-value"},u(e.value)||"N/A")))))}),e.type&&l.createElement("div",{className:"add-details-link hover-button",style:{margin:"10px 16px",color:"#a82227",cursor:"pointer",display:"flex",alignItems:"center",gap:"5px",fontWeight:"bold"},onClick:()=>c.push("/digit-ui/employee/vendor/registry/new-surveyor?supervisorId="+m)},l.createElement(a.AddIcon,{fill:"#a82227"}),u(e.type+"_ADD")))}))),D&&l.createElement(a.Modal,{headerBarMain:l.createElement(Y,{label:u((()=>{switch(p){case"DELETE":case"DELETE_VENDOR":return"ES_VENDOR_SUPERVISOR_DELETE_POPUP_HEADER";case"ADD_VENDOR":case"EDIT_VENDOR":return"ES_VENDOR_SUPERVISOR_ADD_VENDOR_POPUP_HEADER"}})())}),headerBarEnd:l.createElement(K,{onClick:w}),actionCancelLabel:u("CS_COMMON_CANCEL"),actionCancelOnSubmit:w,actionSaveLabel:u("DELETE"===p||"DELETE_VENDOR"===p?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(p){case"DELETE":return(()=>{var e;const t={supervisor:{...null==O||null===(e=O[0])||void 0===e?void 0:e.supervisorData,status:"INACTIVE"}};h(t,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"DELETE_SUPERVISOR"}),E.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(()=>{M(),c.push("/digit-ui/employee/vendor/search-vendor")},5e3)}}),R(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=null==O||null===(e=O[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],a=(null==n?void 0:n.supervisors)||[];a=a.map(e=>(e.id===m&&(e.vendorSupervisorStatus="INACTIVE"),e));const i={vendor:{...n,supervisors:a}};V(i,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),f(),setTimeout(M,5e3)}}),R(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=I,l=null==O||null===(e=O[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:{...t,supervisors:t.supervisors?[...t.supervisors,l]:[l]}};V(n,{onError:e=>{g({key:"error",action:e}),f(),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"ADD_VENDOR"}),E.invalidateQueries("SUPERVISOR_SEARCH"),f(),setTimeout(M,5e3)}}),R(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=I,l=null==O||null===(e=O[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:{...t,supervisors:t.supervisors?[...t.supervisors,l]:[l]}};V(n,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"EDIT_VENDOR"}),f(),E.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(M,5e3)}}),R(!1),_(null)})()}}},l.createElement(a.Card,{style:{boxShadow:"none"}},"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(L,{t:u,title:"ES_VENDOR_SUPERVISOR_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(a.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0)),N&&l.createElement(a.Toast,{error:"error"===N.key,label:u("success"===N.key?`ES_VENDOR_${N.action}_SUCCESS`:N.action),onClose:M}),l.createElement(a.ActionBar,{style:{zIndex:"19"}},v?l.createElement(a.Menu,{localeKeyPrefix:"ES_VENDOR_SUPERVISOR_ACTION",options:["EDIT","DELETE"],t:u,onSelect:e=>{S(!1),_(e)}}):null,l.createElement(a.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)})))},SupervisorAreaAssignment:e=>{var n,i,o,r;let{config:s,onSelect:d,t:u,formData:c}=e;const E=Digit.ULBService.getCurrentTenantId(),[m,v]=t.useState((null==c||null===(n=c.areaAssignment)||void 0===n?void 0:n.zone)||null),[S,p]=t.useState((null==c||null===(i=c.areaAssignment)||void 0===i?void 0:i.cluster)||null),[_,D]=t.useState((null==c||null===(o=c.areaAssignment)||void 0===o?void 0:o.ward)||null),[R,N]=t.useState((null==c||null===(r=c.areaAssignment)||void 0===r?void 0:r.areas)||[]),[g,y]=t.useState([]),[T,I]=t.useState([]),[C,O]=t.useState([]),[A,f]=t.useState([]),{data:b,isLoading:h}=Digit.Hooks.useCommonMDMS(E,"egov-location",["TenantBoundary"]);t.useEffect(()=>{if(b){var e,t,l,n;const a=null==b||null===(e=b.MdmsRes)||void 0===e||null===(t=e["egov-location"])||void 0===t||null===(l=t.TenantBoundary)||void 0===l||null===(n=l[0])||void 0===n?void 0:n.boundary;a&&a.children&&y(a.children)}},[b]),t.useEffect(()=>{var e,t;m?(I(m.children||[]),m.code!==(null==c||null===(e=c.areaAssignment)||void 0===e||null===(t=e.zone)||void 0===t?void 0:t.code)&&(p(null),D(null),N([]))):I([])},[m]),t.useEffect(()=>{var e,t;S?(O(S.children||[]),S.code!==(null==c||null===(e=c.areaAssignment)||void 0===e||null===(t=e.cluster)||void 0===t?void 0:t.code)&&(D(null),N([]))):O([])},[S]),t.useEffect(()=>{var e,t;_?(f(_.children||[]),_.code!==(null==c||null===(e=c.areaAssignment)||void 0===e||null===(t=e.ward)||void 0===t?void 0:t.code)&&N([])):f([])},[_]);const V=(e,t)=>{const l={...null==c?void 0:c.areaAssignment,[e]:t};"zone"===e?(l.cluster=null,l.ward=null,l.areas=[]):"cluster"===e?(l.ward=null,l.areas=[]):"ward"===e&&(l.areas=[]),d(s.key,l)};return h?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,u("ES_VENDOR_SUPERVISOR_ZONE")+" *"),l.createElement(a.Dropdown,{selected:m,option:g,select:e=>{v(e),V("zone",e)},optionKey:"name",t:u})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,u("ES_VENDOR_SUPERVISOR_CLUSTER")+" *"),l.createElement(a.Dropdown,{selected:S,option:T,select:e=>{p(e),V("cluster",e)},optionKey:"name",t:u,disable:!m})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,u("ES_VENDOR_SUPERVISOR_WARD")+" *"),l.createElement(a.Dropdown,{selected:_,option:C,select:e=>{D(e),V("ward",e)},optionKey:"name",t:u,disable:!S})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,u("ES_VENDOR_SUPERVISOR_AREA")+" *"),l.createElement(a.MultiSelectDropdown,{options:A,selected:R,onSelect:e=>{N(e),V("areas",e)},optionsKey:"name",t:u,disable:!_})))},AddSurveyor:e=>{var n;const o=Digit.ULBService.getCurrentTenantId(),{t:s}=i.useTranslation(),[d,u]=t.useState(null),c=r.useQueryClient(),[E,m]=t.useState(!1),{mutate:v}=Digit.Hooks.fsm.useSurveyorCreate(o),{data:S}=Digit.Hooks.fsm.useVendorSearch(o,{status:"ACTIVE"}),p=[{code:"MGR1",name:"John Doe (Agency Admin)"},{code:"SUP1",name:"Jane Smith (Supervisor)"}],_=function(e,t,n,a){return void 0===t&&(t=[]),void 0===n&&(n=[]),[{head:"ES_VENDOR_SURVEYOR_BASIC_DETAILS",body:[{label:"ES_VENDOR_SURVEYOR_FULL_NAME",isMandatory:!0,type:"text",populators:{name:"fullName",validation:{required:!0,pattern:/^[A-Za-z\s]+$/},error:e("ES_VENDOR_INVALID_NAME")}},{label:"ES_VENDOR_SURVEYOR_MOBILE_NUMBER",isMandatory:!0,type:"mobileNumber",populators:{name:"mobileNumber",validation:{required:!0,pattern:/^[6-9]\d{9}$/},error:e("ES_VENDOR_INVALID_MOBILE")}},{label:"ES_VENDOR_SURVEYOR_EMAIL_ID",isMandatory:!0,type:"text",populators:{name:"emailId",validation:{required:!0,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("ES_VENDOR_INVALID_EMAIL")}},{label:"ES_VENDOR_SURVEYOR_STAFF_CODE",isMandatory:!0,type:"text",populators:{name:"employeeId",validation:{required:!0}}},{label:"ES_VENDOR_SURVEYOR_GENDER",isMandatory:!1,type:"component",key:"selectGender",component:"SelectGender",texts:{header:"CS_COMMON_CHOOSE_GENDER",cardText:"CS_COMMON_SELECT_GENDER",submitBarLabel:"CS_COMMON_NEXT"}}]},{head:"ES_VENDOR_SURVEYOR_ROLE_ACCESS",body:[{label:"ES_VENDOR_SURVEYOR_ROLE",isMandatory:!0,type:"custom",populators:{name:"role",component:(t,n)=>l.createElement(x,{option:[{code:"SURVEYOR",name:"Surveyor"}],optionKey:"name",select:t.onChange,selected:t.value,t:e,disable:!0}),defaultValue:{code:"SURVEYOR",name:"Surveyor"}}},{label:"ES_VENDOR_SURVEYOR_AGENCY_NAME",isMandatory:!0,type:"custom",populators:{name:"agencyName",component:(n,a)=>l.createElement(x,{option:t,optionKey:"name",select:n.onChange,selected:n.value,t:e})}},{label:"ES_VENDOR_SURVEYOR_REPORTING_MANAGER",isMandatory:!1,type:"custom",populators:{name:"reportingManager",component:(t,a)=>l.createElement(x,{option:n,optionKey:"name",select:t.onChange,selected:t.value,t:e})}}]},{head:"ES_VENDOR_SURVEYOR_AREA_ASSIGNMENT",body:[{isMandatory:!0,type:"component",key:"areaAssignment",component:"SupervisorAreaAssignment",withoutLabel:!0}]}]}(s,(null==S||null===(n=S.vendor)||void 0===n?void 0:n.map(e=>({code:e.id,name:e.name,...e})))||[],p),{supervisorId:D}=Digit.Hooks.useQueryParams(),R={role:{code:"SURVEYOR",name:"Surveyor"},reportingManager:p.find(e=>e.code===D)||null},N=()=>{u(null)};return l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{route:"surveyor-details",timeLine:[{actions:s("ES_VENDOR_SURVEYOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormComposer,{isDisabled:!E,label:s("ES_COMMON_APPLICATION_SUBMIT"),config:_.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n;const a={surveyor:{tenantId:o,name:null==e?void 0:e.fullName,employeeId:null==e?void 0:e.employeeId,status:"ACTIVE",owner:{tenantId:o,name:null==e?void 0:e.fullName,gender:(null==e||null===(t=e.gender)||void 0===t?void 0:t.code)||"OTHERS",emailId:null==e?void 0:e.emailId,mobileNumber:null==e?void 0:e.mobileNumber},vendorSurveyorStatus:"ACTIVE",additionalDetails:{agencyId:null==e||null===(l=e.agencyName)||void 0===l?void 0:l.code,reportingManager:null==e||null===(n=e.reportingManager)||void 0===n?void 0:n.code,areaAssignment:null==e?void 0:e.areaAssignment}}};v(a,{onError:e=>{u({key:"error",action:e}),setTimeout(N,5e3)},onSuccess:()=>{u({key:"success",action:"ADD_SURVEYOR"}),c.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(N,5e3)}})},defaultValues:R,onFormValueChange:(e,t)=>{var l,n,a,i;const o=(null==t||null===(l=t.areaAssignment)||void 0===l?void 0:l.zone)&&(null==t||null===(n=t.areaAssignment)||void 0===n?void 0:n.ward)&&(null==t||null===(a=t.areaAssignment)||void 0===a||null===(i=a.areas)||void 0===i?void 0:i.length)>0;m(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.employeeId)&&(null==t?void 0:t.agencyName)&&o))},noBreakLine:!0,mode:"onChange",noCard:!0}),d&&l.createElement(a.Toast,{error:"error"===d.key,label:s("success"===d.key?`ES_VENDOR_${d.action}_SUCCESS`:d.action),onClose:N})))},SurveyorDetails:e=>{var o,s;const d=Digit.ULBService.getCurrentTenantId(),{t:u}=i.useTranslation(),c=n.useHistory(),E=r.useQueryClient(),{id:m}=n.useParams(),[v,S]=t.useState(!1),[p,_]=t.useState(null),[D,R]=t.useState(!1),[N,g]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),{data:O,isLoading:A,refetch:f}=Digit.Hooks.fsm.useSurveyorDetails(d,{ids:m},{staleTime:Infinity}),{data:b}=Digit.Hooks.fsm.useDsoSearch(d,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{mutate:h}=Digit.Hooks.fsm.useSurveyorUpdate(d),{mutate:V}=Digit.Hooks.fsm.useVendorUpdate(d);t.useEffect(()=>{if(b){let e=b.map(e=>e.dsoDetails);T(e)}},[b]),t.useEffect(()=>{f()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return R(!0);case"EDIT":return c.push("/digit-ui/employee/vendor/modify-surveyor/"+m);case"HOME":return c.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SURVEYOR")}},[p]);const M=()=>{g(null)},w=()=>{_(null),C({}),R(!1)};return A?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(a.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==O||null===(o=O[0])||void 0===o||null===(s=o.employeeResponse)||void 0===s?void 0:s.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(a.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(a.Card,{className:"card-with-background",style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"additional-grid"},null==e||null===(n=e.values)||void 0===n?void 0:n.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},u(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},u(e.value)||"N/A","ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"===e.value&&l.createElement("span",{className:"add-details-link hover-button",onClick:()=>_("ADD_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.AddIcon,{fill:"#a82227"})),"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"!==e.value&&l.createElement(l.Fragment,null,l.createElement("div",{className:"add-details-link hover-button",onClick:()=>_("EDIT_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>_("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},u(e.value)||"N/A"))))))}))),D&&l.createElement(a.Modal,{headerBarMain:l.createElement(H,{label:u((()=>{switch(p){case"DELETE":case"DELETE_VENDOR":return"ES_VENDOR_SURVEYOR_DELETE_POPUP_HEADER";case"ADD_VENDOR":case"EDIT_VENDOR":return"ES_VENDOR_SURVEYOR_ADD_VENDOR_POPUP_HEADER"}})())}),headerBarEnd:l.createElement(U,{onClick:w}),actionCancelLabel:u("CS_COMMON_CANCEL"),actionCancelOnSubmit:w,actionSaveLabel:u("DELETE"===p||"DELETE_VENDOR"===p?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(p){case"DELETE":return(()=>{var e;const t={surveyor:{...null==O||null===(e=O[0])||void 0===e?void 0:e.surveyorData,status:"INACTIVE"}};h(t,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"DELETE_SURVEYOR"}),E.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(()=>{M(),c.push("/digit-ui/employee/vendor/search-vendor")},5e3)}}),R(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=null==O||null===(e=O[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],a=(null==n?void 0:n.surveyors)||[];a=a.map(e=>(e.id===m&&(e.vendorSurveyorStatus="INACTIVE"),e));const i={vendor:{...n,surveyors:a}};V(i,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),f(),setTimeout(M,5e3)}}),R(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=I,l=null==O||null===(e=O[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:{...t,surveyors:t.surveyors?[...t.surveyors,l]:[l]}};V(n,{onError:e=>{g({key:"error",action:e}),f(),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"ADD_VENDOR"}),E.invalidateQueries("SURVEYOR_SEARCH"),f(),setTimeout(M,5e3)}}),R(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=I,l=null==O||null===(e=O[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:{...t,surveyors:t.surveyors?[...t.surveyors,l]:[l]}};V(n,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"EDIT_VENDOR"}),f(),E.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(M,5e3)}}),R(!1),_(null)})()}}},l.createElement(a.Card,{style:{boxShadow:"none"}},"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(L,{t:u,title:"ES_VENDOR_SURVEYOR_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(a.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0)),N&&l.createElement(a.Toast,{error:"error"===N.key,label:u("success"===N.key?`ES_VENDOR_${N.action}_SUCCESS`:N.action),onClose:M}),l.createElement(a.ActionBar,{style:{zIndex:"19"}},v?l.createElement(a.Menu,{localeKeyPrefix:"ES_VENDOR_SURVEYOR_ACTION",options:["EDIT","DELETE"],t:u,onSelect:e=>{S(!1),_(e)}}):null,l.createElement(a.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)})))}},ie=e=>{let{userType:a,tenants:i}=e;const{path:o,url:r}=n.useRouteMatch();return Object.entries(ae).forEach(e=>{let[t,l]=e;Digit.ComponentRegistryService.setComponent(t,l)}),Digit.SessionStorage.set("VENDOR_TENANTS",i),t.useEffect(()=>"employee"===a&&Digit.LocalizationService.getLocale({modules:["rainmaker-"+Digit.ULBService.getCurrentTenantId()],locale:Digit.StoreData.getCurrentLanguage(),tenantId:Digit.ULBService.getCurrentTenantId()}),[]),l.createElement("employee"===a?d:M,{path:o,url:r,userType:a})},oe=e=>{const[,,l]=Digit.Hooks.useSessionStorage("VENDOR",{});return t.useEffect(()=>{l()},[]),null};exports.VENDORComponents={VENDORCard:()=>{const{t:e}=i.useTranslation(),t=n.useHistory(),o=window.location.pathname.toLowerCase().includes("citizen");if(!Digit.Utils.vendorAccess()&&!Digit.UserService.hasAccess(["WT_VENDOR","MT_VENDOR"]))return null;const r=[{label:e("VENDOR_NEW_REGISTERATION"),link:o?"/digit-ui/citizen/vendor/registry/new-vendor":"/digit-ui/employee/vendor/registry/new-vendor"},{label:e("SEARCH_VENDOR"),link:o?"/digit-ui/citizen/vendor/search-vendor":"/digit-ui/employee/vendor/search-vendor"}],s=Digit.UserService.hasAccess(["WT_VENDOR"]),d={Icon:l.createElement(a.PropertyHouse,null),moduleName:e("TITLE_VENDOR_MANAGEMENT"),kpis:[{count:0,label:e("Inbox"),link:o?"/digit-ui/citizen/vendor/search-vendor":"/digit-ui/employee/vendor/search-vendor"}],links:r.filter(e=>!(null!=e&&e.role)||s),...o?{onDetailsClick:()=>t.push("/digit-ui/citizen/vendor/search-vendor")}:{}};return o?l.createElement("div",{className:"wt-citizen-card-premium"},l.createElement(a.EmployeeModuleCard,d)):l.createElement(a.EmployeeModuleCard,d)},VENDORModule:ie,VENDORLinks:oe},exports.VENDORLinks=oe,exports.VENDORModule=ie;
1
+ var e,t=require("react"),l=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=require("react-router-dom"),a=require("@djb25/digit-ui-react-components"),i=require("react-i18next"),o=require("react-hook-form"),r=require("react-query");function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var n in l)({}).hasOwnProperty.call(l,n)&&(e[n]=l[n])}return e}).apply(null,arguments)}function d(e,t){if(null==e)return{};var l={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;l[n]=e[n]}return l}const u=e=>{let t=e.path;const o=i.useTranslation().t,r=n.useLocation();sessionStorage.removeItem("revalidateddone");const d=Digit.ComponentRegistryService.getComponent("AddVendor"),u=Digit.ComponentRegistryService.getComponent("SearchVendor"),c=Digit.ComponentRegistryService.getComponent("SearchApp"),E=Digit.ComponentRegistryService.getComponent("AddDriver"),m=Digit.ComponentRegistryService.getComponent("EditVendorDetails"),v=Digit.ComponentRegistryService.getComponent("AddVehicle"),S=Digit.ComponentRegistryService.getComponent("VENDORCreate"),p=Digit.ComponentRegistryService.getComponent("DriverDetails"),_=Digit.ComponentRegistryService.getComponent("VehicleDetails"),D=Digit.ComponentRegistryService.getComponent("AddSupervisor"),R=Digit.ComponentRegistryService.getComponent("SupervisorDetails"),g=Digit.ComponentRegistryService.getComponent("AddSurveyor"),N=Digit.ComponentRegistryService.getComponent("SurveyorDetails"),y=Digit.ComponentRegistryService.getComponent("EditDriver"),T=Digit.ComponentRegistryService.getComponent("EditVehicle");return l.createElement(n.Switch,null,l.createElement(a.AppContainer,null,l.createElement(l.Fragment,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(a.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(a.ArrowLeft,{className:"icon"}),"Back"),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const e=r.pathname;let t=[{icon:a.HomeIcon,path:"/digit-ui/employee"},{label:o("TITLE_VENDOR_MANAGEMENT"),path:"/digit-ui/employee/vendor/search-vendor"}];return e.includes("/registry/new-vendor")?t.push({label:o("ES_FSM_REGISTRY_TITLE_NEW_VENDOR")}):e.includes("/search-vendor")?t.push({label:o("SEARCH_VENDOR")}):e.includes("/registry/new-driver")?t.push({label:o("ES_FSM_REGISTRY_TITLE_NEW_DRIVER")}):e.includes("/registry/vendor-details")||e.includes("/registry/modify-vendor/")?t.push({label:o("VENDOR_VENDOR_DETAILS")}):e.includes("/registry/vehicle-details")||e.includes("/registry/modify-vehicle/")?t.push({label:o("VENDOR_VEHICLE_DETAILS")}):e.includes("/registry/new-vehicle")?t.push({label:o("ES_FSM_REGISTRY_TITLE_NEW_VEHICLE")}):e.includes("/registry/driver-details")||e.includes("/registry/modify-driver/")?t.push({label:o("VENDOR_DRIVER_DETAILS")}):e.includes("/registry/additionaldetails")?t.push({label:o("VENDOR_ADDITIONAL_DETAILS")}):e.includes("/registry/new-supervisor")?t.push({label:o("ES_FSM_REGISTRY_TITLE_NEW_SUPERVISOR")}):e.includes("/registry/supervisor-details")||e.includes("/registry/modify-supervisor/")?t.push({label:o("VENDOR_SUPERVISOR_DETAILS")}):e.includes("/registry/new-surveyor")?t.push({label:o("ES_FSM_REGISTRY_TITLE_NEW_SURVEYOR")}):(e.includes("/registry/surveyor-details")||e.includes("/registry/modify-surveyor/"))&&t.push({label:o("VENDOR_SURVEYOR_DETAILS")}),t})()}),l.createElement(a.PrivateRoute,{path:t+"/search-vendor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"normal"},l.createElement(u,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/new-driver",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(E,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/new-vehicle",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(v,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/additionaldetails",component:e=>{const n=e.location.pathname.includes("/info");return l.createElement(a.LayoutWrapper,{layoutClass:n?"action":"normal"},l.createElement(S,s({},e,{parentRoute:t})))}}),l.createElement(a.PrivateRoute,{path:t+"/registry/driver-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(p,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/modify-driver/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(y,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/common-search/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"normal"},l.createElement(c,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/new-vendor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(d,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/vendor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(m,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/vehicle-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(_,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/modify-vehicle/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(T,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/new-supervisor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(D,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/supervisor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(R,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/new-surveyor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(g,s({},e,{parentRoute:t})))}),l.createElement(a.PrivateRoute,{path:t+"/registry/surveyor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(N,s({},e,{parentRoute:t})))})))))};function c(e,t){try{var l=e()}catch(e){return t(e)}return l&&l.then?l.then(void 0,t):l}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));const E=function(e){return void 0===e&&(e=""),function(e){return void 0===e&&(e=""),!(!e||null==e||void 0===e||""===e)}(e)?e:"NA"},m=function(e,t,l){if(void 0===e&&(e=""),void 0===t&&(t=""),void 0===l&&(l=""),""===t)return e;for(;e.includes(t);)e=e.replace(t,l);return e},v=e=>{var n,i;let r=e.isLoading,s=e.t,d=e.onSubmit,u=e.data,c=e.count,E=e.setShowToast,m=e.vendorData;const v=window.Digit.Utils.browser.isMobile(),S=new Date,p=S.toISOString().split("T")[0],_=new Date(S);_.setDate(S.getDate()-7);const D=_.toISOString().split("T")[0],R=o.useForm({defaultValues:{offset:0,limit:!v&&10,sortBy:"commencementDate",sortOrder:"DESC",fromDate:D,toDate:p}}),g=R.register,N=R.control,y=R.handleSubmit,T=R.setValue,I=R.getValues,C=R.reset,A=R.formState;t.useEffect(()=>{g("offset",0),g("limit",10),g("sortBy","commencementDate"),g("sortOrder","DESC"),T("fromDate",D),T("toDate",p)},[g,y,T,p,D]),t.useEffect(()=>{var e;if(console.log("Fetched Vendor Data:"),null!=m&&null!==(e=m.vendor)&&void 0!==e&&e.length){const e=m.vendor.map(e=>e.name);console.log("Vendor Names:",e)}},[m]);const O=t.useMemo(()=>[{Header:s("VENDOR_REGISTRATION_NO"),accessor:"requestId",disableSortBy:!0,Cell:e=>{var t;const n=null===(t=e.row.original.vendorAdditionalDetails)||void 0===t?void 0:t.registrationNo;return l.createElement("div",null,n||"N/A")}},{Header:s("CONTACT_PERSON_NAME"),disableSortBy:!0,Cell:e=>{var t;const n=null===(t=e.row.original.vendorAdditionalDetails)||void 0===t?void 0:t.contactPerson;return l.createElement("div",null,n||"N/A")}},{Header:s("VENDOR_MOBILE_NUMBER"),disableSortBy:!0,Cell:e=>{var t;const n=null===(t=e.row.original.vendorAdditionalDetails)||void 0===t?void 0:t.vendorMobileNumber;return l.createElement("div",null,n||"N/A")}},{Header:s("VENDOR_BANK_NAME"),disableSortBy:!0,Cell:e=>{var t;const n=null===(t=e.row.original.vendorAdditionalDetails)||void 0===t?void 0:t.bank;return l.createElement("div",null,n||"N/A")}},{Header:s("VENDOR_STATUS"),disableSortBy:!0,Cell:e=>{var t;const n=null===(t=e.row.original.vendorAdditionalDetails)||void 0===t?void 0:t.status;return l.createElement("div",null,n||"N/A")}}],[]),h=t.useCallback(e=>{0!==e.length&&(T("sortBy",e.id),T("sortOrder",e.desc?"DESC":"ASC"))},[]);function f(){T("offset",I("offset")-I("limit")),y(d)()}return l.createElement(l.Fragment,null,l.createElement("div",null,l.createElement(a.Header,null,s("VENDOR_COMMON_SEARCH_ADDITIONAL_DETAILS")),l.createElement(a.SearchForm,{onSubmit:d,handleSubmit:y},l.createElement(a.SearchField,null,l.createElement("label",null,s("VENDOR_NAME")),l.createElement(o.Controller,{control:N,name:"vendorName",render:e=>{var t;return l.createElement(a.Dropdown,{selected:e.value||"",select:e.onChange,onBlur:e.onBlur,option:(null==m||null===(t=m.vendor)||void 0===t?void 0:t.map(e=>({name:e.name,i18nKey:e.name})))||[],optionKey:"i18nKey",t:s,disable:!1})}})),l.createElement(a.SearchField,null,l.createElement("label",null,s("VENDOR_MOBILE_NO")),l.createElement(a.MobileNumber,{name:"mobileNumber",inputRef:g({minLength:{value:10,message:s("CORE_COMMON_MOBILE_ERROR")},maxLength:{value:10,message:s("CORE_COMMON_MOBILE_ERROR")},pattern:{value:/[6789][0-9]{9}/,message:s("CORE_COMMON_MOBILE_ERROR")}}),type:"number",componentInFront:l.createElement("div",{className:"employee-card-input employee-card-input--front"},"+91")}),l.createElement(a.CardLabelError,null,null==A||null===(n=A.errors)||void 0===n||null===(i=n.mobileNumber)||void 0===i?void 0:i.message)),l.createElement(a.SearchField,null,l.createElement("label",null,s("VENDOR_FROM_DATE")),l.createElement(o.Controller,{render:e=>l.createElement(a.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"fromDate",control:N})),l.createElement(a.SearchField,null,l.createElement("label",null,s("VENDOR_TO_DATE")),l.createElement(o.Controller,{render:e=>l.createElement(a.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"toDate",control:N})),l.createElement(a.SearchField,{className:"submit"},l.createElement(a.SubmitBar,{label:s("ES_COMMON_SEARCH"),submit:!0}),l.createElement("p",{style:{marginTop:"10px"},onClick:()=>{C({fromDate:D,toDate:"",mobileNumber:"",vendorName:"",offset:0,limit:10,sortBy:"commencementDate",sortOrder:"DESC"}),E(null),f()}},s("ES_COMMON_CLEAR_ALL")))),!r&&null!=u&&u.display?l.createElement(a.Card,{style:{marginTop:20}},s(u.display).split("\\n").map((e,t)=>l.createElement("p",{key:t,style:{textAlign:"center"}},e))):r||""===u?""!==u||r&&l.createElement(a.Loader,null):l.createElement(a.Table,{t:s,data:u,totalRecords:c,columns:O,getCellProps:e=>({style:{minWidth:e.column.Header===s("EW_INBOX_APPLICATION_NO")?"240px":"",padding:"20px 18px",fontSize:"16px"}}),onPageSizeChange:function(e){T("limit",Number(e.target.value)),y(d)()},currentPage:I("offset")/I("limit"),onNextPage:function(){T("offset",I("offset")+I("limit")),y(d)()},onPrevPage:f,pageSizeLimit:I("limit"),onSort:h,disableSort:!1,sortParams:[{id:I("sortBy"),desc:"DESC"===I("sortOrder")}]})))},S=e=>{let o=e.parentRoute;const r=i.useTranslation().t,s=[{text:r("ES_TITLE_NEW_DESULDGING_APPLICATION"),link:"/digit-ui/employee/fsm/new-application",roles:["FSM_CREATOR_EMP"]},{text:r("ES_TITILE_SEARCH_APPLICATION"),link:o+"/search"},{text:r("ES_TITLE_REPORTS"),link:"/employee/report/fsm/FSMDailyDesludingReport",roles:["FSM_ADMIN"],hyperlink:!0}],d=t.useState([]),u=d[0],c=d[1],E=Digit.UserService.getUser().info.roles;return t.useEffect(()=>{let e=s.filter(e=>{let t=e.roles;return(null==t?void 0:t.some(e=>null==E?void 0:E.map(e=>e.code).includes(e)))||!(null!=t&&t.length)});c(e)},[]),l.createElement(a.Card,{className:"employeeCard inboxLinksFSM"},l.createElement("div",{className:"complaint-links-container"},l.createElement("div",{className:"header"},l.createElement("span",{className:"logo"},l.createElement(a.ShippingTruck,null))," ",l.createElement("span",{className:"text"},r("ES_TITLE_FAECAL_SLUDGE_MGMT"))),l.createElement("div",{className:"body"},u.map((e,t)=>{let a=e.link,i=e.text,o=e.hyperlink;return l.createElement("span",{className:"link",key:t},void 0!==o&&o?l.createElement("a",{href:a},r(i)):l.createElement(n.Link,{to:a},r(i)))}))))},p=["className","t","currentPage","columns","data","getCellProps","disableSort","onSort","onNextPage","onPrevPage","onPageSizeChange","pageSizeLimit","sortParams","totalRecords","isPaginationRequired","showCSVExport","csvExportFileName","csvExportData","getCSVExportData","csvExportColumns","csvExportButtonLabel"],_=e=>{let t=e.className,n=void 0===t?"table":t,i=e.t,o=e.currentPage,r=e.columns,u=e.data,c=e.getCellProps,E=e.disableSort,m=e.onSort,v=e.onNextPage,S=e.onPrevPage,_=e.onPageSizeChange,D=e.pageSizeLimit,R=e.sortParams,g=e.totalRecords,N=e.isPaginationRequired,y=e.showCSVExport,T=e.csvExportFileName,I=e.csvExportData,C=e.getCSVExportData,A=e.csvExportColumns,O=e.csvExportButtonLabel,h=d(e,p);return l.createElement(a.Table,s({className:n,t:i,data:u,currentPage:o,columns:r,getCellProps:c,onNextPage:v,onPrevPage:S,pageSizeLimit:D,disableSort:E,onPageSizeChange:_,onSort:m,sortParams:R,totalRecords:g,isPaginationRequired:N,showCSVExport:y,csvExportFileName:T,csvExportData:I,getCSVExportData:C,csvExportColumns:A,csvExportButtonLabel:O},h))},D=e=>{var t;let n=e.status,o=e.searchParams,r=e.onAssignmentChange,d=e.statusMap;return i.useTranslation(),l.createElement(a.CheckBox,{styles:{height:"unset"},onChange:e=>r(s({},e,{state:n.state}),n),checked:null==o?void 0:o.applicationStatus.some(e=>e.uuid===n.uuid),label:n.name+" ("+((null==d||null===(t=d.find(e=>e.statusid===n.uuid))||void 0===t?void 0:t.count)||"-")+")"})},R=e=>{var n,o,r,d,u;let c=e.onAssignmentChange,E=e.searchParams,m=e.businessServices,v=e.statusMap;const S=i.useTranslation().t,p=t.useState(!1),_=p[0],R=p[1],g=Digit.Hooks.useApplicationStatusGeneral({businessServices:m},{}),N=(g.data||{}).userRoleStates,y=(e,t)=>t(map[e.stateBusinessService])+" - "+t("ES_PTR_COMMON_STATUS_"+(e.state||"CREATED"));return g.isLoading?l.createElement(a.Loader,null):null!=N&&N.filter(e=>!e.isTerminateState).length?l.createElement("div",{className:"status-container"},l.createElement("div",{className:"filter-label",style:{fontWeight:"normal"}},S("ES_INBOX_STATUS")),null==N||null===(n=N.filter(e=>!e.isTerminateState))||void 0===n||null===(o=n.slice(0,4))||void 0===o?void 0:o.map((e,t)=>l.createElement(D,{businessServices:m,key:t,onAssignmentChange:c,status:s({name:y(e,S),code:e.applicationStatus},e),searchParams:E,statusMap:v})),(null==N||null===(r=N.filter(e=>!e.isTerminateState))||void 0===r?void 0:r.slice(4).length)>0?l.createElement(l.Fragment,null,_&&(null==N||null===(d=N.filter(e=>!e.isTerminateState))||void 0===d||null===(u=d.slice(4))||void 0===u?void 0:u.map((e,t)=>l.createElement(D,{businessServices:m,key:e.uuid,onAssignmentChange:c,status:s({name:y(e,S),code:e.applicationStatus},e),searchParams:E,statusMap:v}))),l.createElement("div",{className:"filter-button",onClick:()=>R(!_)}," ",S(_?"ES_COMMON_LESS":"ES_COMMON_MORE")," ")):null):null},g=e=>{let t=e.onFilterChange,n=e.searchParams,i=e.t;const o=Digit.Hooks.fsm.useInbox(e.tenantId,s({},n,e.paginationParms,{fromDate:null!=n&&n.fromDate?new Date(null==n?void 0:n.fromDate).getTime():void 0,toDate:null!=n&&n.toDate?new Date(null==n?void 0:n.toDate).getTime():void 0,total:!0,uuid:{code:"ASSIGNED_TO_ALL",name:i("ES_INBOX_ASSIGNED_TO_ALL")}})).data,r=[{code:"ASSIGNED_TO_ME",name:i("ES_INBOX_ASSIGNED_TO_ME")+" (0)"},{code:"ASSIGNED_TO_ALL",name:i("ES_INBOX_ASSIGNED_TO_ALL")+" ("+((null==o?void 0:o.totalCount)||0)+")"}];return l.createElement(l.Fragment,null,l.createElement(a.RadioButtons,{onSelect:e=>t({uuid:{code:e.code}}),selectedOption:r.filter(e=>{var t;return e.code===(null==n||null===(t=n.uuid)||void 0===t?void 0:t.code)})[0],optionsKey:"name",options:r}))},N=["searchParams","paginationParms","onFilterChange","onSearch","removeParam"],y=e=>{var t,o,r,s;let u=e.searchParams,c=e.paginationParms,E=e.onFilterChange,m=e.onSearch,v=d(e,N);const S=i.useTranslation().t,p=n.useLocation(),_=Digit.UserService.hasAccess(["FSM_DSO"])||!1,D=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1,y=Digit.UserService.hasAccess("FSM_EMP_FSTPO")&&p.pathname.includes("fstp-fsm-request")||!1,T=Digit.ULBService.getCurrentTenantId(),I=Digit.ULBService.getStateId(),C=Digit.Hooks.fsm.useMDMS(I,"DIGIT-UI","RoleStatusMapping"),A=C.data,O=C.isFetched,h=Digit.UserService.getUser().info.roles.map(e=>e.code),f=null==A?void 0:A.filter(e=>h.filter(t=>t===e.userRole)[0]),b=null==f?void 0:f.reduce((e,t)=>({fixed:(null==t?void 0:t.fixed)&&(null==e?void 0:e.fixed),statuses:[...null==e?void 0:e.statuses,...null==t?void 0:t.statuses].filter((e,t,l)=>l.indexOf(e)==t),zeroCheck:(null==t?void 0:t.zeroCheck)||(null==e?void 0:e.zeroCheck)}),{statuses:[]}),V=()=>{if(D)return E()};return l.createElement(l.Fragment,null,(!_&&!D&&u||(null==b||null===(t=b.statuses)||void 0===t?void 0:t.length)>0||y)&&l.createElement("div",{className:"filter",style:{marginTop:D?"-0px":"revert"}},l.createElement("div",{className:"filter-card"},l.createElement("div",{className:"heading"},l.createElement("div",{className:"filter-label"},S("ES_COMMON_FILTER_BY"),":"),l.createElement("div",{className:"clearAll",onClick:V},S("ES_COMMON_CLEAR_ALL")),"desktop"===v.type&&l.createElement("span",{className:"clear-search",onClick:V},S("ES_COMMON_CLEAR_ALL")),"mobile"===v.type&&l.createElement("span",{onClick:v.onClose},l.createElement(a.CloseSvg,null))),l.createElement("div",null,!_&&!D&&u&&l.createElement(g,{onFilterChange:E,searchParams:u,paginationParms:c,tenantId:T,t:S}),l.createElement("div",null)),(null==b||null===(o=b.statuses)||void 0===o?void 0:o.length)>0||y?l.createElement("div",null,l.createElement("div",{className:"filter-label"},S("ES_INBOX_LOCALITY")),l.createElement(a.Localities,{selectLocality:e=>{E(D?{locality:[e]}:{locality:[...null==u?void 0:u.locality,e]})},tenantId:T,boundaryType:"revenue"}),l.createElement("div",{className:"tag-container"},null==u?void 0:u.locality.map((e,t)=>l.createElement(a.RemoveableTag,{key:t,text:e.i18nkey,onClick:()=>{E({locality:null==u?void 0:u.locality.filter(t=>t.code!==e.code)})}})))):null,l.createElement("div",null,O&&b&&null!=v&&null!==(r=v.applications)&&void 0!==r&&r.statuses?l.createElement(R,{onAssignmentChange:(e,t)=>{E(e.target.checked?{applicationStatus:[...null==u?void 0:u.applicationStatus,t]}:{applicationStatus:null==u?void 0:u.applicationStatus.filter(e=>t.name!==e.name)})},fsmfilters:u,mergedRoleDetails:b,statusMap:null==v||null===(s=v.applications)||void 0===s?void 0:s.statuses}):p.pathname.includes("fstp-fsm-request")?"":l.createElement(a.Loader,null)))),"mobile"===v.type&&v.onClose&&l.createElement(a.ActionBar,null,l.createElement(a.ApplyFilterBar,{submit:!1,labelLink:S("ES_COMMON_CLEAR_ALL"),buttonLink:S("ES_COMMON_FILTER"),onClear:V,onSubmit:()=>{"mobile"===v.type?m({delete:["applicationNos"]}):m()},style:{flex:1}})))},T=e=>e.areApplicationStatus?l.createElement(a.Dropdown,{option:e.applicationStatuses,optionKey:"name",selected:e.value,select:e.onAssignmentChange}):l.createElement(a.Loader,null),I=e=>{var r,d,u,c,E,m,v,S,p,_,D;let R=e.onSearch,g=e.type,N=e.onClose,y=e.onTabChange,I=e.searchFields,C=e.searchParams,A=e.isInboxPage,O=e.selectedTab,h=e.matchedRoles;const f=A?Digit.SessionStorage.get("vendor/inbox/searchParams"):Digit.SessionStorage.get("vendor/search/searchParams"),b=i.useTranslation().t,V=n.useHistory(),L=o.useForm({defaultValues:f||C}),M=L.register,w=L.handleSubmit,P=L.reset,k=L.watch,x=L.control,F=t.useState(!1),H=F[0],B=F[1],U=window.Digit.Utils.browser.isMobile(),Y=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1;function G(){const e=I.reduce((e,t)=>s({},e,{[null==t?void 0:t.name]:""}),{});P(e),A?Digit.SessionStorage.del("fsm/inbox/searchParams"):Digit.SessionStorage.del("fsm/search/searchParams"),R({})}const W=e=>null,K=Digit.SessionStorage.get("User").info.type,z=[...null!=h&&null!==(r=h.wt)&&void 0!==r&&r.includes("WT_VENDOR")?["VENDOR"]:[],...null!=h&&null!==(d=h.wt)&&void 0!==d&&d.includes("WT_VENDOR")?["DRIVER","VEHICLE"]:[],...null!=h&&null!==(u=h.ekyc)&&void 0!==u&&u.includes("EKYC-VENDOR")?["SUPERVISOR"]:[],...null!=h&&null!==(c=h.ekyc)&&void 0!==c&&c.includes("EKYC_SUPERVISOR")||null!=h&&null!==(E=h.ekyc)&&void 0!==E&&E.includes("EKYC-VENDOR")?["SURVEYOR"]:[]];return l.createElement(l.Fragment,null,l.createElement("div",{className:"search-container",style:{width:"auto"}},l.createElement("div",{className:"search-complaint-container"},("mobile"===g||U)&&l.createElement("div",{className:"complaint-header"},l.createElement("h2",null,b("ES_COMMON_SEARCH_BY")),l.createElement("span",{style:{position:"absolute",top:"2%",right:"8px"},onClick:N},l.createElement(a.CloseSvg,null))),l.createElement("div",{className:"search-tabs-container"},l.createElement("div",null,(null==h||null===(m=h.wt)||void 0===m?void 0:m.includes("WT_VENDOR"))&&l.createElement("button",{className:"VENDOR"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{G(),y("VENDOR")}},b("ES_FSM_REGISTRY_INBOX_TAB_VENDOR")),(null==h||null===(v=h.wt)||void 0===v?void 0:v.includes("WT_VENDOR"))&&l.createElement("button",{className:"VEHICLE"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{G(),y("VEHICLE")}},b("ES_FSM_REGISTRY_INBOX_TAB_VEHICLE")),(null==h||null===(S=h.wt)||void 0===S?void 0:S.includes("WT_VENDOR"))&&l.createElement("button",{className:"DRIVER"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{G(),y("DRIVER")}},b("ES_FSM_REGISTRY_INBOX_TAB_DRIVER")),(null==h||null===(p=h.ekyc)||void 0===p?void 0:p.includes("EKYC-VENDOR"))&&l.createElement("button",{className:"SUPERVISOR"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{G(),y("SUPERVISOR")}},b("ES_FSM_REGISTRY_INBOX_TAB_SUPERVISOR")),((null==h||null===(_=h.ekyc)||void 0===_?void 0:_.includes("EKYC_SUPERVISOR"))||(null==h||null===(D=h.ekyc)||void 0===D?void 0:D.includes("EKYC-VENDOR")))&&l.createElement("button",{className:"SURVEYOR"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{G(),y("SURVEYOR")}},b("ES_FSM_REGISTRY_INBOX_TAB_SURVEYOR"))),l.createElement("div",{className:"action-bar-wrap-registry"},l.createElement("div",{className:"search-add",onClick:()=>{B(!H)}},b("ES_VENDOR_REGISTRY_INBOX_HEADER_ADD"),l.createElement("div",{className:"search-add-icon"},l.createElement(a.AddIcon,{className:""}))),H&&l.createElement(a.Menu,{localeKeyPrefix:"ES_FSM_ACTION_CREATE",options:z,t:b,onSelect:function(e){const t=null==K?void 0:K.toLowerCase();switch(e){case"VENDOR":return V.push("/digit-ui/"+t+"/vendor/registry/new-vendor");case"VEHICLE":return V.push("/digit-ui/"+t+"/vendor/registry/new-vehicle");case"DRIVER":return V.push("/digit-ui/"+t+"/vendor/registry/new-driver");case"SUPERVISOR":return V.push("/digit-ui/"+t+"/vendor/registry/new-supervisor");case"SURVEYOR":return V.push("/digit-ui/"+t+"/vendor/registry/new-surveyor")}}}))),l.createElement("form",{onSubmit:w(e=>{e.mobileNumber||delete e.mobileNumber,R(e),"mobile"===g&&N()})},l.createElement("div",{className:Y?"for-pt for-search flex-box":"flex-box",style:{gap:"16px"}},null==I?void 0:I.map((e,t)=>l.createElement("span",{key:t,className:0===t?"finance-mainlayout-col1 complaint-input":"finance-mainlayout-col1 mobile-input"},(e=>{switch(e.type){case"date":return l.createElement(o.Controller,{render:e=>l.createElement(a.DatePicker,{date:e.value,onChange:e.onChange}),name:e.name,control:x,defaultValue:null});case"status":return l.createElement(o.Controller,{render:e=>l.createElement(T,{onAssignmentChange:e.onChange,value:e.value}),name:e.name,control:x,defaultValue:null});case"dropdown":return l.createElement(o.Controller,{render:t=>l.createElement(a.Dropdown,{option:e.options,optionKey:e.optionsKey,value:t.value,selected:t.value,select:t.onChange,t:b,placeholder:e.label}),name:e.name,control:x,defaultValue:null});default:return l.createElement(a.TextInput,s({},e,{inputRef:M},M(e.name,{validate:W}),{watch:k,shouldUpdate:!0,placeholder:e.label}))}})(e))),l.createElement("div",{style:{display:"flex",justifyContent:"end",gap:"16px",alignItems:"center"}},"desktop"===g&&!U&&l.createElement("span",{className:"clear-search generic-button"},l.createElement(a.LinkLabel,{style:s({},{}),onClick:G},b("ES_COMMON_CLEAR_SEARCH"))),"desktop"===g&&!U&&l.createElement(a.SubmitBar,{className:"submit-bar-search",label:b("ES_COMMON_SEARCH"),submit:!0})))))))},C=["id"],A=e=>{if(!e)return{};if("object"==typeof e)return e;if("string"!=typeof e)return{};try{return JSON.parse(e)}catch(e){return{}}},O=e=>{var t;return e?"string"==typeof e||"number"==typeof e?[String(e)]:[null==e?void 0:e.id,null==e?void 0:e.fillingStationId,null==e?void 0:e.bookingId,null==e?void 0:e.fillingPointId,null==e?void 0:e.uuid,null==e||null===(t=e.fillingpointmetadata)||void 0===t?void 0:t.fillingPointId].filter(e=>null!=e&&""!==e).map(String):[]},h=function(e,t){void 0===t&&(t=[]);const l=function(e){var t,l,n,a,i,o,r,s,d,u,c,E,m;void 0===e&&(e={});const v=e=>Array.isArray(e)?e.flatMap(O):O(e);return Array.from(new Set([...[null===(t=e)||void 0===t?void 0:t.fillingPointId,null===(l=e)||void 0===l||null===(n=l.dsoDetails)||void 0===n?void 0:n.fillingPointId,null===(a=e)||void 0===a||null===(i=a.fillingpointmetadata)||void 0===i?void 0:i.fillingPointId,null===(o=e)||void 0===o?void 0:o.fillingPtName,null===(r=e)||void 0===r?void 0:r.filling_pt_name,null===(s=e)||void 0===s||null===(d=s.fillingPoint)||void 0===d?void 0:d.fillingPointId].filter(e=>null!=e&&""!==e).map(String),...v(null===(u=e)||void 0===u?void 0:u.fillingPoint),...v(null===(c=e)||void 0===c||null===(E=c.dsoDetails)||void 0===E?void 0:E.fillingPoint),...v(null===(m=e)||void 0===m?void 0:m.fillingPointDetail)]))}(e);return l.length&&t.find(e=>O(e).some(e=>l.includes(e)))||null},f=function(e){var t,l,n,a,i,o,r,s,d,u,c,E,m,v,S,p,_,D,R,g,N,y;if(void 0===e&&(e={}),Array.isArray(null===(t=e)||void 0===t?void 0:t.fillingPoint)){const t=e.fillingPoint.map(e=>(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.fillingPointId)).filter(Boolean);if(t.length>0)return t.join(", ")}return(null===(l=e)||void 0===l||null===(n=l.fillingPoint)||void 0===n?void 0:n.fillingPointName)||(null===(a=e)||void 0===a||null===(i=a.dsoDetails)||void 0===i||null===(o=i.fillingPoint)||void 0===o?void 0:o.fillingPointName)||(null===(r=e)||void 0===r?void 0:r.fillingPointName)||(null===(s=e)||void 0===s||null===(d=s.dsoDetails)||void 0===d?void 0:d.fillingPointName)||(null===(u=e)||void 0===u?void 0:u.fillingPointId)||(null===(c=e)||void 0===c||null===(E=c.dsoDetails)||void 0===E?void 0:E.fillingPointId)||("string"==typeof(null===(m=e)||void 0===m?void 0:m.fillingPoint)?null===(v=e)||void 0===v?void 0:v.fillingPoint:null)||("string"==typeof(null===(S=e)||void 0===S||null===(p=S.dsoDetails)||void 0===p?void 0:p.fillingPoint)?null===(_=e)||void 0===_||null===(D=_.dsoDetails)||void 0===D?void 0:D.fillingPoint:null)||(null===(R=e)||void 0===R||null===(g=R.fillingpointmetadata)||void 0===g?void 0:g.fillingPointId)||(null===(N=e)||void 0===N?void 0:N.filling_pt_name)||(null===(y=e)||void 0===y?void 0:y.fillingPtName)||"NA"},b=function(e,t){var l,n,a,i,o,r,s;void 0===e&&(e={}),void 0===t&&(t=[]);const d=(null===(l=e)||void 0===l||null===(n=l.vendor)||void 0===n?void 0:n.id)||(null===(a=e)||void 0===a||null===(i=a.vendorData)||void 0===i?void 0:i.id)||(null===(o=e)||void 0===o?void 0:o.vendorId);return d&&(t.find(e=>(null==e?void 0:e.id)===d)||(null===(r=e)||void 0===r?void 0:r.vendor)||(null===(s=e)||void 0===s?void 0:s.vendorData))||null},V=function(e){var t,l,n,a;void 0===e&&(e={});const i=[...Array.isArray(null===(t=e)||void 0===t?void 0:t.fillingPoint)?e.fillingPoint:[null===(l=e)||void 0===l?void 0:l.fillingPoint],...Array.isArray(null===(n=e)||void 0===n?void 0:n.fillingPoints)?e.fillingPoints:[null===(a=e)||void 0===a?void 0:a.fillingPoints]].filter(Boolean),o=new Map;return i.forEach(e=>{const t=O(e)[0]||(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.id);t&&!o.has(t)&&o.set(t,e)}),Array.from(o.values())},L=(e,t)=>{const l=Array.isArray(null==e?void 0:e.drivers)?e.drivers.filter(Boolean).map(e=>{var t;return s({},e,{displayName:e.name+" ("+((null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"N/A")+")"})}):[];if(!t)return[];const n=O(t);return n.length?l.filter(e=>{const t=function(e){var t,l,n,a,i,o,r,s,d,u,c;return void 0===e&&(e={}),Array.from(new Set([null===(t=e)||void 0===t?void 0:t.fillingPointId,null===(l=e)||void 0===l?void 0:l.fillingStationId,null===(n=e)||void 0===n||null===(a=n.additionalDetails)||void 0===a?void 0:a.fillingPointId,null===(i=e)||void 0===i||null===(o=i.additionalDetails)||void 0===o?void 0:o.fillingStationId,null===(r=e)||void 0===r||null===(s=r.fillingpointmetadata)||void 0===s?void 0:s.fillingPointId].filter(e=>null!=e&&""!==e).map(String).concat(O(null===(d=e)||void 0===d?void 0:d.fillingPoint),O(null===(u=e)||void 0===u?void 0:u.fillingPointDetail),O(null===(c=e)||void 0===c?void 0:c.fillingPointDetails))))}(e);return!t.length||t.some(e=>n.includes(e))}):l},M=function(e,t){var l,n,a,i;void 0===e&&(e={}),void 0===t&&(t=[]);const o=(null===(l=e)||void 0===l||null===(n=l.driverData)||void 0===n?void 0:n.id)||(null===(a=e)||void 0===a||null===(i=a.driver)||void 0===i?void 0:i.id);return o&&t.find(e=>(null==e?void 0:e.id)===o)||null},w=e=>{if(!e||"object"!=typeof e)return e;const t=e.id;return s({},d(e,C),{fillingStationId:(null==e?void 0:e.fillingStationId)||t||(null==e?void 0:e.bookingId)||(null==e?void 0:e.uuid)||(null==e?void 0:e.fillingPointId)})},P=e=>{var o,d,u;const E=Digit.ULBService.getCurrentTenantId(),m=i.useTranslation().t,v=n.useHistory(),p=e=>l.createElement("span",{className:"cell-text"},e),D=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1,R=t.useState([]),g=R[0],N=R[1],T=t.useState(null),C=T[0],O=T[1],P=t.useState([]),k=P[0],x=P[1],F=t.useState([]),H=F[0],B=F[1],U=t.useState(!1),Y=U[0],G=U[1],W=t.useState(null),K=W[0],z=W[1],X=Digit.SessionStorage.get("User"),q=X.info.roles,j=null===(o=X.info.type)||void 0===o?void 0:o.toLowerCase(),Q=()=>{z(null),G(!1)},Z=l.useMemo(()=>[{Header:m("WT_NAME"),accessor:"name",Cell:e=>p(e.row.original.name)},{Header:m("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>p(e.row.original.mobileNumber)},{Header:m("WT_EMAIL_ID"),accessor:"emailId",Cell:e=>p(e.row.original.emailId)},{Header:m("WT_VALID_FROM"),accessor:"validFrom",Cell:e=>{let t=e.row;return t.original.validFrom?Digit.DateUtils.ConvertEpochToDate(t.original.validFrom):m("CS_NA")}},{Header:m("WT_VALID_TO"),accessor:"validTo",Cell:e=>{let t=e.row;return t.original.validTo?Digit.DateUtils.ConvertEpochToDate(t.original.validTo):m("CS_NA")}},{Header:m("WT_DOCUMENT"),accessor:"fileStoreId",Cell:e=>{let t=e.row;return t.original.fileStoreId?l.createElement("div",{style:{color:"#f47738",cursor:"pointer",textDecoration:"underline"},onClick:()=>function(e){try{if(!e)return Promise.resolve();const t=c(function(){return Promise.resolve(Digit.UploadServices.Filefetch([e],"dl")).then(function(t){var l;if(null!=t&&null!==(l=t.data)&&void 0!==l&&l[e]){const l=t.data[e].split(",")[0];window.open(l,"_blank")}})},function(e){console.error(e),O({key:"error",action:"Failed to fetch document."}),setTimeout(se,5e3)});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}(t.original.fileStoreId)},l.createElement(a.ViewsIcon,null)):m("CS_NA")}}],[m]),$=r.useQueryClient(),J=Digit.Hooks.fsm.useDsoSearch(E,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{enabled:!1}),ee=J.data,te=J.refetch,le=Digit.Hooks.fsm.useDriverSearch({tenantId:E,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"}}),ne=le.data,ae=le.refetch,ie=Digit.Hooks.fsm.useVendorUpdate(E).mutate,oe=Digit.Hooks.fsm.useUpdateVehicle(E).mutate,re=Digit.Hooks.fsm.useDriverUpdate(E).mutate;t.useEffect(()=>{var t;N((null==e||null===(t=e.data)||void 0===t?void 0:t.table)||[])},[e]),t.useEffect(()=>{"DRIVER"!==e.selectedTab&&"VEHICLE"!==e.selectedTab||(te(),ae())},[e.selectedTab]),t.useEffect(()=>{if(ee){let e=ee.map(e=>{var t;return s({},e.dsoDetails,{displayName:e.dsoDetails.name+" ("+(e.dsoDetails.mobileNumber||(null===(t=e.dsoDetails.owner)||void 0===t?void 0:t.mobileNumber)||"N/A")+")"})});x(e)}},[ee]),t.useEffect(()=>{ne&&B((ne.driver||[]).map(e=>{var t;return s({},e,{displayName:e.name+" ("+((null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"N/A")+")"})}))},[ne]);const se=()=>{O(null)},de=(e,t)=>{N(l=>l.map(l=>(null==l?void 0:l.id)===e?s({},l,t):l))},ue=function(e,t){var l;void 0===t&&(t={});const n=s({},e,t,{driverData:(null===(l=t)||void 0===l?void 0:l.driverData)||(null==e?void 0:e.driverData)||(null==e?void 0:e.driver),fillingPoint:w(Object.prototype.hasOwnProperty.call(t,"fillingPoint")?t.fillingPoint:null==e?void 0:e.fillingPoint)});return delete n.vendor,delete n.popup,delete n.driver,{vehicle:n}},ce=(e,t)=>{var l;return{vendor:s({},e,{owner:s({},null==e?void 0:e.owner,{gender:(null==e||null===(l=e.owner)||void 0===l?void 0:l.gender)||"OTHERS"}),vehicles:t})}},Ee=()=>{switch(e.selectedTab){case"VENDOR":return v.push("/digit-ui/"+j+"/vendor/registry/new-vendor");case"VEHICLE":return v.push("/digit-ui/"+j+"/vendor/registry/new-vehicle");case"DRIVER":return v.push("/digit-ui/"+j+"/vendor/registry/new-driver");case"SUPERVISOR":return v.push("/digit-ui/"+j+"/vendor/registry/new-supervisor");case"SURVEYOR":return v.push("/digit-ui/"+j+"/vendor/registry/new-surveyor")}},me=l.useMemo(()=>"VENDOR"===e.selectedTab?(null==g?void 0:g.map(e=>e.id))||[]:(null==ee?void 0:ee.map(e=>{var t;return null===(t=e.dsoDetails)||void 0===t?void 0:t.id}))||[],[e.selectedTab,g,ee]),ve=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:E,filters:{vendorIds:null==me?void 0:me.join(","),vendorId:null==me?void 0:me.join(",")}},{enabled:(null==me?void 0:me.length)>0}).data,Se=Digit.Hooks.wt.useFillPointSearch({tenantId:E,filters:{limit:1e3}},{enabled:!0}),pe=Se.data,_e=Se.isLoading,De=l.useMemo(()=>{switch(e.selectedTab){case"VENDOR":return[{Header:m("ES_VENDOR_INBOX_VENDOR_NAME"),accessor:"name",Cell:e=>{let t=e.row;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:"/digit-ui/"+j+"/vendor/registry/vendor-details/"+t.original.id},l.createElement("div",null,t.original.name))))}},{Header:m("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>l.createElement("div",null,e.row.original.mobileNumber)},{Header:m("ES_VENDOR_INBOX_DATE_VENDOR_CREATION"),accessor:"createdTime",Cell:e=>{var t,l,n,a;let i=e.row;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(a=n.auditDetails)||void 0===a?void 0:a.createdTime):"")}},{Header:m("ES_VENDOR_INBOX_SERVICE_TYPE"),id:"serviceType",accessor:e=>{var t,l;let n=null===(t=e.dsoDetails)||void 0===t?void 0:t.additionalDetails;if("string"==typeof n)try{n=JSON.parse(n)}catch(e){n={}}return(null===(l=n)||void 0===l?void 0:l.serviceType)||"N/A"},Cell:e=>{var t,n;let a=null===(t=e.row.original.dsoDetails)||void 0===t?void 0:t.additionalDetails;if("string"==typeof a)try{a=JSON.parse(a)}catch(e){console.error("Error parsing additionalDetails:",e),a={}}const i=(null===(n=a)||void 0===n?void 0:n.serviceType)||"N/A";return l.createElement("div",null,i)}},{Header:m("ES_VENDOR_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>{var t;return(null===(t=e.dsoDetails)||void 0===t?void 0:t.status)||""},Cell:t=>{var n,i;let o=t.row;return l.createElement(a.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=o.original)||void 0===n||null===(i=n.dsoDetails)||void 0===i?void 0:i.status),onChange:()=>(t=>{var l,n,a,i;let o=t.original.dsoDetails;const r={vendor:s({},o,{status:"ACTIVE"===(null==o?void 0:o.status)?"DISABLED":"ACTIVE",owner:s({},o.owner,{gender:(null==o||null===(l=o.owner)||void 0===l?void 0:l.gender)||"OTHER",dob:(null==o||null===(n=o.owner)||void 0===n?void 0:n.dob)||new Date("1/1/1970").getTime(),emailId:(null==o||null===(a=o.owner)||void 0===a?void 0:a.emailId)||"abc@egov.com",relationship:(null==o||null===(i=o.owner)||void 0===i?void 0:i.relationship)||"OTHER"})})};ie(r,{onError:(e,t)=>{O({key:"error",action:e}),setTimeout(se,5e3)},onSuccess:(t,l)=>{O({key:"success",action:"VENDOR"}),$.invalidateQueries("DSO_SEARCH"),e.refetchData(),setTimeout(se,3e3)}})})(o),name:"switch-"+o.id})}},{Header:m("ES_VENDOR_ADDITIONAL_DETAILS"),disableSortBy:!0,Cell:e=>{var t,a;let i=e.row;const o=null===(t=i.original)||void 0===t?void 0:t.id;if(!ve)return l.createElement("span",null,"Loading...");const r=null!==(null===(a=i.original)||void 0===a?void 0:a.vendorAdditionalDetails);return l.createElement(n.Link,{to:r?"/digit-ui/"+j+"/vendor/registry/additionaldetails/info?vendorId="+o:"/digit-ui/"+j+"/vendor/registry/additionaldetails/vendor-details?vendorId="+o},l.createElement("button",{className:"submit-bar",style:{backgroundColor:r?"#417505":"#3A8DCC",color:"white"}},r?"View Details":"Add Details"))}},{Header:m("VIEW_WORKORDER_DETAILS"),disableSortBy:!0,Cell:e=>{let t=e.row;return l.createElement("button",{className:"submit-bar",style:{backgroundColor:"#417505",color:"white"},onClick:()=>(z(t.original),void G(!0))},m("VIEW_WORKORDER_DETAILS"))}}];case"VEHICLE":return[{Header:m("ES_FSM_REGISTRY_INBOX_VEHICLE_NAME"),accessor:"registrationNumber",Cell:e=>{let t=e.row;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:"/digit-ui/"+j+"/vendor/registry/vehicle-details/"+t.original.registrationNumber},l.createElement("div",null,t.original.registrationNumber))))}},{Header:m("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{var t,n;return l.createElement("div",null,(null===(t=e.row.original)||void 0===t||null===(n=t.owner)||void 0===n?void 0:n.mobileNumber)||"N/A")}},{Header:m("ES_FSM_REGISTRY_INBOX_DATE_VEHICLE_CREATION"),accessor:"createdTime",Cell:e=>{var t,l,n,a;let i=e.row;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(a=n.auditDetails)||void 0===a?void 0:a.createdTime):"")}},{Header:"Map Vendor",id:"mapVendor",accessor:e=>{var t,l;return(null===(t=e.vendor)||void 0===t?void 0:t.name)||(null===(l=e.vendorData)||void 0===l?void 0:l.name)||"NA"},Cell:t=>{let n=t.row;return l.createElement(a.Dropdown,{className:"fsm-registry-dropdown",selected:b(n.original,k),option:k,select:t=>((t,l)=>{const n=t.original,a=null==n?void 0:n.vendor;if(null==l||!l.id||(null==a?void 0:a.id)===(null==l?void 0:l.id))return;const i=s({},n,{vendorVehicleStatus:"ACTIVE",fillingPoint:null,driverData:null,driver:null});delete i.vendor,delete i.popup,delete i.driver;const o=()=>{const t=Array.isArray(null==l?void 0:l.vehicles)?[...l.vehicles]:[],a=t.findIndex(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id));a>-1?t[a]=s({},t[a],i,{vendorVehicleStatus:"ACTIVE"}):t.push(i);const o=s({},l,{vehicles:t});ie(ce(l,t),{onError:e=>{O({key:"error",action:e}),setTimeout(se,5e3)},onSuccess:()=>{de(null==n?void 0:n.id,{vendor:o,fillingPoint:null,driverData:null,driver:null}),O({key:"success",action:"VEHICLE"}),$.invalidateQueries("DSO_SEARCH"),$.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchData(),e.refetchVendor&&e.refetchVendor(),setTimeout(se,3e3)}})};if(null!=a&&a.id){const e=Array.isArray(null==a?void 0:a.vehicles)?a.vehicles.map(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id)?s({},e,{vendorVehicleStatus:"INACTIVE"}):e):[];ie(ce(a,e),{onError:e=>{O({key:"error",action:e}),setTimeout(se,5e3)},onSuccess:o})}else o()})(n,t),style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"displayName",t:m})}},{Header:m("ES_VENDOR_INBOX_SERVICE_TYPE"),id:"serviceType",accessor:e=>{var t;let l=e.additionalDetails;if("string"==typeof l)try{l=JSON.parse(l)}catch(e){l={}}return(null===(t=l)||void 0===t?void 0:t.serviceType)||"N/A"},Cell:e=>{var t;let n=e.row.original.additionalDetails;if("string"==typeof n)try{n=JSON.parse(n)}catch(e){console.error("Error parsing additionalDetails:",e),n={}}const a=(null===(t=n)||void 0===t?void 0:t.serviceType)||"N/A";return l.createElement("div",null,a)}},{Header:m("WT_FILLING_POINT"),accessor:e=>f(e),id:"fillingPoint",minWidth:250,Cell:t=>{let n=t.row;const i=b(n.original,k),o=V(i);return l.createElement(a.Dropdown,{className:"fsm-registry-dropdown",selected:h(n.original,o),option:o,select:t=>((t,l)=>{const n=ue(t.original,{fillingPoint:l});oe(n,{onError:e=>{var t,l,n,a;O({key:"error",label:(null==e?void 0:e.message)||(null==e||null===(t=e.response)||void 0===t||null===(l=t.data)||void 0===l||null===(n=l.Errors)||void 0===n||null===(a=n[0])||void 0===a?void 0:a.message)||"Failed to map filling point"}),setTimeout(se,5e3)},onSuccess:()=>{var n;const a=b(t.original,k),i=L(a,l),o=M(t.original,i);de(null===(n=t.original)||void 0===n?void 0:n.id,s({fillingPoint:s({},l,{fillingStationId:(null==l?void 0:l.fillingStationId)||(null==l?void 0:l.id)||(null==l?void 0:l.bookingId)||(null==l?void 0:l.uuid)||(null==l?void 0:l.fillingPointId)})},o?{}:{driverData:null,driver:null})),O({key:"success",label:"Filling point mapped successfully"}),$.invalidateQueries("FSM_VEICLES_SEARCH"),$.invalidateQueries("DSO_SEARCH"),e.refetchData(),e.refetchVendor&&e.refetchVendor(),setTimeout(se,3e3)}})})(n,t),style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"fillingPointName",t:m,disable:!i||!o.length})}},{Header:m("ES_FSM_REGISTRY_SELECT_DRIVER"),id:"driver",accessor:e=>{var t,l;return(null===(t=e.driverData)||void 0===t?void 0:t.name)||(null===(l=e.driver)||void 0===l?void 0:l.name)||"NA"},minWidth:250,Cell:t=>{let n=t.row;const i=b(n.original,k),o=h(n.original,V(i)),r=L(i,o);return l.createElement(a.Dropdown,{className:"fsm-registry-dropdown",selected:M(n.original,r),option:r,select:t=>((t,l)=>{const n=ue(t.original,{driverData:l});oe(n,{onError:(e,t)=>{O({key:"error",action:e}),setTimeout(se,5e3)},onSuccess:(n,a)=>{var i;de(null===(i=t.original)||void 0===i?void 0:i.id,{driverData:l}),O({key:"success",action:"VEHICLE"}),$.invalidateQueries("FSM_VEICLES_SEARCH"),$.invalidateQueries("DSO_SEARCH"),e.refetchData(),e.refetchVendor(),setTimeout(se,3e3)}})})(n,t),optionKey:"displayName",t:m,style:{textAlign:"left",width:"100%",minWidth:"250px"},disable:!o||!r.length})}},{Header:m("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let i=t.row;return l.createElement(a.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>(t=>{var l;const n=ue(t.original,{status:"ACTIVE"===(null===(l=t.original)||void 0===l?void 0:l.status)?"DISABLED":"ACTIVE"});oe(n,{onError:(e,t)=>{O({key:"error",action:e}),setTimeout(se,5e3)},onSuccess:(t,l)=>{O({key:"success",action:"VEHICLE"}),$.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(se,3e3)}})})(i),name:"switch-"+i.id})}}];case"DRIVER":return[{Header:m("ES_FSM_REGISTRY_INBOX_USERNAME"),id:"userName",accessor:e=>{var t;return(null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"},Cell:e=>{var t;let a=e.row;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:"/digit-ui/"+j+"/vendor/registry/driver-details/"+a.original.id},l.createElement("div",null,(null===(t=a.original.owner)||void 0===t?void 0:t.userName)||"NA"))))}},{Header:m("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),accessor:"name",Cell:e=>{let t=e.row;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:"/digit-ui/"+j+"/vendor/registry/driver-details/"+t.original.id},l.createElement("div",null,""+(t.original.name||"N/A")))))}},{Header:m("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{var t,n;return l.createElement("div",null,(null===(t=e.row.original)||void 0===t||null===(n=t.owner)||void 0===n?void 0:n.mobileNumber)||"N/A")}},{Header:m("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),accessor:"createdTime",Cell:e=>{var t,l,n,a;let i=e.row;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(a=n.auditDetails)||void 0===a?void 0:a.createdTime):"")}},{Header:m("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),id:"vendorName",accessor:e=>{var t,l;return(null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"},minWidth:250,Cell:t=>{let n=t.row;return l.createElement(a.Dropdown,{className:"fsm-registry-dropdown",selected:(null==k?void 0:k.find(e=>{var t,l;return((null===(t=n.original.vendorData)||void 0===t?void 0:t.id)||(null===(l=n.original.vendor)||void 0===l?void 0:l.id))===e.id}))||n.original.vendorData||n.original.vendor,option:k,select:t=>((t,l)=>{let n=t.original,a=null==n?void 0:n.vendor,i=l;if(delete n.vendor,n.vendorDriverStatus="ACTIVE",a){const e=null==a?void 0:a.drivers;e.splice(e.findIndex(e=>e.id===n.id),1)}const o={vendor:s({},i,{drivers:i.drivers?[...i.drivers,n]:[n]})};ie(o,{onError:(e,t)=>{O({key:"error",action:e}),setTimeout(se,5e3)},onSuccess:(t,l)=>{O({key:"success",action:"VENDOR"}),$.invalidateQueries("DSO_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(se,3e3)}})})(n,t),style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"displayName",t:m})}},{Header:m("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let i=t.row;return l.createElement(a.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>(t=>{var l,n,a,i;let o=t.original;const r={driver:s({},o,{status:"ACTIVE"===(null==o?void 0:o.status)?"DISABLED":"ACTIVE",owner:s({},o.owner,{gender:(null==o||null===(l=o.owner)||void 0===l?void 0:l.gender)||"OTHER",dob:(null==o||null===(n=o.owner)||void 0===n?void 0:n.dob)||new Date("1/1/1970").getTime(),emailId:(null==o||null===(a=o.owner)||void 0===a?void 0:a.emailId)||"abc@egov.com",relationship:(null==o||null===(i=o.owner)||void 0===i?void 0:i.relationship)||"OTHER"})})};re(r,{onError:(e,t)=>{O({key:"error",action:e}),setTimeout(se,5e3)},onSuccess:(t,l)=>{O({key:"success",action:"DRIVER"}),$.invalidateQueries("FSM_DRIVER_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(se,3e3)}})})(i),name:"switch-"+i.id})}}];case"SUPERVISOR":case"SURVEYOR":return[{Header:m("SUPERVISOR"===e.selectedTab?"Supervisor's Mobile No.":"Surveyor's Mobile No."),id:"userName",accessor:e=>{var t;return(null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"},Cell:t=>{var a;let i=t.row;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:"/digit-ui/"+j+"/vendor/registry/"+("SUPERVISOR"===e.selectedTab?"supervisor-details":"surveyor-details")+"/"+i.original.id},l.createElement("div",null,(null===(a=i.original.owner)||void 0===a?void 0:a.userName)||"NA"))))}},{Header:m("SUPERVISOR"===e.selectedTab?"ES_FSM_REGISTRY_INBOX_SUPERVISOR_NAME":"ES_FSM_REGISTRY_INBOX_SURVEYOR_NAME"),accessor:"name",Cell:t=>{let a=t.row;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:"/digit-ui/"+j+"/vendor/registry/"+("SUPERVISOR"===e.selectedTab?"supervisor-details":"surveyor-details")+"/"+a.original.id},l.createElement("div",null,""+(a.original.name||"N/A")))))}},{Header:m("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{var t,n;return l.createElement("div",null,(null===(t=e.row.original)||void 0===t||null===(n=t.owner)||void 0===n?void 0:n.mobileNumber)||"N/A")}},{Header:m("ES_FSM_REGISTRY_INBOX_DATE_CREATION"),accessor:"createdTime",Cell:e=>{var t,l,n,a;let i=e.row;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(a=n.auditDetails)||void 0===a?void 0:a.createdTime):"")}},{Header:m("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),id:"vendorName",accessor:e=>{var t,l;return(null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"},minWidth:250,Cell:t=>{let n=t.row;return l.createElement(a.Dropdown,{className:"fsm-registry-dropdown",selected:(null==k?void 0:k.find(e=>{var t,l;return((null===(t=n.original.vendorData)||void 0===t?void 0:t.id)||(null===(l=n.original.vendor)||void 0===l?void 0:l.id))===e.id}))||n.original.vendorData||n.original.vendor,option:k,select:t=>{console.log("Updating vendor for",e.selectedTab,t)},style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"displayName",t:m})}},{Header:m("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let i=t.row;return l.createElement(a.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>{console.log("Updating status for",e.selectedTab,i.original.id)},name:"switch-"+i.id})}}];default:return[]}},[e.selectedTab,k,H,g,ve,(null==pe?void 0:pe.fillingPoints)||[],m]),Re=l.useMemo(()=>{switch(e.selectedTab){case"VENDOR":return[{Header:m("ES_VENDOR_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,a,i;return((null==e?void 0:e.name)||(null==e||null===(t=e.dsoDetails)||void 0===t?void 0:t.name)||"NA")+" ("+((null==e?void 0:e.mobileNumber)||(null==e||null===(l=e.owner)||void 0===l?void 0:l.mobileNumber)||(null==e||null===(n=e.dsoDetails)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(a=e.dsoDetails)||void 0===a||null===(i=a.owner)||void 0===i?void 0:i.mobileNumber)||"NA")+")"}},{Header:m("ES_VENDOR_INBOX_DATE_VENDOR_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:m("WT_FILLING_POINT"),exportAccessor:e=>f(e)},{Header:m("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t,l;return(null===(t=A(null==e||null===(l=e.dsoDetails)||void 0===l?void 0:l.additionalDetails))||void 0===t?void 0:t.serviceType)||"N/A"}},{Header:m("ES_VENDOR_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>{var t;return(null==e||null===(t=e.dsoDetails)||void 0===t?void 0:t.status)||"NA"}}];case"VEHICLE":return[{Header:m("ES_FSM_REGISTRY_INBOX_VEHICLE_NAME"),exportAccessor:e=>(null==e?void 0:e.registrationNumber)||"NA"},{Header:m("ES_FSM_REGISTRY_INBOX_DATE_VEHICLE_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:"Map Vendor",exportAccessor:e=>{var t,l,n,a,i,o,r,s;return((null==e||null===(t=e.vendor)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendorData)||void 0===l?void 0:l.name)||"NA")+" ("+((null==e||null===(n=e.vendor)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a||null===(i=a.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(o=e.vendorData)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(r=e.vendorData)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA")+")"}},{Header:m("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t;return(null===(t=A(null==e?void 0:e.additionalDetails))||void 0===t?void 0:t.serviceType)||"N/A"}},{Header:m("WT_FILLING_POINT"),exportAccessor:e=>f(e)},{Header:m("ES_FSM_REGISTRY_SELECT_DRIVER"),exportAccessor:e=>{var t,l,n,a,i,o;return((null==e||null===(t=e.driverData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.driver)||void 0===l?void 0:l.name)||"NA")+" ("+((null==e||null===(n=e.driverData)||void 0===n||null===(a=n.owner)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(i=e.driver)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||"NA")+")"}},{Header:m("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];case"DRIVER":return[{Header:m("ES_FSM_REGISTRY_INBOX_USERNAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"}},{Header:m("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),exportAccessor:e=>{var t;return((null==e?void 0:e.name)||"NA")+" ("+((null==e||null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"NA")+")"}},{Header:m("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:m("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,a,i,o,r,s;return((null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA")+" ("+((null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(a=e.vendorData)||void 0===a||null===(i=a.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(o=e.vendor)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA")+")"}},{Header:m("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];case"SURVEYOR":return[{Header:m("ES_FSM_REGISTRY_INBOX_USERNAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"}},{Header:m("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),exportAccessor:e=>{var t;return((null==e?void 0:e.name)||"NA")+" ("+((null==e||null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"NA")+")"}},{Header:m("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:m("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,a,i,o,r,s;return((null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA")+" "+((null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(a=e.vendorData)||void 0===a||null===(i=a.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(o=e.vendor)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA")}},{Header:m("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];case"SUPERVISOR":return[{Header:m("ES_FSM_REGISTRY_INBOX_USERNAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"}},{Header:m("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),exportAccessor:e=>{var t;return((null==e?void 0:e.name)||"NA")+" ("+((null==e||null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"NA")+")"}},{Header:m("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:m("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,a,i,o,r,s;return((null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA")+" "+((null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(a=e.vendorData)||void 0===a||null===(i=a.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(o=e.vendor)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA")}},{Header:m("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];default:return[]}},[e.selectedTab,m]),ge=l.useCallback(function(){return Promise.resolve(g)},[g]);let Ne;if(e.isLoading||_e)Ne=l.createElement("div",{style:{zIndex:10,position:"relative",padding:"10px",backgroundColor:"#fff",width:"75px",height:"75px",borderRadius:"12px",display:"flex",justifyContent:"center",alignItems:"center",margin:"auto"}},l.createElement(a.Loader,null));else if(0===g.length){let t="",n="";"VENDOR"===e.selectedTab?(t="ES_FSM_REGISTRY_EMPTY_CARD_VENDOR",n="ES_FSM_REGISTRY_EMPTY_BUTTON_VENDOR"):"VEHICLE"===e.selectedTab?(t="ES_FSM_REGISTRY_EMPTY_CARD_VEHICLE",n="ES_FSM_REGISTRY_EMPTY_BUTTON_VEHICLE"):"SUPERVISOR"===e.selectedTab?(t="ES_FSM_REGISTRY_EMPTY_CARD_SUPERVISOR",n="ES_FSM_REGISTRY_EMPTY_BUTTON_SUPERVISOR"):"SURVEYOR"===e.selectedTab?(t="ES_FSM_REGISTRY_EMPTY_CARD_SURVEYOR",n="ES_FSM_REGISTRY_EMPTY_BUTTON_SURVEYOR"):(t="ES_FSM_REGISTRY_EMPTY_CARD_DRIVER",n="ES_FSM_REGISTRY_EMPTY_BUTTON_DRIVER"),Ne=l.createElement(a.Card,{className:"flex-center flex-box"},l.createElement("div",{style:{marginTop:"50px",marginBottom:"25px"}},m(t)),l.createElement(a.SubmitBar,{className:"",label:m(n),onSubmit:Ee}))}else g.length>0&&(Ne=l.createElement(_,{className:"table registryTable",t:m,data:g,columns:De,getCellProps:()=>({style:{padding:"8px 12px",fontSize:"13.5px"}}),onPageSizeChange:e.onPageSizeChange,currentPage:e.currentPage,onNextPage:e.onNextPage,onPrevPage:e.onPrevPage,pageSizeLimit:e.pageSizeLimit,onSort:e.onSort,disableSort:e.disableSort,sortParams:e.sortParams,totalRecords:e.totalRecords,showCSVExport:!0,getCSVExportData:ge,csvExportColumns:Re,csvExportFileName:"vendor-"+String(e.selectedTab||"registry").toLowerCase()+"-inbox"}));const ye=q.map(e=>e.code),Te={ekyc:Object.values({ekycVendor:"EKYC-VENDOR",supervisor:"EKYC_SUPERVISOR"}).filter(e=>ye.includes(e)),wt:Object.values({wtVendor:"WT_VENDOR"}).filter(e=>ye.includes(e))};return Te.ekyc.push("EKYC-VENDOR"),l.createElement("div",{className:"inbox-container"},"FSM_EMP_FSTPO"!==e.userRole&&"FSM_ADMIN"!==e.userRole&&!e.isSearch&&l.createElement("div",{className:"filters-container"},l.createElement(S,{parentRoute:e.parentRoute}),l.createElement("div",{style:{marginTop:"24px"}},l.createElement(y,{searchParams:e.searchParams,paginationParms:e.paginationParms,applications:e.data,onFilterChange:e.onFilterChange,type:"desktop"}))),l.createElement("div",{style:{flex:1,width:"100%",marginLeft:"FSM_ADMIN"===e.userRole?"":"24px"}},l.createElement(I,{onSearch:e.onSearch,type:"desktop",searchFields:e.searchFields,isInboxPage:!(null!=e&&e.isSearch),searchParams:e.searchParams,onTabChange:e.onTabChange,selectedTab:e.selectedTab,matchedRoles:Te}),l.createElement("div",{className:"result",style:{marginLeft:D||"FSM_ADMIN"===e.userRole||null!=e&&e.isSearch?"":"24px",flex:1}},Ne)),C&&l.createElement(a.Toast,{error:"error"===C.key,label:m(C.label?C.label:"success"===C.key?"ES_FSM_REGISTRY_"+C.action+"_DISABLE_SUCCESS":C.action),onClose:se}),Y&&l.createElement(a.Modal,{headerBarMain:l.createElement("h1",{className:"heading-m",style:{margin:0}},m("ES_VENDOR_WORKORDER_DETAILS_MODAL")),headerBarEnd:l.createElement("div",{className:"icon-bg-secondary",onClick:Q,style:{cursor:"pointer"}},l.createElement(a.MdClose,null)),actionCancelLabel:m("CS_COMMON_CLOSE"),actionCancelOnSubmit:Q,hideSubmit:!0,formId:"modal-action"},l.createElement("div",{style:{padding:"16px"}},(null==K||null===(d=K.dsoDetails)||void 0===d||null===(u=d.vendorWorkOrder)||void 0===u?void 0:u.length)>0?l.createElement(a.Table,{t:m,data:K.dsoDetails.vendorWorkOrder,columns:Z,getCellProps:e=>({style:{minWidth:"150px",padding:"8px 12px",fontSize:"13.5px"}})}):l.createElement("p",{style:{textAlign:"center",marginTop:"20px"}},m("ES_VENDOR_NO_WORKORDERS")))))},k=["t","config","onSelect","userType","formData"],x=()=>{const e=i.useTranslation().t,t=n.useLocation(),o=n.useRouteMatch().path,r=Digit.ComponentRegistryService.getComponent("SearchVendor"),d=Digit.ComponentRegistryService.getComponent("EditVendorDetails"),u=Digit.ComponentRegistryService.getComponent("AddSupervisor"),c=Digit.ComponentRegistryService.getComponent("SupervisorDetails"),E=Digit.ComponentRegistryService.getComponent("AddSurveyor"),m=Digit.ComponentRegistryService.getComponent("SurveyorDetails"),v=Digit.ComponentRegistryService.getComponent("VENDORCreate"),S=Digit.ComponentRegistryService.getComponent("AddDriver"),p=Digit.ComponentRegistryService.getComponent("DriverDetails"),_=Digit.ComponentRegistryService.getComponent("AddVehicle"),D=Digit.ComponentRegistryService.getComponent("VehicleDetails"),R=Digit.ComponentRegistryService.getComponent("EditDriver"),g=Digit.ComponentRegistryService.getComponent("EditVehicle");return l.createElement(n.Switch,null,l.createElement(a.AppContainer,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(a.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(a.ArrowLeft,{className:"icon"}),e("CS_COMMON_BACK")),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const l=t.pathname;let n=[{icon:a.HomeIcon,path:"/digit-ui/citizen"},{label:e("WT_MODULE_NAME"),path:o+"/wt-Vendor"}];if(l.includes("/inbox")){let t="ES_COMMON_INBOX";l.includes("/mt/inbox")&&(n=[{icon:a.HomeIcon,path:"/digit-ui/citizen"},{label:e("ACTION_TEST_MT"),path:o+"/mt-Vendor"}]),n.push({label:e(t)})}else if(l.includes("/my-bookings")){let t="WT_SEARCH_BOOKINGS";l.includes("/mt/my-bookings")&&(t="MT_SEARCH_BOOKINGS"),n.push({label:e(t)})}else l.includes("/status")?n.push({label:e("WT_MY_APPLICATIONS")}):(l.includes("/booking/")||l.includes("/booking-details")||l.includes("/bookingsearch/booking-details"))&&(n.push({label:e("ES_COMMON_INBOX"),path:l.includes("/mt/")?o+"/mt/inbox":o+"/inbox"}),n.push({label:e("WT_BOOKING_DETAILS")}));const i=[{match:"/registry/new-vendor",label:"ES_FSM_REGISTRY_TITLE_NEW_VENDOR"},{match:"/search-vendor",label:"SEARCH_VENDOR"},{match:"/registry/new-driver",label:"ES_FSM_REGISTRY_TITLE_NEW_DRIVER"},{match:["/registry/vendor-details","/registry/modify-vendor/"],label:"VENDOR_VENDOR_DETAILS"},{match:["/registry/vehicle-details","/registry/modify-vehicle/"],label:"VENDOR_VEHICLE_DETAILS"},{match:"/registry/new-vehicle",label:"ES_FSM_REGISTRY_TITLE_NEW_VEHICLE"},{match:["/registry/driver-details","/registry/modify-driver/"],label:"VENDOR_DRIVER_DETAILS"},{match:"/registry/additionaldetails",label:"VENDOR_ADDITIONAL_DETAILS"},{match:"/registry/new-supervisor",label:"ES_FSM_REGISTRY_TITLE_NEW_SUPERVISOR"},{match:["/registry/supervisor-details","/registry/modify-supervisor/"],label:"VENDOR_SUPERVISOR_DETAILS"},{match:"/registry/new-surveyor",label:"ES_FSM_REGISTRY_TITLE_NEW_SURVEYOR"},{match:["/registry/surveyor-details","/registry/modify-surveyor/"],label:"VENDOR_SURVEYOR_DETAILS"}].find(e=>{let t=e.match;return Array.isArray(t)?t.some(e=>l.includes(e)):l.includes(t)});return i&&n.push({label:e(i.label)}),n})()}),l.createElement(a.PrivateRoute,{path:o+"/search-vendor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"normal"},l.createElement(r,s({},e,{parentRoute:o}))),exact:!0}),l.createElement(a.PrivateRoute,{path:o+"/registry/vendor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(d,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/driver-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(p,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/modify-driver/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(R,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/vehicle-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(D,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/modify-vehicle/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(g,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/new-driver",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(S,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/new-vehicle",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(_,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/new-supervisor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(u,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/additionaldetails",component:e=>{const t=e.location.pathname.includes("/info");return l.createElement(a.LayoutWrapper,{layoutClass:t?"action":"normal"},l.createElement(v,s({},e,{parentRoute:o})))}}),l.createElement(a.PrivateRoute,{path:o+"/registry/supervisor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(c,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/new-surveyor",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(E,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:o+"/registry/surveyor-details/:id",component:e=>l.createElement(a.LayoutWrapper,{layoutClass:"action"},l.createElement(m,s({},e,{parentRoute:o})))}),l.createElement(a.PrivateRoute,{path:""+o,component:()=>Digit.UserService.hasAccess(["WT_VENDOR"])?l.createElement("div",{style:{display:"flex",gap:"24px",flexWrap:"wrap",width:"100%",padding:"8px 0"}},l.createElement(a.CitizenHomeCard,{header:e("TITLE_VENDOR_MANAGEMENT"),links:[{i18nKey:e("SEARCH_VENDOR"),link:"/digit-ui/citizen/vendor/search-vendor"}],Icon:()=>l.createElement(a.PropertyHouse,{className:"fill-path-primary-main"})})):l.createElement(n.Redirect,{to:{pathname:"/digit-ui/citizen/login",state:{from:o+"/wt-Vendor",role:"WT_VENDOR"}}}),exact:!0}))))},F=e=>l.createElement("div",{className:"confirmation_box"},l.createElement("span",null,(0,e.t)(""+e.title)," ")),H=e=>l.createElement("h1",{className:"heading-m"},e.label),B=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),U=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(B,null)),Y=(require("@djb25/digit-ui-react-components"),require("@djb25/digit-ui-react-components").Dropdown),G=require("@djb25/digit-ui-react-components").Dropdown,W=e=>l.createElement("h1",{className:"heading-m"},e.label),K=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),z=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(K,null)),X=e=>l.createElement("h1",{className:"heading-m"},e.label),q=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),j=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(q,null)),Q=e=>{let t=e.jumpTo;const o=i.useTranslation().t,r=n.useHistory();return l.createElement(a.LinkButton,{label:o("CS_COMMON_CHANGE"),className:"check-page-link-button",onClick:function(){r.push(t)}})},Z=e=>{const t=i.useTranslation().t;return e.isSuccess?window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_SUCCESS"):t("ES_VENDOR_RESPONSE_CREATE_ACTION"):e.isLoading?window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_PENDING"):t("CS_VENDOR_APPLICATION_PENDING"):e.isSuccess?void 0:window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_FAILED"):t("CS_VENDOR_APPLICATION_FAILED")},$={padding:"4px 0px",justifyContent:"space-between"},J=e=>{var t,n;return l.createElement(a.Banner,{message:Z(e),applicationNumber:null===(t=e.data)||void 0===t||null===(n=t.VendorAdditionalDetails)||void 0===n?void 0:n[0].registrationNo,info:e.isSuccess?e.t("ES_VENDOR_RESPONSE_CREATE_LABEL"):"",successful:e.isSuccess,style:{width:"100%"}})},ee=[{head:"VENDOR_DETAILS",body:[{route:"info",component:"ServiceDoc",nextStep:"vendor-details",key:"Documents"},{route:"vendor-details",component:"VendorDetails",withoutLabel:!0,key:"vendordet",type:"component",nextStep:"documents",hideInEmployee:!0,isMandatory:!0,texts:{header:"VENDOR_ADDITIONAL_DETAILS",submitBarLabel:"VENDOR_COMMON_NEXT"}}]},{head:"VENDOR_DOCUMENT_DETAILS",body:[{route:"documents",component:"VendorDocuments",withoutLabel:!0,key:"documents",type:"component",nextStep:null,texts:{header:"VENDOR_DOCUMENTS_DETAILS",submitBarLabel:"VENDOR_COMMON_NEXT"}}]}],te=require("@djb25/digit-ui-react-components").DatePicker,le=e=>l.createElement("h1",{className:"heading-m"},e.label),ne=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),ae=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(ne,null)),ie=require("@djb25/digit-ui-react-components").DatePicker,oe=e=>l.createElement("h1",{className:"heading-m"},e.label),re=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),se=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(re,null)),de={VendorDetails:e=>{var n,i,r,d;let u=e.t,c=e.config,E=e.onSelect,m=e.userType,v=e.formData;const S=Digit.UserService.getUser().info,p=v.ownerKey&&v.ownerKey[0]&&v.ownerKey[0].applicantName||(null==v||null===(n=v.ownerKey)||void 0===n?void 0:n.applicantName)||"",_=v.ownerKey&&v.ownerKey[0]&&v.ownerKey[0].emailId||(null==v||null===(i=v.ownerKey)||void 0===i?void 0:i.emailId)||"",D=v.ownerKey&&v.ownerKey[0]&&v.ownerKey[0].mobileNumber||(null==v||null===(r=v.ownerKey)||void 0===r?void 0:r.mobileNumber)||(null==S?void 0:S.mobileNumber),R=v.ownerKey&&v.ownerKey[0]&&v.ownerKey[0].altMobileNumber||(null==v||null===(d=v.ownerKey)||void 0===d?void 0:d.altmobileNumber)||"",g=t.useState(""),N=g[0],y=g[1],T=t.useState(""),I=T[0],C=T[1],A=t.useState(""),O=A[0],h=A[1],f=t.useState(""),b=f[0],V=f[1],L=t.useState(),M=L[0],w=L[1],P=t.useState(""),k=P[0],x=P[1],F=t.useState(""),H=F[0],B=F[1],U=t.useState(""),Y=U[0],G=U[1],W=t.useState(""),K=W[0],z=W[1],X=t.useState(""),q=X[0],j=X[1],Q=t.useState(""),Z=Q[0],$=Q[1],J=t.useState(""),ee=J[0],te=J[1],le=t.useState(""),ne=le[0],ae=le[1],ie=t.useState(""),oe=ie[0],re=ie[1],se=t.useState(""),de=se[0],ue=se[1],ce=t.useState(""),Ee=ce[0],me=ce[1],ve=t.useState(""),Se=ve[0],pe=ve[1],_e=t.useState(""),De=_e[0],Re=_e[1];t.useEffect(()=>{11!==k.length||b||M||Ee?11===k.length&&b&&M?(V(b),w(M),me(Ee)):(V(""),w(""),me("")):fetch("https://ifsc.razorpay.com/"+k).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH&&e.MICR&&(V(e.BANK),w(e.BRANCH),me(e.MICR))}).catch(()=>{})},[k]);const ge=Digit.ULBService.getCurrentTenantId(),Ne=o.useForm().control,ye=Digit.Hooks.fsm.useDsoSearch(ge,{staleTime:Infinity}).data;t.useEffect(()=>{if(ye){const e=ye.find(e=>e.id);e&&(h(e.name),C(e.id))}},[ye]);const Te=()=>{let e,t=v.ownerKey&&v.ownerKey[0];"citizen"===m?(e=s({},t,{applicantName:p,mobileNumber:D,altMobileNumber:R,emailId:_}),E(c.key,s({},v[c.key],e),!1,0)):(e=s({},t,{VendorCategory:N,name:O,VendorId:I,Bank:b,BankbranchName:M,IFSC:k,AccountNo:H,PanNo:Y,GstNo:K,GstState:q,RegistrationNo:Z,EpfNo:ee,EsiNo:ne,VendorType:oe,Status:de,micrNo:Ee,PhoneNo:Se,ContactPerson:De}),E(c.key,e,!1,0))};return t.useEffect(()=>{"citizen"===m&&Te()},[N,I,O,b,M,k,H,Y,K,q,Z,ee,ne,oe,de,Ee,Se,De,m]),l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{timeLine:[{actions:u("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:u("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:u("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormStep,{config:c,onSelect:Te,t:u,className:"formcomposer-grid-container-form"},l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,{className:"card-label-smaller"},l.createElement(a.CustomTooltip,{label:""+u("IFSC_CODE"),isMandatory:!1,message:u("INVALID_IFSC_CODE_ERROR_MESSAGE")})),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"IFSC",value:k,placeholder:"Enter IFSC Code",onChange:function(e){const t=e.target.value.replace(/[^a-zA-Z0-9]/g,"");t.length<=11&&x(t)},style:{width:"100%"},maxLength:11,ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[A-Z]{4}0[A-Z0-9]{6}$",type:"text",title:u("INVALID_IFSC_CODE_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("VENDOR_BANK_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"bankName",placeholder:"Bank Name Auto Select",style:{width:"100%"},value:b,onChange:function(e){V(e.target.value)},disabled:!0})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("VENDOR_BANK_BRANCH_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"BankbranchName",value:M,style:{width:"100%"},placeholder:"Bank Branch Name Auto Select",onChange:function(e){w(e.target.value)},disabled:!1})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("VENDOR_MICR_NO")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"MicrNo",value:Ee,style:{width:"100%"},placeholder:"MICR No",onChange:me,disabled:!1})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("ACCOUNT_NO")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"AccountNo",value:H,onChange:function(e){B(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"[0-9]{9,18}",type:"text",title:u("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("PHONE_NO")),l.createElement(a.MobileNumber,{value:Se,name:"PhoneNo",onChange:pe,style:{width:"100%"}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("CONTACT_PERSON")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"ContactPerson",value:De,onChange:function(e){Re(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:u("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("PAN_NO")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"PanNo",value:Y,onChange:function(e){G(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"[A-Z]{5}[0-9]{4}[A-Z]{1}",type:"text",title:u("INVALID_PAN_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("GST_NO")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"GstNo",value:K,onChange:function(e){z(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[A-Z0-9]{1}[Z]{1}[A-Z0-9]{1}$",type:"text",title:u("INVALID_GST_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("GST_REGISTERED_STATE/UT")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"GstState",value:q,onChange:function(e){j(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:u("PT_NAME_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("REGISTRATION_NO")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"RegistrationNo",value:Z,onChange:function(e){$(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:u("INVALID_REGISTRATION_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("EPF_NO")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"EpfNo",value:ee,onChange:function(e){te(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,15}$",type:"text",title:u("INVALID_EPF_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,""+u("ESI_NO")),l.createElement(a.TextInput,{t:u,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"EsiNo",value:ne,onChange:function(e){ae(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:u("INVALID_ESI_NO_ERROR_MESSAGE")}})),l.createElement(a.LabelFieldPair,null,l.createElement("div",null,u("VENDOR_TYPE"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}},""+u("AST_CLASSIFICATION_ASSET")))),l.createElement(o.Controller,{control:Ne,name:"VendorType",defaultValue:oe,rules:{required:u("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(a.Dropdown,{selected:oe,select:re,option:[{i18nKey:"Supplier",code:"SUPPLIER"},{i18nKey:"Contractor",code:"CONTRACTOR"}],optionKey:"i18nKey",placeholder:"Select",t:u})})),l.createElement(a.LabelFieldPair,null,l.createElement("div",null,u("VENOR_CATEGORY"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}}))),l.createElement(o.Controller,{control:Ne,name:"VendorCategory",defaultValue:N,rules:{required:u("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(a.Dropdown,{selected:N,select:y,option:[{i18nKey:"Firm",code:"FIRM"},{i18nKey:"Individual",code:"Individual"}],optionKey:"i18nKey",placeholder:"Select",t:u})})),l.createElement(a.LabelFieldPair,null,l.createElement("div",null,u("STATUS"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}},""+u("AST_CLASSIFICATION_ASSET")))),l.createElement(o.Controller,{control:Ne,name:"Status",defaultValue:de,rules:{required:u("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(a.Dropdown,{selected:de,select:ue,option:[{i18nKey:"Active",code:"ACTIVE"},{i18nKey:"Inactive",code:"INACTIVE"}],optionKey:"i18nKey",placeholder:"Select",t:u})})))))},VendorDocuments:e=>{var n;let i=e.t,o=e.config,r=e.onSelect,d=e.formData;const u=t.useState([null]),E=u[0],m=u[1],v=t.useState([null]),S=v[0],p=v[1],_=t.useState(null),D=_[0],R=_[1],g=t.useState(1)[1];return Digit.ULBService.getStateId(),Digit.ULBService.getStateId(),t.useState((null==d||null===(n=d.documents)||void 0===n?void 0:n.documents)||[]),t.useEffect(()=>{var e;null!=d&&null!==(e=d.documents)&&void 0!==e&&e.documents&&(p(d.documents.documents),g(d.documents.documents.length),m(new Array(d.documents.documents.length).fill(null)))},[d]),l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{timeLine:[{actions:i("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:i("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:i("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:1,showFinalStep:!1}),l.createElement(a.FormStep,{t:i,config:o,onSelect:()=>{let e;e=s({},d.documents,{documents:S.filter(e=>null!==e)}),r(o.key,e)},onSkip:()=>r(),isDisabled:S.some(e=>null===e)&&E.some(e=>null===e)},E.map((e,t)=>l.createElement(a.LabelFieldPair,{key:t},l.createElement(a.CardLabel,{className:"card-label-smaller"},i("VENDOR_ID")+(0!==t?t:"")),l.createElement("div",{className:"field",style:{display:"flex",alignItems:"center",paddingBottom:"10px"}},l.createElement(a.UploadFile,{onUpload:e=>((e,t)=>{const l=e.target.files[0];m(e=>{const n=[...e];return n[t]=l,n}),function(e,t){try{const l=function(){if(e.size>=5242880)R(i("CS_MAXIMUM_UPLOAD_SIZE_EXCEEDED"));else{const l=c(function(){return Promise.resolve(Digit.UploadServices.Filestorage("EWASTE",e,Digit.ULBService.getStateId())).then(function(e){var l,n;if((null==e||null===(l=e.data)||void 0===l||null===(n=l.files)||void 0===n?void 0:n.length)>0){const l=e.data.files[0].fileStoreId;p(e=>{const n=[...e];return n[t]={filestoreId:l,documentuuid:l,documentType:"Photo"+(t+1)},n})}else R(i("CS_FILE_UPLOAD_ERROR"))})},function(){R(i("CS_FILE_UPLOAD_ERROR"))});if(l&&l.then)return l.then(function(){})}}();Promise.resolve(l&&l.then?l.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}(l,t)})(e,t),onDelete:()=>p(e=>{const l=[...e];return l[t]=null,l}),id:"file-upload-"+t,message:S[t]?"1 "+i("CS_ACTION_FILEUPLOADED"):i("CS_ACTION_NO_FILEUPLOADED"),textStyles:{width:"100%"},inputStyles:{width:"280px"},accept:".pdf, .jpeg, .jpg, .png",buttonType:"button",error:!S[t]})))),D&&l.createElement(a.Toast,{label:D,onClose:()=>R(null),error:!0})))},ServiceDoc:e=>{var t;let n=e.t,i=e.config,o=e.onSelect;const r=Digit.ULBService.getStateId(),s=Digit.Hooks.asset.useAssetDocumentsMDMS(r,"ASSET",null!=i&&i.isMutation?["MutationDocuments"]:"Documents"),d=s.data,u=void 0===d?{}:d;let c=null==u||null===(t=u.ASSET)||void 0===t?void 0:t.Documents;return l.createElement("div",{className:"employee-form-content"},s.isLoading&&l.createElement(a.Loader,null),Array.isArray(c)&&c.map((e,t)=>{let i=e.dropdownData;return l.createElement(a.Card,{key:t},l.createElement("div",null,l.createElement("h3",{style:{margin:0}},t+1,". ",n(m(e.code,".","_")))),i.map((e,t)=>l.createElement("div",{key:t,style:{paddingLeft:"10px",marginBottom:"6px",fontSize:"14px"}},t+1,". ",n(m(null==e?void 0:e.code,".","_")))))}),l.createElement(a.ActionBar,null,l.createElement(a.SubmitBar,{label:n("COMMON_NEXT"),onSubmit:o})))},AddVendor:e=>{const o=Digit.ULBService.getCurrentTenantId(),r=Digit.ULBService.getStateId(),d=i.useTranslation().t,u=n.useHistory(),c=t.useState(1),E=c[0],m=c[1],v=t.useState(null),S=v[0],p=v[1],_=t.useState(!1),D=_[0],R=_[1],g=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1)[1],N=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1)[2],y=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1)[2],T=Digit.Hooks.fsm.useVendorCreate(o).mutate;t.useEffect(()=>{g(!1),y(),N()},[]);const I=function(e,t){return void 0===t&&(t=!1),[{head:"ES_VRNDOR_NEW_VENDOR_DETAILS",body:[{label:"ES_FSM_REGISTRY_NEW_VENDOR_NAME",isMandatory:!0,type:"text",disable:t,populators:{name:"vendorName",validation:{required:!0,pattern:/^[A-Za-z\s.,/]+$/},error:e("FSM_REGISTRY_INVALID_NAME"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_EMAIL",isMandatory:!1,type:"text",key:"emailId",populators:{name:"emailId",validation:{required:!1,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("FSM_REGISTRY_INVALID_EMAIL"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_VENDOR_PHONE",isMandatory:!0,type:"mobileNumber",key:"phone",disable:t,populators:{name:"phone",validation:{required:!0,pattern:/^[6-9]\d{9}$/},labelStyle:{border:"1px solid black",borderRight:"none"},error:e("FSM_REGISTRY_INVALID_PHONE"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_REGISTRY_SERVICE_TYPE",isMandatory:!0,type:"component",key:"serviceType",component:"SelectServiceType",disable:t,populators:{name:"serviceType",defaultValue:{code:"WT",name:"WT",i18nKey:"WT"}},texts:{header:"CS_COMMON_CHOOSE_SERVICE_TYPE",submitBarLabel:"CS_COMMON_NEXT"}}]},{head:"ES_FSM_REGISTRY_NEW_ADDRESS_DETAILS",body:[{label:"HOUSE_NO",isMandatory:!1,type:"text",key:"doorNo",populators:{name:"doorNo",defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_PLOT",isMandatory:!1,type:"text",key:"plotNo",populators:{name:"plotNo",defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_BUILDING_NAME",isMandatory:!1,type:"text",key:"buildingName",populators:{name:"buildingName",defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_STREET",isMandatory:!1,type:"text",key:"street",populators:{name:"street",defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_PINCODE",isMandatory:!1,type:"text",key:"pincode",populators:{name:"pincode",validation:{required:!1,pattern:/^[1-9][0-9]{5}$/},error:e("FSM_REGISTRY_INVALID_PINCODE"),defaultValue:"",className:"payment-form-text-input-correction"}},{route:"address",component:"VendorSelectAddress",withoutLabel:!0,texts:{headerCaption:"CS_FILE_APPLICATION_PROPERTY_LOCATION_LABEL",header:"CS_FILE_APPLICATION_PROPERTY_LOCATION_ADDRESS_TEXT",cardText:"CS_FILE_APPLICATION_PROPERTY_LOCATION_CITY_MOHALLA_TEXT",submitBarLabel:"CS_COMMON_NEXT"},key:"address",isMandatory:!0,type:"component"},{label:"ES_FSM_REGISTRY_NEW_LANDMARK",isMandatory:!1,type:"text",key:"landmark",populators:{name:"landmark",defaultValue:"",className:"payment-form-text-input-correction"}}]}]}(d),C=()=>{p(null)};return l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{route:"vendor-details",timeLine:[{actions:"New Vendor Details",currentStep:1}]},{route:"address-details",timeLine:[{actions:"Address Details",currentStep:2}]}],currentActiveIndex:E-1,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormComposer,{label:d("ES_COMMON_APPLICATION_SUBMIT"),config:I.filter(e=>!e.hideInEmployee).map(e=>s({},e,{isCollapsible:!0,isDefaultOpen:!0,body:e.body.filter(e=>!e.hideInEmployee)})),onSubmit:e=>{var t,l,n,a,i,s,d,c,E,m,v,S,_,D,R,g,N,y,I,A,O,h;const f=e,b=null==f?void 0:f.vendorName,V=null==f?void 0:f.pincode,L=null==f||null===(t=f.street)||void 0===t?void 0:t.trim(),M=null==f||null===(l=f.doorNo)||void 0===l?void 0:l.trim(),w=null==f||null===(n=f.plotNo)||void 0===n?void 0:n.trim(),P=null==f||null===(a=f.landmark)||void 0===a?void 0:a.trim(),k=null==f||null===(i=f.address)||void 0===i||null===(s=i.city)||void 0===s?void 0:s.name,x=null==f||null===(d=f.address)||void 0===d||null===(c=d.city)||void 0===c?void 0:c.state,F=null==f||null===(E=f.address)||void 0===E||null===(m=E.city)||void 0===m?void 0:m.name,H=null==f||null===(v=f.address)||void 0===v||null===(S=v.city)||void 0===S?void 0:S.name,B=null==f||null===(_=f.buildingName)||void 0===_?void 0:_.trim(),U=null==f||null===(D=f.address)||void 0===D||null===(R=D.locality)||void 0===R?void 0:R.code,Y=null==f||null===(g=f.address)||void 0===g||null===(N=g.locality)||void 0===N?void 0:N.name,G=null==f||null===(y=f.address)||void 0===y||null===(I=y.locality)||void 0===I?void 0:I.area,W=null==f||null===(A=f.serviceType)||void 0===A?void 0:A.code,K={vendor:{tenantId:o,name:b,agencyType:"ULB",paymentPreference:"post-service",address:{tenantId:o,landmark:P,doorNo:M,plotNo:w,street:L,city:k,district:F,region:H,state:x,country:"in",pincode:V,buildingName:B,locality:{code:U||"",name:Y||"",label:"Locality",area:G||""},geoLocation:{latitude:(null==f||null===(O=f.address)||void 0===O?void 0:O.latitude)||0,longitude:(null==f||null===(h=f.address)||void 0===h?void 0:h.longitude)||0}},owner:{tenantId:r,name:b,fatherOrHusbandName:b,relationship:"OTHER",gender:"MALE",dob:"915148800",emailId:(null==f?void 0:f.emailId)||"abc@egov.com",mobileNumber:null==f?void 0:f.phone},additionalDetails:{serviceType:W},vehicle:[],drivers:[],source:"WhatsApp"}};T(K,{onError:e=>{p({key:"error",action:e}),setTimeout(C,5e3)},onSuccess:(e,t)=>{p({key:"success",action:"ADD_VENDOR"}),setTimeout(()=>{C(),u.push("/digit-ui/employee/vendor/search-vendor")},2e3)}})},defaultValues:{serviceType:{code:"WT",name:"WT",i18nKey:"WT"},tripData:{noOfTrips:1,amountPerTrip:null,amount:null}},onFormValueChange:(e,t)=>{var l,n,a;const i=(null==t?void 0:t.vendorName)&&(null==t?void 0:t.phone)&&(null==t||null===(l=t.serviceType)||void 0===l?void 0:l.code),o=(null==t||null===(n=t.address)||void 0===n?void 0:n.city)&&(null==t||null===(a=t.address)||void 0===a?void 0:a.locality);R(!(!i||!o)),i?1===E&&(m(2),setTimeout(()=>{const e=Array.from(document.querySelectorAll(".collapsible-card-title")).find(e=>e.textContent.includes(d("ES_FSM_REGISTRY_NEW_ADDRESS_DETAILS")));e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100)):2===E&&(m(1),setTimeout(()=>{const e=Array.from(document.querySelectorAll(".collapsible-card-title")).find(e=>e.textContent.includes(d("ES_VRNDOR_NEW_VENDOR_DETAILS")));e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100))},noBreakLine:!0,noCard:!0,isDisabled:!D}),S&&l.createElement(a.Toast,{error:"error"===S.key,label:d("success"===S.key?"ES_FSM_REGISTRY_"+S.action+"_SUCCESS":S.action),onClose:C})))},VendorSelectAddress:e=>{var n,i,o;let r=e.t,d=e.config,u=e.onSelect,c=e.userType,E=e.formData;const m=Digit.Hooks.vendor.useTenants();let v=Digit.ULBService.getCurrentTenantId();const S=((null==E?void 0:E.address)||"").pincode,p="employee"===c?m.filter(e=>e.code===v):S?m.filter(e=>{var t;return null==e||null===(t=e.pincode)||void 0===t?void 0:t.some(e=>e==S)}):m;let _=null===(n=sessionStorage)||void 0===n?void 0:n.getItem("Digit_FSM_PT");var D;"undefined"!==_&&(_=JSON.parse(null===(D=sessionStorage)||void 0===D?void 0:D.getItem("Digit_FSM_PT")));let R={};_&&(R=p.filter(e=>{var t,l,n;return e.code==(null===(t=_)||void 0===t||null===(l=t.propertyDetails)||void 0===l||null===(n=l.address)||void 0===n?void 0:n.tenantId)}));const g=t.useState(()=>{var e,t;return(null==E||null===(e=E.address)||void 0===e?void 0:e.city)||(null===(t=R)||void 0===t?void 0:t[0])||null}),N=g[0],y=g[1],T=Digit.Hooks.useBoundaryLocalities(null==N?void 0:N.code,"revenue",{enabled:!!N},r).data,I=t.useState(),C=I[0],A=I[1],O=t.useState(()=>{var e,t,l,n,a,i,o;return(null===(e=_)||void 0===e||null===(t=e.propertyDetails)||void 0===t||null===(l=t.address)||void 0===l?void 0:l.locality)||(null==E||null===(n=E.cpt)||void 0===n||null===(a=n.details)||void 0===a||null===(i=a.address)||void 0===i?void 0:i.locality)||(null==E||null===(o=E.address)||void 0===o?void 0:o.locality)}),h=O[0],f=O[1];function b(e){f(null),A(null),Digit.SessionStorage.set("fsm.file.address.city",e),y(e)}function V(e){f(e),"employee"===c&&u(d.key,s({},E[d.key],{locality:e}))}return t.useEffect(()=>{p&&1===p.length&&y(p[0])},[p]),t.useEffect(()=>{if(N&&T){var e,t,l,n,a,i,o,r;let D=T,R=[];if(null!=E&&null!==(e=E.address)&&void 0!==e&&e.locality)f(E.address.locality);else if(null!=E&&null!==(t=E.cpt)&&void 0!==t&&null!==(l=t.details)&&void 0!==l&&null!==(n=l.address)&&void 0!==n&&n.locality)f(E.cpt.details.address.locality);else if(null!==(a=_)&&void 0!==a&&null!==(i=a.propertyDetails)&&void 0!==i&&null!==(o=i.address)&&void 0!==o&&o.locality){var m,v,S;f(null===(m=_)||void 0===m||null===(v=m.propertyDetails)||void 0===v||null===(S=v.address)||void 0===S?void 0:S.locality)}var p;null!=E&&null!==(r=E.address)&&void 0!==r&&r.pincode&&(R=D.filter(e=>{var t;return null===(t=e.pincode)||void 0===t?void 0:t.find(e=>e==E.address.pincode)}),null!=E&&null!==(p=E.address)&&void 0!==p&&p.locality||f()),"employee"===c&&u(d.key,s({},E[d.key],{city:N})),A(()=>R.length>0?R:D),1===R.length&&(f(R[0]),"employee"===c&&u(d.key,s({},E[d.key],{locality:R[0]})))}},[N,null==E||null===(i=E.cpt)||void 0===i||null===(o=i.details)||void 0===o?void 0:o.address,T]),"employee"===c?l.createElement(l.Fragment,null,l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,r("MYCITY_CODE_LABEL"),d.isMandatory?" * ":null),l.createElement(a.Dropdown,{className:"",isMandatory:!0,selected:1===(null==p?void 0:p.length)?p[0]:N,disable:1===(null==p?void 0:p.length),option:p,select:b,optionKey:"code",t:r})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_MOHALLA"),d.isMandatory?" * ":null),l.createElement(a.Dropdown,{className:"",isMandatory:!0,selected:h,option:C,select:V,optionKey:"name",t:r}))):l.createElement(l.Fragment,null,l.createElement(a.FormStep,{config:d,onSelect:function(){u(d.key,{city:N,locality:h})},t:r,isDisabled:!h},l.createElement(a.CardLabel,null,r("MYCITY_CODE_LABEL")+" *"),l.createElement(a.RadioOrSelect,{options:p,selectedOption:N,optionKey:"i18nKey",onSelect:b,t:r}),N&&C&&l.createElement(a.CardLabel,null,r("CS_CREATECOMPLAINT_MOHALLA")+" *"),N&&C&&l.createElement(a.RadioOrSelect,{isMandatory:d.isMandatory,options:C,selectedOption:h,optionKey:"name",onSelect:V,t:r})))},SearchApp:e=>{n.useParams();const o=i.useTranslation().t,r=Digit.ULBService.getCurrentTenantId(),d=t.useState({}),u=d[0],c=d[1],E=t.useState(null),m=E[0],S=E[1],p={enabled:!!(u&&Object.keys(u).length>0)},_=Digit.Hooks.ew.useEWSearch({tenantId:r,filters:u},p),D=_.isLoading,R=_.data,g=void 0===R?{}:R,N=g.EwasteApplication;return l.createElement(l.Fragment,null,l.createElement(v,{t:o,isLoading:D,tenantId:r,setShowToast:S,onSubmit:function(e){var t=new Date(null==e?void 0:e.fromDate);null==t||t.setSeconds((null==t?void 0:t.getSeconds())-19800);var l=new Date(null==e?void 0:e.toDate);null==l||l.setSeconds((null==l?void 0:l.getSeconds())+86399-19800);let n=Object.keys(data).filter(e=>data[e]).reduce((e,t)=>s({},e,{[t]:"object"==typeof data[t]?data[t].code:data[t]}),{});!(Object.entries(n).length>0)||n.requestId||n.creationReason||n.fromDate||n.mobileNumber||n.requestId||n.status||n.toDate?!(Object.entries(n).length>0&&(n.creationReason||n.status))||n.requestId||n.fromDate||n.mobileNumber||n.requestId||n.toDate?Object.entries(n).length>0&&n.fromDate&&!n.toDate||!n.fromDate&&n.toDate?S({warning:!0,label:"ERR_PROVIDE_BOTH_FORM_TO_DATE"}):c(n):S({warning:!0,label:"ERR_PROVIDE_MORE_PARAM_WITH_TYPE_STATUS"}):S({warning:!0,label:"ERR_VENDOR_FILL_VALID_FIELDS"})},data:_.isSuccess&&!D?N.length>0?N:{display:"ES_COMMON_NO_DATA"}:"",count:g.Count}),m&&l.createElement(a.Toast,{error:m.error,warning:m.warning,label:o(m.label),isDleteBtn:!0,onClose:()=>{S(null)}}))},SearchVendor:()=>{var e,n,a,o,r,d;const u=i.useTranslation().t,c=Digit.ULBService.getCurrentTenantId(),E=Digit.Hooks.useQueryParams().selectedTabs,m=t.useState({}),v=m[0],S=m[1],p=t.useState([{id:"createdTime",desc:!0}]),_=p[0],D=p[1],R=t.useState(0),g=R[0],N=R[1],y=t.useState(10),T=y[0],I=y[1],C=t.useState(E||"VENDOR"),A=C[0],O=C[1],h=t.useState(""),f=h[0],b=h[1],V=t.useState(""),L=V[0],M=V[1],w=t.useState([]),k=w[0],x=w[1],F=Digit.Hooks.fsm.useDsoSearch(c,{status:"ACTIVE"},{staleTime:Infinity}).data,H=Digit.Hooks.wt.useFillPointSearch({tenantId:c,filters:{limit:1e3}},{staleTime:Infinity}).data;let B={limit:T,offset:g,sortBy:null==_||null===(e=_[0])||void 0===e?void 0:e.id,sortOrder:null!=_&&null!==(n=_[0])&&void 0!==n&&n.desc?"DESC":"ASC"};const U="VEHICLE"===A?Digit.Hooks.fsm.useVehiclesSearch({tenantId:c,filters:s({},B,{registrationNumber:null==v?void 0:v.registrationNumber,status:"ACTIVE,DISABLED",vendorId:null==v||null===(a=v.vendor)||void 0===a?void 0:a.id,fillingPointId:null==v||null===(o=v.fillingPoint)||void 0===o?void 0:o.id}),config:{enabled:!1}}):"DRIVER"===A?Digit.Hooks.fsm.useDriverSearch({tenantId:c,filters:s({},B,{name:null==v?void 0:v.name,status:"ACTIVE,DISABLED",vendorId:null==v||null===(r=v.vendor)||void 0===r?void 0:r.id}),config:{enabled:!1}}):"SUPERVISOR"===A?Digit.Hooks.fsm.useSupervisorDetails(c,s({},B,{status:"ACTIVE,DISABLED"}),{enabled:!1}):"SURVEYOR"===A?Digit.Hooks.fsm.useSurveyorDetails(c,s({},B,{status:"ACTIVE,DISABLED"}),{enabled:!1}):Digit.Hooks.fsm.useVendorSearch({tenantId:c,filters:s({},B,{name:null==v?void 0:v.name,status:"ACTIVE,DISABLED"}),config:{enabled:!1}}),Y=U.data,G=U.isLoading,W=U.refetch;Digit.Hooks.fsm.useVendorSearch({tenantId:c,filters:s({},B,{name:null==v?void 0:v.name,status:"ACTIVE,DISABLED"}),config:{enabled:!1}});const K=Digit.Hooks.fsm.useDsoSearch(c,{vehicleIds:f,driverIds:L,status:"ACTIVE"},{enabled:!1}),z=K.data,X=K.isLoading,q=K.refetch,j=(null==Y?void 0:Y.totalCount)||50;t.useEffect(()=>{W(),q()},[]),t.useEffect(()=>{W()},[v,_,g,T]),t.useEffect(()=>{if(null!=Y&&Y.vehicle&&"VEHICLE"===A){const e=Y.vehicle.map(e=>e.id).filter(Boolean).join(",");b(e),x(Y.vehicle)}if(null!=Y&&Y.driver&&"DRIVER"===A){const e=Y.driver.map(e=>e.id).filter(Boolean).join(",");M(e),x(null==Y?void 0:Y.driver)}if(null!=Y&&Y.vendor&&"VENDOR"===A){const e=Y.vendor.map(e=>{var t,l,n,a;return{mobileNumber:null===(t=e.owner)||void 0===t?void 0:t.mobileNumber,name:e.name,id:e.id,auditDetails:e.auditDetails,drivers:e.drivers,activeDrivers:null===(l=e.drivers)||void 0===l?void 0:l.filter(e=>"ACTIVE"===e.status),allVehicles:e.vehicles,dsoDetails:e,vendorAdditionalDetails:e.vendorAdditionalDetails,fillingPoint:e.fillingPoint,vehicles:null===(n=e.vehicles)||void 0===n||null===(a=n.filter(e=>"ACTIVE"===e.status))||void 0===a?void 0:a.map(e=>({id:e.id,registrationNumber:null==e?void 0:e.registrationNumber,type:e.type,i18nKey:"FSM_VEHICLE_TYPE_"+e.type,capacity:e.tankCapacity,suctionType:e.suctionType,model:e.model}))}});x(e)}if("SUPERVISOR"===A){const e=[{id:"SUP1",name:"Amit Kumar",employeeId:"EMP001",status:"ACTIVE",owner:{mobileNumber:"9876543210",userName:"9876543210"},auditDetails:{createdTime:(new Date).getTime()},vendorData:{name:"Clean City Agency"}},{id:"SUP2",name:"Rajesh Singh",employeeId:"EMP002",status:"ACTIVE",owner:{mobileNumber:"9876543211",userName:"9876543211"},auditDetails:{createdTime:(new Date).getTime()},vendorData:{name:"Green Environment"}}];x((null==Y?void 0:Y.supervisor)||e)}if("SURVEYOR"===A){const e=[{id:"SUR1",name:"Suresh Raina",employeeId:"EMP101",status:"ACTIVE",owner:{mobileNumber:"9123456780",userName:"9123456780"},auditDetails:{createdTime:(new Date).getTime()},vendorData:{name:"Clean City Agency"}},{id:"SUR2",name:"Mahesh Babu",employeeId:"EMP102",status:"ACTIVE",owner:{mobileNumber:"9123456781",userName:"9123456781"},auditDetails:{createdTime:(new Date).getTime()},vendorData:{name:"Green Environment"}}];x((null==Y?void 0:Y.surveyor)||e)}},[Y,A]),t.useEffect(()=>{""===f&&""===L||q()},[f,L]),t.useEffect(()=>{let e=!0;if(z&&e){if("VEHICLE"===A){const e=null==Y?void 0:Y.vehicle.map(e=>{let t=z.find(t=>{var l,n;return null===(l=t.dsoDetails)||void 0===l||null===(n=l.vehicles)||void 0===n?void 0:n.find(t=>t.id===e.id)});if(t){var l,n;let a=s({},e,{vendor:t.dsoDetails});const i=null===(l=t.dsoDetails)||void 0===l||null===(n=l.vehicles)||void 0===n?void 0:n.find(t=>t.id===e.id);return i&&(a.driverData=i.driverData||i.driver||a.driverData),a}return e});x(e),b("")}if("DRIVER"===A){const e=null==Y?void 0:Y.driver.map(e=>{let t=z.find(t=>{var l,n;return null===(l=t.dsoDetails)||void 0===l||null===(n=l.drivers)||void 0===n?void 0:n.find(t=>t.id===e.id)});return t?s({},e,{vendor:t.dsoDetails}):e});x(e),M("")}}return()=>{e=!1}},[z,Y]);const Q="VEHICLE"===A?[{label:u("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==F?void 0:F.map(e=>{var t;return s({},e.dsoDetails,{displayName:e.dsoDetails.name+" ("+(e.dsoDetails.mobileNumber||(null===(t=e.dsoDetails.owner)||void 0===t?void 0:t.mobileNumber)||"N/A")+")"})}),optionsKey:"displayName"},{label:u("ES_FSM_REGISTRY_SEARCH_FILLING_POINT"),name:"fillingPoint",type:"dropdown",options:null==H||null===(d=H.fillingPoints)||void 0===d?void 0:d.map(e=>s({},e,{name:(null==e?void 0:e.name)||(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.fillingStationId)})),optionsKey:"name"},{label:u("ES_VEHICLE_SEARCH_VEHICLE_NUMBER"),name:"registrationNumber",pattern:"[A-Z]{2}[- ]?[0-9]{2}[- ]?[A-Z]{1,2}[- ]?[0-9]{4}",title:u("ES_FSM_VEHICLE_FORMAT_TIP")}]:"DRIVER"===A?[{label:u("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==F?void 0:F.map(e=>{var t;return s({},e.dsoDetails,{displayName:e.dsoDetails.name+" ("+(e.dsoDetails.mobileNumber||(null===(t=e.dsoDetails.owner)||void 0===t?void 0:t.mobileNumber)||"N/A")+")"})}),optionsKey:"displayName"},{label:u("ES_DRIVER_SEARCH_DRIVER_NAME"),name:"name"}]:"SUPERVISOR"===A||"SURVEYOR"===A?[{label:u("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==F?void 0:F.map(e=>{var t;return s({},e.dsoDetails,{displayName:e.dsoDetails.name+" ("+(e.dsoDetails.mobileNumber||(null===(t=e.dsoDetails.owner)||void 0===t?void 0:t.mobileNumber)||"N/A")+")"})}),optionsKey:"displayName"},{label:u("SUPERVISOR"===A?"ES_SUPERVISOR_SEARCH_NAME":"ES_SURVEYOR_SEARCH_NAME"),name:"name"}]:[{label:u("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"name"}],Z=t.useCallback(e=>{0!==(null==e?void 0:e.length)&&D(e)},[]);return l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(P,{data:{table:k},isLoading:G||X,onSort:Z,disableSort:!1,sortParams:_,userRole:"FSM_ADMIN",onFilterChange:()=>{},searchFields:Q,onSearch:function(e){void 0===e&&(e={}),S(s({},e))},onNextPage:()=>{N(e=>e+T)},onPrevPage:()=>{N(e=>e-T)},currentPage:Math.floor(g/T),pageSizeLimit:T,onPageSizeChange:e=>{I(Number(e.target.value))},totalRecords:j||0,onTabChange:e=>{O(e)},selectedTab:A,refetchData:()=>{W()},refetchVendor:()=>{q()}})))},SelectServiceType:e=>{let n=e.config,i=e.onSelect,o=e.t,r=e.userType,s=e.formData;const d=Digit.ULBService.getCurrentTenantId(),u=(Digit.ULBService.getStateId(),t.useState(null==s?void 0:s.serviceType)),c=u[0],E=u[1],m=t.useState([]),v=m[0],S=m[1],p=Digit.Hooks.useCustomMDMS(d,"tenant",[{name:"citymodule"}],{select:e=>{var t;return null==e||null===(t=e.tenant)||void 0===t?void 0:t.citymodule}}),_=p.data,D=p.isLoading;return t.useEffect(()=>{if(_){const e=_.map(e=>({i18nKey:""+e.code,code:""+e.code,value:""+e.name}));if(S(e),!c||"WT"===c.code){const t=e.find(e=>"WT"===e.code);t&&(E(t),"employee"===r&&i(n.key,t))}}},[_]),D?l.createElement(a.Loader,null):"employee"===r?l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,o(n.label)),l.createElement(a.Dropdown,{className:"payment-form-text-input-correction",isMandatory:n.isMandatory,selected:c,option:v,select:e=>{E(e),"employee"===r&&i(n.key,e)},optionKey:"i18nKey",disable:n.disable,t:o})):void 0},SelectVehicleType:e=>{var n;let i=e.t,o=e.config,r=e.onSelect,d=e.formData;const u=Digit.ULBService.getStateId(),c=Digit.ULBService.getCurrentTenantId(),E=Digit.Hooks.wt.useWTMDMS(u,"Vehicle","VehicleMakeModel"),m=E.data,v=E.isLoading,S=Digit.Hooks.useCustomMDMS(c,"tenant",[{name:"citymodule"}],{select:e=>{var t;return null==e||null===(t=e.tenant)||void 0===t?void 0:t.citymodule}}),p=S.data,_=S.isLoading,D=t.useState({}),R=D[0],g=D[1],N=t.useState([]),y=N[0],T=N[1],I=t.useState({}),C=I[0],A=I[1],O=t.useState([]),h=O[0],f=O[1],b=t.useState({}),V=b[0],L=b[1],M=t.useState(""),w=M[0],P=M[1],k=(null==d||null===(n=d.serviceType)||void 0===n?void 0:n.code)||(null==d?void 0:d.serviceType),x=t.useMemo(()=>{if(!p||!m)return{};const e={};return p.forEach(t=>{"WT"===t.code?e[t.code]=m.filter(e=>["MAHINDRA","TATA","TRACTOR","TAFE","SONALIKA"].includes(e.code)).map(e=>e.code):"CND"===t.code&&(e[t.code]=m.filter(e=>["MAHINDRA","TATA"].includes(e.code)).map(e=>e.code))}),e},[p,m]);return t.useEffect(()=>{g(x)},[x]),t.useEffect(()=>{if(!m)return;const e=R[k],t=e?m.filter(t=>e.includes(t.code)):m;T(t),A({}),f([]),L({}),P("")},[m,k,R]),t.useEffect(()=>{if(!m||null==C||!C.code)return;const e=m.filter(e=>e.make===C.code);f(e),L({}),P("")},[C,m]),t.useEffect(()=>{null!=V&&V.capacity&&P(V.capacity)},[V]),v||_?l.createElement(a.Loader,null):m&&p?l.createElement(l.Fragment,null,l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_MODEL")),l.createElement(a.Dropdown,{className:"form-field",selected:C,option:y,select:e=>{A(e),r(o.key,s({},(null==d?void 0:d[o.key])||{},{modal:e,type:""}))},optionKey:"name",t:i})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_TYPE")),l.createElement(a.Dropdown,{className:"form-field",selected:V,option:h,select:e=>{L(e),P(e.capacity),r(o.key,s({},d[o.key],{type:e}))},optionKey:"name",t:i})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_CAPACITY")),l.createElement(a.TextInput,{className:"",textInputStyle:{width:"100%"},value:w,disable:!0}))):l.createElement("div",null,i("ERROR_FETCHING_DATA"))},BankDetailsComponent:e=>{let n=e.t,i=e.config,o=e.onSelect,r=e.formData;d(e,k);const s=t.useState((null==r?void 0:r.ifscCode)||""),u=s[0],c=s[1],E=t.useState((null==r?void 0:r.bankName)||""),m=E[0],v=E[1],S=t.useState((null==r?void 0:r.branchName)||""),p=S[0],_=S[1],D=t.useState((null==r?void 0:r.accountNumber)||""),R=D[0],g=D[1],N=t.useState(null)[1];return t.useEffect(()=>{11===u.length&&fetch("https://ifsc.razorpay.com/"+u).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH?(v(e.BANK),_(e.BRANCH),"function"==typeof o&&o(i.key,{bankName:e.BANK,branchName:e.BRANCH,ifscCode:u,accountNumber:R}),N({error:!1,label:n("VALID_IFSC_CODE")})):N({error:!0,label:n("INVALID_IFSC_CODE")})}).catch(()=>{N({error:!0,label:n("INVALID_IFSC_CODE")})})},[u]),t.useEffect(()=>{"function"==typeof o&&o(i.key,{bankName:m,branchName:p,ifscCode:u,accountNumber:R})},[R,m,p,u]),l.createElement(l.Fragment,null,l.createElement(a.CardLabel,null,n("ES_FSM_REGISTRY_IFSC_CODE")),l.createElement(a.TextInput,{t:n,type:"text",isMandatory:!1,name:"ifscCode",value:u,onChange:e=>{const t=e.target.value.replace(/[^a-zA-Z0-9]/g,"");t.length<=11&&c(t)},style:{width:"100%"},maxLength:11}),l.createElement(a.CardLabel,null,n("ES_FSM_REGISTRY_ACCOUNT_NUMBER")),l.createElement(a.TextInput,{t:n,type:"text",isMandatory:!1,name:"accountNumber",value:R,onChange:e=>g(e.target.value),style:{width:"100%"}}),l.createElement(a.CardLabel,null,n("ES_FSM_REGISTRY_BANK_NAME")),l.createElement(a.TextInput,{t:n,type:"text",isMandatory:!1,name:"bankName",value:m,onChange:e=>v(e.target.value),disabled:11===u.length&&m,style:{width:"100%"}}),l.createElement(a.CardLabel,null,n("ES_FSM_REGISTRY_BRANCH_NAME")),l.createElement(a.TextInput,{t:n,type:"text",isMandatory:!1,name:"branchName",value:p,onChange:e=>_(e.target.value),disabled:11===u.length&&p,style:{width:"100%"}}))},AddDriver:()=>{var e,o;const d=Digit.ULBService.getCurrentTenantId(),u=i.useTranslation().t,c=Digit.ULBService.getStateId(),E=t.useState(null),m=E[0],v=E[1],S=r.useQueryClient(),p=n.useHistory(),_=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1)[1],D=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1)[2],R=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1)[2],g="WT_VENDOR"===Digit.UserService.getType()||Digit.UserService.hasAccess(["WT_VENDOR"]),N=Digit.Hooks.fsm.useDriverCreate(c).mutate,y=Digit.Hooks.fsm.useVendorUpdate("dl.djb").mutate,T=null===(e=Digit.UserService.getUser())||void 0===e||null===(o=e.info)||void 0===o?void 0:o.mobileNumber,I=Digit.Hooks.fsm.useDsoSearch(d,{mobileNumber:T},{enabled:!(!g||!T)}).data;t.useEffect(()=>{_(!1),R(),D()},[]);const C=function(e,t){return void 0===t&&(t=!1),[{head:"ES_FSM_REGISTRY_DRIVER_DETAILS",body:[{label:"ES_FSM_REGISTRY_DRIVER_NAME",isMandatory:!0,type:"text",disable:t,populators:{name:"driverName",validation:{required:!0,pattern:{value:/^[A-Za-z\s]+$/,message:e("FSM_REGISTRY_INVALID_NAME")}},error:e("FSM_REGISTRY_INVALID_NAME"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_DRIVER_LICENSE",isMandatory:!0,type:"text",key:"license",populators:{name:"license",validation:{required:!0,pattern:{value:/^[A-Z]{2}-[0-9]{2}-[0-9]{4}-[0-9]{7}$/,message:e("ES_FSM_REGISTRY_INVALID_LICENSE")}},error:e("ES_FSM_REGISTRY_INVALID_LICENSE"),required:!1,defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_REGISTRY_SERVICE_TYPE",isMandatory:!0,type:"component",route:"select-service",hideInEmployee:!1,key:"serviceType",component:"SelectServiceType",disable:t,populators:{name:"serviceType",defaultValue:{code:"WT",name:"WT",i18nKey:"WT"}},texts:{headerCaption:"",header:"CS_COMMON_CHOOSE_GENDER",cardText:"CS_COMMON_SELECT_GENDER",submitBarLabel:"CS_COMMON_NEXT",skipText:"CORE_COMMON_SKIP_CONTINUE"}}]},{head:"ES_FSM_REGISTRY_PERSONAL_DETAILS",body:[{label:"ES_FSM_REGISTRY_NEW_GENDER",isMandatory:!0,type:"component",route:"select-gender",hideInEmployee:!1,key:"selectGender",component:"SelectGender",texts:{headerCaption:"",header:"CS_COMMON_CHOOSE_GENDER",cardText:"CS_COMMON_SELECT_GENDER",submitBarLabel:"CS_COMMON_NEXT",skipText:"CORE_COMMON_SKIP_CONTINUE"}},{label:e("ES_FSM_REGISTRY_NEW_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(te,s({onChange:e.onChange,date:e.value},t,{max:(()=>{const e=new Date;return e.setFullYear(e.getFullYear()-18),e.toISOString().split("T")[0]})()}))}},{label:"ES_FSM_REGISTRY_NEW_EMAIL",isMandatory:!1,type:"text",key:"emailId",populators:{name:"emailId",validation:{required:!1,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("FSM_REGISTRY_INVALID_EMAIL"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_DRIVER_PHONE",isMandatory:!0,type:"mobileNumber",key:"phone",disable:t,populators:{name:"phone",validation:{required:!0,pattern:/^[6-9]\d{9}$/},error:e("FSM_REGISTRY_INVALID_PHONE"),defaultValue:"",className:"payment-form-text-input-correction",labelStyle:{border:"1px solid black",borderRight:"none"}}}]}]}(u),A=t.useState(!1),O=A[0],h=A[1],f=()=>{v(null)};return console.log(g,"iscitizen"),l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{route:"vendor-details",timeLine:[{actions:u("ES_FSM_REGISTRY_TITLE_NEW_DRIVER"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormComposer,{isDisabled:!O,label:u("ES_COMMON_APPLICATION_SUBMIT"),config:C.filter(e=>!e.hideInEmployee).map(e=>s({},e,{isCollapsible:!0,isDefaultOpen:!0,body:e.body.filter(e=>!e.hideInEmployee)})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l;const n=null==e?void 0:e.driverName,a=null==e?void 0:e.license,i=null==e||null===(t=e.selectGender)||void 0===t?void 0:t.code,o=null==e?void 0:e.emailId,r=null==e?void 0:e.phone,d=new Date(""+e.dob).getTime()||new Date("1/1/1970").getTime(),u=null==e||null===(l=e.serviceType)||void 0===l?void 0:l.code;N({driver:{tenantId:"dl.djb",name:n,licenseNumber:a,status:"ACTIVE",owner:{tenantId:c,name:n,fatherOrHusbandName:n,relationship:"OTHER",gender:i,dob:d,emailId:o||"abc@egov.com",mobileNumber:r},additionalDetails:{serviceType:u},vendorDriverStatus:"ACTIVE"}},{onError:(e,t)=>{v({key:"error",action:e}),setTimeout(f,5e3)},onSuccess:(e,t)=>{var l;if(v({key:"success",action:"ADD_DRIVER"}),setTimeout(f,5e3),S.invalidateQueries("FSM_DRIVER_SEARCH"),g&&null!=I&&null!==(l=I[0])&&void 0!==l&&l.dsoDetails){const t=e.driver.map(e=>s({},e,{vendorDriverStatus:"ACTIVE",status:"ACTIVE"})),l=I[0].dsoDetails,n={vendor:s({},l,{drivers:l.drivers?[...l.drivers,...t]:[...t]})};y(n,{onError:e=>{v({key:"error",action:e})},onSuccess:()=>{var e,t,l;v({key:"success",action:"ADD_DRIVER"}),S.invalidateQueries("DSO_SEARCH");const n=(null===(e=Digit.UserService.getUser())||void 0===e||null===(t=e.info)||void 0===t||null===(l=t.type)||void 0===l?void 0:l.toLowerCase())||"citizen";setTimeout(()=>{f(),p.push("/digit-ui/"+n+"/vendor/search-vendor?selectedTabs=DRIVER")},3e3)}})}else{var n,a,i;const e=(null===(n=Digit.UserService.getUser())||void 0===n||null===(a=n.info)||void 0===a||null===(i=a.type)||void 0===i?void 0:i.toLowerCase())||"citizen";S.invalidateQueries("FSM_DRIVER_SEARCH"),setTimeout(()=>{f(),p.push("/digit-ui/"+e+"/vendor/search-vendor?selectedTabs=DRIVER")},3e3)}}})},defaultValues:{serviceType:{code:"WT",name:"WT",i18nKey:"WT"},tripData:{noOfTrips:1,amountPerTrip:null,amount:null}},onFormValueChange:(e,t)=>{if(null!=t&&t.license){const l=t.license.replace(/[^A-Za-z0-9]/g,"").toUpperCase();let n=l;l.length>2&&(n=l.slice(0,2)+"-"+l.slice(2)),l.length>4&&(n=n.slice(0,5)+"-"+n.slice(5)),l.length>8&&(n=n.slice(0,10)+"-"+n.slice(10));const a=n.slice(0,18);t.license!==a&&e("license",a)}null!=t&&t.driverName&&/^[A-Za-z\s]+$/.test(null==t?void 0:t.driverName)&&null!=t&&t.license&&/^[A-Z]{2}-[0-9]{2}-[0-9]{4}-[0-9]{7}$/.test(null==t?void 0:t.license)&&null!=t&&t.selectGender&&null!=t&&t.dob&&new Date(null==t?void 0:t.dob).getTime()<=(new Date).setFullYear((new Date).getFullYear()-18)?h(!0):h(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),m&&l.createElement(a.Toast,{error:"error"===m.key,label:u("success"===m.key?"ES_FSM_"+m.action+"_SUCCESS":m.action),onClose:f})))},EditVendorDetails:e=>{var o,d,u;const c=Digit.ULBService.getCurrentTenantId(),E=i.useTranslation().t,m=n.useHistory(),v=r.useQueryClient();let S=n.useParams().id;const p=t.useState(!1),_=p[0],D=p[1],R=t.useState(null),g=R[0],N=R[1],y=t.useState(!1),T=y[0],I=y[1],C=t.useState(null),A=C[0],O=C[1],h=t.useState([]),f=h[0],b=h[1],V=t.useState([]),L=V[0],M=V[1],w=t.useState({}),P=w[0],k=w[1],x=Digit.Hooks.fsm.useDsoSearch(c,{ids:S},{staleTime:Infinity}),B=x.data,Y=x.isLoading,G=x.refetch,W=Digit.Hooks.fsm.useVehiclesSearch({tenantId:c,filters:{status:"ACTIVE",sortBy:"registrationNumber",sortOrder:"ASC",vehicleWithNoVendor:!0}}),K=W.data,z=W.refetch,X=Digit.Hooks.fsm.useDriverSearch({tenantId:c,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE",driverWithNoVendor:!0}}),q=X.data,j=X.refetch,Q=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:c,filters:{vendorId:S}},{enabled:!!S}),Z=Q.data,$=Q.isLoading,J=Digit.Hooks.fsm.useVendorUpdate(c).mutate;function ee(e){D(!1),N(e)}const te=null===(o=Digit.SessionStorage.get("User").info.type)||void 0===o?void 0:o.toLowerCase();t.useEffect(()=>{switch(g){case"DELETE":case"ADD_VEHICLE":case"ADD_DRIVER":return I(!0);case"EDIT":return m.push("/digit-ui/"+te+"/fsm/registry/modify-vendor/"+S);case"HOME":return m.push("/digit-ui/"+te+"/fsm/registry?selectedTabs=VENDOR")}},[g]),t.useEffect(()=>{K&&b((null==K?void 0:K.vehicle)||[])},[K]),t.useEffect(()=>{q&&M((null==q?void 0:q.driver)||[])},[q]);const le=()=>{O(null)},ne=()=>{N(null),k({}),I(!1)},ae=window.Digit.Utils.browser.isMobile();if(Y)return l.createElement(a.Loader,null);const ie=["vendorAdditionalDetailsId","vendorId","tenantId","code","lastModifiedTime","createdTime","lastModifiedBy","createdBy","active","status","vendorType","vendorGroup","narration","documents"];return l.createElement("div",{className:"employee-form-content"},Y?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,l.createElement(a.Card,null,null==B||null===(d=B[0])||void 0===d||null===(u=d.employeeResponse)||void 0===u?void 0:u.map((e,t)=>{var n,i;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(a.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},E(e.title)),l.createElement("div",null,null==e||null===(n=e.values)||void 0===n?void 0:n.map((t,n)=>{var i;if("ES_FSM_REGISTRY_DETAILS_ADDITIONAL_DETAILS"===t.title){var o,r;const e=null==Z||null===(o=Z.VendorDetails)||void 0===o||null===(r=o[0])||void 0===r?void 0:r.vendorAdditionalDetails,n=Object.entries(e||{}).filter(e=>!ie.includes(e[0]));return l.createElement(l.Fragment,{key:t.title},l.createElement(a.Row,{label:E(t.title),text:"",className:"border-none flex-box"}),$?l.createElement(a.Loader,null):e?l.createElement(a.Card,{className:"card-with-background",style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"additional-grid"},n.map(e=>{let t=e[0],n=e[1];if("object"==typeof n&&null!==n)return null;const a=String(t);let i=null!=n&&""!==n?String(n):"N/A";var o,r;return"name"!==t||n&&""!==n||(i=(null==B||null===(o=B[0])||void 0===o||null===(r=o.dsoDetails)||void 0===r?void 0:r.name)||"N/A"),l.createElement(l.Fragment,{key:a},l.createElement("div",{className:"additional-label"},E((e=>{const t=e.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)})(a))),l.createElement("div",{className:"additional-value"},i))})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>m.push("/digit-ui/"+te+"/vendor/registry/additionaldetails/info?vendorId="+S)},E("Edit Details"))):l.createElement("div",{onClick:()=>m.push("/digit-ui/"+te+"/vendor/registry/additionaldetails/vendor-details?vendorId="+S),className:"add-details-link hover-button"},E("Add Additional Details")))}return l.createElement(a.Row,{key:E(String(t.title)),label:E(String(t.title)),text:t.value?E(String(t.value)):"N/A",last:n===(null==e||null===(i=e.values)||void 0===i?void 0:i.length)-1,caption:t.caption,className:"border-none flex-box "+(ae?"":"vendor-details-row")})}),null==e||null===(i=e.child)||void 0===i?void 0:i.map((t,n)=>{var i;return l.createElement(a.Card,{className:"card-with-background",key:t.id||n},l.createElement("div",{className:"card-head"},l.createElement("h2",null,E(e.type)," ",n+1),l.createElement("div",{style:{display:"flex"}},l.createElement("span",{onClick:()=>((e,t,l)=>{if("ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===t)m.push("/digit-ui/"+te+"/fsm/registry/modify-driver/"+l);else{var n,a;let t=null==e||null===(n=e.values)||void 0===n||null===(a=n.find(e=>"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.title))||void 0===a?void 0:a.value;m.push("/digit-ui/"+te+"/fsm/registry/modify-vehicle/"+t)}})(t,e.type,t.id)},l.createElement(a.EditIcon,{style:{cursor:"pointer",marginRight:"20px"},className:"edit",fill:"#a82227"})),l.createElement("span",{onClick:()=>((e,t,l)=>{let n={};if("ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===t){var a,i;let e=null==B||null===(a=B[0])||void 0===a?void 0:a.dsoDetails,t=null==e?void 0:e.drivers;t=t.map(e=>(e.id===l&&(e.vendorDriverStatus="INACTIVE"),e)),n={vendor:s({},e,{owner:s({},e.owner,{gender:(null===(i=e.owner)||void 0===i?void 0:i.gender)||"OTHERS"}),drivers:t})}}else{var o,r,d,u;let t=null==B||null===(o=B[0])||void 0===o?void 0:o.dsoDetails,l=null==t?void 0:t.vehicles,a=null==e||null===(r=e.values)||void 0===r||null===(d=r.find(e=>"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.title))||void 0===d?void 0:d.value;l=l.map(e=>(e.registrationNumber===a&&(e.vendorVehicleStatus="INACTIVE"),e)),n={vendor:s({},t,{owner:s({},t.owner,{gender:(null===(u=t.owner)||void 0===u?void 0:u.gender)||"OTHERS"}),vehicles:l})}}J(n,{onError:(e,t)=>{O({key:"error",action:e}),setTimeout(le,5e3)},onSuccess:(e,l)=>{O({key:"success",action:"ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===t?"DELETE_DRIVER":"DELETE_VEHICLE"}),v.invalidateQueries("DSO_SEARCH"),G(),z(),j(),setTimeout(()=>{le()},5e3)}})})(t,e.type,t.id)},l.createElement(a.DeleteIcon,{style:{cursor:"pointer"},className:"delete",fill:"#a82227"})))),l.createElement("div",{className:"additional-grid",style:{padding:"8px 16px"}},null==t||null===(i=t.values)||void 0===i?void 0:i.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},E(String(e.title))),l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},e.value?E(String(e.value)):"N/A")))))}),e.type&&l.createElement("div",{className:"add-details-link hover-button",onClick:()=>ee("ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===e.type?"ADD_DRIVER":"ADD_VEHICLE")},E(e.type+"_ADD"))))})),T&&l.createElement(a.Modal,{headerBarMain:l.createElement(H,{label:E("DELETE"===g?"ES_FSM_REGISTRY_DELETE_POPUP_HEADER":"ADD_VEHICLE"===g?"ES_FSM_REGISTRY_ADD_VEHICLE_POPUP_HEADER":"ES_FSM_REGISTRY_ADD_DRIVER_POPUP_HEADER")}),headerBarEnd:l.createElement(U,{onClick:ne}),actionCancelLabel:E("CS_COMMON_CANCEL"),actionCancelOnSubmit:ne,actionSaveLabel:E("DELETE"===g?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{var e;let t=null==B||null===(e=B[0])||void 0===e?void 0:e.dsoDetails,l={};if("DELETE"===g&&(l={vendor:s({},t,{status:"INACTIVE"})}),"ADD_VEHICLE"===g){var n;let e=P;e.vendorVehicleStatus="ACTIVE",l={vendor:s({},t,{owner:s({},t.owner,{gender:(null===(n=t.owner)||void 0===n?void 0:n.gender)||"OTHERS"}),vehicles:t.vehicles?[...t.vehicles,e]:[e]})}}if("ADD_DRIVER"===g){var a;let e=P;e.vendorDriverStatus="ACTIVE",l={vendor:s({},t,{owner:s({},t.owner,{gender:(null===(a=t.owner)||void 0===a?void 0:a.gender)||"OTHERS"}),drivers:t.drivers?[...t.drivers,e]:[e]})}}J(l,{onError:(e,t)=>{O({key:"error",action:e}),setTimeout(le,5e3)},onSuccess:(e,t)=>{O({key:"success",action:"DELETE"===g?"DELETE_VENDOR":g}),v.invalidateQueries("DSO_SEARCH"),G(),z(),j(),setTimeout(()=>{le(),"DELETE"===g&&m.push("/digit-ui/"+te+"/fsm/registry")},5e3)}}),I(!1),N(null)}},l.createElement(a.Card,{style:{boxShadow:"none"}},"DELETE"===g?l.createElement(F,{t:E,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VEHICLE"===g?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,E("ES_FSM_REGISTRY_SELECT_VEHICLE")),l.createElement(a.Dropdown,{t:E,option:f,value:P,selected:P,select:k,optionKey:"registrationNumber"})):"ADD_DRIVER"===g?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,E("ES_FSM_REGISTRY_SELECT_DRIVER")),l.createElement(a.Dropdown,{t:E,option:L,value:P,selected:P,select:k,optionKey:"name"})):void 0)),A&&l.createElement(a.Toast,{error:"error"===A.key,label:E("success"===A.key?"ES_FSM_REGISTRY_"+A.action+"_SUCCESS":A.action),onClose:le}),l.createElement(a.ActionBar,{style:{zIndex:"19"}},_?l.createElement(a.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE","HOME"],t:E,onSelect:ee}):null,l.createElement(a.SubmitBar,{label:E("ES_COMMON_TAKE_ACTION"),onSubmit:()=>D(!_)}))))},AddVehicle:e=>{var o,d;const u=Digit.ULBService.getCurrentTenantId(),c=Digit.ULBService.getStateId(),E=t.useState(null),m=E[0],v=E[1],S=n.useHistory(),p=i.useTranslation().t,_=r.useQueryClient(),D=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1)[1],R=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1)[2],g=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1)[2],N="WT_VENDOR"===Digit.UserService.getType()||Digit.UserService.hasAccess(["WT_VENDOR"]),y=Digit.Hooks.fsm.useVehicleCreate(c).mutate,T=Digit.Hooks.fsm.useVendorUpdate("dl.djb").mutate,I=null===(o=Digit.UserService.getUser())||void 0===o||null===(d=o.info)||void 0===d?void 0:d.mobileNumber,C=Digit.Hooks.fsm.useDsoSearch(u,{mobileNumber:I},{enabled:!(!N||!I)}).data;t.useEffect(()=>{D(!1),g(),R()},[]);const A=function(e,t){return void 0===t&&(t=!1),[{head:"ES_FSM_REGISTRY_VEHICLE_DETAILS",body:[{label:"ES_FSM_REGISTRY_VEHICLE_NUMBER",isMandatory:!0,type:"text",disable:t,populators:{name:"registrationNumber",ValidationRequired:!0,validation:{pattern:"^[A-Z]{2}-[0-9]{1,2}[A-Z]{0,2}-(?:[A-Z]{1,2}-)?[0-9]{1,4}$",title:e("ES_FSM_VEHICLE_FORMAT_TIP")},error:e("FSM_REGISTRY_INVALID_REGISTRATION_NUMBER"),defaultValue:""}},{label:"ES_VENDOR_REGISTRY_SERVICE_TYPE",isMandatory:!0,type:"component",key:"serviceType",component:"SelectServiceType",disable:t,populators:{name:"serviceType",defaultValue:{code:"WT",name:"WT",i18nKey:"WT"}},texts:{header:"CS_COMMON_CHOOSE_SERVICE_TYPE",submitBarLabel:"CS_COMMON_NEXT"}},{route:"vehicle",component:"SelectVehicleType",withoutLabel:!0,key:"vehicle",isMandatory:!0,type:"component"},{label:"ES_FSM_REGISTRY_VEHICLE_POLLUTION_CERT",isMandatory:!1,type:"custom",key:"pollutionCert",populators:{name:"pollutionCert",validation:{required:!0},component:(e,t)=>l.createElement(ie,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_VEHICLE_INSURANCE",isMandatory:!1,type:"custom",key:"insurance",populators:{name:"insurance",validation:{required:!0},component:(e,t)=>l.createElement(ie,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_VEHICLE_ROAD_TAX",isMandatory:!1,type:"custom",key:"roadTax",populators:{name:"roadTax",validation:{required:!0},component:(e,t)=>l.createElement(ie,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_NEW_FITNESS",isMandatory:!1,type:"custom",key:"fitnessValidity",populators:{name:"fitnessValidity",validation:{required:!0},component:(e,t)=>l.createElement(ie,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_NEW_VEHICLE_OWNER_NAME",isMandatory:!0,type:"text",disable:t,populators:{name:"ownerName",validation:{required:!0,pattern:{value:/^[A-Za-z\s.,/]+$/,message:e("FSM_REGISTRY_INVALID_NAME")}},error:e("FSM_REGISTRY_INVALID_NAME"),defaultValue:""}},{label:"ES_FSM_REGISTRY_NEW_VEHICLE_OWNER_PHONE",isMandatory:!0,type:"mobileNumber",key:"phone",disable:t,populators:{name:"phone",validation:{required:!0,pattern:/^[6-9]\d{9}$/},error:e("FSM_REGISTRY_INVALID_PHONE"),defaultValue:""}},{label:"ES_FSM_REGISTRY_NEW_GENDER",isMandatory:!0,type:"component",route:"select-gender",hideInEmployee:!1,key:"selectGender",component:"SelectGender"},{label:e("ES_FSM_REGISTRY_NEW_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(ie,s({onChange:e.onChange,date:e.value},t,{max:(()=>{const e=new Date;return e.setFullYear(e.getFullYear()-18),e.toISOString().split("T")[0]})()}))}},{label:"ES_FSM_REGISTRY_NEW_EMAIL",isMandatory:!1,type:"text",key:"emailId",populators:{name:"emailId",validation:{required:!1,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("FSM_REGISTRY_INVALID_EMAIL"),defaultValue:""}}]}]}(p);A[0].body.forEach(e=>{"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.label&&(e.labelChildren=l.createElement("div",{className:"tooltip",style:{paddingLeft:"10px",marginBottom:"-3px"}},l.createElement(a.InfoIcon,null),l.createElement("span",{className:"tooltiptext",style:{width:"320px",left:"230%",fontSize:"14px"}},e.populators.validation.title)))});const O=t.useState(!1),h=O[0],f=O[1],b=()=>{v(null)};return l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{route:"vendor-details",timeLine:[{actions:p("ES_FSM_REGISTRY_TITLE_NEW_VEHICLE"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormComposer,{isDisabled:!h,label:p("ES_COMMON_APPLICATION_SUBMIT"),config:A.filter(e=>!e.hideInEmployee).map(e=>s({},e,{isCollapsible:!0,isDefaultOpen:!0,body:e.body.filter(e=>!e.hideInEmployee)})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,a,i,o,r,d;const u=null==e?void 0:e.registrationNumber,E=null==e||null===(t=e.vehicle)||void 0===t||null===(l=t.type)||void 0===l?void 0:l.code,m=null==e||null===(n=e.vehicle)||void 0===n||null===(a=n.modal)||void 0===a?void 0:a.code,p=null==e||null===(i=e.vehicle)||void 0===i||null===(o=i.type)||void 0===o?void 0:o.capacity,D=new Date(""+(null==e?void 0:e.pollutionCert)).getTime(),R=new Date(""+(null==e?void 0:e.insurance)).getTime(),g=new Date(""+(null==e?void 0:e.roadTax)).getTime(),I=new Date(""+(null==e?void 0:e.fitnessValidity)).getTime(),A=null==e?void 0:e.ownerName,O=null==e?void 0:e.phone,h=null==e||null===(r=e.serviceType)||void 0===r?void 0:r.code,f=null==e||null===(d=e.selectGender)||void 0===d?void 0:d.code,V=null==e?void 0:e.emailId,L=new Date(""+e.dob).getTime()||new Date("1/1/1970").getTime();y({vehicle:{tenantId:"dl.djb",registrationNumber:u,model:m,type:E,tankCapacity:p,suctionType:"SEWER_SUCTION_MACHINE",pollutionCertiValidTill:D,InsuranceCertValidTill:R,fitnessValidTill:I,roadTaxPaidTill:g,gpsEnabled:!0,source:"Municipal records",owner:{tenantId:c,name:A,fatherOrHusbandName:A,relationship:"OTHER",correspondenceAddress:"",mobileNumber:O,gender:f,dob:L,emailId:V||"abc@egov.com"},additionalDetails:{serviceType:h},vehicleOwner:"ULB"}},{onError:(e,t)=>{v({key:"error",action:e}),setTimeout(b,5e3)},onSuccess:(e,t)=>{var l;if(v({key:"success",action:"ADD_VEHICLE"}),_.invalidateQueries("FSM_VEICLES_SEARCH"),N&&null!=C&&null!==(l=C[0])&&void 0!==l&&l.dsoDetails){const t=e.vehicle.map(e=>s({},e,{vendorVehicleStatus:"ACTIVE",status:"ACTIVE"})),l=C[0].dsoDetails,n={vendor:s({},l,{vehicles:l.vehicles?[...l.vehicles,...t]:[...t]})};T(n,{onError:e=>{v({key:"error",action:e})},onSuccess:()=>{var e,t,l;v({key:"success",action:"ADD_VEHICLE"}),_.invalidateQueries("DSO_SEARCH");const n=(null===(e=Digit.UserService.getUser())||void 0===e||null===(t=e.info)||void 0===t||null===(l=t.type)||void 0===l?void 0:l.toLowerCase())||"citizen";setTimeout(()=>{b(),S.push("/digit-ui/"+n+"/vendor/search-vendor?selectedTabs=VEHICLE")},3e3)}})}else{var n,a,i;const e=(null===(n=Digit.UserService.getUser())||void 0===n||null===(a=n.info)||void 0===a||null===(i=a.type)||void 0===i?void 0:i.toLowerCase())||"citizen";_.invalidateQueries("FSM_VEICLES_SEARCH"),setTimeout(()=>{b(),S.push("/digit-ui/"+e+"/vendor/search-vendor?selectedTabs=VEHICLE")},3e3)}}})},defaultValues:{serviceType:{code:"WT",name:"WT",i18nKey:"WT"},tripData:{noOfTrips:1,amountPerTrip:null,amount:null}},onFormValueChange:(e,t)=>{var l,n;if(null!=t&&t.registrationNumber){let l=(e=>{const t=e.toUpperCase().replace(/[^A-Z0-9]/g,"");if(t.length<=2)return t;const l=t.slice(0,2),n=t.slice(2);if(!n)return l;const a=n.match(/^(\d{1,2})/);if(!a)return l+"-"+n;const i=a[1],o=n.slice(i.length),r=o.match(/^([A-Z]*)/),s=r?r[1]:"",d=o.slice(s.length);if(!d)return l+"-"+i+s;if(s.length>=3){const e=s.length<=3?1:2;return l+"-"+i+s.slice(0,e)+"-"+s.slice(e)+"-"+d.slice(0,4)}return l+"-"+i+s+"-"+d.slice(0,4)})(t.registrationNumber);l.length>15&&(l=l.slice(0,15)),l!==t.registrationNumber&&e("registrationNumber",l)}null!=t&&t.registrationNumber&&null!=t&&t.ownerName&&null!=t&&t.phone&&null!=t&&null!==(l=t.vehicle)&&void 0!==l&&l.modal&&null!=t&&null!==(n=t.vehicle)&&void 0!==n&&n.type&&null!=t&&t.selectGender&&null!=t&&t.dob&&new Date(null==t?void 0:t.dob).getTime()<=(new Date).setFullYear((new Date).getFullYear()-18)?f(!0):f(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),m&&l.createElement(a.Toast,{error:"error"===m.key,label:p("success"===m.key?"ES_FSM_REGISTRY_"+m.action+"_SUCCESS":m.action),onClose:b})))},VENDORCreate:e=>{var t,a,o,d;const u=r.useQueryClient(),c=n.useRouteMatch(),E=i.useTranslation().t,m=n.useLocation().pathname,v=n.useHistory();let S=[];const p=Digit.Hooks.useSessionStorage("VENDOR_Test",{}),_=p[0],D=p[1],R=p[2];function g(e,t,l,n,a){if(void 0===a&&(a=!1),"owners"===e){let l=_.owners||[];l[n]=t,D(s({},_,{[e]:[...l]}))}else if("units"===e){let e=_.units||[];e=t,D(s({},_,{units:e}))}else D(s({},_,{[e]:s({},_[e],t)}));((e,t,l,n)=>{let a,i=m.split("/").pop(),o=i.charAt(i.length-1),r=!1;Number(parseInt(i))||"0"===i||"-1"===i?"-1"===i||"-2"===i?(i=m.slice(0,-3),i=i.split("/").pop(),r=!0):(i=m.slice(0,-2),i=i.split("/").pop(),r=!0):r=!1,isNaN(o)||(r=!0);let s=S.find(e=>e.route===(i||"0")).nextStep,d=void 0===s?{}:s,u=v.push;if(e&&(u=v.replace),l&&(d=n),null===d)return console.log("matchhhhh pathhhh",c.path),u(c.path+"/check");a=isNaN(d.split("/").pop())&&r&&"map"!==d?c.path+"/"+d+"/"+t:c.path+"/"+d,u(a)})(l,n,a,e)}_&&Object.keys(_).length>0&&window.location.href.includes("/info")&&"true"!==sessionStorage.getItem("docReqScreenByBack")&&(R(),u.invalidateQueries("VENDOR_CREATE"));const N=()=>{},y=()=>{};ee.forEach(e=>{S=S.concat(e.body.filter(e=>!e.hideInCitizen))}),S.indexRoute="info";const T=null===(t=Digit)||void 0===t||null===(a=t.ComponentRegistryService)||void 0===a?void 0:a.getComponent("VENDORCheckPage"),I=null===(o=Digit)||void 0===o||null===(d=o.ComponentRegistryService)||void 0===d?void 0:d.getComponent("NewResponse");return l.createElement(l.Fragment,null,l.createElement(n.Switch,null,S.map((e,t)=>{const a=e.component,i=e.texts,o=e.inputs,r=e.key,s="string"==typeof a?Digit.ComponentRegistryService.getComponent(a):a;return l.createElement(n.Route,{path:c.path+"/"+e.route,key:t},l.createElement(s,{config:{texts:i,inputs:o,key:r},onSelect:g,onSkip:N,t:E,formData:_,onAdd:y}))}),l.createElement(n.Route,{path:c.path+"/check"},l.createElement(T,{onSubmit:function(){try{return v.push(c.path+"/acknowledgement"),Promise.resolve()}catch(e){return Promise.reject(e)}},value:_})),l.createElement(n.Route,{path:c.path+"/acknowledgement"},l.createElement(I,{data:_,onSuccess:()=>{R(),u.invalidateQueries("VENDOR_CREATE")}})),l.createElement(n.Route,null,l.createElement(n.Redirect,{to:c.path+"/"+S.indexRoute}))))},VENDORCheckPage:e=>{var n,o,r,s;let d=e.onSubmit,u=e.value,c=void 0===u?{}:u;const m=i.useTranslation().t,v=c.vendordet,S=c.documents;console.log("vendordetailssppsss",v),console.log("documents",S);const p=t.useState(!1),_=p[0],D=p[1];return l.createElement(l.Fragment,null,window.location.href.includes("/employee")?l.createElement(a.VerticalTimeline,{config:[{timeLine:[{actions:m("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:m("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:m("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:2,showFinalStep:!1}):null,l.createElement("div",{style:{flex:"1",overflowY:"auto",marginBottom:"20px"}},l.createElement(a.Card,null,l.createElement(a.CardHeader,null,m("VENDOR_CHECK_DETAILS")),l.createElement("div",null,l.createElement("br",null),l.createElement(a.CardSubHeader,null,m("VENDOR_ADDITIONAL_DETAILS")),l.createElement(a.StatusTable,null,l.createElement(l.Fragment,null,l.createElement(a.Row,{label:m("VENDOR_ID"),text:""+m(E(null==v?void 0:v.VendorId)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("VENDOR_BANK_IFSC_CODE"),text:""+m(E(null==v?void 0:v.IFSC)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("VENDOR_BANK_NAME"),text:""+m(E(null==v?void 0:v.Bank)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("VENDOR_BANK_BRANCH"),text:""+m(E(null==v?void 0:v.BankbranchName)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("VENDOR_MICR_NO"),text:""+m(E(null==v?void 0:v.micrNo)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("BANK_ACCONT_NO"),text:""+m(E(null==v?void 0:v.AccountNo)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("PAN_NO"),text:""+m(E(null==v?void 0:v.PanNo)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("GST_NO"),text:""+m(E(null==v?void 0:v.GstNo)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("GST_REGISTERED_STATE/UT"),text:""+m(E(null==v?void 0:v.GstState)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("REGISTRATION_NO"),text:""+m(E(null==v?void 0:v.RegistrationNo)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("EPF_NO"),text:""+m(E(null==v?void 0:v.EpfNo)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("ESI_NO"),text:""+m(E(null==v?void 0:v.EsiNo)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("VENDOR_TYPE"),text:""+m(E(null==v||null===(n=v.VendorType)||void 0===n?void 0:n.code)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("VENDOR_CATEGORY"),text:""+m(E(null==v||null===(o=v.VendorCategory)||void 0===o?void 0:o.code)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}),l.createElement(a.Row,{label:m("VENDOR_STATUS"),text:""+m(E(null==v||null===(r=v.Status)||void 0===r?void 0:r.code)),actionButton:l.createElement(Q,{jumpTo:"/digit-ui/"+(window.location.pathname.includes("/citizen")?"citizen":"employee")+"/vendor/registry/additionaldetails/vendor-details"})}))),l.createElement("br",null),l.createElement(a.CardSubHeader,null,m("VENDOR_DOCUMENTS_DETAILS")),l.createElement(a.StatusTable,null,l.createElement(a.StatusTable,null,l.createElement(a.Row,{label:m("VENDOR_DOCUMENTS"),text:(null==S||null===(s=S.documents)||void 0===s?void 0:s.length)>0?S.documents.map((e,t)=>l.createElement("div",{key:t},l.createElement("span",{style:{color:"#5a6ee1",cursor:"pointer",textDecoration:"underline"},onClick:()=>{var t;(t=null==e?void 0:e.filestoreId)?Digit.UploadServices.Filefetch([t],Digit.ULBService.getStateId()).then(e=>{var t,l,n;const a=null==e||null===(t=e.data)||void 0===t||null===(l=t.fileStoreIds)||void 0===l||null===(n=l[0])||void 0===n?void 0:n.url;if(a){const e=a.split(",")[0];if(e){const t=document.createElement("a");t.href=e,t.target="_blank",t.rel="noopener noreferrer",document.body.appendChild(t),t.click(),document.body.removeChild(t)}}else console.error("URL missing in response. Full res:",e)}):console.error("fileId is null or undefined!")}},m(e.documentType)))):m("CS_NA")}))),l.createElement("br",null),l.createElement(a.CheckBox,{label:m("AST_FINAL_DECLARATION_MESSAGE"),onChange:()=>{D(!_)},styles:{height:"auto"},checked:_})),l.createElement("br",null),l.createElement("div",{className:"formcomposer-section-button"},l.createElement(a.SubmitBar,{label:m("COMMON_BUTTON_SUBMIT"),onSubmit:d,disabled:!_})))))},NewResponse:e=>{let o=e.data,r=e.onSuccess;const s=i.useTranslation().t,d=Digit.Hooks.vendor.useVendorAdditionaldetailsAPI(Digit.ULBService.getCurrentTenantId());return t.useEffect(()=>{try{var e,t;o.tenantId=null===(e=o.address)||void 0===e||null===(t=e.city)||void 0===t?void 0:t.code;let l=(e=>{var t,l,n,a,i,o,r,s,d,u,c,E,m,v,S,p,_,D,R,g,N,y,T,I,C;return{VendorAdditionalDetails:{tenantId:Digit.ULBService.getCurrentTenantId(),code:"VENDOR12345454",name:(null==e||null===(t=e.vendordet)||void 0===t?void 0:t.userName)||"N/A",vendorCompany:null==e||null===(l=e.vendordet)||void 0===l?void 0:l.Company,vendorPhone:null==e||null===(n=e.vendordet)||void 0===n?void 0:n.PhoneNo,vendorEmail:"vendor@example.com",contactPerson:null==e||null===(a=e.vendordet)||void 0===a?void 0:a.ContactPerson,vendorMobileNumber:"9876543210",bankAccountNumber:null==e||null===(i=e.vendordet)||void 0===i?void 0:i.AccountNo,bank:null==e||null===(o=e.vendordet)||void 0===o?void 0:o.Bank,bankBranchName:null==e||null===(r=e.vendordet)||void 0===r?void 0:r.BankbranchName,micrNo:null==e||null===(s=e.vendordet)||void 0===s?void 0:s.micrNo,epfNo:null==e||null===(d=e.vendordet)||void 0===d?void 0:d.EpfNo,esiNo:null==e||null===(u=e.vendordet)||void 0===u?void 0:u.EsiNo,gstRegisteredState:null==e||null===(c=e.vendordet)||void 0===c?void 0:c.GstState,ifscCode:null==e||null===(E=e.vendordet)||void 0===E?void 0:E.IFSC,panNo:null==e||null===(m=e.vendordet)||void 0===m?void 0:m.PanNo,registrationNo:null==e||null===(v=e.vendordet)||void 0===v?void 0:v.RegistrationNo,status:null==e||null===(S=e.vendordet)||void 0===S||null===(p=S.Status)||void 0===p?void 0:p.code,vendorCategory:null==e||null===(_=e.vendordet)||void 0===_||null===(D=_.VendorCategory)||void 0===D?void 0:D.code,vendorId:null==e||null===(R=e.vendordet)||void 0===R?void 0:R.VendorId,gstTinNo:null==e||null===(g=e.vendordet)||void 0===g?void 0:g.GstNo,serviceType:null==e||null===(N=e.vendordet)||void 0===N||null===(y=N.VendorType)||void 0===y?void 0:y.code,documents:null==e||null===(T=e.documents)||void 0===T?void 0:T.documents,active:null,vendorAdditionalDetailsId:null,vendorGroup:(null==e||null===(I=e.vendordet)||void 0===I?void 0:I.vendorGroup)||"N/A",vendorType:(null==e||null===(C=e.vendordet)||void 0===C?void 0:C.vendorType)||"N/A"}}})(o);console.log("formdata in acknowejkfdlgi ::: ",l),d.mutate(l,{onSuccess:r}),console.log("mutation in acknowejkfdlgi ::: ",d)}catch(e){}},[]),d.isLoading||d.isIdle?l.createElement(a.Loader,null):l.createElement(a.Card,{className:"vehicle-details-card"},l.createElement(J,{t:s,data:d.data,isSuccess:d.isSuccess,isLoading:d.isIdle||d.isLoading}),l.createElement(a.StatusTable,null,d.isSuccess&&l.createElement(a.Row,{rowContainerStyle:$,last:!0,textStyle:{whiteSpace:"pre",width:"60%"}})),l.createElement(n.Link,{to:"/digit-ui/employee"},l.createElement(a.LinkButton,{label:s("CORE_COMMON_GO_TO_HOME")})))},DriverDetails:()=>{var e,o;const d=Digit.ULBService.getCurrentTenantId(),u=i.useTranslation().t,c=n.useHistory(),E=r.useQueryClient(),m=n.useParams().id,v=t.useState(!1),S=v[0],p=v[1],_=t.useState(null),D=_[0],R=_[1],g=t.useState(!1),N=g[0],y=g[1],T=t.useState(null),I=T[0],C=T[1],A=t.useState([]),O=A[0],h=A[1],f=t.useState({}),b=f[0],V=f[1],L=Digit.Hooks.fsm.useDriverDetails(d,{ids:m},{staleTime:Infinity}),M=L.data,w=L.isLoading,P=L.refetch,k=Digit.Hooks.fsm.useDsoSearch(d,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}).data,x=Digit.Hooks.fsm.useDriverUpdate(d).mutate,H=Digit.Hooks.fsm.useVendorUpdate(d).mutate;function B(e){R(e),p(!1)}t.useEffect(()=>{if(k){let e=k.map(e=>e.dsoDetails);h(e)}},[k]),t.useEffect(()=>{P()},[]),t.useEffect(()=>{switch(D){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return y(!0);case"EDIT":return c.push("/digit-ui/employee/fsm/registry/modify-driver/"+m);case"HOME":return c.push("/digit-ui/employee/fsm/registry?selectedTabs=DRIVER")}},[D]);const U=()=>{C(null)},Y=()=>{R(null),V({}),y(!1)},G=()=>"DELETE"===D||"DELETE_VENDOR"===D?l.createElement(F,{t:u,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===D||"EDIT_VENDOR"===D?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(a.Dropdown,{t:u,option:O,value:b,selected:b,select:V,optionKey:"name"})):void 0;return w||w?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(a.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==M||null===(e=M[0])||void 0===e||null===(o=e.employeeResponse)||void 0===o?void 0:o.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(a.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(a.Card,{className:"card-with-background",style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"additional-grid"},null==e||null===(n=e.values)||void 0===n?void 0:n.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},u(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},u(e.value)||"N/A","ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"===e.value&&l.createElement("span",{className:"add-details-link hover-button",onClick:()=>B("ADD_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.AddIcon,{className:"",fill:"#a82227"})),"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"!==e.value&&l.createElement("div",{className:"add-details-link hover-button",onClick:()=>B("EDIT_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.EditIcon,null)),"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"!==e.value&&l.createElement("div",{className:"add-details-link hover-button",onClick:()=>B("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.DeleteIcon,{className:"delete",fill:"#a82227"}))):l.createElement("div",{className:"additional-value"},u(e.value)||"N/A"))))))}))),N&&l.createElement(a.Modal,{headerBarMain:l.createElement(le,{label:u((()=>{switch(D){case"DELETE":case"DELETE_VENDOR":return"ES_FSM_REGISTRY_DELETE_POPUP_HEADER";case"ADD_VENDOR":case"EDIT_VENDOR":return"ES_FSM_REGISTRY_ADD_VENDOR_POPUP_HEADER"}})())}),headerBarEnd:l.createElement(ae,{onClick:Y}),actionCancelLabel:u("CS_COMMON_CANCEL"),actionCancelOnSubmit:Y,actionSaveLabel:u("DELETE"===D||"DELETE_VENDOR"===D?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(D){case"DELETE":return(()=>{var e;const t={driver:s({},null==M||null===(e=M[0])||void 0===e?void 0:e.driverData,{status:"INACTIVE"})};x(t,{onError:(e,t)=>{C({key:"error",action:e}),setTimeout(U,5e3)},onSuccess:(e,t)=>{C({key:"success",action:"DELETE_DRIVER"}),E.invalidateQueries("DSO_SEARCH"),setTimeout(()=>{U(),c.push("/digit-ui/employee/fsm/registry")},5e3)}}),y(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let a={},i=null==M||null===(e=M[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],o=null==i?void 0:i.drivers;o=o.map(e=>(e.id===m&&(e.vendorDriverStatus="INACTIVE"),e)),a={vendor:s({},i,{owner:s({},i.owner,{gender:(null===(n=i.owner)||void 0===n?void 0:n.gender)||"OTHERS"}),drivers:o})},H(a,{onError:(e,t)=>{C({key:"error",action:e}),setTimeout(U,5e3)},onSuccess:(e,t)=>{C({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),P(),setTimeout(U,5e3)}}),y(!1)})();case"ADD_VENDOR":return(()=>{var e,t;let l=b,n=null==M||null===(e=M[0])||void 0===e?void 0:e.driverData;n.vendorDriverStatus="ACTIVE";const a={vendor:s({},l,{owner:s({},l.owner,{gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"}),drivers:l.drivers?[...l.drivers,n]:[n]})};H(a,{onError:(e,t)=>{C({key:"error",action:e}),P(),setTimeout(U,5e3)},onSuccess:(e,t)=>{C({key:"success",action:"ADD_VENDOR"}),E.invalidateQueries("DSO_SEARCH"),P(),setTimeout(U,5e3)}}),y(!1),R(null)})();case"EDIT_VENDOR":return(()=>{var e,t;let l=b,n=null==M||null===(e=M[0])||void 0===e?void 0:e.driverData;n.vendorDriverStatus="ACTIVE";const a={vendor:s({},l,{owner:s({},l.owner,{gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"}),drivers:l.drivers?[...l.drivers,n]:[n]})};H(a,{onError:(e,t)=>{C({key:"error",action:e}),setTimeout(U,5e3)},onSuccess:(e,t)=>{C({key:"success",action:"EDIT_VENDOR"}),P(),E.invalidateQueries("DSO_SEARCH"),setTimeout(U,5e3)}}),y(!1),R(null)})()}},formId:"modal-action"},"DELETE"===D||"DELETE_VENDOR"===D?G():l.createElement(a.Card,{style:{boxShadow:"none"}},G())),I&&l.createElement(a.Toast,{error:"error"===I.key,label:u("success"===I.key?"ES_FSM_REGISTRY_"+I.action+"_SUCCESS":I.action),onClose:U}),l.createElement(a.ActionBar,{style:{zIndex:"19"}},S?l.createElement(a.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:u,onSelect:B}):null,l.createElement(a.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>p(!S)})))},VehicleDetails:e=>{var o,d;const u=Digit.ULBService.getCurrentTenantId(),c=i.useTranslation().t,E=n.useHistory(),m=r.useQueryClient();let v=n.useParams().id;const S=t.useState(!1),p=S[0],_=S[1],D=t.useState(null),R=D[0],g=D[1],N=t.useState(!1),y=N[0],T=N[1],I=t.useState(null),C=I[0],A=I[1],O=t.useState([]),h=O[0],f=O[1],b=t.useState({}),V=b[0],L=b[1],M=t.useState(null),w=M[0],P=M[1],k=Digit.Hooks.fsm.useVehicleDetails(u,{registrationNumber:v},{staleTime:Infinity}),x=k.data,H=k.isLoading,B=k.refetch;t.useEffect(()=>{var e,t;!H&&x&&P(null==x||null===(e=x[0])||void 0===e||null===(t=e.vehicleData)||void 0===t?void 0:t.id)},[x,H]);const U=Digit.Hooks.fsm.useDsoSearch(u,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}).data;t.useEffect(()=>{if(U){let e=U.map(e=>e.dsoDetails);f(e)}},[U]);const Y=Digit.Hooks.fsm.useUpdateVehicle(u).mutate,G=Digit.Hooks.fsm.useVendorUpdate(u).mutate;function W(e){_(!1),g(e)}t.useEffect(()=>{B()},[]),t.useEffect(()=>{switch(R){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return T(!0);case"EDIT":return E.push("/digit-ui/employee/fsm/registry/modify-vehicle/"+v);case"HOME":return E.push("/digit-ui/employee/fsm/registry?selectedTabs=VEHICLE")}},[R]);const K=()=>{A(null)},z=()=>{g(null),L({}),T(!1)},X=()=>"DELETE"===R||"DELETE_VENDOR"===R?l.createElement(F,{t:c,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===R||"EDIT_VENDOR"===R?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,c("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(a.Dropdown,{t:c,option:h,value:V,selected:V,select:L,optionKey:"name"})):void 0;return H?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,H?l.createElement(a.Loader,null):l.createElement("div",{className:"employee-form-content"},l.createElement(a.Card,{className:"vehicle-details-card",style:{position:"relative"}},null==x||null===(o=x[0])||void 0===o||null===(d=o.employeeResponse)||void 0===d?void 0:d.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(a.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},c(e.title)),l.createElement(a.Card,{className:"card-with-background",style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"additional-grid"},null==e||null===(n=e.values)||void 0===n?void 0:n.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},c(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{display:"flex",alignItems:"center",gap:"8px"}},"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"===e.value&&l.createElement("div",{onClick:()=>W("ADD_VENDOR"),style:{color:"#a82227",display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"}},l.createElement(a.AddIcon,{className:"",fill:"#a82227"})," ",c(e.value)||"N/A"),"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"!==e.value&&l.createElement(l.Fragment,null,l.createElement("span",null,e.value),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>W("EDIT_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.EditIcon,{fill:"#a82227"})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>W("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.DeleteIcon,{className:"delete",fill:"#a82227"})))):l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},c(e.value)||"N/A"))))))})),y&&l.createElement(a.Modal,{headerBarMain:l.createElement(oe,{label:c((()=>{switch(R){case"DELETE":case"DELETE_VENDOR":return"ES_FSM_REGISTRY_DELETE_POPUP_HEADER";case"ADD_VENDOR":case"EDIT_VENDOR":return"ES_FSM_REGISTRY_ADD_VENDOR_POPUP_HEADER"}})())}),headerBarEnd:l.createElement(se,{onClick:z}),actionCancelLabel:c("CS_COMMON_CANCEL"),actionCancelOnSubmit:z,actionSaveLabel:c("DELETE"===R||"DELETE_VENDOR"===R?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(R){case"DELETE":return(()=>{var e;const t={vehicle:s({},null==x||null===(e=x[0])||void 0===e?void 0:e.vehicleData,{status:"INACTIVE"})};Y(t,{onError:(e,t)=>{A({key:"error",action:e}),setTimeout(K,5e3)},onSuccess:(e,t)=>{A({key:"success",action:"DELETE_VEHICLE"}),m.invalidateQueries("FSM_VEICLES_SEARCH"),setTimeout(()=>{K(),E.push("/digit-ui/employee/fsm/registry")},5e3)}}),T(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let a={},i=null==x||null===(e=x[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],o=null==i?void 0:i.vehicles;o=o.map(e=>(e.id===w&&(e.vendorVehicleStatus="INACTIVE"),e)),a={vendor:s({},i,{owner:s({},i.owner,{gender:(null===(n=i.owner)||void 0===n?void 0:n.gender)||"OTHERS"}),vehicles:o})},G(a,{onError:(e,t)=>{A({key:"error",action:e}),setTimeout(K,5e3)},onSuccess:(e,t)=>{A({key:"success",action:"DELETE_VENDOR"}),m.invalidateQueries("FSM_VENDOR_SEARCH"),B(),setTimeout(K,5e3)}}),T(!1)})();case"ADD_VENDOR":return(()=>{var e,t;let l=V,n=null==x||null===(e=x[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const a={vendor:s({},l,{owner:s({},l.owner,{gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"}),vehicles:l.vehicles?[...l.vehicles,n]:[n]})};G(a,{onError:(e,t)=>{A({key:"error",action:e}),setTimeout(K,5e3)},onSuccess:(e,t)=>{A({key:"success",action:"EDIT_VENDOR"}),B(),m.invalidateQueries("DSO_SEARCH"),setTimeout(K,5e3)}}),T(!1),g(null)})();case"EDIT_VENDOR":return(()=>{var e,t;let l=V,n=null==x||null===(e=x[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const a={vendor:s({},l,{owner:s({},l.owner,{gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"}),vehicles:l.vehicles?[...l.vehicles,n]:[n]})};G(a,{onError:(e,t)=>{A({key:"error",action:e}),setTimeout(K,5e3)},onSuccess:(e,t)=>{A({key:"success",action:"EDIT_VENDOR"}),B(),m.invalidateQueries("DSO_SEARCH"),setTimeout(K,5e3)}}),T(!1),g(null)})()}}},"DELETE"===R||"DELETE_VENDOR"===R?X():l.createElement(a.Card,{style:{boxShadow:"none"}},X())),C&&l.createElement(a.Toast,{error:"error"===C.key,label:c("success"===C.key?"ES_FSM_REGISTRY_"+C.action+"_SUCCESS":C.action),onClose:K}),l.createElement(a.ActionBar,{style:{zIndex:"19"}},p?l.createElement(a.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:c,onSelect:W}):null,l.createElement(a.SubmitBar,{label:c("ES_COMMON_TAKE_ACTION"),onSubmit:()=>_(!p)}))))},AddSupervisor:e=>{var n;const o=Digit.ULBService.getCurrentTenantId(),d=i.useTranslation().t,u=t.useState(null),c=u[0],E=u[1],m=r.useQueryClient(),v=t.useState(!1),S=v[0],p=v[1],_=Digit.Hooks.fsm.useSupervisorCreate(o).mutate,D=Digit.Hooks.fsm.useVendorSearch(o,{status:"ACTIVE"}).data,R=function(e,t,n,a){return void 0===t&&(t=[]),void 0===n&&(n=[]),void 0===a&&(a=!1),[{head:"ES_VENDOR_SUPERVISOR_BASIC_DETAILS",body:[{label:"ES_VENDOR_SUPERVISOR_FULL_NAME",isMandatory:!0,type:"text",disable:a,populators:{name:"fullName",validation:{required:!0,pattern:{value:/^[A-Za-z\s]+$/,message:e("ES_VENDOR_INVALID_NAME")}},error:e("ES_VENDOR_INVALID_NAME"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_SUPERVISOR_MOBILE_NUMBER",isMandatory:!0,type:"mobileNumber",disable:a,populators:{name:"mobileNumber",validation:{required:!0,pattern:/^[6-9]\d{9}$/},error:e("ES_VENDOR_INVALID_MOBILE"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_SUPERVISOR_EMAIL_ID",isMandatory:!0,type:"text",populators:{name:"emailId",validation:{required:!0,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("ES_VENDOR_INVALID_EMAIL"),defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_SUPERVISOR_EMPLOYEE_ID",isMandatory:!0,type:"text",populators:{name:"employeeId",validation:{required:!0},defaultValue:"",className:"payment-form-text-input-correction"}},{label:"ES_VENDOR_SUPERVISOR_GENDER",isMandatory:!1,type:"component",key:"gender",component:"SelectGender",texts:{headerCaption:"",header:"CS_COMMON_CHOOSE_GENDER",cardText:"CS_COMMON_SELECT_GENDER",submitBarLabel:"CS_COMMON_NEXT",skipText:"CORE_COMMON_SKIP_CONTINUE"}}]},{head:"ES_VENDOR_SUPERVISOR_ROLE_ACCESS",body:[{label:"ES_VENDOR_SUPERVISOR_ROLE",isMandatory:!0,type:"custom",populators:{name:"role",component:(t,n)=>l.createElement(Y,{option:[{code:"SUPERVISOR",name:"Supervisor"}],optionKey:"name",select:t.onChange,selected:t.value,t:e,disable:!0}),defaultValue:{code:"SUPERVISOR",name:"Supervisor"}}},{label:"ES_VENDOR_SUPERVISOR_AGENCY_NAME",isMandatory:!0,type:"custom",populators:{name:"agencyName",component:(n,a)=>l.createElement(Y,{option:t,optionKey:"name",select:n.onChange,selected:n.value,t:e})}},{label:"ES_VENDOR_SUPERVISOR_REPORTING_MANAGER",isMandatory:!1,type:"custom",populators:{name:"reportingManager",component:(t,a)=>l.createElement(Y,{option:n,optionKey:"name",select:t.onChange,selected:t.value,t:e})}}]},{head:"ES_VENDOR_SUPERVISOR_AREA_ASSIGNMENT",body:[{type:"component",component:"SupervisorAreaAssignment",key:"areaAssignment",withoutLabel:!0}]}]}(d,(null==D||null===(n=D.vendor)||void 0===n?void 0:n.map(e=>s({code:e.id,name:e.name},e)))||[],[{code:"MGR1",name:"John Doe (Agency Admin)"},{code:"MGR2",name:"Jane Smith (Agency Admin)"}]),g=()=>{E(null)};return l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{route:"supervisor-details",timeLine:[{actions:d("ES_VENDOR_SUPERVISOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormComposer,{isDisabled:!S,label:d("ES_COMMON_APPLICATION_SUBMIT"),config:R.map(e=>s({},e,{isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n;const a={supervisor:{tenantId:o,name:null==e?void 0:e.fullName,employeeId:null==e?void 0:e.employeeId,status:"ACTIVE",owner:{tenantId:o,name:null==e?void 0:e.fullName,gender:(null==e||null===(t=e.gender)||void 0===t?void 0:t.code)||"OTHERS",emailId:null==e?void 0:e.emailId,mobileNumber:null==e?void 0:e.mobileNumber},vendorSupervisorStatus:"ACTIVE",additionalDetails:{agencyId:null==e||null===(l=e.agencyName)||void 0===l?void 0:l.code,reportingManager:null==e||null===(n=e.reportingManager)||void 0===n?void 0:n.code,areaAssignment:null==e?void 0:e.areaAssignment}}};_(a,{onError:e=>{E({key:"error",action:e}),setTimeout(g,5e3)},onSuccess:()=>{E({key:"success",action:"ADD_SUPERVISOR"}),m.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(g,5e3)}})},defaultValues:{role:{code:"SUPERVISOR",name:"Supervisor"}},onFormValueChange:(e,t)=>{var l,n,a,i,o;const r=(null==t||null===(l=t.areaAssignment)||void 0===l?void 0:l.zone)&&(null==t||null===(n=t.areaAssignment)||void 0===n?void 0:n.cluster)&&(null==t||null===(a=t.areaAssignment)||void 0===a?void 0:a.ward)&&(null==t||null===(i=t.areaAssignment)||void 0===i||null===(o=i.areas)||void 0===o?void 0:o.length)>0;p(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.employeeId)&&(null==t?void 0:t.agencyName)&&r))},noBreakLine:!0,mode:"onChange",noCard:!0}),c&&l.createElement(a.Toast,{error:"error"===c.key,label:d("success"===c.key?"ES_VENDOR_"+c.action+"_SUCCESS":c.action),onClose:g})))},SupervisorDetails:e=>{var o,d;const u=Digit.ULBService.getCurrentTenantId(),c=i.useTranslation().t,E=n.useHistory(),m=r.useQueryClient(),v=n.useParams().id,S=t.useState(!1),p=S[0],_=S[1],D=t.useState(null),R=D[0],g=D[1],N=t.useState(!1),y=N[0],T=N[1],I=t.useState(null),C=I[0],A=I[1],O=t.useState([]),h=O[0],f=O[1],b=t.useState({}),V=b[0],L=b[1],M=Digit.Hooks.fsm.useSupervisorDetails(u,{ids:v},{staleTime:Infinity}),w=M.data,P=M.isLoading,k=M.refetch,x=Digit.Hooks.fsm.useDsoSearch(u,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}).data,H=Digit.Hooks.fsm.useSupervisorUpdate(u).mutate,B=Digit.Hooks.fsm.useVendorUpdate(u).mutate;t.useEffect(()=>{if(x){let e=x.map(e=>e.dsoDetails);f(e)}},[x]),t.useEffect(()=>{k()},[]),t.useEffect(()=>{switch(R){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return T(!0);case"EDIT":return E.push("/digit-ui/employee/vendor/modify-supervisor/"+v);case"HOME":return E.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SUPERVISOR")}},[R]);const U=()=>{A(null)},Y=()=>{g(null),L({}),T(!1)};return P?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(a.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==w||null===(o=w[0])||void 0===o||null===(d=o.employeeResponse)||void 0===d?void 0:d.map((e,t)=>{var n,i;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(a.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},c(e.title)),l.createElement(a.Card,{className:"card-with-background",style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"additional-grid"},null==e||null===(n=e.values)||void 0===n?void 0:n.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},c(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},c(e.value)||"N/A","ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"===e.value&&l.createElement("span",{className:"add-details-link hover-button",onClick:()=>g("ADD_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.AddIcon,{fill:"#a82227"})),"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"!==e.value&&l.createElement(l.Fragment,null,l.createElement("div",{className:"add-details-link hover-button",onClick:()=>g("EDIT_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>g("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},c(e.value)||"N/A"))))),null==e||null===(i=e.child)||void 0===i?void 0:i.map((t,n)=>{var i;return l.createElement(a.Card,{className:"card-with-background",key:t.id||n,style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"card-head",style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px"}},l.createElement("h2",{style:{fontSize:"18px",fontWeight:"bold"}},c(e.type)," ",n+1),l.createElement("div",{style:{display:"flex",gap:"15px"}},l.createElement("span",{onClick:()=>E.push("/digit-ui/employee/vendor/registry/modify-surveyor/"+t.id)},l.createElement(a.EditIcon,{fill:"#a82227",style:{cursor:"pointer"}})))),l.createElement("div",{className:"additional-grid"},null==t||null===(i=t.values)||void 0===i?void 0:i.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},c(e.title)),l.createElement("div",{className:"additional-value"},c(e.value)||"N/A")))))}),e.type&&l.createElement("div",{className:"add-details-link hover-button",style:{margin:"10px 16px",color:"#a82227",cursor:"pointer",display:"flex",alignItems:"center",gap:"5px",fontWeight:"bold"},onClick:()=>E.push("/digit-ui/employee/vendor/registry/new-surveyor?supervisorId="+v)},l.createElement(a.AddIcon,{fill:"#a82227"}),c(e.type+"_ADD")))}))),y&&l.createElement(a.Modal,{headerBarMain:l.createElement(X,{label:c((()=>{switch(R){case"DELETE":case"DELETE_VENDOR":return"ES_VENDOR_SUPERVISOR_DELETE_POPUP_HEADER";case"ADD_VENDOR":case"EDIT_VENDOR":return"ES_VENDOR_SUPERVISOR_ADD_VENDOR_POPUP_HEADER"}})())}),headerBarEnd:l.createElement(j,{onClick:Y}),actionCancelLabel:c("CS_COMMON_CANCEL"),actionCancelOnSubmit:Y,actionSaveLabel:c("DELETE"===R||"DELETE_VENDOR"===R?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(R){case"DELETE":return(()=>{var e;const t={supervisor:s({},null==w||null===(e=w[0])||void 0===e?void 0:e.supervisorData,{status:"INACTIVE"})};H(t,{onError:e=>{A({key:"error",action:e}),setTimeout(U,5e3)},onSuccess:()=>{A({key:"success",action:"DELETE_SUPERVISOR"}),m.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(()=>{U(),E.push("/digit-ui/employee/vendor/search-vendor")},5e3)}}),T(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=null==w||null===(e=w[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],a=(null==n?void 0:n.supervisors)||[];a=a.map(e=>(e.id===v&&(e.vendorSupervisorStatus="INACTIVE"),e));const i={vendor:s({},n,{supervisors:a})};B(i,{onError:e=>{A({key:"error",action:e}),setTimeout(U,5e3)},onSuccess:()=>{A({key:"success",action:"DELETE_VENDOR"}),m.invalidateQueries("FSM_VENDOR_SEARCH"),k(),setTimeout(U,5e3)}}),T(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=V,l=null==w||null===(e=w[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:s({},t,{supervisors:t.supervisors?[...t.supervisors,l]:[l]})};B(n,{onError:e=>{A({key:"error",action:e}),k(),setTimeout(U,5e3)},onSuccess:()=>{A({key:"success",action:"ADD_VENDOR"}),m.invalidateQueries("SUPERVISOR_SEARCH"),k(),setTimeout(U,5e3)}}),T(!1),g(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=V,l=null==w||null===(e=w[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:s({},t,{supervisors:t.supervisors?[...t.supervisors,l]:[l]})};B(n,{onError:e=>{A({key:"error",action:e}),setTimeout(U,5e3)},onSuccess:()=>{A({key:"success",action:"EDIT_VENDOR"}),k(),m.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(U,5e3)}}),T(!1),g(null)})()}}},l.createElement(a.Card,{style:{boxShadow:"none"}},"DELETE"===R||"DELETE_VENDOR"===R?l.createElement(F,{t:c,title:"ES_VENDOR_SUPERVISOR_DELETE_TEXT"}):"ADD_VENDOR"===R||"EDIT_VENDOR"===R?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,c("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(a.Dropdown,{t:c,option:h,value:V,selected:V,select:L,optionKey:"name"})):void 0)),C&&l.createElement(a.Toast,{error:"error"===C.key,label:c("success"===C.key?"ES_VENDOR_"+C.action+"_SUCCESS":C.action),onClose:U}),l.createElement(a.ActionBar,{style:{zIndex:"19"}},p?l.createElement(a.Menu,{localeKeyPrefix:"ES_VENDOR_SUPERVISOR_ACTION",options:["EDIT","DELETE"],t:c,onSelect:e=>{_(!1),g(e)}}):null,l.createElement(a.SubmitBar,{label:c("ES_COMMON_TAKE_ACTION"),onSubmit:()=>_(!p)})))},SupervisorAreaAssignment:e=>{var n,i,o,r;let d=e.config,u=e.onSelect,c=e.t,E=e.formData;const m=Digit.ULBService.getCurrentTenantId(),v=t.useState((null==E||null===(n=E.areaAssignment)||void 0===n?void 0:n.zone)||null),S=v[0],p=v[1],_=t.useState((null==E||null===(i=E.areaAssignment)||void 0===i?void 0:i.cluster)||null),D=_[0],R=_[1],g=t.useState((null==E||null===(o=E.areaAssignment)||void 0===o?void 0:o.ward)||null),N=g[0],y=g[1],T=t.useState((null==E||null===(r=E.areaAssignment)||void 0===r?void 0:r.areas)||[]),I=T[0],C=T[1],A=t.useState([]),O=A[0],h=A[1],f=t.useState([]),b=f[0],V=f[1],L=t.useState([]),M=L[0],w=L[1],P=t.useState([]),k=P[0],x=P[1],F=Digit.Hooks.useCommonMDMS(m,"egov-location",["TenantBoundary"]),H=F.data,B=F.isLoading;t.useEffect(()=>{if(H){var e,t,l,n;const a=null==H||null===(e=H.MdmsRes)||void 0===e||null===(t=e["egov-location"])||void 0===t||null===(l=t.TenantBoundary)||void 0===l||null===(n=l[0])||void 0===n?void 0:n.boundary;a&&a.children&&h(a.children)}},[H]),t.useEffect(()=>{var e,t;S?(V(S.children||[]),S.code!==(null==E||null===(e=E.areaAssignment)||void 0===e||null===(t=e.zone)||void 0===t?void 0:t.code)&&(R(null),y(null),C([]))):V([])},[S]),t.useEffect(()=>{var e,t;D?(w(D.children||[]),D.code!==(null==E||null===(e=E.areaAssignment)||void 0===e||null===(t=e.cluster)||void 0===t?void 0:t.code)&&(y(null),C([]))):w([])},[D]),t.useEffect(()=>{var e,t;N?(x(N.children||[]),N.code!==(null==E||null===(e=E.areaAssignment)||void 0===e||null===(t=e.ward)||void 0===t?void 0:t.code)&&C([])):x([])},[N]);const U=(e,t)=>{const l=s({},null==E?void 0:E.areaAssignment,{[e]:t});"zone"===e?(l.cluster=null,l.ward=null,l.areas=[]):"cluster"===e?(l.ward=null,l.areas=[]):"ward"===e&&(l.areas=[]),u(d.key,l)};return B?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,c("ES_VENDOR_SUPERVISOR_ZONE")+" *"),l.createElement(a.Dropdown,{selected:S,option:O,select:e=>{p(e),U("zone",e)},optionKey:"name",t:c})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,c("ES_VENDOR_SUPERVISOR_CLUSTER")+" *"),l.createElement(a.Dropdown,{selected:D,option:b,select:e=>{R(e),U("cluster",e)},optionKey:"name",t:c,disable:!S})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,c("ES_VENDOR_SUPERVISOR_WARD")+" *"),l.createElement(a.Dropdown,{selected:N,option:M,select:e=>{y(e),U("ward",e)},optionKey:"name",t:c,disable:!D})),l.createElement(a.LabelFieldPair,null,l.createElement(a.CardLabel,null,c("ES_VENDOR_SUPERVISOR_AREA")+" *"),l.createElement(a.MultiSelectDropdown,{options:k,selected:I,onSelect:e=>{C(e),U("areas",e)},optionsKey:"name",t:c,disable:!N})))},AddSurveyor:e=>{var n;const o=Digit.ULBService.getCurrentTenantId(),d=i.useTranslation().t,u=t.useState(null),c=u[0],E=u[1],m=r.useQueryClient(),v=t.useState(!1),S=v[0],p=v[1],_=Digit.Hooks.fsm.useSurveyorCreate(o).mutate,D=Digit.Hooks.fsm.useVendorSearch(o,{status:"ACTIVE"}).data,R=[{code:"MGR1",name:"John Doe (Agency Admin)"},{code:"SUP1",name:"Jane Smith (Supervisor)"}],g=function(e,t,n,a){return void 0===t&&(t=[]),void 0===n&&(n=[]),[{head:"ES_VENDOR_SURVEYOR_BASIC_DETAILS",body:[{label:"ES_VENDOR_SURVEYOR_FULL_NAME",isMandatory:!0,type:"text",populators:{name:"fullName",validation:{required:!0,pattern:/^[A-Za-z\s]+$/},error:e("ES_VENDOR_INVALID_NAME")}},{label:"ES_VENDOR_SURVEYOR_MOBILE_NUMBER",isMandatory:!0,type:"mobileNumber",populators:{name:"mobileNumber",validation:{required:!0,pattern:/^[6-9]\d{9}$/},error:e("ES_VENDOR_INVALID_MOBILE")}},{label:"ES_VENDOR_SURVEYOR_EMAIL_ID",isMandatory:!0,type:"text",populators:{name:"emailId",validation:{required:!0,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("ES_VENDOR_INVALID_EMAIL")}},{label:"ES_VENDOR_SURVEYOR_STAFF_CODE",isMandatory:!0,type:"text",populators:{name:"employeeId",validation:{required:!0}}},{label:"ES_VENDOR_SURVEYOR_GENDER",isMandatory:!1,type:"component",key:"selectGender",component:"SelectGender",texts:{header:"CS_COMMON_CHOOSE_GENDER",cardText:"CS_COMMON_SELECT_GENDER",submitBarLabel:"CS_COMMON_NEXT"}}]},{head:"ES_VENDOR_SURVEYOR_ROLE_ACCESS",body:[{label:"ES_VENDOR_SURVEYOR_ROLE",isMandatory:!0,type:"custom",populators:{name:"role",component:(t,n)=>l.createElement(G,{option:[{code:"SURVEYOR",name:"Surveyor"}],optionKey:"name",select:t.onChange,selected:t.value,t:e,disable:!0}),defaultValue:{code:"SURVEYOR",name:"Surveyor"}}},{label:"ES_VENDOR_SURVEYOR_AGENCY_NAME",isMandatory:!0,type:"custom",populators:{name:"agencyName",component:(n,a)=>l.createElement(G,{option:t,optionKey:"name",select:n.onChange,selected:n.value,t:e})}},{label:"ES_VENDOR_SURVEYOR_REPORTING_MANAGER",isMandatory:!1,type:"custom",populators:{name:"reportingManager",component:(t,a)=>l.createElement(G,{option:n,optionKey:"name",select:t.onChange,selected:t.value,t:e})}}]},{head:"ES_VENDOR_SURVEYOR_AREA_ASSIGNMENT",body:[{isMandatory:!0,type:"component",key:"areaAssignment",component:"SupervisorAreaAssignment",withoutLabel:!0}]}]}(d,(null==D||null===(n=D.vendor)||void 0===n?void 0:n.map(e=>s({code:e.id,name:e.name},e)))||[],R),N=Digit.Hooks.useQueryParams().supervisorId,y={role:{code:"SURVEYOR",name:"Surveyor"},reportingManager:R.find(e=>e.code===N)||null},T=()=>{E(null)};return l.createElement(l.Fragment,null,l.createElement(a.VerticalTimeline,{config:[{route:"surveyor-details",timeLine:[{actions:d("ES_VENDOR_SURVEYOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(a.FormComposer,{isDisabled:!S,label:d("ES_COMMON_APPLICATION_SUBMIT"),config:g.map(e=>s({},e,{isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n;const a={surveyor:{tenantId:o,name:null==e?void 0:e.fullName,employeeId:null==e?void 0:e.employeeId,status:"ACTIVE",owner:{tenantId:o,name:null==e?void 0:e.fullName,gender:(null==e||null===(t=e.gender)||void 0===t?void 0:t.code)||"OTHERS",emailId:null==e?void 0:e.emailId,mobileNumber:null==e?void 0:e.mobileNumber},vendorSurveyorStatus:"ACTIVE",additionalDetails:{agencyId:null==e||null===(l=e.agencyName)||void 0===l?void 0:l.code,reportingManager:null==e||null===(n=e.reportingManager)||void 0===n?void 0:n.code,areaAssignment:null==e?void 0:e.areaAssignment}}};_(a,{onError:e=>{E({key:"error",action:e}),setTimeout(T,5e3)},onSuccess:()=>{E({key:"success",action:"ADD_SURVEYOR"}),m.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(T,5e3)}})},defaultValues:y,onFormValueChange:(e,t)=>{var l,n,a,i;const o=(null==t||null===(l=t.areaAssignment)||void 0===l?void 0:l.zone)&&(null==t||null===(n=t.areaAssignment)||void 0===n?void 0:n.ward)&&(null==t||null===(a=t.areaAssignment)||void 0===a||null===(i=a.areas)||void 0===i?void 0:i.length)>0;p(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.employeeId)&&(null==t?void 0:t.agencyName)&&o))},noBreakLine:!0,mode:"onChange",noCard:!0}),c&&l.createElement(a.Toast,{error:"error"===c.key,label:d("success"===c.key?"ES_VENDOR_"+c.action+"_SUCCESS":c.action),onClose:T})))},SurveyorDetails:e=>{var o,d;const u=Digit.ULBService.getCurrentTenantId(),c=i.useTranslation().t,E=n.useHistory(),m=r.useQueryClient(),v=n.useParams().id,S=t.useState(!1),p=S[0],_=S[1],D=t.useState(null),R=D[0],g=D[1],N=t.useState(!1),y=N[0],T=N[1],I=t.useState(null),C=I[0],A=I[1],O=t.useState([]),h=O[0],f=O[1],b=t.useState({}),V=b[0],L=b[1],M=Digit.Hooks.fsm.useSurveyorDetails(u,{ids:v},{staleTime:Infinity}),w=M.data,P=M.isLoading,k=M.refetch,x=Digit.Hooks.fsm.useDsoSearch(u,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}).data,H=Digit.Hooks.fsm.useSurveyorUpdate(u).mutate,B=Digit.Hooks.fsm.useVendorUpdate(u).mutate;t.useEffect(()=>{if(x){let e=x.map(e=>e.dsoDetails);f(e)}},[x]),t.useEffect(()=>{k()},[]),t.useEffect(()=>{switch(R){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return T(!0);case"EDIT":return E.push("/digit-ui/employee/vendor/modify-surveyor/"+v);case"HOME":return E.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SURVEYOR")}},[R]);const U=()=>{A(null)},Y=()=>{g(null),L({}),T(!1)};return P?l.createElement(a.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(a.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==w||null===(o=w[0])||void 0===o||null===(d=o.employeeResponse)||void 0===d?void 0:d.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(a.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},c(e.title)),l.createElement(a.Card,{className:"card-with-background",style:{margin:"10px 16px",padding:"20px"}},l.createElement("div",{className:"additional-grid"},null==e||null===(n=e.values)||void 0===n?void 0:n.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},c(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},c(e.value)||"N/A","ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"===e.value&&l.createElement("span",{className:"add-details-link hover-button",onClick:()=>g("ADD_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.AddIcon,{fill:"#a82227"})),"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"!==e.value&&l.createElement(l.Fragment,null,l.createElement("div",{className:"add-details-link hover-button",onClick:()=>g("EDIT_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>g("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(a.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},c(e.value)||"N/A"))))))}))),y&&l.createElement(a.Modal,{headerBarMain:l.createElement(W,{label:c((()=>{switch(R){case"DELETE":case"DELETE_VENDOR":return"ES_VENDOR_SURVEYOR_DELETE_POPUP_HEADER";case"ADD_VENDOR":case"EDIT_VENDOR":return"ES_VENDOR_SURVEYOR_ADD_VENDOR_POPUP_HEADER"}})())}),headerBarEnd:l.createElement(z,{onClick:Y}),actionCancelLabel:c("CS_COMMON_CANCEL"),actionCancelOnSubmit:Y,actionSaveLabel:c("DELETE"===R||"DELETE_VENDOR"===R?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(R){case"DELETE":return(()=>{var e;const t={surveyor:s({},null==w||null===(e=w[0])||void 0===e?void 0:e.surveyorData,{status:"INACTIVE"})};H(t,{onError:e=>{A({key:"error",action:e}),setTimeout(U,5e3)},onSuccess:()=>{A({key:"success",action:"DELETE_SURVEYOR"}),m.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(()=>{U(),E.push("/digit-ui/employee/vendor/search-vendor")},5e3)}}),T(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=null==w||null===(e=w[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],a=(null==n?void 0:n.surveyors)||[];a=a.map(e=>(e.id===v&&(e.vendorSurveyorStatus="INACTIVE"),e));const i={vendor:s({},n,{surveyors:a})};B(i,{onError:e=>{A({key:"error",action:e}),setTimeout(U,5e3)},onSuccess:()=>{A({key:"success",action:"DELETE_VENDOR"}),m.invalidateQueries("FSM_VENDOR_SEARCH"),k(),setTimeout(U,5e3)}}),T(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=V,l=null==w||null===(e=w[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:s({},t,{surveyors:t.surveyors?[...t.surveyors,l]:[l]})};B(n,{onError:e=>{A({key:"error",action:e}),k(),setTimeout(U,5e3)},onSuccess:()=>{A({key:"success",action:"ADD_VENDOR"}),m.invalidateQueries("SURVEYOR_SEARCH"),k(),setTimeout(U,5e3)}}),T(!1),g(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=V,l=null==w||null===(e=w[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:s({},t,{surveyors:t.surveyors?[...t.surveyors,l]:[l]})};B(n,{onError:e=>{A({key:"error",action:e}),setTimeout(U,5e3)},onSuccess:()=>{A({key:"success",action:"EDIT_VENDOR"}),k(),m.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(U,5e3)}}),T(!1),g(null)})()}}},l.createElement(a.Card,{style:{boxShadow:"none"}},"DELETE"===R||"DELETE_VENDOR"===R?l.createElement(F,{t:c,title:"ES_VENDOR_SURVEYOR_DELETE_TEXT"}):"ADD_VENDOR"===R||"EDIT_VENDOR"===R?l.createElement(l.Fragment,null,l.createElement(a.CardText,null,c("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(a.Dropdown,{t:c,option:h,value:V,selected:V,select:L,optionKey:"name"})):void 0)),C&&l.createElement(a.Toast,{error:"error"===C.key,label:c("success"===C.key?"ES_VENDOR_"+C.action+"_SUCCESS":C.action),onClose:U}),l.createElement(a.ActionBar,{style:{zIndex:"19"}},p?l.createElement(a.Menu,{localeKeyPrefix:"ES_VENDOR_SURVEYOR_ACTION",options:["EDIT","DELETE"],t:c,onSelect:e=>{_(!1),g(e)}}):null,l.createElement(a.SubmitBar,{label:c("ES_COMMON_TAKE_ACTION"),onSubmit:()=>_(!p)})))}},ue=e=>{let a=e.stateCode,i=e.userType,o=e.tenants;const r=n.useRouteMatch(),s=r.path,d=r.url,c=Digit.StoreData.getCurrentLanguage();return Digit.Services.useStore({stateCode:a,moduleCode:"VENDOR",language:c}),Object.entries(de).forEach(e=>{Digit.ComponentRegistryService.setComponent(e[0],e[1])}),Digit.SessionStorage.set("VENDOR_TENANTS",o),t.useEffect(()=>"employee"===i&&Digit.LocalizationService.getLocale({modules:["rainmaker-"+Digit.ULBService.getCurrentTenantId()],locale:Digit.StoreData.getCurrentLanguage(),tenantId:Digit.ULBService.getCurrentTenantId()}),[]),l.createElement("employee"===i?u:x,{path:s,url:d,userType:i})},ce=e=>{const l=Digit.Hooks.useSessionStorage("VENDOR",{})[2];return t.useEffect(()=>{l()},[]),null};exports.VENDORComponents={VENDORCard:()=>{const e=i.useTranslation().t,t=n.useHistory(),o=window.location.pathname.toLowerCase().includes("citizen");if(!Digit.Utils.vendorAccess()&&!Digit.UserService.hasAccess(["WT_VENDOR","MT_VENDOR"]))return null;const r=[{label:e("VENDOR_NEW_REGISTERATION"),link:o?"/digit-ui/citizen/vendor/registry/new-vendor":"/digit-ui/employee/vendor/registry/new-vendor"},{label:e("SEARCH_VENDOR"),link:o?"/digit-ui/citizen/vendor/search-vendor":"/digit-ui/employee/vendor/search-vendor"}],d=Digit.UserService.hasAccess(["WT_VENDOR"]),u=s({Icon:l.createElement(a.PropertyHouse,null),moduleName:e("TITLE_VENDOR_MANAGEMENT"),kpis:[{count:0,label:e("Inbox"),link:o?"/digit-ui/citizen/vendor/search-vendor":"/digit-ui/employee/vendor/search-vendor"}],links:r.filter(e=>!(null!=e&&e.role)||d)},o?{onDetailsClick:()=>t.push("/digit-ui/citizen/vendor/search-vendor")}:{});return o?l.createElement("div",{className:"wt-citizen-card-premium"},l.createElement(a.EmployeeModuleCard,u)):l.createElement(a.EmployeeModuleCard,u)},VENDORModule:ue,VENDORLinks:ce},exports.VENDORLinks=ce,exports.VENDORModule=ue;