@djb25/digit-ui-module-vendor 1.0.42 → 1.0.43

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"),i=require("@djb25/digit-ui-react-components"),o=require("react-i18next"),a=require("react-hook-form"),r=require("react-query");function d(){return(d=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 s=e=>{let{path:t}=e;const{t:a}=o.useTranslation(),r=n.useLocation();sessionStorage.removeItem("revalidateddone");const s=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"),R=Digit.ComponentRegistryService.getComponent("AddSupervisor"),D=Digit.ComponentRegistryService.getComponent("SupervisorDetails"),N=Digit.ComponentRegistryService.getComponent("EditSupervisor"),g=Digit.ComponentRegistryService.getComponent("AddSurveyor"),y=Digit.ComponentRegistryService.getComponent("SurveyorDetails"),T=Digit.ComponentRegistryService.getComponent("EditSurveyor"),I=Digit.ComponentRegistryService.getComponent("EditDriver"),C=Digit.ComponentRegistryService.getComponent("EditVehicle");return l.createElement(n.Switch,null,l.createElement(i.AppContainer,null,l.createElement(l.Fragment,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(i.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(i.ArrowLeft,{className:"icon"}),"Back"),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const e=r.pathname;let t=[{icon:i.HomeIcon,path:"/digit-ui/employee"},{label:a("TITLE_VENDOR_MANAGEMENT"),path:"/digit-ui/employee/vendor/search-vendor"}];return e.includes("/registry/new-vendor")?t.push({label:a("ES_FSM_REGISTRY_TITLE_NEW_VENDOR")}):e.includes("/search-vendor")?t.push({label:a("SEARCH_VENDOR")}):e.includes("/registry/new-driver")?t.push({label:a("ES_FSM_REGISTRY_TITLE_NEW_DRIVER")}):e.includes("/registry/vendor-details")||e.includes("/registry/modify-vendor/")?t.push({label:a("VENDOR_VENDOR_DETAILS")}):e.includes("/registry/vehicle-details")||e.includes("/registry/modify-vehicle/")?t.push({label:a("VENDOR_VEHICLE_DETAILS")}):e.includes("/registry/new-vehicle")?t.push({label:a("ES_FSM_REGISTRY_TITLE_NEW_VEHICLE")}):e.includes("/registry/driver-details")||e.includes("/registry/modify-driver/")?t.push({label:a("VENDOR_DRIVER_DETAILS")}):e.includes("/registry/additionaldetails")?t.push({label:a("VENDOR_ADDITIONAL_DETAILS")}):e.includes("/registry/new-supervisor")?t.push({label:a("ES_FSM_REGISTRY_TITLE_NEW_SUPERVISOR")}):e.includes("/registry/supervisor-details")||e.includes("/registry/modify-supervisor/")?t.push({label:a("VENDOR_SUPERVISOR_DETAILS")}):e.includes("/registry/new-surveyor")?t.push({label:a("ES_FSM_REGISTRY_TITLE_NEW_SURVEYOR")}):(e.includes("/registry/surveyor-details")||e.includes("/registry/modify-surveyor/"))&&t.push({label:a("VENDOR_SURVEYOR_DETAILS")}),t})()}),l.createElement(i.PrivateRoute,{path:t+"/search-vendor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"normal"},l.createElement(u,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/new-driver",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(E,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/new-vehicle",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(v,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/additionaldetails",component:e=>{const n=e.location.pathname.includes("/info");return l.createElement(i.LayoutWrapper,{layoutClass:n?"action":"normal"},l.createElement(S,d({},e,{parentRoute:t})))}}),l.createElement(i.PrivateRoute,{path:t+"/registry/driver-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(p,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/modify-driver/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(I,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/common-search/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"normal"},l.createElement(c,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/new-vendor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(s,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/vendor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(m,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/vehicle-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(_,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/modify-vehicle/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(C,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/new-supervisor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(R,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/supervisor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(D,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/modify-supervisor/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(N,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/new-surveyor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(g,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/surveyor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(y,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/modify-surveyor/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(T,d({},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=(e,t)=>{const l=new Date(e);if(e){let e=l.getMonth()+1,n=l.getDate(),i=l.getFullYear();return e=(e>9?"":"0")+e,n=(n>9?"":"0")+n,"asset-create"===t?`${n}-${e}-${i}`:`${n}/${e}/${i}`}return null},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,o;let{isLoading:r,t:d,onSubmit:s,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 R=_.toISOString().split("T")[0],{register:D,control:N,handleSubmit:g,setValue:y,getValues:T,reset:I,formState:C}=a.useForm({defaultValues:{offset:0,limit:!v&&10,sortBy:"commencementDate",sortOrder:"DESC",fromDate:R,toDate:p}});t.useEffect(()=>{D("offset",0),D("limit",10),D("sortBy","commencementDate"),D("sortOrder","DESC"),y("fromDate",R),y("toDate",p)},[D,g,y,p,R]),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:d("VENDOR_REGISTRATION_NO"),accessor:"requestId",disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const i=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.registrationNo;return l.createElement("div",null,i||"N/A")}},{Header:d("CONTACT_PERSON_NAME"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const i=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.contactPerson;return l.createElement("div",null,i||"N/A")}},{Header:d("VENDOR_MOBILE_NUMBER"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const i=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.vendorMobileNumber;return l.createElement("div",null,i||"N/A")}},{Header:d("VENDOR_BANK_NAME"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const i=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.bank;return l.createElement("div",null,i||"N/A")}},{Header:d("VENDOR_STATUS"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const i=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.status;return l.createElement("div",null,i||"N/A")}}],[]),A=t.useCallback(e=>{0!==e.length&&(y("sortBy",e.id),y("sortOrder",e.desc?"DESC":"ASC"))},[]);function h(){y("offset",T("offset")-T("limit")),g(s)()}return l.createElement(l.Fragment,null,l.createElement("div",null,l.createElement(i.Header,null,d("VENDOR_COMMON_SEARCH_ADDITIONAL_DETAILS")),l.createElement(i.SearchForm,{onSubmit:s,handleSubmit:g},l.createElement(i.SearchField,null,l.createElement("label",null,d("VENDOR_NAME")),l.createElement(a.Controller,{control:N,name:"vendorName",render:e=>{var t;return l.createElement(i.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:d,disable:!1})}})),l.createElement(i.SearchField,null,l.createElement("label",null,d("VENDOR_MOBILE_NO")),l.createElement(i.MobileNumber,{name:"mobileNumber",inputRef:D({minLength:{value:10,message:d("CORE_COMMON_MOBILE_ERROR")},maxLength:{value:10,message:d("CORE_COMMON_MOBILE_ERROR")},pattern:{value:/[6789][0-9]{9}/,message:d("CORE_COMMON_MOBILE_ERROR")}}),type:"number",componentInFront:l.createElement("div",{className:"employee-card-input employee-card-input--front"},"+91")}),l.createElement(i.CardLabelError,null,null==C||null===(n=C.errors)||void 0===n||null===(o=n.mobileNumber)||void 0===o?void 0:o.message)),l.createElement(i.SearchField,null,l.createElement("label",null,d("VENDOR_FROM_DATE")),l.createElement(a.Controller,{render:e=>l.createElement(i.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"fromDate",control:N})),l.createElement(i.SearchField,null,l.createElement("label",null,d("VENDOR_TO_DATE")),l.createElement(a.Controller,{render:e=>l.createElement(i.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"toDate",control:N})),l.createElement(i.SearchField,{className:"submit"},l.createElement(i.SubmitBar,{label:d("ES_COMMON_SEARCH"),submit:!0}),l.createElement("p",{style:{marginTop:"10px"},onClick:()=>{I({fromDate:R,toDate:"",mobileNumber:"",vendorName:"",offset:0,limit:10,sortBy:"commencementDate",sortOrder:"DESC"}),E(null),h()}},d("ES_COMMON_CLEAR_ALL")))),!r&&null!=u&&u.display?l.createElement(i.Card,{style:{marginTop:20}},d(u.display).split("\\n").map((e,t)=>l.createElement("p",{key:t,style:{textAlign:"center"}},e))):r||""===u?""!==u||r&&l.createElement(i.Loader,null):l.createElement(i.Table,{t:d,data:u,totalRecords:c,columns:O,getCellProps:e=>({style:{minWidth:e.column.Header===d("EW_INBOX_APPLICATION_NO")?"240px":"",padding:"20px 18px",fontSize:"16px"}}),onPageSizeChange:function(e){y("limit",Number(e.target.value)),g(s)()},currentPage:T("offset")/T("limit"),onNextPage:function(){y("offset",T("offset")+T("limit")),g(s)()},onPrevPage:h,pageSizeLimit:T("limit"),onSort:A,disableSort:!1,sortParams:[{id:T("sortBy"),desc:"DESC"===T("sortOrder")}]})))},S=e=>{let{parentRoute:a}=e;const{t:r}=o.useTranslation(),d=[{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:a+"/search"},{text:r("ES_TITLE_REPORTS"),link:"/employee/report/fsm/FSMDailyDesludingReport",roles:["FSM_ADMIN"],hyperlink:!0}],[s,u]=t.useState([]),{roles:c}=Digit.UserService.getUser().info;return t.useEffect(()=>{let e=d.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(i.Card,{className:"employeeCard inboxLinksFSM"},l.createElement("div",{className:"complaint-links-container"},l.createElement("div",{className:"header"},l.createElement("span",{className:"logo"},l.createElement(i.ShippingTruck,null))," ",l.createElement("span",{className:"text"},r("ES_TITLE_FAECAL_SLUDGE_MGMT"))),l.createElement("div",{className:"body"},s.map((e,t)=>{let{link:i,text:o,hyperlink:a=!1,accessTo:d=[]}=e;return l.createElement("span",{className:"link",key:t},a?l.createElement("a",{href:i},r(o)):l.createElement(n.Link,{to:i},r(o)))}))))},p=e=>{let{className:t="table",t:n,currentPage:o,columns:a,data:r,getCellProps:s,disableSort:u,onSort:c,onNextPage:E,onPrevPage:m,onPageSizeChange:v,pageSizeLimit:S,sortParams:p,totalRecords:_,isPaginationRequired:R,showCSVExport:D,csvExportFileName:N,csvExportData:g,getCSVExportData:y,csvExportColumns:T,csvExportButtonLabel:I,...C}=e;return l.createElement(i.Card,null,l.createElement(i.Table,d({className:t,t:n,data:r,currentPage:o,columns:a,getCellProps:s,onNextPage:E,onPrevPage:m,pageSizeLimit:S,disableSort:u,onPageSizeChange:v,onSort:c,sortParams:p,totalRecords:_,isPaginationRequired:R,showCSVExport:D,csvExportFileName:N,csvExportData:g,getCSVExportData:y,csvExportColumns:T,csvExportButtonLabel:I},C)))},_=e=>{var t;let{status:n,searchParams:a,onAssignmentChange:r,statusMap:d}=e;return o.useTranslation(),l.createElement(i.CheckBox,{styles:{height:"unset"},onChange:e=>r({...e,state:n.state},n),checked:null==a?void 0:a.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,a,r,d,s;let{onAssignmentChange:u,searchParams:c,businessServices:E,statusMap:m}=e;const{t:v}=o.useTranslation(),[S,p]=t.useState(!1),{data:R,isLoading:D}=Digit.Hooks.useApplicationStatusGeneral({businessServices:E},{}),{userRoleStates:N}=R||{},g=(e,t)=>t(map[e.stateBusinessService])+" - "+t("ES_PTR_COMMON_STATUS_"+(e.state||"CREATED"));return D?l.createElement(i.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===(a=n.slice(0,4))||void 0===a?void 0:a.map((e,t)=>l.createElement(_,{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===(d=N.filter(e=>!e.isTerminateState))||void 0===d||null===(s=d.slice(4))||void 0===s?void 0:s.map((e,t)=>l.createElement(_,{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:()=>p(!S)}," ",v(S?"ES_COMMON_LESS":"ES_COMMON_MORE")," ")):null):null},D=e=>{let{onFilterChange:t,searchParams:n,paginationParms:o,tenantId:a,t:r}=e;const{data:d}=Digit.Hooks.fsm.useInbox(a,{...n,...o,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")}}),s=[{code:"ASSIGNED_TO_ME",name:r("ES_INBOX_ASSIGNED_TO_ME")+" (0)"},{code:"ASSIGNED_TO_ALL",name:`${r("ES_INBOX_ASSIGNED_TO_ALL")} (${(null==d?void 0:d.totalCount)||0})`}];return l.createElement(l.Fragment,null,l.createElement(i.RadioButtons,{onSelect:e=>t({uuid:{code:e.code}}),selectedOption:s.filter(e=>{var t;return e.code===(null==n||null===(t=n.uuid)||void 0===t?void 0:t.code)})[0],optionsKey:"name",options:s}))},N=e=>{var t,a,r,d;let{searchParams:s,paginationParms:u,onFilterChange:c,onSearch:E,...m}=e;const{t:v}=o.useTranslation(),S=n.useLocation(),p=Digit.UserService.hasAccess(["FSM_DSO"])||!1,_=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:[]}),h=()=>{if(_)return c()};return l.createElement(l.Fragment,null,(!p&&!_&&s||(null==A||null===(t=A.statuses)||void 0===t?void 0:t.length)>0||N)&&l.createElement("div",{className:"filter",style:{marginTop:_?"-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:h},v("ES_COMMON_CLEAR_ALL")),"desktop"===m.type&&l.createElement("span",{className:"clear-search",onClick:h},v("ES_COMMON_CLEAR_ALL")),"mobile"===m.type&&l.createElement("span",{onClick:m.onClose},l.createElement(i.CloseSvg,null))),l.createElement("div",null,!p&&!_&&s&&l.createElement(D,{onFilterChange:c,searchParams:s,paginationParms:u,tenantId:g,t:v}),l.createElement("div",null)),(null==A||null===(a=A.statuses)||void 0===a?void 0:a.length)>0||N?l.createElement("div",null,l.createElement("div",{className:"filter-label"},v("ES_INBOX_LOCALITY")),l.createElement(i.Localities,{selectLocality:e=>{c(_?{locality:[e]}:{locality:[...null==s?void 0:s.locality,e]})},tenantId:g,boundaryType:"revenue"}),l.createElement("div",{className:"tag-container"},null==s?void 0:s.locality.map((e,t)=>l.createElement(i.RemoveableTag,{key:t,text:e.i18nkey,onClick:()=>{c({locality:null==s?void 0:s.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(R,{onAssignmentChange:(e,t)=>{c(e.target.checked?{applicationStatus:[...null==s?void 0:s.applicationStatus,t]}:{applicationStatus:null==s?void 0:s.applicationStatus.filter(e=>t.name!==e.name)})},fsmfilters:s,mergedRoleDetails:A,statusMap:null==m||null===(d=m.applications)||void 0===d?void 0:d.statuses}):S.pathname.includes("fstp-fsm-request")?"":l.createElement(i.Loader,null)))),"mobile"===m.type&&m.onClose&&l.createElement(i.ActionBar,null,l.createElement(i.ApplyFilterBar,{submit:!1,labelLink:v("ES_COMMON_CLEAR_ALL"),buttonLink:v("ES_COMMON_FILTER"),onClear:h,onSubmit:()=>{"mobile"===m.type?E({delete:["applicationNos"]}):E()},style:{flex:1}})))},g=e=>{let{onAssignmentChange:t,value:n,applicationStatuses:o,areApplicationStatus:a}=e;return a?l.createElement(i.Dropdown,{option:o,optionKey:"name",selected:n,select:t}):l.createElement(i.Loader,null)},y=e=>{var r,s,u,c,E,m,v,S,p,_;let{onSearch:R,type:D,onClose:N,onTabChange:y,searchFields:T,searchParams:I,isInboxPage:C,selectedTab:O,matchedRoles:A}=e;const h=C?Digit.SessionStorage.get("vendor/inbox/searchParams"):Digit.SessionStorage.get("vendor/search/searchParams"),{t:b}=o.useTranslation(),f=n.useHistory(),{register:V,handleSubmit:L,reset:M,watch:w,control:k}=a.useForm({defaultValues:h||I}),[P,F]=t.useState(!1),x=window.Digit.Utils.browser.isMobile(),H=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1;function U(){const e=T.reduce((e,t)=>({...e,[null==t?void 0:t.name]:""}),{});M(e),C?Digit.SessionStorage.del("fsm/inbox/searchParams"):Digit.SessionStorage.del("fsm/search/searchParams"),R({})}const B=e=>null,Y=Digit.SessionStorage.get("User").info.type,G=[...null!=A&&null!==(r=A.wt)&&void 0!==r&&r.includes("WT_VENDOR")?["VENDOR"]:[],...null!=A&&null!==(s=A.wt)&&void 0!==s&&s.includes("WT_VENDOR")?["DRIVER","VEHICLE"]:[],...null!=A&&null!==(u=A.ekyc)&&void 0!==u&&u.includes("EKYC_VENDOR")?["SUPERVISOR"]:[],...null!=A&&null!==(c=A.ekyc)&&void 0!==c&&c.includes("EKYC_SUPERVISOR")||null!=A&&null!==(E=A.ekyc)&&void 0!==E&&E.includes("EKYC_VENDOR")?["SURVEYOR"]:[]];return l.createElement(l.Fragment,null,l.createElement("div",{className:"search-container"},l.createElement("div",{className:"search-complaint-container"},("mobile"===D||x)&&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(i.CloseSvg,null))),l.createElement("div",{className:"search-tabs-container"},l.createElement("div",null,l.createElement("button",{className:"VENDOR"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),y("VENDOR")}},b("ES_FSM_REGISTRY_INBOX_TAB_VENDOR")),(null==A||null===(m=A.wt)||void 0===m?void 0:m.includes("WT_VENDOR"))&&l.createElement("button",{className:"VEHICLE"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),y("VEHICLE")}},b("ES_FSM_REGISTRY_INBOX_TAB_VEHICLE")),(null==A||null===(v=A.wt)||void 0===v?void 0:v.includes("WT_VENDOR"))&&l.createElement("button",{className:"DRIVER"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),y("DRIVER")}},b("ES_FSM_REGISTRY_INBOX_TAB_DRIVER")),(null==A||null===(S=A.ekyc)||void 0===S?void 0:S.includes("EKYC_VENDOR"))&&l.createElement("button",{className:"SUPERVISOR"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),y("SUPERVISOR")}},b("ES_FSM_REGISTRY_INBOX_TAB_SUPERVISOR")),((null==A||null===(p=A.ekyc)||void 0===p?void 0:p.includes("EKYC_SUPERVISOR"))||(null==A||null===(_=A.ekyc)||void 0===_?void 0:_.includes("EKYC_VENDOR")))&&l.createElement("button",{className:"SURVEYOR"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),y("SURVEYOR")}},b("ES_FSM_REGISTRY_INBOX_TAB_SURVEYOR"))),l.createElement("div",{className:"action-bar-wrap-registry"},l.createElement("div",{className:"search-add",onClick:()=>{F(!P)}},b("ES_VENDOR_REGISTRY_INBOX_HEADER_ADD"),l.createElement("div",{className:"search-add-icon"},l.createElement(i.AddIcon,{className:""}))),P&&l.createElement(i.Menu,{localeKeyPrefix:"ES_FSM_ACTION_CREATE",options:G,t:b,onSelect:function(e){const t=null==Y?void 0:Y.toLowerCase();switch(e){case"VENDOR":return f.push(`/digit-ui/${t}/vendor/registry/new-vendor`);case"VEHICLE":return f.push(`/digit-ui/${t}/vendor/registry/new-vehicle`);case"DRIVER":return f.push(`/digit-ui/${t}/vendor/registry/new-driver`);case"SUPERVISOR":return f.push(`/digit-ui/${t}/vendor/registry/new-supervisor`);case"SURVEYOR":return f.push(`/digit-ui/${t}/vendor/registry/new-surveyor`)}}}))),l.createElement("form",{onSubmit:L(e=>{e.mobileNumber||delete e.mobileNumber,R(e),"mobile"===D&&N()})},l.createElement("div",{className:H?"for-pt for-search flex-box":"flex-box",style:{gap:"16px"}},null==T?void 0:T.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(a.Controller,{render:e=>l.createElement(i.DatePicker,{date:e.value,onChange:e.onChange}),name:e.name,control:k,defaultValue:null});case"status":return l.createElement(a.Controller,{render:e=>l.createElement(g,{onAssignmentChange:e.onChange,value:e.value}),name:e.name,control:k,defaultValue:null});case"dropdown":return l.createElement(a.Controller,{render:t=>l.createElement(i.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:k,defaultValue:null});default:return l.createElement(i.TextInput,d({},e,{inputRef:V},V(e.name,{validate:B}),{watch:w,shouldUpdate:!0,placeholder:e.label}))}})(e))),l.createElement("div",{style:{display:"flex",justifyContent:"end",gap:"16px",alignItems:"center"}},"desktop"===D&&!x&&l.createElement("span",{className:"clear-search generic-button"},l.createElement(i.LinkLabel,{style:{},onClick:U},b("ES_COMMON_CLEAR_SEARCH"))),"desktop"===D&&!x&&l.createElement(i.SubmitBar,{className:"submit-bar-search",label:b("ES_COMMON_SEARCH"),submit:!0})))))))},T=e=>{if(!e)return{};if("object"==typeof e)return e;if("string"!=typeof e)return{};try{return JSON.parse(e)}catch(e){return{}}},I=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):[]},C=function(e,t){void 0===t&&(t=[]);const l=function(e){var t,l,n,i,o,a,r,d,s,u,c,E,m;void 0===e&&(e={});const v=e=>Array.isArray(e)?e.flatMap(I):I(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===(i=e)||void 0===i||null===(o=i.fillingpointmetadata)||void 0===o?void 0:o.fillingPointId,null===(a=e)||void 0===a?void 0:a.fillingPtName,null===(r=e)||void 0===r?void 0:r.filling_pt_name,null===(d=e)||void 0===d||null===(s=d.fillingPoint)||void 0===s?void 0:s.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=>I(e).some(e=>l.includes(e)))||null},O=function(e){var t,l,n,i,o,a,r,d,s,u,c,E,m,v,S,p,_,R,D,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===(i=e)||void 0===i||null===(o=i.dsoDetails)||void 0===o||null===(a=o.fillingPoint)||void 0===a?void 0:a.fillingPointName)||(null===(r=e)||void 0===r?void 0:r.fillingPointName)||(null===(d=e)||void 0===d||null===(s=d.dsoDetails)||void 0===s?void 0:s.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===(R=_.dsoDetails)||void 0===R?void 0:R.fillingPoint:null)||(null===(D=e)||void 0===D||null===(N=D.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"},A=function(e,t){var l,n,i,o,a,r,d;void 0===e&&(e={}),void 0===t&&(t=[]);const s=(null===(l=e)||void 0===l||null===(n=l.vendor)||void 0===n?void 0:n.id)||(null===(i=e)||void 0===i||null===(o=i.vendorData)||void 0===o?void 0:o.id)||(null===(a=e)||void 0===a?void 0:a.vendorId);return s&&(t.find(e=>(null==e?void 0:e.id)===s)||(null===(r=e)||void 0===r?void 0:r.vendor)||(null===(d=e)||void 0===d?void 0:d.vendorData))||null},h=function(e){var t,l,n,i;void 0===e&&(e={});const o=[...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===(i=e)||void 0===i?void 0:i.fillingPoints]].filter(Boolean),a=new Map;return o.forEach(e=>{const t=I(e)[0]||(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.id);t&&!a.has(t)&&a.set(t,e)}),Array.from(a.values())},b=(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=I(t);return n.length?l.filter(e=>{const t=function(e){var t,l,n,i,o,a,r,d,s,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===(i=n.additionalDetails)||void 0===i?void 0:i.fillingPointId,null===(o=e)||void 0===o||null===(a=o.additionalDetails)||void 0===a?void 0:a.fillingStationId,null===(r=e)||void 0===r||null===(d=r.fillingpointmetadata)||void 0===d?void 0:d.fillingPointId].filter(e=>null!=e&&""!==e).map(String).concat(I(null===(s=e)||void 0===s?void 0:s.fillingPoint),I(null===(u=e)||void 0===u?void 0:u.fillingPointDetail),I(null===(c=e)||void 0===c?void 0:c.fillingPointDetails))))}(e);return!t.length||t.some(e=>n.includes(e))}):l},f=function(e,t){var l,n,i,o;void 0===e&&(e={}),void 0===t&&(t=[]);const a=(null===(l=e)||void 0===l||null===(n=l.driverData)||void 0===n?void 0:n.id)||(null===(i=e)||void 0===i||null===(o=i.driver)||void 0===o?void 0:o.id);return a&&t.find(e=>(null==e?void 0:e.id)===a)||null},V=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)}},L=e=>{var a,d,s;const c=Digit.ULBService.getCurrentTenantId(),{t:E}=o.useTranslation(),m=n.useHistory(),v=e=>l.createElement("span",{className:"cell-text"},e),_=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1,[R,D]=t.useState([]),[g,I]=t.useState(null),[L,M]=t.useState([]),[w,k]=t.useState([]),[P,F]=t.useState(!1),[x,H]=t.useState(null),U=Digit.SessionStorage.get("User"),B=U.info.roles,Y=null===(a=U.info.type)||void 0===a?void 0:a.toLowerCase(),G=()=>{H(null),F(!1)},W=l.useMemo(()=>[{Header:E("WT_NAME"),accessor:"name",Cell:e=>{let{row:t}=e;return v(t.original.name)}},{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{let{row:t}=e;return v(t.original.mobileNumber)}},{Header:E("WT_EMAIL_ID"),accessor:"emailId",Cell:e=>{let{row:t}=e;return v(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),I({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(i.ViewsIcon,null)):E("CS_NA")}}],[E]),K=r.useQueryClient(),{data:$,refetch:z}=Digit.Hooks.fsm.useDsoSearch(c,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{enabled:!1}),{data:Z,refetch:q}=Digit.Hooks.fsm.useDriverSearch({tenantId:c,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"}}),{mutate:j}=Digit.Hooks.fsm.useVendorUpdate(c),{mutate:X}=Digit.Hooks.fsm.useUpdateVehicle(c),{mutate:Q}=Digit.Hooks.fsm.useDriverUpdate(c);t.useEffect(()=>{var t;D((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"})`}});M(e)}},[$]),t.useEffect(()=>{Z&&k((Z.driver||[]).map(e=>{var t;return{...e,displayName:`${e.name} (${(null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"N/A"})`}}))},[Z]);const J=()=>{I(null)},ee=(e,t)=>{D(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:V(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}/vendor/registry/new-vehicle`);case"DRIVER":return m.push(`/digit-ui/${Y}/vendor/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`)}},ie=l.useMemo(()=>"VENDOR"===e.selectedTab?(null==R?void 0:R.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,R,$]),{data:oe}=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:c,filters:{vendorIds:null==ie?void 0:ie.join(","),vendorId:null==ie?void 0:ie.join(",")}},{enabled:(null==ie?void 0:ie.length)>0}),{data:ae,isLoading:re}=Digit.Hooks.wt.useFillPointSearch({tenantId:c,filters:{limit:1e3}},{enabled:!0}),de=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,i;let{row:o}=e;return v(null!==(t=o.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=o.original)||void 0===n||null===(i=n.auditDetails)||void 0===i?void 0:i.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:i}=e,o=null===(t=i.original.dsoDetails)||void 0===t?void 0:t.additionalDetails;if("string"==typeof o)try{o=JSON.parse(o)}catch(e){console.error("Error parsing additionalDetails:",e),o={}}const a=(null===(n=o)||void 0===n?void 0:n.serviceType)||"N/A";return l.createElement("div",null,a)}},{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,o;let{row:a}=t;return l.createElement(i.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=a.original)||void 0===n||null===(o=n.dsoDetails)||void 0===o?void 0:o.status),onChange:()=>(t=>{var l,n,i,o;let a=t.original.dsoDetails;const r={vendor:{...a,status:"ACTIVE"===(null==a?void 0:a.status)?"DISABLED":"ACTIVE",owner:{...a.owner,gender:(null==a||null===(l=a.owner)||void 0===l?void 0:l.gender)||"OTHER",dob:(null==a||null===(n=a.owner)||void 0===n?void 0:n.dob)||new Date("1/1/1970").getTime(),emailId:(null==a||null===(i=a.owner)||void 0===i?void 0:i.emailId)||"abc@egov.com",relationship:(null==a||null===(o=a.owner)||void 0===o?void 0:o.relationship)||"OTHER"}}};j(r,{onError:(e,t)=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{I({key:"success",action:"VENDOR"}),K.invalidateQueries("DSO_SEARCH"),e.refetchData(),setTimeout(J,3e3)}})})(a),name:"switch-"+a.id})}},{Header:E("ES_VENDOR_ADDITIONAL_DETAILS"),disableSortBy:!0,Cell:e=>{var t,i;let{row:o}=e;const a=null===(t=o.original)||void 0===t?void 0:t.id;if(!oe)return l.createElement("span",null,"Loading...");const r=null!==(null===(i=o.original)||void 0===i?void 0:i.vendorAdditionalDetails);return l.createElement(n.Link,{to:r?`/digit-ui/${Y}/vendor/registry/additionaldetails/info?vendorId=`+a:`/digit-ui/${Y}/vendor/registry/additionaldetails/vendor-details?vendorId=`+a},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:i}=e;return l.createElement("div",null,(null===(t=i.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,i;let{row:o}=e;return v(null!==(t=o.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=o.original)||void 0===n||null===(i=n.auditDetails)||void 0===i?void 0:i.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(i.Dropdown,{className:"fsm-registry-dropdown",selected:A(n.original,L),option:L,select:t=>((t,l)=>{const n=t.original,i=null==n?void 0:n.vendor;if(null==l||!l.id||(null==i?void 0:i.id)===(null==l?void 0:l.id))return;const o={...n,vendorVehicleStatus:"ACTIVE",fillingPoint:null,driverData:null,driver:null};delete o.vendor,delete o.popup,delete o.driver;const a=()=>{const t=Array.isArray(null==l?void 0:l.vehicles)?[...l.vehicles]:[],i=t.findIndex(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id));i>-1?t[i]={...t[i],...o,vendorVehicleStatus:"ACTIVE"}:t.push(o);const a={...l,vehicles:t};j(le(l,t),{onError:e=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:()=>{ee(null==n?void 0:n.id,{vendor:a,fillingPoint:null,driverData:null,driver:null}),I({key:"success",action:"VEHICLE"}),K.invalidateQueries("DSO_SEARCH"),K.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchData(),e.refetchVendor&&e.refetchVendor(),setTimeout(J,3e3)}})};if(null!=i&&i.id){const e=Array.isArray(null==i?void 0:i.vehicles)?i.vehicles.map(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id)?{...e,vendorVehicleStatus:"INACTIVE"}:e):[];j(le(i,e),{onError:e=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:a})}else a()})(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,i=n.original.additionalDetails;if("string"==typeof i)try{i=JSON.parse(i)}catch(e){console.error("Error parsing additionalDetails:",e),i={}}const o=(null===(t=i)||void 0===t?void 0:t.serviceType)||"N/A";return l.createElement("div",null,o)}},{Header:E("WT_FILLING_POINT"),accessor:e=>O(e),id:"fillingPoint",minWidth:250,Cell:t=>{let{row:n}=t;const o=A(n.original,L),a=h(o);return l.createElement(i.Dropdown,{className:"fsm-registry-dropdown",selected:C(n.original,a),option:a,select:t=>((t,l)=>{const n=te(t.original,{fillingPoint:l});X(n,{onError:e=>{var t,l,n,i;I({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===(i=n[0])||void 0===i?void 0:i.message)||"Failed to map filling point"}),setTimeout(J,5e3)},onSuccess:()=>{var n;const i=A(t.original,L),o=b(i,l),a=f(t.original,o);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)},...a?{}:{driverData:null,driver:null}}),I({key:"success",label:"Filling point mapped successfully"}),K.invalidateQueries("FSM_VEICLES_SEARCH"),K.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:!o||!a.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 o=A(n.original,L),a=C(n.original,h(o)),r=b(o,a);return l.createElement(i.Dropdown,{className:"fsm-registry-dropdown",selected:f(n.original,r),option:r,select:t=>((t,l)=>{const n=te(t.original,{driverData:l});X(n,{onError:(e,t)=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(n,i)=>{var o;ee(null===(o=t.original)||void 0===o?void 0:o.id,{driverData:l}),I({key:"success",action:"VEHICLE"}),K.invalidateQueries("FSM_VEICLES_SEARCH"),K.invalidateQueries("DSO_SEARCH"),e.refetchData(),e.refetchVendor(),setTimeout(J,3e3)}})})(n,t),optionKey:"displayName",t:E,style:{textAlign:"left",width:"100%",minWidth:"250px"},disable:!a||!r.length})}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let{row:o}=t;return l.createElement(i.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=o.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"});X(n,{onError:(e,t)=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{I({key:"success",action:"VEHICLE"}),K.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(J,3e3)}})})(o),name:"switch-"+o.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:i}=e;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/driver-details/`+i.original.id},l.createElement("div",null,(null===(t=i.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:i}=e;return l.createElement("div",null,(null===(t=i.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,i;let{row:o}=e;return v(null!==(t=o.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=o.original)||void 0===n||null===(i=n.auditDetails)||void 0===i?void 0:i.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(i.Dropdown,{className:"fsm-registry-dropdown",selected:(null==L?void 0:L.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:L,select:t=>((t,l)=>{let n=t.original,i=null==n?void 0:n.vendor,o=l;if(delete n.vendor,n.vendorDriverStatus="ACTIVE",i){const e=null==i?void 0:i.drivers;e.splice(e.findIndex(e=>e.id===n.id),1)}const a={vendor:{...o,drivers:o.drivers?[...o.drivers,n]:[n]}};j(a,{onError:(e,t)=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{I({key:"success",action:"VENDOR"}),K.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:o}=t;return l.createElement(i.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=o.original)||void 0===n?void 0:n.status),onChange:()=>(t=>{var l,n,i,o;let a=t.original;const r={driver:{...a,status:"ACTIVE"===(null==a?void 0:a.status)?"DISABLED":"ACTIVE",owner:{...a.owner,gender:(null==a||null===(l=a.owner)||void 0===l?void 0:l.gender)||"OTHER",dob:(null==a||null===(n=a.owner)||void 0===n?void 0:n.dob)||new Date("1/1/1970").getTime(),emailId:(null==a||null===(i=a.owner)||void 0===i?void 0:i.emailId)||"abc@egov.com",relationship:(null==a||null===(o=a.owner)||void 0===o?void 0:o.relationship)||"OTHER"}}};Q(r,{onError:(e,t)=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{I({key:"success",action:"DRIVER"}),K.invalidateQueries("FSM_DRIVER_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(J,3e3)}})})(o),name:"switch-"+o.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 i;let{row:o}=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"}/`+o.original.id},l.createElement("div",null,(null===(i=o.original.owner)||void 0===i?void 0:i.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: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,""+(i.original.name||"N/A")))))}},..."SURVEYOR"===e.selectedTab?[{Header:E("ES_FSM_REGISTRY_INBOX_SUPERVISOR_NAME"),accessor:e=>{var t;return(null===(t=e.reportingManager)||void 0===t?void 0:t.name)||"NA"},Cell:e=>{var t,n;let{row:i}=e;return l.createElement("div",null,(null===(t=i.original)||void 0===t||null===(n=t.reportingManager)||void 0===n?void 0:n.name)||"NA")}}]:[],{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{var t,n;let{row:i}=e;return l.createElement("div",null,(null===(t=i.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,i;let{row:o}=e;return v(null!==(t=o.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=o.original)||void 0===n||null===(i=n.auditDetails)||void 0===i?void 0:i.createdTime):"")}},{Header:E("SUPERVISOR"===e.selectedTab?"ES_VENDOR_SUPERVISOR_AGENCY_NAME":"ES_VENDOR_SURVEYOR_AGENCY_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(i.Dropdown,{className:"fsm-registry-dropdown",selected:(null==L?void 0:L.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:L,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:o}=t;return l.createElement(i.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=o.original)||void 0===n?void 0:n.status),onChange:()=>{console.log("Updating status for",e.selectedTab,o.original.id)},name:"switch-"+o.id})}}];default:return[]}},[e.selectedTab,L,w,R,oe,(null==ae?void 0:ae.fillingPoints)||[],E]),se=l.useMemo(()=>{switch(e.selectedTab){case"VENDOR":return[{Header:E("ES_VENDOR_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,i,o;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===(i=e.dsoDetails)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.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=>O(e)},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t,l;return(null===(t=T(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,i,o,a,r,d;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===(i=e.vendor)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(a=e.vendorData)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendorData)||void 0===r||null===(d=r.owner)||void 0===d?void 0:d.mobileNumber)||"NA"})`}},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t;return(null===(t=T(null==e?void 0:e.additionalDetails))||void 0===t?void 0:t.serviceType)||"N/A"}},{Header:E("WT_FILLING_POINT"),exportAccessor:e=>O(e)},{Header:E("ES_FSM_REGISTRY_SELECT_DRIVER"),exportAccessor:e=>{var t,l,n,i,o,a;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===(i=n.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(o=e.driver)||void 0===o||null===(a=o.owner)||void 0===a?void 0:a.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,i,o,a,r,d;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===(i=e.vendorData)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(d=r.owner)||void 0===d?void 0:d.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_SUPERVISOR_NAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.reportingManager)||void 0===t?void 0:t.name)||"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,i,o,a,r,d;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===(i=e.vendorData)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(d=r.owner)||void 0===d?void 0:d.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,i,o,a,r,d;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===(i=e.vendorData)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(d=r.owner)||void 0===d?void 0:d.mobileNumber)||"NA"}`}},{Header:E("ES_VENDOR_SUPERVISOR_AGENCY_NAME"),exportAccessor:e=>{var t,l,n,i,o,a,r,d;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===(i=e.vendorData)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(d=r.owner)||void 0===d?void 0:d.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(R)},[R]);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(i.Loader,null));else if(0===R.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(i.Card,{className:"flex-center flex-box"},l.createElement("div",{style:{marginTop:"50px",marginBottom:"25px"}},E(t)),l.createElement(i.SubmitBar,{className:"",label:E(n),onSubmit:ne}))}else R.length>0&&(ce=l.createElement(p,{className:"table registryTable",t:E,data:R,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:ue,csvExportColumns:se,csvExportFileName:`vendor-${String(e.selectedTab||"registry").toLowerCase()}-inbox`}));const Ee=B.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 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(N,{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",display:"flex",flexDirection:"column",gap:"12px"}},l.createElement(y,{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)),g&&l.createElement(i.Toast,{error:"error"===g.key,label:E(g.label?g.label:"success"===g.key?`ES_FSM_REGISTRY_${g.action}_DISABLE_SUCCESS`:g.action),onClose:J}),P&&l.createElement(i.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(i.MdClose,null)),actionCancelLabel:E("CS_COMMON_CLOSE"),actionCancelOnSubmit:G,hideSubmit:!0,formId:"modal-action"},l.createElement("div",{style:{padding:"16px"}},(null==x||null===(d=x.dsoDetails)||void 0===d||null===(s=d.vendorWorkOrder)||void 0===s?void 0:s.length)>0?l.createElement(i.Table,{t:E,data:x.dsoDetails.vendorWorkOrder,columns:W,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}=o.useTranslation(),t=n.useLocation(),{path:a}=n.useRouteMatch(),r=Digit.ComponentRegistryService.getComponent("SearchVendor"),s=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"),R=Digit.ComponentRegistryService.getComponent("VehicleDetails"),D=Digit.ComponentRegistryService.getComponent("EditDriver"),N=Digit.ComponentRegistryService.getComponent("EditVehicle");return l.createElement(n.Switch,null,l.createElement(i.AppContainer,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(i.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(i.ArrowLeft,{className:"icon"}),e("CS_COMMON_BACK")),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const l=t.pathname;let n=[{icon:i.HomeIcon,path:"/digit-ui/citizen"},{label:e("WT_MODULE_NAME"),path:a+"/wt-Vendor"}];if(l.includes("/inbox")){let t="ES_COMMON_INBOX";l.includes("/mt/inbox")&&(n=[{icon:i.HomeIcon,path:"/digit-ui/citizen"},{label:e("ACTION_TEST_MT"),path:a+"/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/")?a+"/mt/inbox":a+"/inbox"}),n.push({label:e("WT_BOOKING_DETAILS")}));const o=[{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 o&&n.push({label:e(o.label)}),n})()}),l.createElement(i.PrivateRoute,{path:a+"/search-vendor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"normal"},l.createElement(r,d({},e,{parentRoute:a}))),exact:!0}),l.createElement(i.PrivateRoute,{path:a+"/registry/vendor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(s,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/driver-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(p,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/modify-driver/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(D,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/vehicle-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(R,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/modify-vehicle/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(N,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/new-driver",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(S,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/new-vehicle",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(_,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/new-supervisor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(u,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/additionaldetails",component:e=>{const t=e.location.pathname.includes("/info");return l.createElement(i.LayoutWrapper,{layoutClass:t?"action":"normal"},l.createElement(v,d({},e,{parentRoute:a})))}}),l.createElement(i.PrivateRoute,{path:a+"/registry/supervisor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(c,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/new-surveyor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(E,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/surveyor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(m,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:""+a,component:()=>Digit.UserService.hasAccess(["WT_VENDOR","EKYC_VENDOR","EKYC_SUPERVISOR"])?l.createElement("div",{style:{display:"flex",gap:"24px",flexWrap:"wrap",width:"100%",padding:"8px 0"}},l.createElement(i.CitizenHomeCard,{header:e("TITLE_VENDOR_MANAGEMENT"),links:[{i18nKey:e("SEARCH_VENDOR"),link:"/digit-ui/citizen/vendor/search-vendor"}],Icon:()=>l.createElement(i.PropertyHouse,{className:"fill-path-primary-main"})})):l.createElement(n.Redirect,{to:{pathname:"/digit-ui/citizen/login",state:{from:a+"/wt-Vendor",role:"WT_VENDOR"}}}),exact:!0}))))},w=e=>{let{t:t,title:n}=e;return l.createElement("div",{className:"confirmation_box"},l.createElement("span",null,t(""+n)," "))},k=e=>l.createElement("h1",{className:"heading-m"},e.label),P=()=>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"})),F=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(P,null)),{DatePicker:x}=require("@djb25/digit-ui-react-components"),H=function(e,t,n,i){return void 0===i&&(i=!1),[{head:e("ES_VENDOR_SUPERVISOR_BASIC_DETAILS"),body:[{label:e("ES_VENDOR_SUPERVISOR_FULL_NAME"),isMandatory:!0,type:"text",disable:i,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:e("ES_VENDOR_SUPERVISOR_MOBILE_NUMBER"),isMandatory:!0,type:"mobileNumber",disable:i,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:e("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:e("ES_VENDOR_SUPERVISOR_EMPLOYEE_ID"),isMandatory:!0,type:"text",populators:{name:"employeeId",validation:{required:!0},defaultValue:"",className:"payment-form-text-input-correction"}},{label:e("ES_VENDOR_SUPERVISOR_GENDER"),isMandatory:!0,type:"component",key:"gender",component:"SelectGender"},{label:e("ES_FSM_REGISTRY_NEW_FATHER_NAME"),isMandatory:!0,type:"text",populators:{name:"fatherOrHusbandName",validation:{required:!0},className:"payment-form-text-input-correction"}},{label:e("ES_FSM_REGISTRY_NEW_RELATIONSHIP"),isMandatory:!0,type:"component",key:"relationship",component:"SelectEkycDropdown",populators:{name:"relationship",options:[{code:"FATHER",name:"ES_COMMON_RELATION_FATHER"},{code:"HUSBAND",name:"ES_COMMON_RELATION_HUSBAND"},{code:"OTHER",name:"ES_COMMON_RELATION_OTHER"}],optionsKey:"name"}},{label:e("ES_FSM_REGISTRY_NEW_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(x,d({onChange:e.onChange,date:e.value},t))}},{label:e("ES_FSM_REGISTRY_NEW_CORRESPONDENCE_ADDRESS"),isMandatory:!0,type:"text",populators:{name:"correspondenceAddress",validation:{required:!0},className:"payment-form-text-input-correction"}},{label:e("ES_VENDOR_SUPERVISOR_ASSIGNED_ZONE"),isMandatory:!0,type:"component",key:"assignedZone",component:"SelectEkycDropdown",populators:{name:"assignedZone",options:[{code:"ZONE-01",name:"ZONE-01"},{code:"ZONE-02",name:"ZONE-02"},{code:"ZONE-03",name:"ZONE-03"},{code:"ZONE-04",name:"ZONE-04"},{code:"ZONE-05",name:"ZONE-05"}],optionsKey:"name"}},{label:e("ES_VENDOR_SUPERVISOR_DESCRIPTION"),isMandatory:!1,type:"text",populators:{name:"description",className:"payment-form-text-input-correction"}}]}]},U=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"})),Y=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(B,null)),{DatePicker:G}=require("@djb25/digit-ui-react-components"),W=function(e,t,n,i){return[{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:e("ES_VENDOR_SURVEYOR_GENDER"),isMandatory:!0,type:"component",key:"gender",component:"SelectGender"},{label:e("ES_FSM_REGISTRY_NEW_FATHER_NAME"),isMandatory:!0,type:"text",populators:{name:"fatherOrHusbandName",validation:{required:!0},className:"payment-form-text-input-correction"}},{label:e("ES_FSM_REGISTRY_NEW_RELATIONSHIP"),isMandatory:!0,type:"component",key:"relationship",component:"SelectEkycDropdown",populators:{name:"relationship",options:[{code:"FATHER",name:"ES_COMMON_RELATION_FATHER"},{code:"HUSBAND",name:"ES_COMMON_RELATION_HUSBAND"},{code:"OTHER",name:"ES_COMMON_RELATION_OTHER"}],optionsKey:"name"}},{label:e("ES_FSM_REGISTRY_NEW_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(G,d({onChange:e.onChange,date:e.value},t))}},{label:e("ES_FSM_REGISTRY_NEW_CORRESPONDENCE_ADDRESS"),isMandatory:!0,type:"text",populators:{name:"correspondenceAddress",validation:{required:!0},className:"payment-form-text-input-correction"}},{label:e("ES_VENDOR_SURVEYOR_DESCRIPTION"),isMandatory:!1,type:"text",populators:{name:"description",className:"payment-form-text-input-correction"}}]}]},K=e=>l.createElement("h1",{className:"heading-m"},e.label),$=()=>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($,null)),Z=e=>{let{jumpTo:t}=e;const{t:a}=o.useTranslation(),r=n.useHistory();return l.createElement(i.LinkButton,{label:a("CS_COMMON_CHANGE"),className:"check-page-link-button",onClick:function(){r.push(t)}})},q=e=>{const{t:t}=o.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")},j={padding:"4px 0px",justifyContent:"space-between"},X=e=>{var t,n;return l.createElement(i.Banner,{message:q(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"),ee=e=>l.createElement("h1",{className:"heading-m"},e.label),te=()=>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"})),le=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(te,null)),{DatePicker:ne}=require("@djb25/digit-ui-react-components"),ie=e=>l.createElement("h1",{className:"heading-m"},e.label),oe=()=>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(oe,null)),re={VendorDetails:e=>{var n,o,r,d;let{t:s,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===(o=m.ownerKey)||void 0===o?void 0:o.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),R=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].altMobileNumber||(null==m||null===(d=m.ownerKey)||void 0===d?void 0:d.altmobileNumber)||"",[D,N]=t.useState(""),[g,y]=t.useState(""),[T,I]=t.useState(""),[C,O]=t.useState(""),[A,h]=t.useState(),[b,f]=t.useState(""),[V,L]=t.useState(""),[M,w]=t.useState(""),[k,P]=t.useState(""),[F,x]=t.useState(""),[H,U]=t.useState(""),[B,Y]=t.useState(""),[G,W]=t.useState(""),[K,$]=t.useState(""),[z,Z]=t.useState(""),[q,j]=t.useState(""),[X,Q]=t.useState(""),[J,ee]=t.useState("");t.useEffect(()=>{11!==b.length||C||A||q?11===b.length&&C&&A?(O(C),h(A),j(q)):(O(""),h(""),j("")):fetch("https://ifsc.razorpay.com/"+b).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH&&e.MICR&&(O(e.BANK),h(e.BRANCH),j(e.MICR))}).catch(()=>{})},[b]);const te=Digit.ULBService.getCurrentTenantId(),{control:le}=a.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 ie=()=>{let e,t=m.ownerKey&&m.ownerKey[0];"citizen"===E?(e={...t,applicantName:S,mobileNumber:_,altMobileNumber:R,emailId:p},c(u.key,{...m[u.key],...e},!1,0)):(e={...t,VendorCategory:D,name:T,VendorId:g,Bank:C,BankbranchName:A,IFSC:b,AccountNo:V,PanNo:M,GstNo:k,GstState:F,RegistrationNo:H,EpfNo:B,EsiNo:G,VendorType:K,Status:z,micrNo:q,PhoneNo:X,ContactPerson:J},c(u.key,e,!1,0))};return t.useEffect(()=>{"citizen"===E&&ie()},[D,g,T,C,A,b,V,M,k,F,H,B,G,K,z,q,X,J,E]),l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{timeLine:[{actions:s("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:s("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:s("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(i.FormStep,{config:u,onSelect:ie,t:s,className:"formcomposer-grid-container-form"},l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,{className:"card-label-smaller"},l.createElement(i.CustomTooltip,{label:""+s("IFSC_CODE"),isMandatory:!1,message:s("INVALID_IFSC_CODE_ERROR_MESSAGE")})),l.createElement(i.TextInput,{t:s,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&&f(t)},style:{width:"100%"},maxLength:11,ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[A-Z]{4}0[A-Z0-9]{6}$",type:"text",title:s("INVALID_IFSC_CODE_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("VENDOR_BANK_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(i.TextInput,{t:s,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(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("VENDOR_BANK_BRANCH_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"BankbranchName",value:A,style:{width:"100%"},placeholder:"Bank Branch Name Auto Select",onChange:function(e){h(e.target.value)},disabled:!1})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("VENDOR_MICR_NO")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"MicrNo",value:q,style:{width:"100%"},placeholder:"MICR No",onChange:j,disabled:!1})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("ACCOUNT_NO")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"AccountNo",value:V,onChange:function(e){L(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"[0-9]{9,18}",type:"text",title:s("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("PHONE_NO")),l.createElement(i.MobileNumber,{value:X,name:"PhoneNo",onChange:Q,style:{width:"100%"}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("CONTACT_PERSON")),l.createElement(i.TextInput,{t:s,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:s("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("PAN_NO")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"PanNo",value:M,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:s("INVALID_PAN_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("GST_NO")),l.createElement(i.TextInput,{t:s,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:s("INVALID_GST_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("GST_REGISTERED_STATE/UT")),l.createElement(i.TextInput,{t:s,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:s("PT_NAME_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("REGISTRATION_NO")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"RegistrationNo",value:H,onChange:function(e){U(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:s("INVALID_REGISTRATION_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("EPF_NO")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"EpfNo",value:B,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:s("INVALID_EPF_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("ESI_NO")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"EsiNo",value:G,onChange:function(e){W(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:s("INVALID_ESI_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement("div",null,s("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"}},""+s("AST_CLASSIFICATION_ASSET")))),l.createElement(a.Controller,{control:le,name:"VendorType",defaultValue:K,rules:{required:s("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(i.Dropdown,{selected:K,select:$,option:[{i18nKey:"Supplier",code:"SUPPLIER"},{i18nKey:"Contractor",code:"CONTRACTOR"}],optionKey:"i18nKey",placeholder:"Select",t:s})})),l.createElement(i.LabelFieldPair,null,l.createElement("div",null,s("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(a.Controller,{control:le,name:"VendorCategory",defaultValue:D,rules:{required:s("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(i.Dropdown,{selected:D,select:N,option:[{i18nKey:"Firm",code:"FIRM"},{i18nKey:"Individual",code:"Individual"}],optionKey:"i18nKey",placeholder:"Select",t:s})})),l.createElement(i.LabelFieldPair,null,l.createElement("div",null,s("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"}},""+s("AST_CLASSIFICATION_ASSET")))),l.createElement(a.Controller,{control:le,name:"Status",defaultValue:z,rules:{required:s("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(i.Dropdown,{selected:z,select:Z,option:[{i18nKey:"Active",code:"ACTIVE"},{i18nKey:"Inactive",code:"INACTIVE"}],optionKey:"i18nKey",placeholder:"Select",t:s})})))))},VendorDocuments:e=>{var n;let{t:o,config:a,onSelect:r,formData:d}=e;const[s,c]=t.useState([null]),[E,m]=t.useState([null]),[v,S]=t.useState(null),[p,_]=t.useState(1),[R,D]=(Digit.ULBService.getStateId(),Digit.ULBService.getStateId(),t.useState((null==d||null===(n=d.documents)||void 0===n?void 0:n.documents)||[]));return t.useEffect(()=>{var e;null!=d&&null!==(e=d.documents)&&void 0!==e&&e.documents&&(m(d.documents.documents),_(d.documents.documents.length),c(new Array(d.documents.documents.length).fill(null)))},[d]),l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{timeLine:[{actions:o("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:o("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:o("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:1,showFinalStep:!1}),l.createElement(i.FormStep,{t:o,config:a,onSelect:()=>{let e;e={...d.documents,documents:E.filter(e=>null!==e)},r(a.key,e)},onSkip:()=>r(),isDisabled:E.some(e=>null===e)&&s.some(e=>null===e)},s.map((e,t)=>l.createElement(i.LabelFieldPair,{key:t},l.createElement(i.CardLabel,{className:"card-label-smaller"},o("VENDOR_ID")+(0!==t?t:"")),l.createElement("div",{className:"field",style:{display:"flex",alignItems:"center",paddingBottom:"10px"}},l.createElement(i.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(o("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(o("CS_FILE_UPLOAD_ERROR"))})},function(){S(o("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 "+o("CS_ACTION_FILEUPLOADED"):o("CS_ACTION_NO_FILEUPLOADED"),textStyles:{width:"100%"},inputStyles:{width:"280px"},accept:".pdf, .jpeg, .jpg, .png",buttonType:"button",error:!E[t]})))),v&&l.createElement(i.Toast,{label:v,onClose:()=>S(null),error:!0})))},ServiceDoc:e=>{var t;let{t:n,config:o,onSelect:a}=e;const r=Digit.ULBService.getStateId(),d=null!=o&&o.isMutation?["MutationDocuments"]:"Documents",{isLoading:s,data:u={}}=Digit.Hooks.asset.useAssetDocumentsMDMS(r,"ASSET",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&&l.createElement(i.Loader,null),Array.isArray(c)&&c.map((e,t)=>{let{code:o,dropdownData:a}=e;return l.createElement(i.Card,{key:t},l.createElement("div",null,l.createElement("h3",{style:{margin:0}},t+1,". ",n(m(o,".","_")))),a.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(i.ActionBar,null,l.createElement(i.SubmitBar,{label:n("COMMON_NEXT"),onSubmit:a})))},AddVendor:e=>{const a=Digit.ULBService.getCurrentTenantId(),{t:r}=o.useTranslation(),[s,u]=(n.useHistory(),t.useState(1)),[c,m]=t.useState(null),[v,S]=t.useState(!1),[,p]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,_]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,R]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1);Digit.Hooks.fsm.useVendorCreate(a),t.useEffect(()=>{p(!1),R(),_()},[]);const D={serviceType:{code:"WT",name:"WT",i18nKey:"WT"},tripData:{noOfTrips:1,amountPerTrip:null,amount:null}},[N,g]=t.useState(D),y=function(e,t,n){var o,a;void 0===t&&(t=!1),void 0===n&&(n={});const r="EKYC"===(null===(o=n)||void 0===o||null===(a=o.serviceType)||void 0===a?void 0:a.code);return[{head:"ES_VRNDOR_NEW_VENDOR_DETAILS",isCollapsible:!0,isDefaultOpen:!0,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"}},...r?[{label:"ES_VENDOR_CONTRACT_START_DATE",isMandatory:!0,type:"custom",key:"contractStartDate",populators:{name:"contractStartDate",validation:{required:!0},component:(e,t)=>l.createElement(i.DatePicker,d({onChange:e.onChange,date:e.value},t))}},{label:"ES_VENDOR_CONTRACT_END_DATE",isMandatory:!0,type:"custom",key:"contractEndDate",populators:{name:"contractEndDate",validation:{required:!0},component:(e,t)=>l.createElement(i.DatePicker,d({onChange:e.onChange,date:e.value},t))}},{label:"ES_VENDOR_ZONE",isMandatory:!0,type:"component",key:"zoneIds",component:"SelectEkycZones"},{label:"ES_VENDOR_CLUSTER",isMandatory:!0,type:"component",key:"clusterIds",component:"SelectEkycClusters"},{label:"ES_FSM_REGISTRY_NEW_OWNER_NAME",isMandatory:!0,type:"text",populators:{name:"ownerName",validation:{required:!0,pattern:/^[A-Za-z\s.,/]+$/},error:e("FSM_REGISTRY_INVALID_NAME"),className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_GENDER",isMandatory:!0,type:"component",key:"gender",component:"SelectEkycDropdown",populators:{name:"gender",options:[{code:"MALE",name:"ES_COMMON_GENDER_MALE"},{code:"FEMALE",name:"ES_COMMON_GENDER_FEMALE"},{code:"OTHER",name:"ES_COMMON_GENDER_OTHER"}],optionsKey:"name"}},{label:"ES_FSM_REGISTRY_NEW_DOB",isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(i.DatePicker,d({onChange:e.onChange,date:e.value},t,{max:E((new Date).setFullYear((new Date).getFullYear()))}))}}]:[]]},{isCreateConnection:!0,className:"new-application-card",body:[{type:"component",key:"propertyAddress",component:"CPTPropertyLocationDetails",withoutLabel:!0,props:{hidePropertySearch:!0,hideZRO:!0}}]}]}(r,!1,N);return l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{route:"vendor-details",timeLine:[{actions:"New Vendor Details",currentStep:1}]},{route:"address-details",timeLine:[{actions:"Address Details",currentStep:2}]}],currentActiveIndex:s-1,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(i.FormComposer,{config:y,userType:"employee",onFormValueChange:(e,t)=>{var l,n,i,o,a,d;(null==t||null===(l=t.serviceType)||void 0===l?void 0:l.code)===(null==N||null===(n=N.serviceType)||void 0===n?void 0:n.code)&&JSON.stringify(null==t?void 0:t.zoneIds)===JSON.stringify(null==N?void 0:N.zoneIds)||g(t);const c="EKYC"===(null==t||null===(i=t.serviceType)||void 0===i?void 0:i.code),E=(null==t?void 0:t.vendorName)&&(null==t?void 0:t.phone)&&(null==t||null===(o=t.serviceType)||void 0===o?void 0:o.code),m=(null==t||null===(a=t.address)||void 0===a?void 0:a.city)&&(null==t||null===(d=t.address)||void 0===d?void 0:d.locality);let v=!0;var p,_;c&&(v=(null==t?void 0:t.ownerName)&&(null==t?void 0:t.contractStartDate)&&(null==t?void 0:t.contractEndDate)&&(null==t||null===(p=t.zoneIds)||void 0===p?void 0:p.length)>0&&(null==t||null===(_=t.clusterIds)||void 0===_?void 0:_.length)>0&&(null==t?void 0:t.fatherOrHusbandName)&&(null==t?void 0:t.gender)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.relationship)),S(!!(E&&m&&v)),E?1===s&&(u(2),setTimeout(()=>{const e=Array.from(document.querySelectorAll(".collapsible-card-title")).find(e=>e.textContent.includes(r("ES_FSM_REGISTRY_NEW_ADDRESS_DETAILS")));e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100)):2===s&&(u(1),setTimeout(()=>{const e=Array.from(document.querySelectorAll(".collapsible-card-title")).find(e=>e.textContent.includes(r("ES_VRNDOR_NEW_VENDOR_DETAILS")));e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100))},label:r("ES_COMMON_APPLICATION_SUBMIT"),onSubmit:e=>{var t,l,n,i,o,r,d,s,u,c,E,m,v,S,p,_,R,D,N,g,y,T,I,C,O;const A=e;console.log(A);const h=null==A?void 0:A.vendorName,b=null==A?void 0:A.pincode,f=null==A||null===(t=A.street)||void 0===t?void 0:t.trim(),V=null==A||null===(l=A.doorNo)||void 0===l?void 0:l.trim(),L=null==A||null===(n=A.plotNo)||void 0===n?void 0:n.trim(),M=null==A||null===(i=A.landmark)||void 0===i?void 0:i.trim(),w=null==A||null===(o=A.address)||void 0===o||null===(r=o.city)||void 0===r?void 0:r.name,k=null==A||null===(d=A.address)||void 0===d||null===(s=d.city)||void 0===s?void 0:s.state,P=null==A||null===(u=A.address)||void 0===u||null===(c=u.city)||void 0===c?void 0:c.name,F=null==A||null===(E=A.address)||void 0===E||null===(m=E.city)||void 0===m?void 0:m.name,x=null==A||null===(v=A.buildingName)||void 0===v?void 0:v.trim(),H=null==A||null===(S=A.address)||void 0===S||null===(p=S.locality)||void 0===p?void 0:p.code,U=null==A||null===(_=A.address)||void 0===_||null===(R=_.locality)||void 0===R?void 0:R.name,B=null==A||null===(D=A.address)||void 0===D||null===(N=D.locality)||void 0===N?void 0:N.area,Y=null==A?void 0:A.emailId,G=null==A?void 0:A.phone,W="EKYC"===(null==A||null===(g=A.serviceType)||void 0===g?void 0:g.code);let K={tenantId:a,name:h,agencyType:"ULB",paymentPreference:"post-service",address:{tenantId:a,landmark:M,doorNo:V,plotNo:L,street:f,city:w,district:P,region:F,state:k,country:"india",pincode:b,buildingName:x,locality:{code:H||"",name:U||"",label:"Locality",area:B||""},geoLocation:{latitude:(null==A||null===(y=A.address)||void 0===y?void 0:y.latitude)||28.6139,longitude:(null==A||null===(T=A.address)||void 0===T?void 0:T.longitude)||77.209}},owner:{tenantId:"dl",name:(null==A?void 0:A.ownerName)||h,fatherOrHusbandName:(null==A?void 0:A.fatherOrHusbandName)||h,relationship:(null==A||null===(I=A.relationship)||void 0===I?void 0:I.code)||"OTHER",gender:(null==A||null===(C=A.gender)||void 0===C?void 0:C.code)||"MALE",dob:null!=A&&A.dob?(new Date(A.dob).getTime()/1e3).toString():"915148800",emailId:Y||"",mobileNumber:G},additionalDetails:{serviceType:W?"ekyc":null==A||null===(O=A.serviceType)||void 0===O?void 0:O.code},vehicles:[],drivers:[],source:W?"eKYC Portal":"WhatsApp"};var $,z;W&&(K={...K,zoneIds:(null==A||null===($=A.zoneIds)||void 0===$?void 0:$.map(e=>e.code))||[],clusterIds:(null==A||null===(z=A.clusterIds)||void 0===z?void 0:z.map(e=>e.code))||[],contractStartDate:A.contractStartDate?new Date(A.contractStartDate).getTime():null,contractEndDate:A.contractEndDate?new Date(A.contractEndDate).getTime():null})},defaultValues:D,noCard:!0,noBreakLine:!0,isDisabled:!v}),c&&l.createElement(i.Toast,{error:"error"===c.key,label:r("success"===c.key?`ES_FSM_REGISTRY_${c.action}_SUCCESS`:c.action),onClose:()=>{m(null)}})))},VendorSelectAddress:e=>{var n,o,a;let{t:r,config:d,onSelect:s,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 R={};p&&(R=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[D,N]=t.useState(()=>{var e,t;return(null==c||null===(e=c.address)||void 0===e?void 0:e.city)||(null===(t=R)||void 0===t?void 0:t[0])||null}),{data:g}=Digit.Hooks.useBoundaryLocalities(null==D?void 0:D.code,"revenue",{enabled:!!D},r),[y,T]=t.useState(),[I,C]=t.useState(()=>{var e,t,l,n,i,o,a;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===(i=n.details)||void 0===i||null===(o=i.address)||void 0===o?void 0:o.locality)||(null==c||null===(a=c.address)||void 0===a?void 0:a.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&&s(d.key,{...c[d.key],locality:e})}return t.useEffect(()=>{S&&1===S.length&&N(S[0])},[S]),t.useEffect(()=>{if(D&&g){var e,t,l,n,i,o,a,r;let _=g,R=[];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!==(i=p)&&void 0!==i&&null!==(o=i.propertyDetails)&&void 0!==o&&null!==(a=o.address)&&void 0!==a&&a.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&&(R=_.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&&s(d.key,{...c[d.key],city:D}),T(()=>R.length>0?R:_),1===R.length&&(C(R[0]),"employee"===u&&s(d.key,{...c[d.key],locality:R[0]}))}},[D,null==c||null===(o=c.cpt)||void 0===o||null===(a=o.details)||void 0===a?void 0:a.address,g]),"employee"===u?l.createElement(l.Fragment,null,l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,r("MYCITY_CODE_LABEL"),d.isMandatory?" * ":null),l.createElement(i.Dropdown,{className:"",isMandatory:!0,selected:1===(null==S?void 0:S.length)?S[0]:D,disable:1===(null==S?void 0:S.length),option:S,select:O,optionKey:"code",t:r})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_MOHALLA"),d.isMandatory?" * ":null),l.createElement(i.Dropdown,{className:"",isMandatory:!0,selected:I,option:y,select:A,optionKey:"name",t:r}))):l.createElement(l.Fragment,null,l.createElement(i.FormStep,{config:d,onSelect:function(){s(d.key,{city:D,locality:I})},t:r,isDisabled:!I},l.createElement(i.CardLabel,null,r("MYCITY_CODE_LABEL")+" *"),l.createElement(i.RadioOrSelect,{options:S,selectedOption:D,optionKey:"i18nKey",onSelect:O,t:r}),D&&y&&l.createElement(i.CardLabel,null,r("CS_CREATECOMPLAINT_MOHALLA")+" *"),D&&y&&l.createElement(i.RadioOrSelect,{isMandatory:d.isMandatory,options:y,selectedOption:I,optionKey:"name",onSelect:A,t:r})))},SearchApp:e=>{n.useParams();const{t:a}=o.useTranslation(),r=Digit.ULBService.getCurrentTenantId(),[d,s]=t.useState({}),[u,c]=t.useState(null),E={enabled:!!(d&&Object.keys(d).length>0)},{isLoading:m,isSuccess:S,data:{EwasteApplication:p,Count:_}={}}=Digit.Hooks.ew.useEWSearch({tenantId:r,filters:d},E);return l.createElement(l.Fragment,null,l.createElement(v,{t:a,isLoading:m,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"}):s(n):c({warning:!0,label:"ERR_PROVIDE_MORE_PARAM_WITH_TYPE_STATUS"}):c({warning:!0,label:"ERR_VENDOR_FILL_VALID_FIELDS"})},data:S&&!m?p.length>0?p:{display:"ES_COMMON_NO_DATA"}:"",count:_}),u&&l.createElement(i.Toast,{error:u.error,warning:u.warning,label:a(u.label),isDleteBtn:!0,onClose:()=>{c(null)}}))},SearchVendor:()=>{var e,n,i,a,r,d,s,u,c,E;const{t:m}=o.useTranslation(),v=Digit.ULBService.getCurrentTenantId(),{selectedTabs:S}=Digit.Hooks.useQueryParams(),[p,_]=t.useState({}),[R,D]=t.useState([{id:"createdTime",desc:!0}]),[N,g]=t.useState(0),[y,T]=t.useState(10),[I,C]=t.useState(S||"VENDOR"),[O,A]=t.useState(""),[h,b]=t.useState(""),[f,V]=t.useState([]),M=Digit.UserService.getUser(),w="CITIZEN"===(null==M||null===(e=M.info)||void 0===e?void 0:e.type),k=null==M||null===(n=M.info)||void 0===n?void 0:n.uuid,{data:P}=Digit.Hooks.fsm.useDsoSearch(v,{status:"ACTIVE"},{staleTime:Infinity}),{data:F}=Digit.Hooks.wt.useFillPointSearch({tenantId:v,filters:{limit:1e3}},{staleTime:Infinity});let x={limit:y,offset:N,sortBy:null==R||null===(i=R[0])||void 0===i?void 0:i.id,sortOrder:null!=R&&null!==(a=R[0])&&void 0!==a&&a.desc?"DESC":"ASC"};const{data:H,isLoading:U,refetch:B}="VEHICLE"===I?Digit.Hooks.fsm.useVehiclesSearch({tenantId:v,filters:{...x,registrationNumber:null==p?void 0:p.registrationNumber,status:"ACTIVE,DISABLED",vendorId:w?k:null==p||null===(r=p.vendor)||void 0===r?void 0:r.id,fillingPointId:null==p||null===(d=p.fillingPoint)||void 0===d?void 0:d.id},config:{enabled:!1}}):"DRIVER"===I?Digit.Hooks.fsm.useDriverSearch({tenantId:v,filters:{...x,name:null==p?void 0:p.name,status:"ACTIVE,DISABLED",vendorId:w?k:null==p||null===(s=p.vendor)||void 0===s?void 0:s.id},config:{enabled:!1}}):"SUPERVISOR"===I?Digit.Hooks.fsm.useSupervisorSearch(v,{...x,status:"ACTIVE,DISABLED",vendorId:w?k:null==p||null===(u=p.vendor)||void 0===u?void 0:u.id,name:null==p?void 0:p.name},{enabled:!1}):"SURVEYOR"===I?Digit.Hooks.fsm.useSurveyorSearch(v,{...x,status:"ACTIVE,DISABLED",vendorId:w?k:null==p||null===(c=p.vendor)||void 0===c?void 0:c.id,name:null==p?void 0:p.name},{enabled:!1}):Digit.Hooks.fsm.useVendorSearch({tenantId:v,filters:{...x,name:null==p?void 0:p.name,status:"ACTIVE,DISABLED"},config:{enabled:!1}});Digit.Hooks.fsm.useVendorSearch({tenantId:v,filters:{...x,name:null==p?void 0:p.name,status:"ACTIVE,DISABLED"},config:{enabled:!1}});const{data:Y,isLoading:G,refetch:W}=Digit.Hooks.fsm.useDsoSearch(v,{vehicleIds:O,driverIds:h,status:"ACTIVE"},{enabled:!1}),K=(null==H?void 0:H.totalCount)||50;t.useEffect(()=>{B(),W()},[]),t.useEffect(()=>{B()},[p,R,N,y]),t.useEffect(()=>{if(null!=H&&H.vehicle&&"VEHICLE"===I){const e=H.vehicle.map(e=>e.id).filter(Boolean).join(",");A(e),V(H.vehicle)}if(null!=H&&H.driver&&"DRIVER"===I){const e=H.driver.map(e=>e.id).filter(Boolean).join(",");b(e),V(null==H?void 0:H.driver)}if(null!=H&&H.vendor&&"VENDOR"===I){const e=H.vendor.map(e=>{var t,l,n,i;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===(i=n.filter(e=>"ACTIVE"===e.status))||void 0===i?void 0:i.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}))}});V(e)}"SUPERVISOR"===I&&V((null==H?void 0:H.supervisors)||(null==H?void 0:H.supervisor)||[]),"SURVEYOR"===I&&V((null==H?void 0:H.surveyors)||(null==H?void 0:H.surveyor)||[])},[H,I]),t.useEffect(()=>{""===O&&""===h||W()},[O,h]),t.useEffect(()=>{let e=!0;if(Y&&e){if("VEHICLE"===I){const e=null==H?void 0:H.vehicle.map(e=>{let t=Y.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 i={...e,vendor:t.dsoDetails};const o=null===(l=t.dsoDetails)||void 0===l||null===(n=l.vehicles)||void 0===n?void 0:n.find(t=>t.id===e.id);return o&&(i.driverData=o.driverData||o.driver||i.driverData),i}return e});V(e),A("")}if("DRIVER"===I){const e=null==H?void 0:H.driver.map(e=>{let t=Y.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});V(e),b("")}}return()=>{e=!1}},[Y,H]);const $="VEHICLE"===I?[{label:m("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==P?void 0:P.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:m("ES_FSM_REGISTRY_SEARCH_FILLING_POINT"),name:"fillingPoint",type:"dropdown",options:null==F||null===(E=F.fillingPoints)||void 0===E?void 0:E.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:m("ES_VEHICLE_SEARCH_VEHICLE_NUMBER"),name:"registrationNumber",pattern:"[A-Z]{2}[- ]?[0-9]{2}[- ]?[A-Z]{1,2}[- ]?[0-9]{4}",title:m("ES_FSM_VEHICLE_FORMAT_TIP")}]:"DRIVER"===I?[{label:m("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==P?void 0:P.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:m("ES_DRIVER_SEARCH_DRIVER_NAME"),name:"name"}]:"SUPERVISOR"===I||"SURVEYOR"===I?[{label:m("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==P?void 0:P.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:m("SUPERVISOR"===I?"ES_SUPERVISOR_SEARCH_NAME":"ES_SURVEYOR_SEARCH_NAME"),name:"name"}]:[{label:m("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(L,{data:{table:f},isLoading:U||G,onSort:z,disableSort:!1,sortParams:R,userRole:"FSM_ADMIN",onFilterChange:()=>{},searchFields:$,onSearch:function(e){void 0===e&&(e={}),_({...e})},onNextPage:()=>{g(e=>e+y)},onPrevPage:()=>{g(e=>e-y)},currentPage:Math.floor(N/y),pageSizeLimit:y,onPageSizeChange:e=>{T(Number(e.target.value))},totalRecords:K||0,onTabChange:e=>{C(e)},selectedTab:I,refetchData:()=>{B()},refetchVendor:()=>{W()}})))},SelectServiceType:e=>{let{config:n,onSelect:o,t:a,userType:r,formData:d}=e;const s=Digit.ULBService.getCurrentTenantId(),[u,c]=(Digit.ULBService.getStateId(),t.useState(null==d?void 0:d.serviceType)),[E,m]=t.useState([]),{data:v,isLoading:S}=Digit.Hooks.useCustomMDMS(s,"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&&o(n.key,t))}}},[v]),S?l.createElement(i.Loader,null):"employee"===r?l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,a(n.label)),l.createElement(i.Dropdown,{className:"payment-form-text-input-correction",isMandatory:n.isMandatory,selected:u,option:E,select:e=>{c(e),"employee"===r&&o(n.key,e)},optionKey:"i18nKey",disable:n.disable,t:a})):void 0},SelectVehicleType:e=>{var n;let{t:o,config:a,onSelect:r,formData:d}=e;const s=Digit.ULBService.getStateId(),u=Digit.ULBService.getCurrentTenantId(),{data:c,isLoading:E}=Digit.Hooks.wt.useWTMDMS(s,"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({}),[_,R]=t.useState([]),[D,N]=t.useState({}),[g,y]=t.useState([]),[T,I]=t.useState({}),[C,O]=t.useState(""),A=(null==d||null===(n=d.serviceType)||void 0===n?void 0:n.code)||(null==d?void 0:d.serviceType),h=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(h)},[h]),t.useEffect(()=>{if(!c)return;const e=S[A],t=e?c.filter(t=>e.includes(t.code)):c;R(t),N({}),y([]),I({}),O("")},[c,A,S]),t.useEffect(()=>{if(!c||null==D||!D.code)return;const e=c.filter(e=>e.make===D.code);y(e),I({}),O("")},[D,c]),t.useEffect(()=>{null!=T&&T.capacity&&O(T.capacity)},[T]),E||v?l.createElement(i.Loader,null):c&&m?l.createElement(l.Fragment,null,l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,o("ES_FSM_REGISTRY_VEHICLE_MODEL")),l.createElement(i.Dropdown,{className:"form-field",selected:D,option:_,select:e=>{N(e),r(a.key,{...(null==d?void 0:d[a.key])||{},modal:e,type:""})},optionKey:"name",t:o})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,o("ES_FSM_REGISTRY_VEHICLE_TYPE")),l.createElement(i.Dropdown,{className:"form-field",selected:T,option:g,select:e=>{I(e),O(e.capacity),r(a.key,{...d[a.key],type:e})},optionKey:"name",t:o})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,o("ES_FSM_REGISTRY_VEHICLE_CAPACITY")),l.createElement(i.TextInput,{className:"",textInputStyle:{width:"100%"},value:C,disable:!0}))):l.createElement("div",null,o("ERROR_FETCHING_DATA"))},BankDetailsComponent:e=>{let{t:n,config:o,onSelect:a,formData:r,...d}=e;const[s,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)||""),[_,R]=t.useState(null);return t.useEffect(()=>{11===s.length&&fetch("https://ifsc.razorpay.com/"+s).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH?(E(e.BANK),v(e.BRANCH),"function"==typeof a&&a(o.key,{bankName:e.BANK,branchName:e.BRANCH,ifscCode:s,accountNumber:S}),R({error:!1,label:n("VALID_IFSC_CODE")})):R({error:!0,label:n("INVALID_IFSC_CODE")})}).catch(()=>{R({error:!0,label:n("INVALID_IFSC_CODE")})})},[s]),t.useEffect(()=>{"function"==typeof a&&a(o.key,{bankName:c,branchName:m,ifscCode:s,accountNumber:S})},[S,c,m,s]),l.createElement(l.Fragment,null,l.createElement(i.CardLabel,null,n("ES_FSM_REGISTRY_IFSC_CODE")),l.createElement(i.TextInput,{t:n,type:"text",isMandatory:!1,name:"ifscCode",value:s,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(i.CardLabel,null,n("ES_FSM_REGISTRY_ACCOUNT_NUMBER")),l.createElement(i.TextInput,{t:n,type:"text",isMandatory:!1,name:"accountNumber",value:S,onChange:e=>p(e.target.value),style:{width:"100%"}}),l.createElement(i.CardLabel,null,n("ES_FSM_REGISTRY_BANK_NAME")),l.createElement(i.TextInput,{t:n,type:"text",isMandatory:!1,name:"bankName",value:c,onChange:e=>E(e.target.value),disabled:11===s.length&&c,style:{width:"100%"}}),l.createElement(i.CardLabel,null,n("ES_FSM_REGISTRY_BRANCH_NAME")),l.createElement(i.TextInput,{t:n,type:"text",isMandatory:!1,name:"branchName",value:m,onChange:e=>v(e.target.value),disabled:11===s.length&&m,style:{width:"100%"}}))},AddDriver:()=>{var e,a;const s=Digit.ULBService.getCurrentTenantId(),{t:u}=o.useTranslation(),c=Digit.ULBService.getStateId(),[E,m]=t.useState(null),v=r.useQueryClient(),S=n.useHistory(),[,p]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,_]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,R]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),D="WT_VENDOR"===Digit.UserService.getType()||Digit.UserService.hasAccess(["WT_VENDOR"]),{mutate:N}=Digit.Hooks.fsm.useDriverCreate(c),{mutate:g}=Digit.Hooks.fsm.useVendorUpdate("dl.djb"),y=null===(e=Digit.UserService.getUser())||void 0===e||null===(a=e.info)||void 0===a?void 0:a.mobileNumber,{data:T}=Digit.Hooks.fsm.useDsoSearch(s,{mobileNumber:y},{enabled:!(!D||!y)});t.useEffect(()=>{p(!1),R(),_()},[]);const I=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,d({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),[C,O]=t.useState(!1),A=()=>{m(null)};return console.log(D,"iscitizen"),l.createElement(l.Fragment,null,l.createElement(i.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(i.FormComposer,{isDisabled:!C,label:u("ES_COMMON_APPLICATION_SUBMIT"),config:I.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;const n=null==e?void 0:e.driverName,i=null==e?void 0:e.license,o=null==e||null===(t=e.selectGender)||void 0===t?void 0:t.code,a=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(),s=null==e||null===(l=e.serviceType)||void 0===l?void 0:l.code;N({driver:{tenantId:"dl.djb",name:n,licenseNumber:i,status:"ACTIVE",owner:{tenantId:c,name:n,fatherOrHusbandName:n,relationship:"OTHER",gender:o,dob:d,emailId:a||"abc@egov.com",mobileNumber:r},additionalDetails:{serviceType:s},vendorDriverStatus:"ACTIVE"}},{onError:(e,t)=>{m({key:"error",action:e}),setTimeout(A,5e3)},onSuccess:(e,t)=>{var l;if(m({key:"success",action:"ADD_DRIVER"}),setTimeout(A,5e3),v.invalidateQueries("FSM_DRIVER_SEARCH"),D&&null!=T&&null!==(l=T[0])&&void 0!==l&&l.dsoDetails){const t=e.driver.map(e=>({...e,vendorDriverStatus:"ACTIVE",status:"ACTIVE"})),l=T[0].dsoDetails,n={vendor:{...l,drivers:l.drivers?[...l.drivers,...t]:[...t]}};g(n,{onError:e=>{m({key:"error",action:e})},onSuccess:()=>{var e,t,l;m({key:"success",action:"ADD_DRIVER"}),v.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(()=>{A(),S.push(`/digit-ui/${n}/vendor/search-vendor?selectedTabs=DRIVER`)},3e3)}})}else{var n,i,o;const e=(null===(n=Digit.UserService.getUser())||void 0===n||null===(i=n.info)||void 0===i||null===(o=i.type)||void 0===o?void 0:o.toLowerCase())||"citizen";v.invalidateQueries("FSM_DRIVER_SEARCH"),setTimeout(()=>{A(),S.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 i=n.slice(0,18);t.license!==i&&e("license",i)}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)?O(!0):O(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(i.Toast,{error:"error"===E.key,label:u("success"===E.key?`ES_FSM_${E.action}_SUCCESS`:E.action),onClose:A})))},EditVendorDetails:e=>{var a,d,s,u,c,E,m,v,S,p,_;const R=Digit.ULBService.getCurrentTenantId(),{t:D}=o.useTranslation(),N=n.useHistory(),g=r.useQueryClient();let{id:y}=n.useParams();const[T,I]=t.useState(!1),[C,O]=t.useState(null),[A,h]=t.useState(!1),[b,f]=t.useState(null),[V,L]=t.useState([]),[M,P]=t.useState([]),[x,H]=t.useState({}),{data:U,isLoading:B,refetch:Y}=Digit.Hooks.fsm.useDsoSearch(R,{ids:y},{staleTime:Infinity}),{data:G,isLoading:W}=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:R,filters:{vendorId:y}},{enabled:!!y});let K=null==U||null===(a=U[0])||void 0===a||null===(d=a.dsoDetails)||void 0===d?void 0:d.additionalDetails;if("string"==typeof K)try{K=JSON.parse(K)}catch(e){console.error("Error parsing additional details",e)}const $=(null==G||null===(s=G.VendorDetails)||void 0===s||null===(u=s[0])||void 0===u||null===(c=u.vendorAdditionalDetails)||void 0===c?void 0:c.serviceType)||(null===(E=K)||void 0===E?void 0:E.serviceType),z="EKYC"===$||"ekyc"===$,{data:Z,refetch:q}=Digit.Hooks.fsm.useVehiclesSearch({tenantId:R,filters:{status:"ACTIVE",sortBy:"registrationNumber",sortOrder:"ASC",vehicleWithNoVendor:!0},config:{enabled:!z}}),{data:j,refetch:X}=Digit.Hooks.fsm.useDriverSearch({tenantId:R,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE",driverWithNoVendor:!0},config:{enabled:!z}}),{data:Q}=Digit.Hooks.fsm.useSupervisorSearch(R,{vendorId:y},{enabled:z}),{data:J}=Digit.Hooks.fsm.useSurveyorSearch(R,{vendorId:y},{enabled:z}),{mutate:ee}=Digit.Hooks.fsm.useVendorUpdate(R);function te(e){I(!1),O(e)}const le=null===(m=Digit.SessionStorage.get("User").info.type)||void 0===m?void 0:m.toLowerCase();t.useEffect(()=>{switch(C){case"DELETE":case"ADD_VEHICLE":case"ADD_DRIVER":return h(!0);case"EDIT":return N.push(`/digit-ui/${le}/fsm/registry/modify-vendor/${y}`);case"HOME":return N.push(`/digit-ui/${le}/fsm/registry?selectedTabs=VENDOR`)}},[C]),t.useEffect(()=>{Z&&L((null==Z?void 0:Z.vehicle)||[])},[Z]),t.useEffect(()=>{j&&P((null==j?void 0:j.driver)||[])},[j]);const ne=()=>{f(null)},ie=()=>{O(null),H({}),h(!1)},oe=window.Digit.Utils.browser.isMobile();if(B)return l.createElement(i.Loader,null);const ae=["vendorAdditionalDetailsId","vendorId","tenantId","code","lastModifiedTime","createdTime","lastModifiedBy","createdBy","active","status","vendorType","vendorGroup","narration","documents"];return l.createElement("div",{className:"employee-form-content"},B?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement(i.Card,null,null==U||null===(v=U[0])||void 0===v||null===(S=v.employeeResponse)||void 0===S?void 0:S.map((e,t)=>{var n,o;return z&&t>0?null:l.createElement(l.Fragment,{key:t},t>0&&l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},D(e.title)),l.createElement("div",null,null==e||null===(n=e.values)||void 0===n?void 0:n.map((t,n)=>{var o;if("ES_FSM_REGISTRY_DETAILS_ADDITIONAL_DETAILS"===t.title){var a,r;const e=null==G||null===(a=G.VendorDetails)||void 0===a||null===(r=a[0])||void 0===r?void 0:r.vendorAdditionalDetails,n=Object.entries(e||{}).filter(e=>{let[t]=e;return!ae.includes(t)});return l.createElement(l.Fragment,{key:t.title},l.createElement(i.Row,{label:D(t.title),text:"",className:"border-none flex-box"}),W?l.createElement(i.Loader,null):e?l.createElement(i.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 i=String(t);let o=null!=n&&""!==n?String(n):"N/A";var a,r;return"name"!==t||n&&""!==n||(o=(null==U||null===(a=U[0])||void 0===a||null===(r=a.dsoDetails)||void 0===r?void 0:r.name)||"N/A"),l.createElement(l.Fragment,{key:i},l.createElement("div",{className:"additional-label"},D((e=>{const t=e.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)})(i))),l.createElement("div",{className:"additional-value"},o))})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/additionaldetails/info?vendorId=${y}`)},D("Edit Details"))):l.createElement("div",{onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/additionaldetails/vendor-details?vendorId=${y}`),className:"add-details-link hover-button"},D("Add Additional Details")))}return l.createElement(i.Row,{key:D(String(t.title)),label:D(String(t.title)),text:t.value?D(String(t.value)):"N/A",last:n===(null==e||null===(o=e.values)||void 0===o?void 0:o.length)-1,caption:t.caption,className:"border-none flex-box "+(oe?"":"vendor-details-row")})}),null==e||null===(o=e.child)||void 0===o?void 0:o.map((t,n)=>{var o;return l.createElement(i.Card,{className:"card-with-background",key:t.id||n},l.createElement("div",{className:"card-head"},l.createElement("h2",null,D(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)N.push(`/digit-ui/${le}/fsm/registry/modify-driver/${l}`);else{var n,i;let t=null==e||null===(n=e.values)||void 0===n||null===(i=n.find(e=>"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.title))||void 0===i?void 0:i.value;N.push(`/digit-ui/${le}/fsm/registry/modify-vehicle/${t}`)}})(t,e.type,t.id)},l.createElement(i.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 i,o;let e=null==U||null===(i=U[0])||void 0===i?void 0:i.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===(o=e.owner)||void 0===o?void 0:o.gender)||"OTHERS"},drivers:t}}}else{var a,r,d,s;let t=null==U||null===(a=U[0])||void 0===a?void 0:a.dsoDetails,l=null==t?void 0:t.vehicles,i=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===i&&(e.vendorVehicleStatus="INACTIVE"),e)),n={vendor:{...t,owner:{...t.owner,gender:(null===(s=t.owner)||void 0===s?void 0:s.gender)||"OTHERS"},vehicles:l}}}ee(n,{onError:(e,t)=>{f({key:"error",action:e}),setTimeout(ne,5e3)},onSuccess:(e,l)=>{f({key:"success",action:"ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===t?"DELETE_DRIVER":"DELETE_VEHICLE"}),g.invalidateQueries("DSO_SEARCH"),Y(),q(),X(),setTimeout(()=>{ne()},5e3)}})})(t,e.type,t.id)},l.createElement(i.DeleteIcon,{style:{cursor:"pointer"},className:"delete",fill:"#a82227"})))),l.createElement("div",{className:"additional-grid",style:{padding:"8px 16px"}},null==t||null===(o=t.values)||void 0===o?void 0:o.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},D(String(e.title))),l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},e.value?D(String(e.value)):"N/A")))))}),e.type&&l.createElement("div",{className:"add-details-link hover-button",onClick:()=>te("ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===e.type?"ADD_DRIVER":"ADD_VEHICLE")},D(e.type+"_ADD"))))}),z&&l.createElement(l.Fragment,null,l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},D("ES_VENDOR_SUPERVISOR_DETAILS")),l.createElement("div",null,null==Q||null===(p=Q.supervisor)||void 0===p?void 0:p.map((e,t)=>{var n,o;return l.createElement(i.Card,{className:"card-with-background",key:e.id||t},l.createElement("div",{className:"card-head"},l.createElement("h2",null,D("ES_VENDOR_SUPERVISOR_DETAILS")," ",t+1),l.createElement("div",{style:{display:"flex"}},l.createElement("span",{onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/supervisor-details/${e.id}`)},l.createElement(i.EditIcon,{style:{cursor:"pointer",marginRight:"20px"},className:"edit",fill:"#a82227"})))),l.createElement("div",{className:"additional-grid",style:{padding:"8px 16px"}},l.createElement("div",{className:"additional-label"},D("ES_FSM_REGISTRY_NEW_OWNER_NAME")),l.createElement("div",{className:"additional-value"},null===(n=e.owner)||void 0===n?void 0:n.name),l.createElement("div",{className:"additional-label"},D("ES_FSM_REGISTRY_VENDOR_PHONE")),l.createElement("div",{className:"additional-value"},null===(o=e.owner)||void 0===o?void 0:o.mobileNumber),l.createElement("div",{className:"additional-label"},D("ES_VENDOR_STATUS")),l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.status?{color:"green"}:{}},e.status)))}),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/new-supervisor?vendorId=${y}`)},D("ES_VENDOR_ADD_SUPERVISOR"))),l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},D("ES_VENDOR_SURVEYOR_DETAILS")),l.createElement("div",null,null==J||null===(_=J.surveyor)||void 0===_?void 0:_.map((e,t)=>{var n,o;return l.createElement(i.Card,{className:"card-with-background",key:e.id||t},l.createElement("div",{className:"card-head"},l.createElement("h2",null,D("ES_VENDOR_SURVEYOR_DETAILS")," ",t+1),l.createElement("div",{style:{display:"flex"}},l.createElement("span",{onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/surveyor-details/${e.id}`)},l.createElement(i.EditIcon,{style:{cursor:"pointer",marginRight:"20px"},className:"edit",fill:"#a82227"})))),l.createElement("div",{className:"additional-grid",style:{padding:"8px 16px"}},l.createElement("div",{className:"additional-label"},D("ES_FSM_REGISTRY_NEW_OWNER_NAME")),l.createElement("div",{className:"additional-value"},null===(n=e.owner)||void 0===n?void 0:n.name),l.createElement("div",{className:"additional-label"},D("ES_FSM_REGISTRY_VENDOR_PHONE")),l.createElement("div",{className:"additional-value"},null===(o=e.owner)||void 0===o?void 0:o.mobileNumber),l.createElement("div",{className:"additional-label"},D("ES_VENDOR_STATUS")),l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.status?{color:"green"}:{}},e.status)))}),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/new-surveyor?vendorId=${y}`)},D("ES_VENDOR_ADD_SURVEYOR"))))),A&&l.createElement(i.Modal,{headerBarMain:l.createElement(k,{label:D("DELETE"===C?"ES_FSM_REGISTRY_DELETE_POPUP_HEADER":"ADD_VEHICLE"===C?"ES_FSM_REGISTRY_ADD_VEHICLE_POPUP_HEADER":"ES_FSM_REGISTRY_ADD_DRIVER_POPUP_HEADER")}),headerBarEnd:l.createElement(F,{onClick:ie}),actionCancelLabel:D("CS_COMMON_CANCEL"),actionCancelOnSubmit:ie,actionSaveLabel:D("DELETE"===C?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{var e;let t=null==U||null===(e=U[0])||void 0===e?void 0:e.dsoDetails,l={};if("DELETE"===C&&(l={vendor:{...t,status:"INACTIVE"}}),"ADD_VEHICLE"===C){var n;let e=x;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"===C){var i;let e=x;e.vendorDriverStatus="ACTIVE",l={vendor:{...t,owner:{...t.owner,gender:(null===(i=t.owner)||void 0===i?void 0:i.gender)||"OTHERS"},drivers:t.drivers?[...t.drivers,e]:[e]}}}ee(l,{onError:(e,t)=>{f({key:"error",action:e}),setTimeout(ne,5e3)},onSuccess:(e,t)=>{f({key:"success",action:"DELETE"===C?"DELETE_VENDOR":C}),g.invalidateQueries("DSO_SEARCH"),Y(),q(),X(),setTimeout(()=>{ne(),"DELETE"===C&&N.push(`/digit-ui/${le}/fsm/registry`)},5e3)}}),h(!1),O(null)}},l.createElement(i.Card,{style:{boxShadow:"none"}},"DELETE"===C?l.createElement(w,{t:D,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VEHICLE"===C?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,D("ES_FSM_REGISTRY_SELECT_VEHICLE")),l.createElement(i.Dropdown,{t:D,option:V,value:x,selected:x,select:H,optionKey:"registrationNumber"})):"ADD_DRIVER"===C?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,D("ES_FSM_REGISTRY_SELECT_DRIVER")),l.createElement(i.Dropdown,{t:D,option:M,value:x,selected:x,select:H,optionKey:"name"})):void 0)),b&&l.createElement(i.Toast,{error:"error"===b.key,label:D("success"===b.key?`ES_FSM_REGISTRY_${b.action}_SUCCESS`:b.action),onClose:ne}),l.createElement(i.ActionBar,{style:{zIndex:"19"}},T?l.createElement(i.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE","HOME"],t:D,onSelect:te}):null,l.createElement(i.SubmitBar,{label:D("ES_COMMON_TAKE_ACTION"),onSubmit:()=>I(!T)}))))},AddVehicle:e=>{var a,s;const u=Digit.ULBService.getCurrentTenantId(),c=Digit.ULBService.getStateId(),[E,m]=t.useState(null),v=n.useHistory(),{t:S}=o.useTranslation(),p=r.useQueryClient(),[,_]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,R]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,D]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),N="WT_VENDOR"===Digit.UserService.getType()||Digit.UserService.hasAccess(["WT_VENDOR"]),{mutate:g}=Digit.Hooks.fsm.useVehicleCreate(c),{mutate:y}=Digit.Hooks.fsm.useVendorUpdate("dl.djb"),T=null===(a=Digit.UserService.getUser())||void 0===a||null===(s=a.info)||void 0===s?void 0:s.mobileNumber,{data:I}=Digit.Hooks.fsm.useDsoSearch(u,{mobileNumber:T},{enabled:!(!N||!T)});t.useEffect(()=>{_(!1),D(),R()},[]);const C=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(ne,d({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(ne,d({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(ne,d({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(ne,d({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(ne,d({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:""}}]}]}(S);C[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(i.InfoIcon,null),l.createElement("span",{className:"tooltiptext",style:{width:"320px",left:"230%",fontSize:"14px"}},e.populators.validation.title)))});const[O,A]=t.useState(!1),h=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{route:"vendor-details",timeLine:[{actions:S("ES_FSM_REGISTRY_TITLE_NEW_VEHICLE"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(i.FormComposer,{isDisabled:!O,label:S("ES_COMMON_APPLICATION_SUBMIT"),config:C.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,i,o,a,r,d;const s=null==e?void 0:e.registrationNumber,u=null==e||null===(t=e.vehicle)||void 0===t||null===(l=t.type)||void 0===l?void 0:l.code,E=null==e||null===(n=e.vehicle)||void 0===n||null===(i=n.modal)||void 0===i?void 0:i.code,S=null==e||null===(o=e.vehicle)||void 0===o||null===(a=o.type)||void 0===a?void 0:a.capacity,_=new Date(""+(null==e?void 0:e.pollutionCert)).getTime(),R=new Date(""+(null==e?void 0:e.insurance)).getTime(),D=new Date(""+(null==e?void 0:e.roadTax)).getTime(),T=new Date(""+(null==e?void 0:e.fitnessValidity)).getTime(),C=null==e?void 0:e.ownerName,O=null==e?void 0:e.phone,A=null==e||null===(r=e.serviceType)||void 0===r?void 0:r.code,b=null==e||null===(d=e.selectGender)||void 0===d?void 0:d.code,f=null==e?void 0:e.emailId,V=new Date(""+e.dob).getTime()||new Date("1/1/1970").getTime();g({vehicle:{tenantId:"dl.djb",registrationNumber:s,model:E,type:u,tankCapacity:S,suctionType:"SEWER_SUCTION_MACHINE",pollutionCertiValidTill:_,InsuranceCertValidTill:R,fitnessValidTill:T,roadTaxPaidTill:D,gpsEnabled:!0,source:"Municipal records",owner:{tenantId:c,name:C,fatherOrHusbandName:C,relationship:"OTHER",correspondenceAddress:"",mobileNumber:O,gender:b,dob:V,emailId:f||"abc@egov.com"},additionalDetails:{serviceType:A},vehicleOwner:"ULB"}},{onError:(e,t)=>{var l,n,i,o;const a=(null==e||null===(l=e.response)||void 0===l||null===(n=l.data)||void 0===n||null===(i=n.Errors)||void 0===i||null===(o=i[0])||void 0===o?void 0:o.message)||(null==e?void 0:e.message)||"An error occurred";m({key:"error",action:a}),setTimeout(h,5e3)},onSuccess:(e,t)=>{var l,n,i,o;if(!0===(null==e?void 0:e.error)||(null==e||null===(l=e.Errors)||void 0===l?void 0:l.length)>0||(null==e||null===(n=e.data)||void 0===n||null===(i=n.Errors)||void 0===i?void 0:i.length)>0){var a,r,d,s,u;const t=(null==e||null===(a=e.data)||void 0===a||null===(r=a.Errors)||void 0===r||null===(d=r[0])||void 0===d?void 0:d.message)||(null==e||null===(s=e.Errors)||void 0===s||null===(u=s[0])||void 0===u?void 0:u.message)||(null==e?void 0:e.message)||"An error occurred";return m({key:"error",action:t}),void setTimeout(h,5e3)}if(m({key:"success",action:"ADD_VEHICLE"}),p.invalidateQueries("FSM_VEICLES_SEARCH"),N&&null!=I&&null!==(o=I[0])&&void 0!==o&&o.dsoDetails){var c;const t=(null==e||null===(c=e.vehicle)||void 0===c?void 0:c.map(e=>({...e,vendorVehicleStatus:"ACTIVE",status:"ACTIVE"})))||[],l=I[0].dsoDetails,n={vendor:{...l,vehicles:l.vehicles?[...l.vehicles,...t]:[...t]}};y(n,{onError:e=>{var t,l,n,i;const o=(null==e||null===(t=e.response)||void 0===t||null===(l=t.data)||void 0===l||null===(n=l.Errors)||void 0===n||null===(i=n[0])||void 0===i?void 0:i.message)||(null==e?void 0:e.message)||"An error occurred";m({key:"error",action:o}),setTimeout(h,5e3)},onSuccess:e=>{var t,l,n,i,o,a;if(!0===(null==e?void 0:e.error)||(null==e||null===(t=e.Errors)||void 0===t?void 0:t.length)>0||(null==e||null===(l=e.data)||void 0===l||null===(n=l.Errors)||void 0===n?void 0:n.length)>0){var r,d,s,u,c;const t=(null==e||null===(r=e.data)||void 0===r||null===(d=r.Errors)||void 0===d||null===(s=d[0])||void 0===s?void 0:s.message)||(null==e||null===(u=e.Errors)||void 0===u||null===(c=u[0])||void 0===c?void 0:c.message)||(null==e?void 0:e.message)||"An error occurred";return m({key:"error",action:t}),void setTimeout(h,5e3)}m({key:"success",action:"ADD_VEHICLE"}),p.invalidateQueries("DSO_SEARCH");const E=(null===(i=Digit.UserService.getUser())||void 0===i||null===(o=i.info)||void 0===o||null===(a=o.type)||void 0===a?void 0:a.toLowerCase())||"citizen";setTimeout(()=>{h(),v.push(`/digit-ui/${E}/vendor/search-vendor?selectedTabs=VEHICLE`)},3e3)}})}else{var E,S,_;const e=(null===(E=Digit.UserService.getUser())||void 0===E||null===(S=E.info)||void 0===S||null===(_=S.type)||void 0===_?void 0:_.toLowerCase())||"citizen";p.invalidateQueries("FSM_VEICLES_SEARCH"),setTimeout(()=>{h(),v.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 i=n.match(/^(\d{1,2})/);if(!i)return l+"-"+n;const o=i[1],a=n.slice(o.length),r=a.match(/^([A-Z]*)/),d=r?r[1]:"",s=a.slice(d.length);if(!s)return l+"-"+o+d;if(d.length>=3){const e=d.length<=3?1:2;return l+"-"+o+d.slice(0,e)+"-"+d.slice(e)+"-"+s.slice(0,4)}return l+"-"+o+d+"-"+s.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)?A(!0):A(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(i.Toast,{error:"error"===E.key,label:S("success"===E.key?`ES_FSM_REGISTRY_${E.action}_SUCCESS`:E.action),onClose:h})))},VENDORCreate:e=>{var t,i,a,d;const s=r.useQueryClient(),u=n.useRouteMatch(),{t:c}=o.useTranslation(),{pathname:E}=n.useLocation(),m=n.useHistory();let v=[];const[S,p,_]=Digit.Hooks.useSessionStorage("VENDOR_Test",{});function R(e,t,l,n,i){if(void 0===i&&(i=!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 i,o=E.split("/").pop(),a=o.charAt(o.length-1),r=!1;Number(parseInt(o))||"0"===o||"-1"===o?"-1"===o||"-2"===o?(o=E.slice(0,-3),o=o.split("/").pop(),r=!0):(o=E.slice(0,-2),o=o.split("/").pop(),r=!0):r=!1,isNaN(a)||(r=!0);let{nextStep:d={}}=v.find(e=>e.route===(o||"0")),s=m.push;if(e&&(s=m.replace),l&&(d=n),null===d)return console.log("matchhhhh pathhhh",u.path),s(u.path+"/check");i=isNaN(d.split("/").pop())&&r&&"map"!==d?`${u.path}/${d}/${t}`:`${u.path}/${d}`,s(i)})(l,n,i,e)}S&&Object.keys(S).length>0&&window.location.href.includes("/info")&&"true"!==sessionStorage.getItem("docReqScreenByBack")&&(_(),s.invalidateQueries("VENDOR_CREATE"));const D=()=>{},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===(i=t.ComponentRegistryService)||void 0===i?void 0:i.getComponent("VENDORCheckPage"),y=null===(a=Digit)||void 0===a||null===(d=a.ComponentRegistryService)||void 0===d?void 0:d.getComponent("NewResponse");return l.createElement(l.Fragment,null,l.createElement(n.Switch,null,v.map((e,t)=>{const{component:i,texts:o,inputs:a,key:r}=e,d="string"==typeof i?Digit.ComponentRegistryService.getComponent(i):i;return l.createElement(n.Route,{path:`${u.path}/${e.route}`,key:t},l.createElement(d,{config:{texts:o,inputs:a,key:r},onSelect:R,onSkip:D,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:()=>{_(),s.invalidateQueries("VENDOR_CREATE")}})),l.createElement(n.Route,null,l.createElement(n.Redirect,{to:`${u.path}/${v.indexRoute}`}))))},VENDORCheckPage:e=>{var n,a,r,d;let{onSubmit:s,value:u={}}=e;const{t:E}=o.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(i.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(i.Card,null,l.createElement(i.CardHeader,null,E("VENDOR_CHECK_DETAILS")),l.createElement("div",null,l.createElement("br",null),l.createElement(i.CardSubHeader,null,E("VENDOR_ADDITIONAL_DETAILS")),l.createElement(i.StatusTable,null,l.createElement(l.Fragment,null,l.createElement(i.Row,{label:E("VENDOR_ID"),text:""+E(c(null==m?void 0:m.VendorId)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_BANK_IFSC_CODE"),text:""+E(c(null==m?void 0:m.IFSC)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_BANK_NAME"),text:""+E(c(null==m?void 0:m.Bank)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_BANK_BRANCH"),text:""+E(c(null==m?void 0:m.BankbranchName)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_MICR_NO"),text:""+E(c(null==m?void 0:m.micrNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("BANK_ACCONT_NO"),text:""+E(c(null==m?void 0:m.AccountNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("PAN_NO"),text:""+E(c(null==m?void 0:m.PanNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("GST_NO"),text:""+E(c(null==m?void 0:m.GstNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("GST_REGISTERED_STATE/UT"),text:""+E(c(null==m?void 0:m.GstState)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("REGISTRATION_NO"),text:""+E(c(null==m?void 0:m.RegistrationNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("EPF_NO"),text:""+E(c(null==m?void 0:m.EpfNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("ESI_NO"),text:""+E(c(null==m?void 0:m.EsiNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_TYPE"),text:""+E(c(null==m||null===(n=m.VendorType)||void 0===n?void 0:n.code)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_CATEGORY"),text:""+E(c(null==m||null===(a=m.VendorCategory)||void 0===a?void 0:a.code)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_STATUS"),text:""+E(c(null==m||null===(r=m.Status)||void 0===r?void 0:r.code)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}))),l.createElement("br",null),l.createElement(i.CardSubHeader,null,E("VENDOR_DOCUMENTS_DETAILS")),l.createElement(i.StatusTable,null,l.createElement(i.StatusTable,null,l.createElement(i.Row,{label:E("VENDOR_DOCUMENTS"),text:(null==v||null===(d=v.documents)||void 0===d?void 0:d.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 i=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(i){const e=i.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(i.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(i.SubmitBar,{label:E("COMMON_BUTTON_SUBMIT"),onSubmit:s,disabled:!S})))))},NewResponse:e=>{let{data:a,onSuccess:r}=e;const{t:d}=o.useTranslation(),s=Digit.Hooks.vendor.useVendorAdditionaldetailsAPI(Digit.ULBService.getCurrentTenantId());return t.useEffect(()=>{try{var e,t;a.tenantId=null===(e=a.address)||void 0===e||null===(t=e.city)||void 0===t?void 0:t.code;let l=(e=>{var t,l,n,i,o,a,r,d,s,u,c,E,m,v,S,p,_,R,D,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===(i=e.vendordet)||void 0===i?void 0:i.ContactPerson,vendorMobileNumber:"9876543210",bankAccountNumber:null==e||null===(o=e.vendordet)||void 0===o?void 0:o.AccountNo,bank:null==e||null===(a=e.vendordet)||void 0===a?void 0:a.Bank,bankBranchName:null==e||null===(r=e.vendordet)||void 0===r?void 0:r.BankbranchName,micrNo:null==e||null===(d=e.vendordet)||void 0===d?void 0:d.micrNo,epfNo:null==e||null===(s=e.vendordet)||void 0===s?void 0:s.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===(R=_.VendorCategory)||void 0===R?void 0:R.code,vendorId:null==e||null===(D=e.vendordet)||void 0===D?void 0:D.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"}}})(a);console.log("formdata in acknowejkfdlgi ::: ",l),s.mutate(l,{onSuccess:r}),console.log("mutation in acknowejkfdlgi ::: ",s)}catch(e){}},[]),s.isLoading||s.isIdle?l.createElement(i.Loader,null):l.createElement(i.Card,{className:"vehicle-details-card"},l.createElement(X,{t:d,data:s.data,isSuccess:s.isSuccess,isLoading:s.isIdle||s.isLoading}),l.createElement(i.StatusTable,null,s.isSuccess&&l.createElement(i.Row,{rowContainerStyle:j,last:!0,textStyle:{whiteSpace:"pre",width:"60%"}})),l.createElement(n.Link,{to:"/digit-ui/employee"},l.createElement(i.LinkButton,{label:d("CORE_COMMON_GO_TO_HOME")})))},DriverDetails:()=>{var e,a;const d=Digit.ULBService.getCurrentTenantId(),{t:s}=o.useTranslation(),u=n.useHistory(),c=r.useQueryClient(),{id:E}=n.useParams(),[m,v]=t.useState(!1),[S,p]=t.useState(null),[_,R]=t.useState(!1),[D,N]=t.useState(null),[g,y]=t.useState([]),[T,I]=t.useState({}),{data:C,isLoading:O,refetch:A}=Digit.Hooks.fsm.useDriverDetails(d,{ids:E},{staleTime:Infinity}),{data:h}=Digit.Hooks.fsm.useDsoSearch(d,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{mutate:b}=Digit.Hooks.fsm.useDriverUpdate(d),{mutate:f}=Digit.Hooks.fsm.useVendorUpdate(d);function V(e){p(e),v(!1)}t.useEffect(()=>{if(h){let e=h.map(e=>e.dsoDetails);y(e)}},[h]),t.useEffect(()=>{A()},[]),t.useEffect(()=>{switch(S){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return R(!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 L=()=>{N(null)},M=()=>{p(null),I({}),R(!1)},k=()=>"DELETE"===S||"DELETE_VENDOR"===S?l.createElement(w,{t:s,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===S||"EDIT_VENDOR"===S?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,s("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(i.Dropdown,{t:s,option:g,value:T,selected:T,select:I,optionKey:"name"})):void 0;return O||O?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(i.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==C||null===(e=C[0])||void 0===e||null===(a=e.employeeResponse)||void 0===a?void 0:a.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},s(e.title)),l.createElement(i.Card,{className:"card-with-background"},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"},s(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},s(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(i.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(i.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(i.DeleteIcon,{className:"delete",fill:"#a82227"}))):l.createElement("div",{className:"additional-value"},s(e.value)||"N/A"))))))}))),_&&l.createElement(i.Modal,{headerBarMain:l.createElement(ee,{label:s((()=>{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(le,{onClick:M}),actionCancelLabel:s("CS_COMMON_CANCEL"),actionCancelOnSubmit:M,actionSaveLabel:s("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(L,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"DELETE_DRIVER"}),c.invalidateQueries("DSO_SEARCH"),setTimeout(()=>{L(),u.push("/digit-ui/employee/fsm/registry")},5e3)}}),R(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let i={},o=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],a=null==o?void 0:o.drivers;a=a.map(e=>(e.id===E&&(e.vendorDriverStatus="INACTIVE"),e)),i={vendor:{...o,owner:{...o.owner,gender:(null===(n=o.owner)||void 0===n?void 0:n.gender)||"OTHERS"},drivers:a}},f(i,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(L,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"DELETE_VENDOR"}),c.invalidateQueries("FSM_VENDOR_SEARCH"),A(),setTimeout(L,5e3)}}),R(!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 i={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]}};f(i,{onError:(e,t)=>{N({key:"error",action:e}),A(),setTimeout(L,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"ADD_VENDOR"}),c.invalidateQueries("DSO_SEARCH"),A(),setTimeout(L,5e3)}}),R(!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 i={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]}};f(i,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(L,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"EDIT_VENDOR"}),A(),c.invalidateQueries("DSO_SEARCH"),setTimeout(L,5e3)}}),R(!1),p(null)})()}},formId:"modal-action"},"DELETE"===S||"DELETE_VENDOR"===S?k():l.createElement(i.Card,{style:{boxShadow:"none"}},k())),D&&l.createElement(i.Toast,{error:"error"===D.key,label:s("success"===D.key?`ES_FSM_REGISTRY_${D.action}_SUCCESS`:D.action),onClose:L}),l.createElement(i.ActionBar,{style:{zIndex:"19"}},m?l.createElement(i.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:s,onSelect:V}):null,l.createElement(i.SubmitBar,{label:s("ES_COMMON_TAKE_ACTION"),onSubmit:()=>v(!m)})))},VehicleDetails:e=>{var a,d;const s=Digit.ULBService.getCurrentTenantId(),{t:u}=o.useTranslation(),c=n.useHistory(),E=r.useQueryClient();let{id:m}=n.useParams();const[v,S]=t.useState(!1),[p,_]=t.useState(null),[R,D]=t.useState(!1),[N,g]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),[O,A]=t.useState(null),{data:h,isLoading:b,refetch:f}=Digit.Hooks.fsm.useVehicleDetails(s,{registrationNumber:m},{staleTime:Infinity});t.useEffect(()=>{var e,t;!b&&h&&A(null==h||null===(e=h[0])||void 0===e||null===(t=e.vehicleData)||void 0===t?void 0:t.id)},[h,b]);const{data:V}=Digit.Hooks.fsm.useDsoSearch(s,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{});t.useEffect(()=>{if(V){let e=V.map(e=>e.dsoDetails);T(e)}},[V]);const{mutate:L}=Digit.Hooks.fsm.useUpdateVehicle(s),{mutate:M}=Digit.Hooks.fsm.useVendorUpdate(s);function k(e){S(!1),_(e)}t.useEffect(()=>{f()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return D(!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({}),D(!1)},x=()=>"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(w,{t:u,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(i.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0;return b?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,b?l.createElement(i.Loader,null):l.createElement("div",{className:"employee-form-content"},l.createElement(i.Card,{className:"vehicle-details-card",style:{position:"relative"}},null==h||null===(a=h[0])||void 0===a||null===(d=a.employeeResponse)||void 0===d?void 0:d.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(i.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(i.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(i.EditIcon,{fill:"#a82227"})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>k("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(i.DeleteIcon,{className:"delete",fill:"#a82227"})))):l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},u(e.value)||"N/A"))))))})),R&&l.createElement(i.Modal,{headerBarMain:l.createElement(ie,{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(ae,{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==h||null===(e=h[0])||void 0===e?void 0:e.vehicleData,status:"INACTIVE"}};L(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)}}),D(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let i={},o=null==h||null===(e=h[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],a=null==o?void 0:o.vehicles;a=a.map(e=>(e.id===O&&(e.vendorVehicleStatus="INACTIVE"),e)),i={vendor:{...o,owner:{...o.owner,gender:(null===(n=o.owner)||void 0===n?void 0:n.gender)||"OTHERS"},vehicles:a}},M(i,{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"),f(),setTimeout(P,5e3)}}),D(!1)})();case"ADD_VENDOR":return(()=>{var e,t;let l=I,n=null==h||null===(e=h[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const i={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]}};M(i,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"EDIT_VENDOR"}),f(),E.invalidateQueries("DSO_SEARCH"),setTimeout(P,5e3)}}),D(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e,t;let l=I,n=null==h||null===(e=h[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const i={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]}};M(i,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"EDIT_VENDOR"}),f(),E.invalidateQueries("DSO_SEARCH"),setTimeout(P,5e3)}}),D(!1),_(null)})()}}},"DELETE"===p||"DELETE_VENDOR"===p?x():l.createElement(i.Card,{style:{boxShadow:"none"}},x())),N&&l.createElement(i.Toast,{error:"error"===N.key,label:u("success"===N.key?`ES_FSM_REGISTRY_${N.action}_SUCCESS`:N.action),onClose:P}),l.createElement(i.ActionBar,{style:{zIndex:"19"}},v?l.createElement(i.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:u,onSelect:k}):null,l.createElement(i.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)}))))},AddSupervisor:e=>{var a;const{t:d}=o.useTranslation(),s=(n.useHistory(),null===(a=Digit.UserService.getUser())||void 0===a?void 0:a.info),u=Digit.ULBService.getCurrentTenantId(),c=null!=u&&u.includes(".")?u:u+".djb",[E,m]=t.useState(null),v=r.useQueryClient(),[S,p]=t.useState(!1),{mutate:_}=Digit.Hooks.fsm.useSupervisorCreate(c),{search:R}=n.useLocation(),D=new URLSearchParams(R).get("vendorId")||(null==s?void 0:s.uuid),N=H(d),g=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(i.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(i.FormComposer,{isDisabled:!S,label:d("ES_COMMON_APPLICATION_SUBMIT"),config:N.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,i,o;const a=null==s||null===(t=s.roles)||void 0===t?void 0:t.some(e=>"EKYC_VENDOR"===e.code),r={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_create",msgId:Date.now()+"|en_IN",authToken:(null===(l=Digit.UserService.getUser())||void 0===l?void 0:l.access_token)||(null==s?void 0:s.authToken),...a&&{userInfo:{id:null==s?void 0:s.id,uuid:null==s?void 0:s.uuid,userName:null==s?void 0:s.userName,name:null==s?void 0:s.name,type:null==s?void 0:s.type,tenantId:(null==s?void 0:s.tenantId)||u,roles:null==s?void 0:s.roles}}},supervisor:{tenantId:c,vendorId:D,assignedZoneId:(null==e||null===(n=e.assignedZone)||void 0===n?void 0:n.code)||(null==e?void 0:e.assignedZone)||null,description:(null==e?void 0:e.description)||"",owner:{tenantId:c,name:null==e?void 0:e.fullName,fatherOrHusbandName:null==e?void 0:e.fatherOrHusbandName,relationship:null==e||null===(i=e.relationship)||void 0===i?void 0:i.code,dob:null!=e&&e.dob?new Date(e.dob).getTime():null,gender:(null==e||null===(o=e.gender)||void 0===o?void 0:o.code)||"OTHERS",mobileNumber:null==e?void 0:e.mobileNumber,emailId:null==e?void 0:e.emailId,correspondenceAddress:null==e?void 0:e.correspondenceAddress}}};_(r,{onError:e=>{m({key:"error",action:e}),setTimeout(g,5e3)},onSuccess:()=>{m({key:"success",action:"ADD_SUPERVISOR"}),v.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(g,5e3)}})},defaultValues:{role:{code:"SUPERVISOR",name:"Supervisor"}},onFormValueChange:(e,t)=>{p(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.fatherOrHusbandName)&&(null==t?void 0:t.relationship)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.gender)&&(null==t?void 0:t.correspondenceAddress)&&(null==t?void 0:t.assignedZone)))},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(i.Toast,{error:"error"===E.key,label:d("success"===E.key?`ES_VENDOR_${E.action}_SUCCESS`:E.action),onClose:g})))},SupervisorDetails:e=>{var a,d;const s=Digit.ULBService.getCurrentTenantId(),{t:u}=o.useTranslation(),c=n.useHistory(),E=r.useQueryClient(),{id:m}=n.useParams(),[v,S]=t.useState(!1),[p,_]=t.useState(null),[R,D]=t.useState(!1),[N,g]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),{data:O}=Digit.Hooks.fsm.useDsoSearch(s,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{data:A,isLoading:h,refetch:b}=Digit.Hooks.fsm.useSupervisorSearch(s,{ids:m},{staleTime:Infinity}),f=l.useMemo(()=>{var e;return null!=A&&null!==(e=A.supervisors)&&void 0!==e&&e.length?A.supervisors.map(e=>{var t,l,n,i;const o=null==O?void 0:O.find(t=>{var l,n;return(null===(l=t.dsoDetails)||void 0===l?void 0:l.id)===e.vendorId||(null===(n=t.dsoDetails)||void 0===n?void 0:n.vendorId)===e.vendorId}),a=(null==o||null===(t=o.dsoDetails)||void 0===t?void 0:t.name)||e.vendorId||"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR";return{supervisorData:e,vendorDetails:{vendor:o?[o.dsoDetails]:[]},employeeResponse:[{title:"ES_VENDOR_SUPERVISOR_BASIC_DETAILS",values:[{title:"ES_VENDOR_SUPERVISOR_FULL_NAME",value:null==e?void 0:e.name},{title:"ES_VENDOR_SUPERVISOR_MOBILE_NUMBER",value:(null==e||null===(l=e.owner)||void 0===l?void 0:l.mobileNumber)||(null==e?void 0:e.mobileNo)},{title:"ES_VENDOR_SUPERVISOR_EMAIL_ID",value:null==e||null===(n=e.owner)||void 0===n?void 0:n.emailId},{title:"ES_VENDOR_SUPERVISOR_STAFF_CODE",value:(null==e?void 0:e.employeeId)||"N/A"},{title:"ES_VENDOR_SUPERVISOR_GENDER",value:null==e||null===(i=e.owner)||void 0===i?void 0:i.gender},{title:"ES_VENDOR_SUPERVISOR_AGENCY_NAME",value:a,type:"custom"}]},{title:"ES_VENDOR_SUPERVISOR_MAPPED_SURVEYORS",type:"ES_FSM_REGISTRY_DETAILS_TYPE_SURVEYOR",child:[]}]}}):[]},[A,O]),{mutate:V}=Digit.Hooks.fsm.useSupervisorUpdate(s),{mutate:L}=Digit.Hooks.fsm.useVendorUpdate(s);t.useEffect(()=>{if(O){let e=O.map(e=>e.dsoDetails);T(e)}},[O]),t.useEffect(()=>{b()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return D(!0);case"EDIT":return c.push("/digit-ui/employee/vendor/registry/modify-supervisor/"+m);case"HOME":return c.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SUPERVISOR")}},[p]);const M=()=>{g(null)},k=()=>{_(null),C({}),D(!1)};return h?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(i.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==f||null===(a=f[0])||void 0===a||null===(d=a.employeeResponse)||void 0===d?void 0:d.map((e,t)=>{var n,o;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(i.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(i.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(i.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>_("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(i.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},u(e.value)||"N/A"))))),null==e||null===(o=e.child)||void 0===o?void 0:o.map((t,n)=>{var o;return l.createElement(i.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(i.EditIcon,{fill:"#a82227",style:{cursor:"pointer"}})))),l.createElement("div",{className:"additional-grid"},null==t||null===(o=t.values)||void 0===o?void 0:o.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(i.AddIcon,{fill:"#a82227"}),u(e.type+"_ADD")))}))),R&&l.createElement(i.Modal,{headerBarMain:l.createElement(U,{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(Y,{onClick:k}),actionCancelLabel:u("CS_COMMON_CANCEL"),actionCancelOnSubmit:k,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==f||null===(e=f[0])||void 0===e?void 0:e.supervisorData,status:"INACTIVE"}};V(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)}}),D(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=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],i=(null==n?void 0:n.supervisors)||[];i=i.map(e=>(e.id===m&&(e.vendorSupervisorStatus="INACTIVE"),e));const o={vendor:{...n,supervisors:i}};L(o,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),b(),setTimeout(M,5e3)}}),D(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=I,l=null==f||null===(e=f[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:{...t,supervisors:t.supervisors?[...t.supervisors,l]:[l]}};L(n,{onError:e=>{g({key:"error",action:e}),b(),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"ADD_VENDOR"}),E.invalidateQueries("SUPERVISOR_SEARCH"),b(),setTimeout(M,5e3)}}),D(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=I,l=null==f||null===(e=f[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:{...t,supervisors:t.supervisors?[...t.supervisors,l]:[l]}};L(n,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"EDIT_VENDOR"}),b(),E.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(M,5e3)}}),D(!1),_(null)})()}}},l.createElement(i.Card,{style:{boxShadow:"none"}},"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(w,{t:u,title:"ES_VENDOR_SUPERVISOR_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(i.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0)),N&&l.createElement(i.Toast,{error:"error"===N.key,label:u("success"===N.key?`ES_VENDOR_${N.action}_SUCCESS`:N.action),onClose:M}),l.createElement(i.ActionBar,{style:{zIndex:"19"}},v?l.createElement(i.Menu,{localeKeyPrefix:"ES_VENDOR_SUPERVISOR_ACTION",options:["EDIT","DELETE"],t:u,onSelect:e=>{S(!1),_(e)}}):null,l.createElement(i.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)})))},EditSupervisor:()=>{var e;const{t:a}=o.useTranslation(),d=n.useHistory(),s=r.useQueryClient(),{id:u}=n.useParams(),c=null===(e=Digit.UserService.getUser())||void 0===e?void 0:e.info,E=Digit.ULBService.getCurrentTenantId(),m=null!=E&&E.includes(".")?E:E+".djb",[v,S]=t.useState(null),[p,_]=t.useState(!1),[R,D]=t.useState({}),[N,g]=t.useState({}),{data:y,isLoading:T}=Digit.Hooks.fsm.useSupervisorSearch(m,{ids:u},{staleTime:Infinity}),{mutate:I}=Digit.Hooks.fsm.useSupervisorUpdate(m),C=H(a);t.useEffect(()=>{if(y&&y.supervisors&&y.supervisors.length>0){var e,t,l,n,i,o,a,r,d;let s=y.supervisors[0];g(s);let u={fullName:(null==s||null===(e=s.owner)||void 0===e?void 0:e.name)||(null==s?void 0:s.name),mobileNumber:(null==s||null===(t=s.owner)||void 0===t?void 0:t.mobileNumber)||(null==s?void 0:s.mobileNo),emailId:null==s||null===(l=s.owner)||void 0===l?void 0:l.emailId,employeeId:null==s?void 0:s.employeeId,gender:null!=s&&null!==(n=s.owner)&&void 0!==n&&n.gender?{code:s.owner.gender,name:"COMMON_GENDER_"+s.owner.gender}:null,fatherOrHusbandName:null==s||null===(i=s.owner)||void 0===i?void 0:i.fatherOrHusbandName,relationship:null!=s&&null!==(o=s.owner)&&void 0!==o&&o.relationship?{code:s.owner.relationship,name:"ES_COMMON_RELATION_"+s.owner.relationship}:null,dob:(null==s||null===(a=s.owner)||void 0===a?void 0:a.dob)&&Digit.DateUtils.ConvertTimestampToDate(null==s||null===(r=s.owner)||void 0===r?void 0:r.dob,"yyyy-MM-dd"),correspondenceAddress:null==s||null===(d=s.owner)||void 0===d?void 0:d.correspondenceAddress,description:null==s?void 0:s.description,assignedZone:null!=s&&s.assignedZoneId?{code:s.assignedZoneId,name:s.assignedZoneId}:null};D(u)}},[y]);const O=()=>{S(null)};return T||0===Object.keys(R).length?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{timeLine:[{actions:a("ES_VENDOR_SUPERVISOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(i.FormComposer,{isDisabled:!p,label:a("ES_COMMON_APPLICATION_SUBMIT"),config:C.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,i,o,a,r,E,v,p,_;const R={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_update",msgId:Date.now()+"|en_IN",authToken:null==c?void 0:c.authToken,userInfo:{id:null==c?void 0:c.id,uuid:null==c?void 0:c.uuid,userName:null==c?void 0:c.userName,name:null==c?void 0:c.name,type:null==c?void 0:c.type,tenantId:m,roles:null==c?void 0:c.roles}},supervisor:{...N,description:(null==e?void 0:e.description)||(null==N?void 0:N.description)||"",assignedZoneId:(null==e||null===(t=e.assignedZone)||void 0===t?void 0:t.code)||(null==N?void 0:N.assignedZoneId)||null,owner:{...N.owner,name:(null==e?void 0:e.fullName)||(null===(l=N.owner)||void 0===l?void 0:l.name),fatherOrHusbandName:(null==e?void 0:e.fatherOrHusbandName)||(null===(n=N.owner)||void 0===n?void 0:n.fatherOrHusbandName),relationship:(null==e||null===(i=e.relationship)||void 0===i?void 0:i.code)||(null===(o=N.owner)||void 0===o?void 0:o.relationship),gender:(null==e||null===(a=e.gender)||void 0===a?void 0:a.code)||(null===(r=N.owner)||void 0===r?void 0:r.gender)||"OTHERS",dob:null!=e&&e.dob?new Date(e.dob).getTime():null===(E=N.owner)||void 0===E?void 0:E.dob,emailId:(null==e?void 0:e.emailId)||(null===(v=N.owner)||void 0===v?void 0:v.emailId),mobileNumber:(null==e?void 0:e.mobileNumber)||(null===(p=N.owner)||void 0===p?void 0:p.mobileNumber),correspondenceAddress:(null==e?void 0:e.correspondenceAddress)||(null===(_=N.owner)||void 0===_?void 0:_.correspondenceAddress)}}};I(R,{onError:e=>{S({key:"error",action:e}),setTimeout(O,5e3)},onSuccess:()=>{S({key:"success",action:"UPDATE_SUPERVISOR"}),s.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(()=>{O(),d.push("/digit-ui/employee/vendor/registry/supervisor-details/"+u)},5e3)}})},defaultValues:R,onFormValueChange:(e,t)=>{_(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.fatherOrHusbandName)&&(null==t?void 0:t.relationship)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.gender)&&(null==t?void 0:t.correspondenceAddress)&&(null==t?void 0:t.assignedZone)))},noBreakLine:!0,mode:"onChange",noCard:!0}),v&&l.createElement(i.Toast,{error:"error"===v.key,label:a("success"===v.key?`ES_VENDOR_${v.action}_SUCCESS`:v.action),onClose:O})))},SupervisorAreaAssignment:e=>{var n,o,a,r;let{config:d,onSelect:s,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===(o=c.areaAssignment)||void 0===o?void 0:o.cluster)||null),[_,R]=t.useState((null==c||null===(a=c.areaAssignment)||void 0===a?void 0:a.ward)||null),[D,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,h]=t.useState([]),{data:b,isLoading:f}=Digit.Hooks.useCommonMDMS(E,"egov-location",["TenantBoundary"]);t.useEffect(()=>{if(console.log("Boundary Data State:",{boundaryData:b,isLoading:f}),b){var e,t,l,n,i;const o=(null==b||null===(e=b["egov-location"])||void 0===e||null===(t=e.TenantBoundary)||void 0===t?void 0:t[0])||(null==b||null===(l=b.MdmsRes)||void 0===l||null===(n=l["egov-location"])||void 0===n||null===(i=n.TenantBoundary)||void 0===i?void 0:i[0]),a=(null==o?void 0:o.boundary)||(null==o?void 0:o.children)||[];Array.isArray(a)&&a.length>0?y(a):f||y([{code:"ZONE-01",name:"ZONE-01",children:[{code:"CLUSTER-01",name:"CLUSTER-01",children:[{code:"WARD-01",name:"WARD-01",children:[{code:"AREA-01",name:"AREA-01"},{code:"AREA-02",name:"AREA-02"}]}]}]},{code:"ZONE-02",name:"ZONE-02"}])}else f||y([{code:"ZONE-01",name:"ZONE-01",children:[{code:"CLUSTER-01",name:"CLUSTER-01",children:[{code:"WARD-01",name:"WARD-01",children:[{code:"AREA-01",name:"AREA-01"},{code:"AREA-02",name:"AREA-02"}]}]}]},{code:"ZONE-02",name:"ZONE-02"}])},[b,f]),t.useEffect(()=>{if(m){var e,t;const l=m.children||m.boundary||[];I(l.length>0?l:[{code:"CLUSTER-01",name:"CLUSTER-01",children:[{code:"WARD-01",name:"WARD-01",children:[{code:"AREA-01",name:"AREA-01"},{code:"AREA-02",name:"AREA-02"}]}]}]),m.code!==(null==c||null===(e=c.areaAssignment)||void 0===e||null===(t=e.zone)||void 0===t?void 0:t.code)&&(p(null),R(null),N([]))}else I([])},[m]),t.useEffect(()=>{if(S){var e,t;const l=S.children||S.boundary||[];O(l.length>0?l:[{code:"WARD-01",name:"WARD-01",children:[{code:"AREA-01",name:"AREA-01"},{code:"AREA-02",name:"AREA-02"}]}]),S.code!==(null==c||null===(e=c.areaAssignment)||void 0===e||null===(t=e.cluster)||void 0===t?void 0:t.code)&&(R(null),N([]))}else O([])},[S]),t.useEffect(()=>{if(_){var e,t;const l=_.children||_.localities||_.boundary||[];h(l.length>0?l:[{code:"AREA-01",name:"AREA-01"},{code:"AREA-02",name:"AREA-02"}]),_.code!==(null==c||null===(e=c.areaAssignment)||void 0===e||null===(t=e.ward)||void 0===t?void 0:t.code)&&N([])}else h([])},[_]);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=[]),s(d.key,l)};return f?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,u("ES_VENDOR_SUPERVISOR_ZONE")+" *"),l.createElement(i.Dropdown,{selected:m,option:g,select:e=>{v(e),V("zone",e)},optionKey:"name",t:u})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,u("ES_VENDOR_SUPERVISOR_CLUSTER")+" *"),l.createElement(i.Dropdown,{selected:S,option:T,select:e=>{p(e),V("cluster",e)},optionKey:"name",t:u,disable:!m})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,u("ES_VENDOR_SUPERVISOR_WARD")+" *"),l.createElement(i.Dropdown,{selected:_,option:C,select:e=>{R(e),V("ward",e)},optionKey:"name",t:u,disable:!S})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,u("ES_VENDOR_SUPERVISOR_AREA")+" *"),l.createElement(i.MultiSelectDropdown,{options:A,selected:D,onSelect:e=>{N(e),V("areas",e)},optionsKey:"name",t:u,disable:!_})))},AddSurveyor:e=>{var a;const{t:d}=o.useTranslation(),s=null===(a=Digit.UserService.getUser())||void 0===a?void 0:a.info,u=Digit.ULBService.getCurrentTenantId(),c=null!=u&&u.includes(".")?u:u+".djb",[E,m]=t.useState(null),v=r.useQueryClient(),[S,p]=t.useState(!1),{mutate:_}=Digit.Hooks.fsm.useSurveyorCreate(c),{search:R}=n.useLocation(),D=(new URLSearchParams(R).get("vendorId"),W(d)),N=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(i.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(i.FormComposer,{isDisabled:!S,label:d("ES_COMMON_APPLICATION_SUBMIT"),config:D.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,i;const o=null==s||null===(t=s.roles)||void 0===t?void 0:t.some(e=>"EKYC_SUPERVISOR"===e.code),a={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_create",msgId:Date.now()+"|en_IN",authToken:(null===(l=Digit.UserService.getUser())||void 0===l?void 0:l.access_token)||(null==s?void 0:s.authToken),...o&&{userInfo:{id:null==s?void 0:s.id,uuid:null==s?void 0:s.uuid,userName:null==s?void 0:s.userName,name:null==s?void 0:s.name,type:null==s?void 0:s.type,tenantId:(null==s?void 0:s.tenantId)||u,roles:null==s?void 0:s.roles}}},surveyor:{tenantId:c,description:(null==e?void 0:e.description)||"",additionalDetails:{serviceType:"ekyc"},owner:{tenantId:c,name:null==e?void 0:e.fullName,fatherOrHusbandName:null==e?void 0:e.fatherOrHusbandName,relationship:null==e||null===(n=e.relationship)||void 0===n?void 0:n.code,gender:(null==e||null===(i=e.gender)||void 0===i?void 0:i.code)||"OTHERS",dob:null!=e&&e.dob?new Date(e.dob).getTime():null,emailId:null==e?void 0:e.emailId,mobileNumber:null==e?void 0:e.mobileNumber,correspondenceAddress:null==e?void 0:e.correspondenceAddress}}};_(a,{onError:e=>{m({key:"error",action:e}),setTimeout(N,5e3)},onSuccess:()=>{m({key:"success",action:"ADD_SURVEYOR"}),v.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(N,5e3)}})},defaultValues:{role:{code:"SURVEYOR",name:"Surveyor"}},onFormValueChange:(e,t)=>{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.fatherOrHusbandName)&&(null==t?void 0:t.relationship)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.correspondenceAddress)))},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(i.Toast,{error:"error"===E.key,label:d("success"===E.key?`ES_VENDOR_${E.action}_SUCCESS`:E.action),onClose:N})))},SurveyorDetails:e=>{var a,d;const s=Digit.ULBService.getCurrentTenantId(),{t:u}=o.useTranslation(),c=n.useHistory(),E=r.useQueryClient(),{id:m}=n.useParams(),[v,S]=t.useState(!1),[p,_]=t.useState(null),[R,D]=t.useState(!1),[N,g]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),{data:O}=Digit.Hooks.fsm.useDsoSearch(s,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{data:A,isLoading:h,refetch:b}=Digit.Hooks.fsm.useSurveyorSearch(s,{ids:m},{staleTime:Infinity}),f=l.useMemo(()=>{var e;return null!=A&&null!==(e=A.surveyors)&&void 0!==e&&e.length?A.surveyors.map(e=>{var t,l,n,i;const o=null==O?void 0:O.find(t=>{var l,n;return(null===(l=t.dsoDetails)||void 0===l?void 0:l.id)===e.vendorId||(null===(n=t.dsoDetails)||void 0===n?void 0:n.vendorId)===e.vendorId}),a=(null==o||null===(t=o.dsoDetails)||void 0===t?void 0:t.name)||e.vendorId||"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR";return{surveyorData:e,vendorDetails:{vendor:o?[o.dsoDetails]:[]},employeeResponse:[{title:"ES_VENDOR_SURVEYOR_BASIC_DETAILS",values:[{title:"ES_VENDOR_SURVEYOR_FULL_NAME",value:null==e?void 0:e.name},{title:"ES_VENDOR_SURVEYOR_MOBILE_NUMBER",value:(null==e||null===(l=e.owner)||void 0===l?void 0:l.mobileNumber)||(null==e?void 0:e.mobileNo)},{title:"ES_VENDOR_SURVEYOR_EMAIL_ID",value:null==e||null===(n=e.owner)||void 0===n?void 0:n.emailId},{title:"ES_VENDOR_SURVEYOR_STAFF_CODE",value:(null==e?void 0:e.employeeId)||"N/A"},{title:"ES_VENDOR_SURVEYOR_GENDER",value:null==e||null===(i=e.owner)||void 0===i?void 0:i.gender},{title:"ES_VENDOR_SURVEYOR_AGENCY_NAME",value:a,type:"custom"}]}]}}):[]},[A,O]),{mutate:V}=Digit.Hooks.fsm.useSurveyorUpdate(s),{mutate:L}=Digit.Hooks.fsm.useVendorUpdate(s);t.useEffect(()=>{if(O){let e=O.map(e=>e.dsoDetails);T(e)}},[O]),t.useEffect(()=>{b()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return D(!0);case"EDIT":return c.push("/digit-ui/employee/vendor/registry/modify-surveyor/"+m);case"HOME":return c.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SURVEYOR")}},[p]);const M=()=>{g(null)},k=()=>{_(null),C({}),D(!1)};return h?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(i.Card,null,null==f||null===(a=f[0])||void 0===a||null===(d=a.employeeResponse)||void 0===d?void 0:d.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(i.Card,{className:"card-with-background"},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(i.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(i.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>_("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(i.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},u(e.value)||"N/A"))))))}))),R&&l.createElement(i.Modal,{headerBarMain:l.createElement(K,{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(z,{onClick:k}),actionCancelLabel:u("CS_COMMON_CANCEL"),actionCancelOnSubmit:k,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==f||null===(e=f[0])||void 0===e?void 0:e.surveyorData,status:"INACTIVE"}};V(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)}}),D(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=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],i=(null==n?void 0:n.surveyors)||[];i=i.map(e=>(e.id===m&&(e.vendorSurveyorStatus="INACTIVE"),e));const o={vendor:{...n,surveyors:i}};L(o,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),b(),setTimeout(M,5e3)}}),D(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=I,l=null==f||null===(e=f[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:{...t,surveyors:t.surveyors?[...t.surveyors,l]:[l]}};L(n,{onError:e=>{g({key:"error",action:e}),b(),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"ADD_VENDOR"}),E.invalidateQueries("SURVEYOR_SEARCH"),b(),setTimeout(M,5e3)}}),D(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=I,l=null==f||null===(e=f[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:{...t,surveyors:t.surveyors?[...t.surveyors,l]:[l]}};L(n,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"EDIT_VENDOR"}),b(),E.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(M,5e3)}}),D(!1),_(null)})()}}},l.createElement(i.Card,{style:{boxShadow:"none"}},"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(w,{t:u,title:"ES_VENDOR_SURVEYOR_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(i.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0)),N&&l.createElement(i.Toast,{error:"error"===N.key,label:u("success"===N.key?`ES_VENDOR_${N.action}_SUCCESS`:N.action),onClose:M}),l.createElement(i.ActionBar,{style:{zIndex:"19"}},v?l.createElement(i.Menu,{localeKeyPrefix:"ES_VENDOR_SURVEYOR_ACTION",options:["EDIT","DELETE"],t:u,onSelect:e=>{S(!1),_(e)}}):null,l.createElement(i.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)})))},EditSurveyor:()=>{var e;const{t:a}=o.useTranslation(),d=n.useHistory(),s=r.useQueryClient(),{id:u}=n.useParams(),c=null===(e=Digit.UserService.getUser())||void 0===e?void 0:e.info,E=Digit.ULBService.getCurrentTenantId(),m=null!=E&&E.includes(".")?E:E+".djb",[v,S]=t.useState(null),[p,_]=t.useState(!1),[R,D]=t.useState({}),[N,g]=t.useState({}),{data:y,isLoading:T}=Digit.Hooks.fsm.useSurveyorSearch(m,{ids:u},{staleTime:Infinity}),{mutate:I}=Digit.Hooks.fsm.useSurveyorUpdate(m),C=W(a);t.useEffect(()=>{if(y&&y.surveyors&&y.surveyors.length>0){var e,t,l,n,i,o,a,r,d;let s=y.surveyors[0];g(s);let u={fullName:(null==s||null===(e=s.owner)||void 0===e?void 0:e.name)||(null==s?void 0:s.name),mobileNumber:(null==s||null===(t=s.owner)||void 0===t?void 0:t.mobileNumber)||(null==s?void 0:s.mobileNo),emailId:null==s||null===(l=s.owner)||void 0===l?void 0:l.emailId,employeeId:null==s?void 0:s.employeeId,gender:null!=s&&null!==(n=s.owner)&&void 0!==n&&n.gender?{code:s.owner.gender,name:"COMMON_GENDER_"+s.owner.gender}:null,fatherOrHusbandName:null==s||null===(i=s.owner)||void 0===i?void 0:i.fatherOrHusbandName,relationship:null!=s&&null!==(o=s.owner)&&void 0!==o&&o.relationship?{code:s.owner.relationship,name:"ES_COMMON_RELATION_"+s.owner.relationship}:null,dob:(null==s||null===(a=s.owner)||void 0===a?void 0:a.dob)&&Digit.DateUtils.ConvertTimestampToDate(null==s||null===(r=s.owner)||void 0===r?void 0:r.dob,"yyyy-MM-dd"),correspondenceAddress:null==s||null===(d=s.owner)||void 0===d?void 0:d.correspondenceAddress,description:null==s?void 0:s.description};D(u)}},[y]);const O=()=>{S(null)};return T||0===Object.keys(R).length?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{timeLine:[{actions:a("ES_VENDOR_SURVEYOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(i.FormComposer,{isDisabled:!p,label:a("ES_COMMON_APPLICATION_SUBMIT"),config:C.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,i,o,a,r,E,v,p;const _={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_update",msgId:Date.now()+"|en_IN",authToken:null==c?void 0:c.authToken,userInfo:{id:null==c?void 0:c.id,uuid:null==c?void 0:c.uuid,userName:null==c?void 0:c.userName,name:null==c?void 0:c.name,type:null==c?void 0:c.type,tenantId:m,roles:null==c?void 0:c.roles}},surveyor:{...N,description:(null==e?void 0:e.description)||(null==N?void 0:N.description)||"",name:(null==e?void 0:e.fullName)||(null==N?void 0:N.name),mobileNo:(null==e?void 0:e.mobileNumber)||(null==N?void 0:N.mobileNo),employeeId:(null==e?void 0:e.employeeId)||(null==N?void 0:N.employeeId),owner:{...N.owner,name:(null==e?void 0:e.fullName)||(null===(t=N.owner)||void 0===t?void 0:t.name),fatherOrHusbandName:(null==e?void 0:e.fatherOrHusbandName)||(null===(l=N.owner)||void 0===l?void 0:l.fatherOrHusbandName),relationship:(null==e||null===(n=e.relationship)||void 0===n?void 0:n.code)||(null===(i=N.owner)||void 0===i?void 0:i.relationship),gender:(null==e||null===(o=e.gender)||void 0===o?void 0:o.code)||(null===(a=N.owner)||void 0===a?void 0:a.gender)||"OTHERS",dob:null!=e&&e.dob?new Date(e.dob).getTime():null===(r=N.owner)||void 0===r?void 0:r.dob,emailId:(null==e?void 0:e.emailId)||(null===(E=N.owner)||void 0===E?void 0:E.emailId),mobileNumber:(null==e?void 0:e.mobileNumber)||(null===(v=N.owner)||void 0===v?void 0:v.mobileNumber),correspondenceAddress:(null==e?void 0:e.correspondenceAddress)||(null===(p=N.owner)||void 0===p?void 0:p.correspondenceAddress)}}};I(_,{onError:e=>{S({key:"error",action:e}),setTimeout(O,5e3)},onSuccess:()=>{S({key:"success",action:"UPDATE_SURVEYOR"}),s.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(()=>{O(),d.push("/digit-ui/employee/vendor/registry/surveyor-details/"+u)},5e3)}})},defaultValues:R,onFormValueChange:(e,t)=>{_(!!((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.fatherOrHusbandName)&&(null==t?void 0:t.relationship)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.correspondenceAddress)))},noBreakLine:!0,mode:"onChange",noCard:!0}),v&&l.createElement(i.Toast,{error:"error"===v.key,label:a("success"===v.key?`ES_VENDOR_${v.action}_SUCCESS`:v.action),onClose:O})))},SelectEkycZones:e=>{let{config:n,onSelect:o,t:a,formData:r}=e;const d=Digit.ULBService.getCurrentTenantId(),[s,u]=t.useState([]),[c,E]=t.useState(Array.isArray(null==r?void 0:r.zoneIds)?r.zoneIds:[]),{data:m,isLoading:v}=Digit.Hooks.useCommonMDMS(d,"egov-location",["TenantBoundary"]);return t.useEffect(()=>{var e,t,l,n,i;const o=(null==m||null===(e=m["egov-location"])||void 0===e||null===(t=e.TenantBoundary)||void 0===t?void 0:t[0])||(null==m||null===(l=m.MdmsRes)||void 0===l||null===(n=l["egov-location"])||void 0===n||null===(i=n.TenantBoundary)||void 0===i?void 0:i[0]),a=(null==o?void 0:o.boundary)||(null==o?void 0:o.children)||[];if(Array.isArray(null==a?void 0:a.children)&&(null==a?void 0:a.children.length)>0){const e=null==a?void 0:a.children.map(e=>({code:e.code,name:e.name}));u(e)}else v||u([{code:"ZONE-01",name:"ZONE-01"},{code:"ZONE-02",name:"ZONE-02"},{code:"ZONE-03",name:"ZONE-03"},{code:"ZONE-04",name:"ZONE-04"},{code:"ZONE-05",name:"ZONE-05"}])},[m,v]),v?l.createElement(i.Loader,null):l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,a(n.label)+(n.isMandatory?" *":"")),l.createElement("div",{className:"field"},l.createElement(i.MultiSelectDropdown,{options:s,selected:c,onSelect:e=>{E(e),o(n.key,e)},optionsKey:"name",t:a})))},SelectEkycClusters:e=>{let{config:n,onSelect:o,t:a,formData:r}=e;const d=Digit.ULBService.getCurrentTenantId(),[s,u]=t.useState([]),[c,E]=t.useState(Array.isArray(null==r?void 0:r.clusterIds)?r.clusterIds:[]),m=l.useMemo(()=>Array.isArray(null==r?void 0:r.zoneIds)?r.zoneIds:[],[null==r?void 0:r.zoneIds]),{data:v}=Digit.Hooks.useCommonMDMS(d,"egov-location",["TenantBoundary"]);return t.useEffect(()=>{var e,t,l,n,i;const o=(null==v||null===(e=v["egov-location"])||void 0===e||null===(t=e.TenantBoundary)||void 0===t?void 0:t[0])||(null==v||null===(l=v.MdmsRes)||void 0===l||null===(n=l["egov-location"])||void 0===n||null===(i=n.TenantBoundary)||void 0===i?void 0:i[0]),a=(null==o?void 0:o.boundary)||(null==o?void 0:o.children)||[];let r=[];if(m.length>0&&Array.isArray(a)&&a.length>0&&m.forEach(e=>{const t=a.find(t=>t.code===e.code),l=(null==t?void 0:t.children)||(null==t?void 0:t.boundary)||[];Array.isArray(l)&&l.forEach(e=>{r.push({code:e.code,name:e.name})})}),0===r.length){const e={"ZONE-01":[{code:"CLUSTER-01",name:"CLUSTER-01"}],"ZONE-02":[{code:"CLUSTER-02",name:"CLUSTER-02"}],"ZONE-03":[{code:"CLUSTER-03",name:"CLUSTER-03"}],"ZONE-04":[{code:"CLUSTER-04",name:"CLUSTER-04"}],"ZONE-05":[{code:"CLUSTER-05",name:"CLUSTER-05"}]};m.length>0?m.forEach(t=>{e[t.code]?r=[...r,...e[t.code]]:r.push({code:t.code+"-C1",name:t.name+" Cluster 1"})}):r=[{code:"CLUSTER-01",name:"CLUSTER-01"},{code:"CLUSTER-02",name:"CLUSTER-02"},{code:"CLUSTER-03",name:"CLUSTER-03"}]}u(e=>JSON.stringify(e)===JSON.stringify(r)?e:r)},[null==r?void 0:r.zoneIds,v]),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,a(n.label)+(n.isMandatory?" *":"")),l.createElement("div",{className:"field"},l.createElement(i.MultiSelectDropdown,{options:s,selected:c,onSelect:e=>{E(e),o(n.key,e)},optionsKey:"name",t:a})))},SelectEkycDropdown:e=>{var t,n;let{config:o,onSelect:a,t:r,formData:d}=e;const s=(null==o||null===(t=o.populators)||void 0===t?void 0:t.options)||[],u=(null==o||null===(n=o.populators)||void 0===n?void 0:n.optionsKey)||"name",c=null==d?void 0:d[o.key];return l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,r(o.label)),l.createElement("div",{className:"field"},l.createElement(i.Dropdown,{selected:c,option:s,select:e=>{a(o.key,e)},optionKey:u,t:r})))}},de=e=>{let{stateCode:i,userType:o,tenants:a}=e;const{path:r,url:d}=n.useRouteMatch(),u=Digit.StoreData.getCurrentLanguage();return Digit.Services.useStore({stateCode:i,moduleCode:"VENDOR",language:u}),Object.entries(re).forEach(e=>{let[t,l]=e;Digit.ComponentRegistryService.setComponent(t,l)}),Digit.SessionStorage.set("VENDOR_TENANTS",a),t.useEffect(()=>"employee"===o&&Digit.LocalizationService.getLocale({modules:["rainmaker-"+Digit.ULBService.getCurrentTenantId()],locale:Digit.StoreData.getCurrentLanguage(),tenantId:Digit.ULBService.getCurrentTenantId()}),[]),l.createElement("employee"===o?s:M,{path:r,url:d,userType:o})},se=e=>{const[,,l]=Digit.Hooks.useSessionStorage("VENDOR",{});return t.useEffect(()=>{l()},[]),null};exports.VENDORComponents={VENDORCard:()=>{const{t:e}=o.useTranslation(),t=n.useHistory(),a=window.location.pathname.toLowerCase().includes("citizen");let r=Digit.Utils.vendorAccess()||Digit.UserService.hasAccess(["WT_VENDOR","MT_VENDOR"]);if(a&&(r=Digit.UserService.hasAccess(["WT_VENDOR","EKYC_VENDOR","EKYC_SUPERVISOR"])),!r)return null;const d=[{label:e("VENDOR_NEW_REGISTERATION"),link:a?"/digit-ui/citizen/vendor/registry/new-vendor":"/digit-ui/employee/vendor/registry/new-vendor"},{label:e("SEARCH_VENDOR"),link:a?"/digit-ui/citizen/vendor/search-vendor":"/digit-ui/employee/vendor/search-vendor"}],s=Digit.UserService.hasAccess(["WT_VENDOR"]),u={Icon:l.createElement(i.PropertyHouse,null),moduleName:e("TITLE_VENDOR_MANAGEMENT"),kpis:[{count:0,label:e("Inbox"),link:a?"/digit-ui/citizen/vendor/search-vendor":"/digit-ui/employee/vendor/search-vendor"}],links:d.filter(e=>!(null!=e&&e.role)||s),...a?{onDetailsClick:()=>t.push("/digit-ui/citizen/vendor/search-vendor")}:{}};return a?l.createElement("div",{className:"wt-citizen-card-premium"},l.createElement(i.EmployeeModuleCard,u)):l.createElement(i.EmployeeModuleCard,u)},VENDORModule:de,VENDORLinks:se},exports.VENDORLinks=se,exports.VENDORModule=de;
1
+ var e,t=require("react"),l=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=require("react-router-dom"),i=require("@djb25/digit-ui-react-components"),o=require("react-i18next"),a=require("react-hook-form"),r=require("react-query");function d(){return(d=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 s=e=>{let{path:t}=e;const{t:a}=o.useTranslation(),r=n.useLocation();sessionStorage.removeItem("revalidateddone");const s=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"),R=Digit.ComponentRegistryService.getComponent("AddSupervisor"),D=Digit.ComponentRegistryService.getComponent("SupervisorDetails"),N=Digit.ComponentRegistryService.getComponent("EditSupervisor"),g=Digit.ComponentRegistryService.getComponent("AddSurveyor"),y=Digit.ComponentRegistryService.getComponent("SurveyorDetails"),T=Digit.ComponentRegistryService.getComponent("EditSurveyor"),I=Digit.ComponentRegistryService.getComponent("EditDriver"),C=Digit.ComponentRegistryService.getComponent("EditVehicle");return l.createElement(n.Switch,null,l.createElement(i.AppContainer,null,l.createElement(l.Fragment,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(i.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(i.ArrowLeft,{className:"icon"}),"Back"),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const e=r.pathname;let t=[{icon:i.HomeIcon,path:"/digit-ui/employee"},{label:a("TITLE_VENDOR_MANAGEMENT"),path:"/digit-ui/employee/vendor/search-vendor"}];return e.includes("/registry/new-vendor")?t.push({label:a("ES_FSM_REGISTRY_TITLE_NEW_VENDOR")}):e.includes("/search-vendor")?t.push({label:a("SEARCH_VENDOR")}):e.includes("/registry/new-driver")?t.push({label:a("ES_FSM_REGISTRY_TITLE_NEW_DRIVER")}):e.includes("/registry/vendor-details")||e.includes("/registry/modify-vendor/")?t.push({label:a("VENDOR_VENDOR_DETAILS")}):e.includes("/registry/vehicle-details")||e.includes("/registry/modify-vehicle/")?t.push({label:a("VENDOR_VEHICLE_DETAILS")}):e.includes("/registry/new-vehicle")?t.push({label:a("ES_FSM_REGISTRY_TITLE_NEW_VEHICLE")}):e.includes("/registry/driver-details")||e.includes("/registry/modify-driver/")?t.push({label:a("VENDOR_DRIVER_DETAILS")}):e.includes("/registry/additionaldetails")?t.push({label:a("VENDOR_ADDITIONAL_DETAILS")}):e.includes("/registry/new-supervisor")?t.push({label:a("ES_FSM_REGISTRY_TITLE_NEW_SUPERVISOR")}):e.includes("/registry/supervisor-details")||e.includes("/registry/modify-supervisor/")?t.push({label:a("VENDOR_SUPERVISOR_DETAILS")}):e.includes("/registry/new-surveyor")?t.push({label:a("ES_FSM_REGISTRY_TITLE_NEW_SURVEYOR")}):(e.includes("/registry/surveyor-details")||e.includes("/registry/modify-surveyor/"))&&t.push({label:a("VENDOR_SURVEYOR_DETAILS")}),t})()}),l.createElement(i.PrivateRoute,{path:t+"/search-vendor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"normal"},l.createElement(u,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/new-driver",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(E,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/new-vehicle",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(v,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/additionaldetails",component:e=>{const n=e.location.pathname.includes("/info");return l.createElement(i.LayoutWrapper,{layoutClass:n?"action":"normal"},l.createElement(S,d({},e,{parentRoute:t})))}}),l.createElement(i.PrivateRoute,{path:t+"/registry/driver-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(p,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/modify-driver/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(I,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/common-search/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"normal"},l.createElement(c,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/new-vendor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(s,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/vendor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(m,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/vehicle-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(_,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/modify-vehicle/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(C,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/new-supervisor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(R,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/supervisor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(D,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/modify-supervisor/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(N,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/new-surveyor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(g,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/surveyor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(y,d({},e,{parentRoute:t})))}),l.createElement(i.PrivateRoute,{path:t+"/registry/modify-surveyor/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(T,d({},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=(e,t)=>{const l=new Date(e);if(e){let e=l.getMonth()+1,n=l.getDate(),i=l.getFullYear();return e=(e>9?"":"0")+e,n=(n>9?"":"0")+n,"asset-create"===t?`${n}-${e}-${i}`:`${n}/${e}/${i}`}return null},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,o;let{isLoading:r,t:d,onSubmit:s,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 R=_.toISOString().split("T")[0],{register:D,control:N,handleSubmit:g,setValue:y,getValues:T,reset:I,formState:C}=a.useForm({defaultValues:{offset:0,limit:!v&&10,sortBy:"commencementDate",sortOrder:"DESC",fromDate:R,toDate:p}});t.useEffect(()=>{D("offset",0),D("limit",10),D("sortBy","commencementDate"),D("sortOrder","DESC"),y("fromDate",R),y("toDate",p)},[D,g,y,p,R]),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:d("VENDOR_REGISTRATION_NO"),accessor:"requestId",disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const i=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.registrationNo;return l.createElement("div",null,i||"N/A")}},{Header:d("CONTACT_PERSON_NAME"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const i=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.contactPerson;return l.createElement("div",null,i||"N/A")}},{Header:d("VENDOR_MOBILE_NUMBER"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const i=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.vendorMobileNumber;return l.createElement("div",null,i||"N/A")}},{Header:d("VENDOR_BANK_NAME"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const i=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.bank;return l.createElement("div",null,i||"N/A")}},{Header:d("VENDOR_STATUS"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const i=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.status;return l.createElement("div",null,i||"N/A")}}],[]),A=t.useCallback(e=>{0!==e.length&&(y("sortBy",e.id),y("sortOrder",e.desc?"DESC":"ASC"))},[]);function h(){y("offset",T("offset")-T("limit")),g(s)()}return l.createElement(l.Fragment,null,l.createElement("div",null,l.createElement(i.Header,null,d("VENDOR_COMMON_SEARCH_ADDITIONAL_DETAILS")),l.createElement(i.SearchForm,{onSubmit:s,handleSubmit:g},l.createElement(i.SearchField,null,l.createElement("label",null,d("VENDOR_NAME")),l.createElement(a.Controller,{control:N,name:"vendorName",render:e=>{var t;return l.createElement(i.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:d,disable:!1})}})),l.createElement(i.SearchField,null,l.createElement("label",null,d("VENDOR_MOBILE_NO")),l.createElement(i.MobileNumber,{name:"mobileNumber",inputRef:D({minLength:{value:10,message:d("CORE_COMMON_MOBILE_ERROR")},maxLength:{value:10,message:d("CORE_COMMON_MOBILE_ERROR")},pattern:{value:/[6789][0-9]{9}/,message:d("CORE_COMMON_MOBILE_ERROR")}}),type:"number",componentInFront:l.createElement("div",{className:"employee-card-input employee-card-input--front"},"+91")}),l.createElement(i.CardLabelError,null,null==C||null===(n=C.errors)||void 0===n||null===(o=n.mobileNumber)||void 0===o?void 0:o.message)),l.createElement(i.SearchField,null,l.createElement("label",null,d("VENDOR_FROM_DATE")),l.createElement(a.Controller,{render:e=>l.createElement(i.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"fromDate",control:N})),l.createElement(i.SearchField,null,l.createElement("label",null,d("VENDOR_TO_DATE")),l.createElement(a.Controller,{render:e=>l.createElement(i.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"toDate",control:N})),l.createElement(i.SearchField,{className:"submit"},l.createElement(i.SubmitBar,{label:d("ES_COMMON_SEARCH"),submit:!0}),l.createElement("p",{style:{marginTop:"10px"},onClick:()=>{I({fromDate:R,toDate:"",mobileNumber:"",vendorName:"",offset:0,limit:10,sortBy:"commencementDate",sortOrder:"DESC"}),E(null),h()}},d("ES_COMMON_CLEAR_ALL")))),!r&&null!=u&&u.display?l.createElement(i.Card,{style:{marginTop:20}},d(u.display).split("\\n").map((e,t)=>l.createElement("p",{key:t,style:{textAlign:"center"}},e))):r||""===u?""!==u||r&&l.createElement(i.Loader,null):l.createElement(i.Table,{t:d,data:u,totalRecords:c,columns:O,getCellProps:e=>({style:{minWidth:e.column.Header===d("EW_INBOX_APPLICATION_NO")?"240px":"",padding:"20px 18px",fontSize:"16px"}}),onPageSizeChange:function(e){y("limit",Number(e.target.value)),g(s)()},currentPage:T("offset")/T("limit"),onNextPage:function(){y("offset",T("offset")+T("limit")),g(s)()},onPrevPage:h,pageSizeLimit:T("limit"),onSort:A,disableSort:!1,sortParams:[{id:T("sortBy"),desc:"DESC"===T("sortOrder")}]})))},S=e=>{let{parentRoute:a}=e;const{t:r}=o.useTranslation(),d=[{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:a+"/search"},{text:r("ES_TITLE_REPORTS"),link:"/employee/report/fsm/FSMDailyDesludingReport",roles:["FSM_ADMIN"],hyperlink:!0}],[s,u]=t.useState([]),{roles:c}=Digit.UserService.getUser().info;return t.useEffect(()=>{let e=d.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(i.Card,{className:"employeeCard inboxLinksFSM"},l.createElement("div",{className:"complaint-links-container"},l.createElement("div",{className:"header"},l.createElement("span",{className:"logo"},l.createElement(i.ShippingTruck,null))," ",l.createElement("span",{className:"text"},r("ES_TITLE_FAECAL_SLUDGE_MGMT"))),l.createElement("div",{className:"body"},s.map((e,t)=>{let{link:i,text:o,hyperlink:a=!1,accessTo:d=[]}=e;return l.createElement("span",{className:"link",key:t},a?l.createElement("a",{href:i},r(o)):l.createElement(n.Link,{to:i},r(o)))}))))},p=e=>{let{className:t="table",t:n,currentPage:o,columns:a,data:r,getCellProps:s,disableSort:u,onSort:c,onNextPage:E,onPrevPage:m,onPageSizeChange:v,pageSizeLimit:S,sortParams:p,totalRecords:_,isPaginationRequired:R,showCSVExport:D,csvExportFileName:N,csvExportData:g,getCSVExportData:y,csvExportColumns:T,csvExportButtonLabel:I,...C}=e;return l.createElement(i.Card,null,l.createElement(i.Table,d({className:t,t:n,data:r,currentPage:o,columns:a,getCellProps:s,onNextPage:E,onPrevPage:m,pageSizeLimit:S,disableSort:u,onPageSizeChange:v,onSort:c,sortParams:p,totalRecords:_,isPaginationRequired:R,showCSVExport:D,csvExportFileName:N,csvExportData:g,getCSVExportData:y,csvExportColumns:T,csvExportButtonLabel:I},C)))},_=e=>{var t;let{status:n,searchParams:a,onAssignmentChange:r,statusMap:d}=e;return o.useTranslation(),l.createElement(i.CheckBox,{styles:{height:"unset"},onChange:e=>r({...e,state:n.state},n),checked:null==a?void 0:a.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,a,r,d,s;let{onAssignmentChange:u,searchParams:c,businessServices:E,statusMap:m}=e;const{t:v}=o.useTranslation(),[S,p]=t.useState(!1),{data:R,isLoading:D}=Digit.Hooks.useApplicationStatusGeneral({businessServices:E},{}),{userRoleStates:N}=R||{},g=(e,t)=>t(map[e.stateBusinessService])+" - "+t("ES_PTR_COMMON_STATUS_"+(e.state||"CREATED"));return D?l.createElement(i.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===(a=n.slice(0,4))||void 0===a?void 0:a.map((e,t)=>l.createElement(_,{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===(d=N.filter(e=>!e.isTerminateState))||void 0===d||null===(s=d.slice(4))||void 0===s?void 0:s.map((e,t)=>l.createElement(_,{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:()=>p(!S)}," ",v(S?"ES_COMMON_LESS":"ES_COMMON_MORE")," ")):null):null},D=e=>{let{onFilterChange:t,searchParams:n,paginationParms:o,tenantId:a,t:r}=e;const{data:d}=Digit.Hooks.fsm.useInbox(a,{...n,...o,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")}}),s=[{code:"ASSIGNED_TO_ME",name:r("ES_INBOX_ASSIGNED_TO_ME")+" (0)"},{code:"ASSIGNED_TO_ALL",name:`${r("ES_INBOX_ASSIGNED_TO_ALL")} (${(null==d?void 0:d.totalCount)||0})`}];return l.createElement(l.Fragment,null,l.createElement(i.RadioButtons,{onSelect:e=>t({uuid:{code:e.code}}),selectedOption:s.filter(e=>{var t;return e.code===(null==n||null===(t=n.uuid)||void 0===t?void 0:t.code)})[0],optionsKey:"name",options:s}))},N=e=>{var t,a,r,d;let{searchParams:s,paginationParms:u,onFilterChange:c,onSearch:E,...m}=e;const{t:v}=o.useTranslation(),S=n.useLocation(),p=Digit.UserService.hasAccess(["FSM_DSO"])||!1,_=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:[]}),h=()=>{if(_)return c()};return l.createElement(l.Fragment,null,(!p&&!_&&s||(null==A||null===(t=A.statuses)||void 0===t?void 0:t.length)>0||N)&&l.createElement("div",{className:"filter",style:{marginTop:_?"-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:h},v("ES_COMMON_CLEAR_ALL")),"desktop"===m.type&&l.createElement("span",{className:"clear-search",onClick:h},v("ES_COMMON_CLEAR_ALL")),"mobile"===m.type&&l.createElement("span",{onClick:m.onClose},l.createElement(i.CloseSvg,null))),l.createElement("div",null,!p&&!_&&s&&l.createElement(D,{onFilterChange:c,searchParams:s,paginationParms:u,tenantId:g,t:v}),l.createElement("div",null)),(null==A||null===(a=A.statuses)||void 0===a?void 0:a.length)>0||N?l.createElement("div",null,l.createElement("div",{className:"filter-label"},v("ES_INBOX_LOCALITY")),l.createElement(i.Localities,{selectLocality:e=>{c(_?{locality:[e]}:{locality:[...null==s?void 0:s.locality,e]})},tenantId:g,boundaryType:"revenue"}),l.createElement("div",{className:"tag-container"},null==s?void 0:s.locality.map((e,t)=>l.createElement(i.RemoveableTag,{key:t,text:e.i18nkey,onClick:()=>{c({locality:null==s?void 0:s.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(R,{onAssignmentChange:(e,t)=>{c(e.target.checked?{applicationStatus:[...null==s?void 0:s.applicationStatus,t]}:{applicationStatus:null==s?void 0:s.applicationStatus.filter(e=>t.name!==e.name)})},fsmfilters:s,mergedRoleDetails:A,statusMap:null==m||null===(d=m.applications)||void 0===d?void 0:d.statuses}):S.pathname.includes("fstp-fsm-request")?"":l.createElement(i.Loader,null)))),"mobile"===m.type&&m.onClose&&l.createElement(i.ActionBar,null,l.createElement(i.ApplyFilterBar,{submit:!1,labelLink:v("ES_COMMON_CLEAR_ALL"),buttonLink:v("ES_COMMON_FILTER"),onClear:h,onSubmit:()=>{"mobile"===m.type?E({delete:["applicationNos"]}):E()},style:{flex:1}})))},g=e=>{let{onAssignmentChange:t,value:n,applicationStatuses:o,areApplicationStatus:a}=e;return a?l.createElement(i.Dropdown,{option:o,optionKey:"name",selected:n,select:t}):l.createElement(i.Loader,null)},y=e=>{var r,s,u,c,E,m,v,S,p,_;let{onSearch:R,type:D,onClose:N,onTabChange:y,searchFields:T,searchParams:I,isInboxPage:C,selectedTab:O,matchedRoles:A}=e;const h=C?Digit.SessionStorage.get("vendor/inbox/searchParams"):Digit.SessionStorage.get("vendor/search/searchParams"),{t:b}=o.useTranslation(),f=n.useHistory(),{register:V,handleSubmit:L,reset:M,watch:w,control:k}=a.useForm({defaultValues:h||I}),[P,F]=t.useState(!1),x=window.Digit.Utils.browser.isMobile(),H=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1;function U(){const e=T.reduce((e,t)=>({...e,[null==t?void 0:t.name]:""}),{});M(e),C?Digit.SessionStorage.del("fsm/inbox/searchParams"):Digit.SessionStorage.del("fsm/search/searchParams"),R({})}const B=e=>null,Y=Digit.SessionStorage.get("User").info.type,G=[...null!=A&&null!==(r=A.wt)&&void 0!==r&&r.includes("WT_VENDOR")?["VENDOR"]:[],...null!=A&&null!==(s=A.wt)&&void 0!==s&&s.includes("WT_VENDOR")?["DRIVER","VEHICLE"]:[],...null!=A&&null!==(u=A.ekyc)&&void 0!==u&&u.includes("EKYC_VENDOR")?["SUPERVISOR"]:[],...null!=A&&null!==(c=A.ekyc)&&void 0!==c&&c.includes("EKYC_SUPERVISOR")||null!=A&&null!==(E=A.ekyc)&&void 0!==E&&E.includes("EKYC_VENDOR")?["SURVEYOR"]:[]];return l.createElement(l.Fragment,null,l.createElement("div",{className:"search-container"},l.createElement("div",{className:"search-complaint-container"},("mobile"===D||x)&&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(i.CloseSvg,null))),l.createElement("div",{className:"search-tabs-container"},l.createElement("div",null,l.createElement("button",{className:"VENDOR"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),y("VENDOR")}},b("ES_FSM_REGISTRY_INBOX_TAB_VENDOR")),(null==A||null===(m=A.wt)||void 0===m?void 0:m.includes("WT_VENDOR"))&&l.createElement("button",{className:"VEHICLE"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),y("VEHICLE")}},b("ES_FSM_REGISTRY_INBOX_TAB_VEHICLE")),(null==A||null===(v=A.wt)||void 0===v?void 0:v.includes("WT_VENDOR"))&&l.createElement("button",{className:"DRIVER"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),y("DRIVER")}},b("ES_FSM_REGISTRY_INBOX_TAB_DRIVER")),(null==A||null===(S=A.ekyc)||void 0===S?void 0:S.includes("EKYC_VENDOR"))&&l.createElement("button",{className:"SUPERVISOR"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),y("SUPERVISOR")}},b("ES_FSM_REGISTRY_INBOX_TAB_SUPERVISOR")),((null==A||null===(p=A.ekyc)||void 0===p?void 0:p.includes("EKYC_SUPERVISOR"))||(null==A||null===(_=A.ekyc)||void 0===_?void 0:_.includes("EKYC_VENDOR")))&&l.createElement("button",{className:"SURVEYOR"===O?"search-tab-head-selected":"search-tab-head",onClick:()=>{U(),y("SURVEYOR")}},b("ES_FSM_REGISTRY_INBOX_TAB_SURVEYOR"))),l.createElement("div",{className:"action-bar-wrap-registry"},l.createElement("div",{className:"search-add",onClick:()=>{F(!P)}},b("ES_VENDOR_REGISTRY_INBOX_HEADER_ADD"),l.createElement("div",{className:"search-add-icon"},l.createElement(i.AddIcon,{className:""}))),P&&l.createElement(i.Menu,{localeKeyPrefix:"ES_FSM_ACTION_CREATE",options:G,t:b,onSelect:function(e){const t=null==Y?void 0:Y.toLowerCase();switch(e){case"VENDOR":return f.push(`/digit-ui/${t}/vendor/registry/new-vendor`);case"VEHICLE":return f.push(`/digit-ui/${t}/vendor/registry/new-vehicle`);case"DRIVER":return f.push(`/digit-ui/${t}/vendor/registry/new-driver`);case"SUPERVISOR":return f.push(`/digit-ui/${t}/vendor/registry/new-supervisor`);case"SURVEYOR":return f.push(`/digit-ui/${t}/vendor/registry/new-surveyor`)}}}))),l.createElement("form",{onSubmit:L(e=>{e.mobileNumber||delete e.mobileNumber,R(e),"mobile"===D&&N()})},l.createElement("div",{className:H?"for-pt for-search flex-box":"flex-box",style:{gap:"16px"}},null==T?void 0:T.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(a.Controller,{render:e=>l.createElement(i.DatePicker,{date:e.value,onChange:e.onChange}),name:e.name,control:k,defaultValue:null});case"status":return l.createElement(a.Controller,{render:e=>l.createElement(g,{onAssignmentChange:e.onChange,value:e.value}),name:e.name,control:k,defaultValue:null});case"dropdown":return l.createElement(a.Controller,{render:t=>l.createElement(i.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:k,defaultValue:null});default:return l.createElement(i.TextInput,d({},e,{inputRef:V},V(e.name,{validate:B}),{watch:w,shouldUpdate:!0,placeholder:e.label}))}})(e))),l.createElement("div",{style:{display:"flex",justifyContent:"end",gap:"16px",alignItems:"center"}},"desktop"===D&&!x&&l.createElement("span",{className:"clear-search generic-button"},l.createElement(i.LinkLabel,{style:{},onClick:U},b("ES_COMMON_CLEAR_SEARCH"))),"desktop"===D&&!x&&l.createElement(i.SubmitBar,{className:"submit-bar-search",label:b("ES_COMMON_SEARCH"),submit:!0})))))))},T=e=>{if(!e)return{};if("object"==typeof e)return e;if("string"!=typeof e)return{};try{return JSON.parse(e)}catch(e){return{}}},I=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):[]},C=function(e,t){void 0===t&&(t=[]);const l=function(e){var t,l,n,i,o,a,r,d,s,u,c,E,m;void 0===e&&(e={});const v=e=>Array.isArray(e)?e.flatMap(I):I(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===(i=e)||void 0===i||null===(o=i.fillingpointmetadata)||void 0===o?void 0:o.fillingPointId,null===(a=e)||void 0===a?void 0:a.fillingPtName,null===(r=e)||void 0===r?void 0:r.filling_pt_name,null===(d=e)||void 0===d||null===(s=d.fillingPoint)||void 0===s?void 0:s.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=>I(e).some(e=>l.includes(e)))||null},O=function(e){var t,l,n,i,o,a,r,d,s,u,c,E,m,v,S,p,_,R,D,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===(i=e)||void 0===i||null===(o=i.dsoDetails)||void 0===o||null===(a=o.fillingPoint)||void 0===a?void 0:a.fillingPointName)||(null===(r=e)||void 0===r?void 0:r.fillingPointName)||(null===(d=e)||void 0===d||null===(s=d.dsoDetails)||void 0===s?void 0:s.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===(R=_.dsoDetails)||void 0===R?void 0:R.fillingPoint:null)||(null===(D=e)||void 0===D||null===(N=D.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"},A=function(e,t){var l,n,i,o,a,r,d;void 0===e&&(e={}),void 0===t&&(t=[]);const s=(null===(l=e)||void 0===l||null===(n=l.vendor)||void 0===n?void 0:n.id)||(null===(i=e)||void 0===i||null===(o=i.vendorData)||void 0===o?void 0:o.id)||(null===(a=e)||void 0===a?void 0:a.vendorId);return s&&(t.find(e=>(null==e?void 0:e.id)===s)||(null===(r=e)||void 0===r?void 0:r.vendor)||(null===(d=e)||void 0===d?void 0:d.vendorData))||null},h=function(e){var t,l,n,i;void 0===e&&(e={});const o=[...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===(i=e)||void 0===i?void 0:i.fillingPoints]].filter(Boolean),a=new Map;return o.forEach(e=>{const t=I(e)[0]||(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.id);t&&!a.has(t)&&a.set(t,e)}),Array.from(a.values())},b=(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=I(t);return n.length?l.filter(e=>{const t=function(e){var t,l,n,i,o,a,r,d,s,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===(i=n.additionalDetails)||void 0===i?void 0:i.fillingPointId,null===(o=e)||void 0===o||null===(a=o.additionalDetails)||void 0===a?void 0:a.fillingStationId,null===(r=e)||void 0===r||null===(d=r.fillingpointmetadata)||void 0===d?void 0:d.fillingPointId].filter(e=>null!=e&&""!==e).map(String).concat(I(null===(s=e)||void 0===s?void 0:s.fillingPoint),I(null===(u=e)||void 0===u?void 0:u.fillingPointDetail),I(null===(c=e)||void 0===c?void 0:c.fillingPointDetails))))}(e);return!t.length||t.some(e=>n.includes(e))}):l},f=function(e,t){var l,n,i,o;void 0===e&&(e={}),void 0===t&&(t=[]);const a=(null===(l=e)||void 0===l||null===(n=l.driverData)||void 0===n?void 0:n.id)||(null===(i=e)||void 0===i||null===(o=i.driver)||void 0===o?void 0:o.id);return a&&t.find(e=>(null==e?void 0:e.id)===a)||null},V=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)}},L=e=>{var a,d,s;const c=Digit.ULBService.getCurrentTenantId(),{t:E}=o.useTranslation(),m=n.useHistory(),v=e=>l.createElement("span",{className:"cell-text"},e),_=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1,[R,D]=t.useState([]),[g,I]=t.useState(null),[L,M]=t.useState([]),[w,k]=t.useState([]),[P,F]=t.useState(!1),[x,H]=t.useState(null),U=Digit.SessionStorage.get("User"),B=U.info.roles,Y=null===(a=U.info.type)||void 0===a?void 0:a.toLowerCase(),G=()=>{H(null),F(!1)},W=l.useMemo(()=>[{Header:E("WT_NAME"),accessor:"name",Cell:e=>{let{row:t}=e;return v(t.original.name)}},{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{let{row:t}=e;return v(t.original.mobileNumber)}},{Header:E("WT_EMAIL_ID"),accessor:"emailId",Cell:e=>{let{row:t}=e;return v(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),I({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(i.ViewsIcon,null)):E("CS_NA")}}],[E]),K=r.useQueryClient(),{data:$,refetch:z}=Digit.Hooks.fsm.useDsoSearch(c,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{enabled:!1}),{data:Z,refetch:q}=Digit.Hooks.fsm.useDriverSearch({tenantId:c,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"}}),{mutate:j}=Digit.Hooks.fsm.useVendorUpdate(c),{mutate:X}=Digit.Hooks.fsm.useUpdateVehicle(c),{mutate:Q}=Digit.Hooks.fsm.useDriverUpdate(c);t.useEffect(()=>{var t;D((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"})`}});M(e)}},[$]),t.useEffect(()=>{Z&&k((Z.driver||[]).map(e=>{var t;return{...e,displayName:`${e.name} (${(null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"N/A"})`}}))},[Z]);const J=()=>{I(null)},ee=(e,t)=>{D(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:V(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}/vendor/registry/new-vehicle`);case"DRIVER":return m.push(`/digit-ui/${Y}/vendor/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`)}},ie=l.useMemo(()=>"VENDOR"===e.selectedTab?(null==R?void 0:R.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,R,$]),{data:oe}=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:c,filters:{vendorIds:null==ie?void 0:ie.join(","),vendorId:null==ie?void 0:ie.join(",")}},{enabled:(null==ie?void 0:ie.length)>0}),{data:ae,isLoading:re}=Digit.Hooks.wt.useFillPointSearch({tenantId:c,filters:{limit:1e3}},{enabled:!0}),de=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,i;let{row:o}=e;return v(null!==(t=o.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=o.original)||void 0===n||null===(i=n.auditDetails)||void 0===i?void 0:i.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:i}=e,o=null===(t=i.original.dsoDetails)||void 0===t?void 0:t.additionalDetails;if("string"==typeof o)try{o=JSON.parse(o)}catch(e){console.error("Error parsing additionalDetails:",e),o={}}const a=(null===(n=o)||void 0===n?void 0:n.serviceType)||"N/A";return l.createElement("div",null,a)}},{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,o;let{row:a}=t;return l.createElement(i.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=a.original)||void 0===n||null===(o=n.dsoDetails)||void 0===o?void 0:o.status),onChange:()=>(t=>{var l,n,i,o;let a=t.original.dsoDetails;const r={vendor:{...a,status:"ACTIVE"===(null==a?void 0:a.status)?"DISABLED":"ACTIVE",owner:{...a.owner,gender:(null==a||null===(l=a.owner)||void 0===l?void 0:l.gender)||"OTHER",dob:(null==a||null===(n=a.owner)||void 0===n?void 0:n.dob)||new Date("1/1/1970").getTime(),emailId:(null==a||null===(i=a.owner)||void 0===i?void 0:i.emailId)||"abc@egov.com",relationship:(null==a||null===(o=a.owner)||void 0===o?void 0:o.relationship)||"OTHER"}}};j(r,{onError:(e,t)=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{I({key:"success",action:"VENDOR"}),K.invalidateQueries("DSO_SEARCH"),e.refetchData(),setTimeout(J,3e3)}})})(a),name:"switch-"+a.id})}},{Header:E("ES_VENDOR_ADDITIONAL_DETAILS"),disableSortBy:!0,Cell:e=>{var t,i;let{row:o}=e;const a=null===(t=o.original)||void 0===t?void 0:t.id;if(!oe)return l.createElement("span",null,"Loading...");const r=null!==(null===(i=o.original)||void 0===i?void 0:i.vendorAdditionalDetails);return l.createElement(n.Link,{to:r?`/digit-ui/${Y}/vendor/registry/additionaldetails/info?vendorId=`+a:`/digit-ui/${Y}/vendor/registry/additionaldetails/vendor-details?vendorId=`+a},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:i}=e;return l.createElement("div",null,(null===(t=i.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,i;let{row:o}=e;return v(null!==(t=o.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=o.original)||void 0===n||null===(i=n.auditDetails)||void 0===i?void 0:i.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(i.Dropdown,{className:"fsm-registry-dropdown",selected:A(n.original,L),option:L,select:t=>((t,l)=>{const n=t.original,i=null==n?void 0:n.vendor;if(null==l||!l.id||(null==i?void 0:i.id)===(null==l?void 0:l.id))return;const o={...n,vendorVehicleStatus:"ACTIVE",fillingPoint:null,driverData:null,driver:null};delete o.vendor,delete o.popup,delete o.driver;const a=()=>{const t=Array.isArray(null==l?void 0:l.vehicles)?[...l.vehicles]:[],i=t.findIndex(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id));i>-1?t[i]={...t[i],...o,vendorVehicleStatus:"ACTIVE"}:t.push(o);const a={...l,vehicles:t};j(le(l,t),{onError:e=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:()=>{ee(null==n?void 0:n.id,{vendor:a,fillingPoint:null,driverData:null,driver:null}),I({key:"success",action:"VEHICLE"}),K.invalidateQueries("DSO_SEARCH"),K.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchData(),e.refetchVendor&&e.refetchVendor(),setTimeout(J,3e3)}})};if(null!=i&&i.id){const e=Array.isArray(null==i?void 0:i.vehicles)?i.vehicles.map(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id)?{...e,vendorVehicleStatus:"INACTIVE"}:e):[];j(le(i,e),{onError:e=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:a})}else a()})(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,i=n.original.additionalDetails;if("string"==typeof i)try{i=JSON.parse(i)}catch(e){console.error("Error parsing additionalDetails:",e),i={}}const o=(null===(t=i)||void 0===t?void 0:t.serviceType)||"N/A";return l.createElement("div",null,o)}},{Header:E("WT_FILLING_POINT"),accessor:e=>O(e),id:"fillingPoint",minWidth:250,Cell:t=>{let{row:n}=t;const o=A(n.original,L),a=h(o);return l.createElement(i.Dropdown,{className:"fsm-registry-dropdown",selected:C(n.original,a),option:a,select:t=>((t,l)=>{const n=te(t.original,{fillingPoint:l});X(n,{onError:e=>{var t,l,n,i;I({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===(i=n[0])||void 0===i?void 0:i.message)||"Failed to map filling point"}),setTimeout(J,5e3)},onSuccess:()=>{var n;const i=A(t.original,L),o=b(i,l),a=f(t.original,o);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)},...a?{}:{driverData:null,driver:null}}),I({key:"success",label:"Filling point mapped successfully"}),K.invalidateQueries("FSM_VEICLES_SEARCH"),K.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:!o||!a.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 o=A(n.original,L),a=C(n.original,h(o)),r=b(o,a);return l.createElement(i.Dropdown,{className:"fsm-registry-dropdown",selected:f(n.original,r),option:r,select:t=>((t,l)=>{const n=te(t.original,{driverData:l});X(n,{onError:(e,t)=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(n,i)=>{var o;ee(null===(o=t.original)||void 0===o?void 0:o.id,{driverData:l}),I({key:"success",action:"VEHICLE"}),K.invalidateQueries("FSM_VEICLES_SEARCH"),K.invalidateQueries("DSO_SEARCH"),e.refetchData(),e.refetchVendor(),setTimeout(J,3e3)}})})(n,t),optionKey:"displayName",t:E,style:{textAlign:"left",width:"100%",minWidth:"250px"},disable:!a||!r.length})}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let{row:o}=t;return l.createElement(i.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=o.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"});X(n,{onError:(e,t)=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{I({key:"success",action:"VEHICLE"}),K.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(J,3e3)}})})(o),name:"switch-"+o.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:i}=e;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/driver-details/`+i.original.id},l.createElement("div",null,(null===(t=i.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:i}=e;return l.createElement("div",null,(null===(t=i.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,i;let{row:o}=e;return v(null!==(t=o.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=o.original)||void 0===n||null===(i=n.auditDetails)||void 0===i?void 0:i.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(i.Dropdown,{className:"fsm-registry-dropdown",selected:(null==L?void 0:L.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:L,select:t=>((t,l)=>{let n=t.original,i=null==n?void 0:n.vendor,o=l;if(delete n.vendor,n.vendorDriverStatus="ACTIVE",i){const e=null==i?void 0:i.drivers;e.splice(e.findIndex(e=>e.id===n.id),1)}const a={vendor:{...o,drivers:o.drivers?[...o.drivers,n]:[n]}};j(a,{onError:(e,t)=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{I({key:"success",action:"VENDOR"}),K.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:o}=t;return l.createElement(i.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=o.original)||void 0===n?void 0:n.status),onChange:()=>(t=>{var l,n,i,o;let a=t.original;const r={driver:{...a,status:"ACTIVE"===(null==a?void 0:a.status)?"DISABLED":"ACTIVE",owner:{...a.owner,gender:(null==a||null===(l=a.owner)||void 0===l?void 0:l.gender)||"OTHER",dob:(null==a||null===(n=a.owner)||void 0===n?void 0:n.dob)||new Date("1/1/1970").getTime(),emailId:(null==a||null===(i=a.owner)||void 0===i?void 0:i.emailId)||"abc@egov.com",relationship:(null==a||null===(o=a.owner)||void 0===o?void 0:o.relationship)||"OTHER"}}};Q(r,{onError:(e,t)=>{I({key:"error",action:e}),setTimeout(J,5e3)},onSuccess:(t,l)=>{I({key:"success",action:"DRIVER"}),K.invalidateQueries("FSM_DRIVER_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(J,3e3)}})})(o),name:"switch-"+o.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 i;let{row:o}=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"}/`+o.original.id},l.createElement("div",null,(null===(i=o.original.owner)||void 0===i?void 0:i.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: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,""+(i.original.name||"N/A")))))}},..."SURVEYOR"===e.selectedTab?[{Header:E("ES_FSM_REGISTRY_INBOX_SUPERVISOR_NAME"),accessor:e=>{var t;return(null===(t=e.reportingManager)||void 0===t?void 0:t.name)||"NA"},Cell:e=>{var t,n;let{row:i}=e;return l.createElement("div",null,(null===(t=i.original)||void 0===t||null===(n=t.reportingManager)||void 0===n?void 0:n.name)||"NA")}}]:[],{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{var t,n;let{row:i}=e;return l.createElement("div",null,(null===(t=i.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,i;let{row:o}=e;return v(null!==(t=o.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=o.original)||void 0===n||null===(i=n.auditDetails)||void 0===i?void 0:i.createdTime):"")}},{Header:E("SUPERVISOR"===e.selectedTab?"ES_VENDOR_SUPERVISOR_AGENCY_NAME":"ES_VENDOR_SURVEYOR_AGENCY_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(i.Dropdown,{className:"fsm-registry-dropdown",selected:(null==L?void 0:L.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:L,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:o}=t;return l.createElement(i.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=o.original)||void 0===n?void 0:n.status),onChange:()=>{console.log("Updating status for",e.selectedTab,o.original.id)},name:"switch-"+o.id})}}];default:return[]}},[e.selectedTab,L,w,R,oe,(null==ae?void 0:ae.fillingPoints)||[],E]),se=l.useMemo(()=>{switch(e.selectedTab){case"VENDOR":return[{Header:E("ES_VENDOR_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,i,o;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===(i=e.dsoDetails)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.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=>O(e)},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t,l;return(null===(t=T(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,i,o,a,r,d;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===(i=e.vendor)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(a=e.vendorData)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendorData)||void 0===r||null===(d=r.owner)||void 0===d?void 0:d.mobileNumber)||"NA"})`}},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t;return(null===(t=T(null==e?void 0:e.additionalDetails))||void 0===t?void 0:t.serviceType)||"N/A"}},{Header:E("WT_FILLING_POINT"),exportAccessor:e=>O(e)},{Header:E("ES_FSM_REGISTRY_SELECT_DRIVER"),exportAccessor:e=>{var t,l,n,i,o,a;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===(i=n.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(o=e.driver)||void 0===o||null===(a=o.owner)||void 0===a?void 0:a.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,i,o,a,r,d;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===(i=e.vendorData)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(d=r.owner)||void 0===d?void 0:d.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_SUPERVISOR_NAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.reportingManager)||void 0===t?void 0:t.name)||"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,i,o,a,r,d;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===(i=e.vendorData)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(d=r.owner)||void 0===d?void 0:d.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,i,o,a,r,d;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===(i=e.vendorData)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(d=r.owner)||void 0===d?void 0:d.mobileNumber)||"NA"}`}},{Header:E("ES_VENDOR_SUPERVISOR_AGENCY_NAME"),exportAccessor:e=>{var t,l,n,i,o,a,r,d;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===(i=e.vendorData)||void 0===i||null===(o=i.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(d=r.owner)||void 0===d?void 0:d.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(R)},[R]);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(i.Loader,null));else if(0===R.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(i.Card,{className:"flex-center flex-box"},l.createElement("div",{style:{marginTop:"50px",marginBottom:"25px"}},E(t)),l.createElement(i.SubmitBar,{className:"",label:E(n),onSubmit:ne}))}else R.length>0&&(ce=l.createElement(p,{className:"table registryTable",t:E,data:R,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:ue,csvExportColumns:se,csvExportFileName:`vendor-${String(e.selectedTab||"registry").toLowerCase()}-inbox`}));const Ee=B.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 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(N,{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",display:"flex",flexDirection:"column",gap:"12px"}},l.createElement(y,{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)),g&&l.createElement(i.Toast,{error:"error"===g.key,label:E(g.label?g.label:"success"===g.key?`ES_FSM_REGISTRY_${g.action}_DISABLE_SUCCESS`:g.action),onClose:J}),P&&l.createElement(i.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(i.MdClose,null)),actionCancelLabel:E("CS_COMMON_CLOSE"),actionCancelOnSubmit:G,hideSubmit:!0,formId:"modal-action"},l.createElement("div",{style:{padding:"16px"}},(null==x||null===(d=x.dsoDetails)||void 0===d||null===(s=d.vendorWorkOrder)||void 0===s?void 0:s.length)>0?l.createElement(i.Table,{t:E,data:x.dsoDetails.vendorWorkOrder,columns:W,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}=o.useTranslation(),t=n.useLocation(),{path:a}=n.useRouteMatch(),r=Digit.ComponentRegistryService.getComponent("SearchVendor"),s=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"),R=Digit.ComponentRegistryService.getComponent("VehicleDetails"),D=Digit.ComponentRegistryService.getComponent("EditDriver"),N=Digit.ComponentRegistryService.getComponent("EditVehicle");return l.createElement(n.Switch,null,l.createElement(i.AppContainer,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(i.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(i.ArrowLeft,{className:"icon"}),e("CS_COMMON_BACK")),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const l=t.pathname;let n=[{icon:i.HomeIcon,path:"/digit-ui/citizen"},{label:e("CITIZEN_VENDOR"),path:a+"/citizen-Vendor"}];if(l.includes("/inbox")){let t="ES_COMMON_INBOX";l.includes("/mt/inbox")&&(n=[{icon:i.HomeIcon,path:"/digit-ui/citizen"},{label:e("ACTION_TEST_MT"),path:a+"/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/")?a+"/mt/inbox":a+"/inbox"}),n.push({label:e("WT_BOOKING_DETAILS")}));const o=[{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 o&&n.push({label:e(o.label)}),n})()}),l.createElement(i.PrivateRoute,{path:a+"/search-vendor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"normal"},l.createElement(r,d({},e,{parentRoute:a}))),exact:!0}),l.createElement(i.PrivateRoute,{path:a+"/registry/vendor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(s,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/driver-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(p,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/modify-driver/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(D,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/vehicle-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(R,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/modify-vehicle/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(N,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/new-driver",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(S,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/new-vehicle",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(_,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/new-supervisor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(u,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/additionaldetails",component:e=>{const t=e.location.pathname.includes("/info");return l.createElement(i.LayoutWrapper,{layoutClass:t?"action":"normal"},l.createElement(v,d({},e,{parentRoute:a})))}}),l.createElement(i.PrivateRoute,{path:a+"/registry/supervisor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(c,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/new-surveyor",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(E,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:a+"/registry/surveyor-details/:id",component:e=>l.createElement(i.LayoutWrapper,{layoutClass:"action"},l.createElement(m,d({},e,{parentRoute:a})))}),l.createElement(i.PrivateRoute,{path:""+a,component:()=>Digit.UserService.hasAccess(["WT_VENDOR","EKYC_VENDOR","EKYC_SUPERVISOR"])?l.createElement("div",{style:{display:"flex",gap:"24px",flexWrap:"wrap",width:"100%",padding:"8px 0"}},l.createElement(i.CitizenHomeCard,{header:e("TITLE_VENDOR_MANAGEMENT"),links:[{i18nKey:e("SEARCH_VENDOR"),link:"/digit-ui/citizen/vendor/search-vendor"}],Icon:()=>l.createElement(i.PropertyHouse,{className:"fill-path-primary-main"})})):l.createElement(n.Redirect,{to:{pathname:"/digit-ui/citizen/login",state:{from:""+a,role:"CITIZEN_VENDOR"}}}),exact:!0}))))},w=e=>{let{t:t,title:n}=e;return l.createElement("div",{className:"confirmation_box"},l.createElement("span",null,t(""+n)," "))},k=e=>l.createElement("h1",{className:"heading-m"},e.label),P=()=>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"})),F=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(P,null)),{DatePicker:x}=require("@djb25/digit-ui-react-components"),H=function(e,t,n,i){return void 0===i&&(i=!1),[{head:e("ES_VENDOR_SUPERVISOR_BASIC_DETAILS"),body:[{label:e("ES_VENDOR_SUPERVISOR_FULL_NAME"),isMandatory:!0,type:"text",disable:i,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:e("ES_VENDOR_SUPERVISOR_MOBILE_NUMBER"),isMandatory:!0,type:"mobileNumber",disable:i,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:e("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:e("ES_VENDOR_SUPERVISOR_GENDER"),isMandatory:!0,type:"component",key:"gender",component:"SelectGender"},{label:e("ES_FSM_REGISTRY_NEW_FATHER_NAME"),isMandatory:!0,type:"text",populators:{name:"fatherOrHusbandName",validation:{required:!0},className:"payment-form-text-input-correction"}},{label:e("ES_FSM_REGISTRY_NEW_RELATIONSHIP"),isMandatory:!0,type:"component",key:"relationship",component:"SelectEkycDropdown",populators:{name:"relationship",options:[{code:"FATHER",name:"ES_COMMON_RELATION_FATHER"},{code:"HUSBAND",name:"ES_COMMON_RELATION_HUSBAND"},{code:"OTHER",name:"ES_COMMON_RELATION_OTHER"}],optionsKey:"name"}},{label:e("ES_FSM_REGISTRY_NEW_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(x,d({onChange:e.onChange,date:e.value},t))}},{label:e("ES_FSM_REGISTRY_NEW_CORRESPONDENCE_ADDRESS"),isMandatory:!0,type:"text",populators:{name:"correspondenceAddress",validation:{required:!0},className:"payment-form-text-input-correction"}},{label:e("ES_VENDOR_SUPERVISOR_ASSIGNED_ZONE"),isMandatory:!0,type:"component",key:"assignedZone",component:"SelectEkycDropdown",populators:{name:"assignedZone",options:[{code:"ZONE-01",name:"ZONE-01"},{code:"ZONE-02",name:"ZONE-02"},{code:"ZONE-03",name:"ZONE-03"},{code:"ZONE-04",name:"ZONE-04"},{code:"ZONE-05",name:"ZONE-05"}],optionsKey:"name"}},{label:e("ES_VENDOR_SUPERVISOR_DESCRIPTION"),isMandatory:!1,type:"text",populators:{name:"description",className:"payment-form-text-input-correction"}}]}]},U=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"})),Y=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(B,null)),{DatePicker:G}=require("@djb25/digit-ui-react-components"),W=function(e,t,n,i){return[{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:e("ES_VENDOR_SURVEYOR_GENDER"),isMandatory:!0,type:"component",key:"gender",component:"SelectGender"},{label:e("ES_FSM_REGISTRY_NEW_FATHER_NAME"),isMandatory:!0,type:"text",populators:{name:"fatherOrHusbandName",validation:{required:!0},className:"payment-form-text-input-correction"}},{label:e("ES_FSM_REGISTRY_NEW_RELATIONSHIP"),isMandatory:!0,type:"component",key:"relationship",component:"SelectEkycDropdown",populators:{name:"relationship",options:[{code:"FATHER",name:"ES_COMMON_RELATION_FATHER"},{code:"HUSBAND",name:"ES_COMMON_RELATION_HUSBAND"},{code:"OTHER",name:"ES_COMMON_RELATION_OTHER"}],optionsKey:"name"}},{label:e("ES_FSM_REGISTRY_NEW_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(G,d({onChange:e.onChange,date:e.value},t))}},{label:e("ES_FSM_REGISTRY_NEW_CORRESPONDENCE_ADDRESS"),isMandatory:!0,type:"text",populators:{name:"correspondenceAddress",validation:{required:!0},className:"payment-form-text-input-correction"}},{label:e("ES_VENDOR_SURVEYOR_DESCRIPTION"),isMandatory:!1,type:"text",populators:{name:"description",className:"payment-form-text-input-correction"}}]}]},K=e=>l.createElement("h1",{className:"heading-m"},e.label),$=()=>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($,null)),Z=e=>{let{jumpTo:t}=e;const{t:a}=o.useTranslation(),r=n.useHistory();return l.createElement(i.LinkButton,{label:a("CS_COMMON_CHANGE"),className:"check-page-link-button",onClick:function(){r.push(t)}})},q=e=>{const{t:t}=o.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")},j={padding:"4px 0px",justifyContent:"space-between"},X=e=>{var t,n;return l.createElement(i.Banner,{message:q(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"),ee=e=>l.createElement("h1",{className:"heading-m"},e.label),te=()=>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"})),le=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(te,null)),{DatePicker:ne}=require("@djb25/digit-ui-react-components"),ie=e=>l.createElement("h1",{className:"heading-m"},e.label),oe=()=>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(oe,null)),re={VendorDetails:e=>{var n,o,r,d;let{t:s,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===(o=m.ownerKey)||void 0===o?void 0:o.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),R=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].altMobileNumber||(null==m||null===(d=m.ownerKey)||void 0===d?void 0:d.altmobileNumber)||"",[D,N]=t.useState(""),[g,y]=t.useState(""),[T,I]=t.useState(""),[C,O]=t.useState(""),[A,h]=t.useState(),[b,f]=t.useState(""),[V,L]=t.useState(""),[M,w]=t.useState(""),[k,P]=t.useState(""),[F,x]=t.useState(""),[H,U]=t.useState(""),[B,Y]=t.useState(""),[G,W]=t.useState(""),[K,$]=t.useState(""),[z,Z]=t.useState(""),[q,j]=t.useState(""),[X,Q]=t.useState(""),[J,ee]=t.useState("");t.useEffect(()=>{11!==b.length||C||A||q?11===b.length&&C&&A?(O(C),h(A),j(q)):(O(""),h(""),j("")):fetch("https://ifsc.razorpay.com/"+b).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH&&e.MICR&&(O(e.BANK),h(e.BRANCH),j(e.MICR))}).catch(()=>{})},[b]);const te=Digit.ULBService.getCurrentTenantId(),{control:le}=a.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 ie=()=>{let e,t=m.ownerKey&&m.ownerKey[0];"citizen"===E?(e={...t,applicantName:S,mobileNumber:_,altMobileNumber:R,emailId:p},c(u.key,{...m[u.key],...e},!1,0)):(e={...t,VendorCategory:D,name:T,VendorId:g,Bank:C,BankbranchName:A,IFSC:b,AccountNo:V,PanNo:M,GstNo:k,GstState:F,RegistrationNo:H,EpfNo:B,EsiNo:G,VendorType:K,Status:z,micrNo:q,PhoneNo:X,ContactPerson:J},c(u.key,e,!1,0))};return t.useEffect(()=>{"citizen"===E&&ie()},[D,g,T,C,A,b,V,M,k,F,H,B,G,K,z,q,X,J,E]),l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{timeLine:[{actions:s("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:s("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:s("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(i.FormStep,{config:u,onSelect:ie,t:s,className:"formcomposer-grid-container-form"},l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,{className:"card-label-smaller"},l.createElement(i.CustomTooltip,{label:""+s("IFSC_CODE"),isMandatory:!1,message:s("INVALID_IFSC_CODE_ERROR_MESSAGE")})),l.createElement(i.TextInput,{t:s,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&&f(t)},style:{width:"100%"},maxLength:11,ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[A-Z]{4}0[A-Z0-9]{6}$",type:"text",title:s("INVALID_IFSC_CODE_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("VENDOR_BANK_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(i.TextInput,{t:s,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(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("VENDOR_BANK_BRANCH_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"BankbranchName",value:A,style:{width:"100%"},placeholder:"Bank Branch Name Auto Select",onChange:function(e){h(e.target.value)},disabled:!1})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("VENDOR_MICR_NO")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"MicrNo",value:q,style:{width:"100%"},placeholder:"MICR No",onChange:j,disabled:!1})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("ACCOUNT_NO")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"AccountNo",value:V,onChange:function(e){L(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"[0-9]{9,18}",type:"text",title:s("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("PHONE_NO")),l.createElement(i.MobileNumber,{value:X,name:"PhoneNo",onChange:Q,style:{width:"100%"}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("CONTACT_PERSON")),l.createElement(i.TextInput,{t:s,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:s("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("PAN_NO")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"PanNo",value:M,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:s("INVALID_PAN_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("GST_NO")),l.createElement(i.TextInput,{t:s,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:s("INVALID_GST_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("GST_REGISTERED_STATE/UT")),l.createElement(i.TextInput,{t:s,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:s("PT_NAME_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("REGISTRATION_NO")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"RegistrationNo",value:H,onChange:function(e){U(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:s("INVALID_REGISTRATION_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("EPF_NO")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"EpfNo",value:B,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:s("INVALID_EPF_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,""+s("ESI_NO")),l.createElement(i.TextInput,{t:s,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"EsiNo",value:G,onChange:function(e){W(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:s("INVALID_ESI_NO_ERROR_MESSAGE")}})),l.createElement(i.LabelFieldPair,null,l.createElement("div",null,s("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"}},""+s("AST_CLASSIFICATION_ASSET")))),l.createElement(a.Controller,{control:le,name:"VendorType",defaultValue:K,rules:{required:s("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(i.Dropdown,{selected:K,select:$,option:[{i18nKey:"Supplier",code:"SUPPLIER"},{i18nKey:"Contractor",code:"CONTRACTOR"}],optionKey:"i18nKey",placeholder:"Select",t:s})})),l.createElement(i.LabelFieldPair,null,l.createElement("div",null,s("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(a.Controller,{control:le,name:"VendorCategory",defaultValue:D,rules:{required:s("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(i.Dropdown,{selected:D,select:N,option:[{i18nKey:"Firm",code:"FIRM"},{i18nKey:"Individual",code:"Individual"}],optionKey:"i18nKey",placeholder:"Select",t:s})})),l.createElement(i.LabelFieldPair,null,l.createElement("div",null,s("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"}},""+s("AST_CLASSIFICATION_ASSET")))),l.createElement(a.Controller,{control:le,name:"Status",defaultValue:z,rules:{required:s("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(i.Dropdown,{selected:z,select:Z,option:[{i18nKey:"Active",code:"ACTIVE"},{i18nKey:"Inactive",code:"INACTIVE"}],optionKey:"i18nKey",placeholder:"Select",t:s})})))))},VendorDocuments:e=>{var n;let{t:o,config:a,onSelect:r,formData:d}=e;const[s,c]=t.useState([null]),[E,m]=t.useState([null]),[v,S]=t.useState(null),[p,_]=t.useState(1),[R,D]=(Digit.ULBService.getStateId(),Digit.ULBService.getStateId(),t.useState((null==d||null===(n=d.documents)||void 0===n?void 0:n.documents)||[]));return t.useEffect(()=>{var e;null!=d&&null!==(e=d.documents)&&void 0!==e&&e.documents&&(m(d.documents.documents),_(d.documents.documents.length),c(new Array(d.documents.documents.length).fill(null)))},[d]),l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{timeLine:[{actions:o("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:o("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:o("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:1,showFinalStep:!1}),l.createElement(i.FormStep,{t:o,config:a,onSelect:()=>{let e;e={...d.documents,documents:E.filter(e=>null!==e)},r(a.key,e)},onSkip:()=>r(),isDisabled:E.some(e=>null===e)&&s.some(e=>null===e)},s.map((e,t)=>l.createElement(i.LabelFieldPair,{key:t},l.createElement(i.CardLabel,{className:"card-label-smaller"},o("VENDOR_ID")+(0!==t?t:"")),l.createElement("div",{className:"field",style:{display:"flex",alignItems:"center",paddingBottom:"10px"}},l.createElement(i.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(o("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(o("CS_FILE_UPLOAD_ERROR"))})},function(){S(o("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 "+o("CS_ACTION_FILEUPLOADED"):o("CS_ACTION_NO_FILEUPLOADED"),textStyles:{width:"100%"},inputStyles:{width:"280px"},accept:".pdf, .jpeg, .jpg, .png",buttonType:"button",error:!E[t]})))),v&&l.createElement(i.Toast,{label:v,onClose:()=>S(null),error:!0})))},ServiceDoc:e=>{var t;let{t:n,config:o,onSelect:a}=e;const r=Digit.ULBService.getStateId(),d=null!=o&&o.isMutation?["MutationDocuments"]:"Documents",{isLoading:s,data:u={}}=Digit.Hooks.asset.useAssetDocumentsMDMS(r,"ASSET",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&&l.createElement(i.Loader,null),Array.isArray(c)&&c.map((e,t)=>{let{code:o,dropdownData:a}=e;return l.createElement(i.Card,{key:t},l.createElement("div",null,l.createElement("h3",{style:{margin:0}},t+1,". ",n(m(o,".","_")))),a.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(i.ActionBar,null,l.createElement(i.SubmitBar,{label:n("COMMON_NEXT"),onSubmit:a})))},AddVendor:e=>{const a=Digit.ULBService.getCurrentTenantId(),{t:r}=o.useTranslation(),s=n.useHistory(),[u,c]=t.useState(1),[m,v]=t.useState(null),[,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:R}=Digit.Hooks.fsm.useVendorCreate(a);t.useEffect(()=>{S(!1),_(),p()},[]);const D={serviceType:{code:"WT",name:"WT",i18nKey:"WT"},tripData:{noOfTrips:1,amountPerTrip:null,amount:null}},[N,g]=t.useState(D),y=function(e,t,n){var o,a;void 0===t&&(t=!1),void 0===n&&(n={});const r="EKYC"===(null===(o=n)||void 0===o||null===(a=o.serviceType)||void 0===a?void 0:a.code);return[{head:"ES_VRNDOR_NEW_VENDOR_DETAILS",isCollapsible:!0,isDefaultOpen:!0,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"}},...r?[{label:"ES_VENDOR_CONTRACT_START_DATE",isMandatory:!0,type:"custom",key:"contractStartDate",populators:{name:"contractStartDate",validation:{required:!0},component:(e,t)=>l.createElement(i.DatePicker,d({onChange:e.onChange,date:e.value},t))}},{label:"ES_VENDOR_CONTRACT_END_DATE",isMandatory:!0,type:"custom",key:"contractEndDate",populators:{name:"contractEndDate",validation:{required:!0},component:(e,t)=>l.createElement(i.DatePicker,d({onChange:e.onChange,date:e.value},t))}},{label:"ES_VENDOR_ZONE",isMandatory:!0,type:"component",key:"zoneIds",component:"SelectEkycZones"},{label:"ES_FSM_REGISTRY_NEW_OWNER_NAME",isMandatory:!0,type:"text",populators:{name:"ownerName",validation:{required:!0,pattern:/^[A-Za-z\s.,/]+$/},error:e("FSM_REGISTRY_INVALID_NAME"),className:"payment-form-text-input-correction"}},{label:"ES_FSM_REGISTRY_NEW_GENDER",isMandatory:!0,type:"component",key:"gender",component:"SelectEkycDropdown",populators:{name:"gender",options:[{code:"MALE",name:"ES_COMMON_GENDER_MALE"},{code:"FEMALE",name:"ES_COMMON_GENDER_FEMALE"},{code:"OTHER",name:"ES_COMMON_GENDER_OTHER"}],optionsKey:"name"}},{label:"ES_FSM_REGISTRY_NEW_DOB",isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(i.DatePicker,d({onChange:e.onChange,date:e.value},t,{max:E((new Date).setFullYear((new Date).getFullYear()))}))}}]:[]]},{isCreateConnection:!0,className:"new-application-card",body:[{type:"component",key:"propertyAddress",component:"CPTPropertyLocationDetails",withoutLabel:!0,props:{hidePropertySearch:!0,hideZRO:!0}}]}]}(r,!1,N),T=()=>{v(null)};return l.createElement(l.Fragment,null,l.createElement(i.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(i.FormComposer,{config:y,userType:"employee",onFormValueChange:(e,t)=>{var l,n,i,o;const a=(null==t||null===(l=t.zoneIds)||void 0===l?void 0:l.map(e=>{var t;return null==e||null===(t=e[1])||void 0===t?void 0:t.code}))||[],d=(null==N?void 0:N.zoneIds)||[],s=a.join(",")!==d.join(",");((null==t||null===(n=t.serviceType)||void 0===n?void 0:n.code)!==(null==N||null===(i=N.serviceType)||void 0===i?void 0:i.code)||s)&&g(e=>({...e,serviceType:null==t?void 0:t.serviceType})),s&&g(e=>({...e,zoneIds:a})),(null==t?void 0:t.vendorName)&&(null==t?void 0:t.phone)&&(null==t||null===(o=t.serviceType)||void 0===o?void 0:o.code)?1===u&&(c(2),setTimeout(()=>{const e=Array.from(document.querySelectorAll(".collapsible-card-title")).find(e=>e.textContent.includes(r("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(r("ES_VRNDOR_NEW_VENDOR_DETAILS")));e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100))},label:r("ES_COMMON_APPLICATION_SUBMIT"),onSubmit:e=>{var t,l,n,i,o,r,d,u,c,E,m,S,p,_;console.log("-=-=-=-=-=-==-",e);const D=e,N=null==D?void 0:D.propertyAddress,g=null==N?void 0:N.pincode,y=null==N?void 0:N.streetName,I=null==N?void 0:N.houseNo,C=null==N?void 0:N.landmark,O=null==N||null===(t=N.city)||void 0===t?void 0:t.name,A=null==N||null===(l=N.city)||void 0===l?void 0:l.name,h=null==N||null===(n=N.city)||void 0===n?void 0:n.name,b=null==N||null===(i=N.city)||void 0===i?void 0:i.name,f=null==N||null===(o=N.locality)||void 0===o?void 0:o.code,V=null==N||null===(r=N.locality)||void 0===r?void 0:r.name,L=null==N?void 0:N.subLocality,M=null==D?void 0:D.vendorName,w=null==D||null===(d=D.plotNo)||void 0===d?void 0:d.trim(),k=null==D||null===(u=D.buildingName)||void 0===u?void 0:u.trim(),P=null==D?void 0:D.emailId,F=null==D?void 0:D.phone,x="EKYC"===(null==D||null===(c=D.serviceType)||void 0===c?void 0:c.code);let H={tenantId:a,name:M,agencyType:"ULB",paymentPreference:"post-service",address:{tenantId:a,landmark:C,doorNo:I,plotNo:w,street:y,city:O,district:h,region:b,state:A,country:"india",pincode:g,buildingName:k,locality:{code:f||"",name:V||"",label:"Locality",area:L||""},ward:wardCode?{code:wardCode,name:wardName}:void 0,geoLocation:{latitude:(null==D||null===(E=D.address)||void 0===E?void 0:E.latitude)||28.6139,longitude:(null==D||null===(m=D.address)||void 0===m?void 0:m.longitude)||77.209}},owner:{tenantId:"dl",name:(null==D?void 0:D.ownerName)||M,fatherOrHusbandName:(null==D?void 0:D.fatherOrHusbandName)||M,relationship:(null==D||null===(S=D.relationship)||void 0===S?void 0:S.code)||"OTHER",gender:(null==D||null===(p=D.gender)||void 0===p?void 0:p.code)||"MALE",dob:null!=D&&D.dob?(new Date(D.dob).getTime()/1e3).toString():"915148800",emailId:P||"",mobileNumber:F},additionalDetails:{serviceType:x?"ekyc":null==D||null===(_=D.serviceType)||void 0===_?void 0:_.code},vehicles:[],drivers:[],source:x?"eKYC Portal":"WhatsApp"};var U,B;x&&(H={...H,zoneIds:(null==D||null===(U=D.zoneIds)||void 0===U?void 0:U.map(e=>{var t;return null==e||null===(t=e[1])||void 0===t?void 0:t.code}))||[],clusterIds:(null==D||null===(B=D.clusterIds)||void 0===B?void 0:B.map(e=>{var t;return null==e||null===(t=e[1])||void 0===t?void 0:t.code}))||[],contractStartDate:D.contractStartDate?new Date(D.contractStartDate).getTime():null,contractEndDate:D.contractEndDate?new Date(D.contractEndDate).getTime():null}),console.log(H);const Y={vendor:H};x&&(Y.RequestInfo={apiId:"Rainmaker",msgId:"ekyc-vendor-create"}),R(Y,{onError:e=>{v({key:"error",action:e}),setTimeout(T,5e3)},onSuccess:(e,t)=>{v({key:"success",action:"ADD_VENDOR"}),setTimeout(()=>{T(),s.push("/digit-ui/employee/vendor/search-vendor")},2e3)}})},defaultValues:D,noCard:!0,noBreakLine:!0}),m&&l.createElement(i.Toast,{error:"error"===m.key,label:r("success"===m.key?`ES_FSM_REGISTRY_${m.action}_SUCCESS`:m.action),onClose:T})))},VendorSelectAddress:e=>{var n,o,a;let{t:r,config:d,onSelect:s,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 R={};p&&(R=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[D,N]=t.useState(()=>{var e,t;return(null==c||null===(e=c.address)||void 0===e?void 0:e.city)||(null===(t=R)||void 0===t?void 0:t[0])||null}),{data:g}=Digit.Hooks.useBoundaryLocalities(null==D?void 0:D.code,"revenue",{enabled:!!D},r),{data:y}=Digit.Hooks.useBoundaryLocalities(null==D?void 0:D.code,"admin",{enabled:!!D},r),[T,I]=t.useState(),[C,O]=t.useState(()=>{var e,t,l,n,i,o,a;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===(i=n.details)||void 0===i||null===(o=i.address)||void 0===o?void 0:o.locality)||(null==c||null===(a=c.address)||void 0===a?void 0:a.locality)}),[A,h]=t.useState(),[b,f]=t.useState(()=>{var e;return null==c||null===(e=c.address)||void 0===e?void 0:e.ward});function V(e){O(null),I(null),f(null),h(null),Digit.SessionStorage.set("fsm.file.address.city",e),N(e)}function L(e){O(e),"employee"===u&&s(d.key,{...c[d.key],locality:e,ward:b})}function M(e){f(e),"employee"===u&&s(d.key,{...c[d.key],ward:e,locality:C})}return t.useEffect(()=>{S&&1===S.length&&N(S[0])},[S]),t.useEffect(()=>{if(D&&g){var e,t,l,n,i,o,a,r;let _=g,R=[];if(null!=c&&null!==(e=c.address)&&void 0!==e&&e.locality)O(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)O(c.cpt.details.address.locality);else if(null!==(i=p)&&void 0!==i&&null!==(o=i.propertyDetails)&&void 0!==o&&null!==(a=o.address)&&void 0!==a&&a.locality){var E,m,v;O(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&&(R=_.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||O()),"employee"===u&&s(d.key,{...c[d.key],city:D}),I(()=>R.length>0?R:_),1===R.length&&(O(R[0]),"employee"===u&&s(d.key,{...c[d.key],locality:R[0]}))}},[D,null==c||null===(o=c.cpt)||void 0===o||null===(a=o.details)||void 0===a?void 0:a.address,g]),t.useEffect(()=>{var e;D&&y&&(null!=c&&null!==(e=c.address)&&void 0!==e&&e.ward&&f(c.address.ward),h(y))},[D,y]),"employee"===u?l.createElement(l.Fragment,null,l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,r("MYCITY_CODE_LABEL"),d.isMandatory?" * ":null),l.createElement(i.Dropdown,{className:"",isMandatory:!0,selected:1===(null==S?void 0:S.length)?S[0]:D,disable:1===(null==S?void 0:S.length),option:S,select:V,optionKey:"code",t:r})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_WARD"),d.isMandatory?" * ":null),l.createElement(i.Dropdown,{className:"",isMandatory:!0,selected:b,option:A,select:M,optionKey:"name",t:r})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_MOHALLA"),d.isMandatory?" * ":null),l.createElement(i.Dropdown,{className:"",isMandatory:!0,selected:C,option:T,select:L,optionKey:"name",t:r}))):l.createElement(l.Fragment,null,l.createElement(i.FormStep,{config:d,onSelect:function(){s(d.key,{city:D,locality:C,ward:b})},t:r,isDisabled:!C||!b},l.createElement(i.CardLabel,null,r("MYCITY_CODE_LABEL")+" *"),l.createElement(i.RadioOrSelect,{options:S,selectedOption:D,optionKey:"i18nKey",onSelect:V,t:r}),D&&A&&l.createElement(i.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_WARD")+" *"),D&&A&&l.createElement(i.RadioOrSelect,{isMandatory:d.isMandatory,options:A,selectedOption:b,optionKey:"name",onSelect:M,t:r}),D&&T&&l.createElement(i.CardLabel,null,r("CS_CREATECOMPLAINT_MOHALLA")+" *"),D&&T&&l.createElement(i.RadioOrSelect,{isMandatory:d.isMandatory,options:T,selectedOption:C,optionKey:"name",onSelect:L,t:r})))},SearchApp:e=>{n.useParams();const{t:a}=o.useTranslation(),r=Digit.ULBService.getCurrentTenantId(),[d,s]=t.useState({}),[u,c]=t.useState(null),E={enabled:!!(d&&Object.keys(d).length>0)},{isLoading:m,isSuccess:S,data:{EwasteApplication:p,Count:_}={}}=Digit.Hooks.ew.useEWSearch({tenantId:r,filters:d},E);return l.createElement(l.Fragment,null,l.createElement(v,{t:a,isLoading:m,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"}):s(n):c({warning:!0,label:"ERR_PROVIDE_MORE_PARAM_WITH_TYPE_STATUS"}):c({warning:!0,label:"ERR_VENDOR_FILL_VALID_FIELDS"})},data:S&&!m?p.length>0?p:{display:"ES_COMMON_NO_DATA"}:"",count:_}),u&&l.createElement(i.Toast,{error:u.error,warning:u.warning,label:a(u.label),isDleteBtn:!0,onClose:()=>{c(null)}}))},SearchVendor:()=>{var e,n,i,a,r,d,s,u,c,E;const{t:m}=o.useTranslation(),v=Digit.ULBService.getCurrentTenantId(),{selectedTabs:S}=Digit.Hooks.useQueryParams(),[p,_]=t.useState({}),[R,D]=t.useState([{id:"createdTime",desc:!0}]),[N,g]=t.useState(0),[y,T]=t.useState(10),[I,C]=t.useState(S||"VENDOR"),[O,A]=t.useState(""),[h,b]=t.useState(""),[f,V]=t.useState([]),M=Digit.UserService.getUser(),w="CITIZEN"===(null==M||null===(e=M.info)||void 0===e?void 0:e.type),k=null==M||null===(n=M.info)||void 0===n?void 0:n.uuid,{data:P}=Digit.Hooks.fsm.useDsoSearch(v,{status:"ACTIVE"},{staleTime:Infinity}),{data:F}=Digit.Hooks.wt.useFillPointSearch({tenantId:v,filters:{limit:1e3}},{staleTime:Infinity});let x={limit:y,offset:N,sortBy:null==R||null===(i=R[0])||void 0===i?void 0:i.id,sortOrder:null!=R&&null!==(a=R[0])&&void 0!==a&&a.desc?"DESC":"ASC"};const{data:H,isLoading:U,refetch:B}="VEHICLE"===I?Digit.Hooks.fsm.useVehiclesSearch({tenantId:v,filters:{...x,registrationNumber:null==p?void 0:p.registrationNumber,status:"ACTIVE,DISABLED",vendorId:w?k:null==p||null===(r=p.vendor)||void 0===r?void 0:r.id,fillingPointId:null==p||null===(d=p.fillingPoint)||void 0===d?void 0:d.id},config:{enabled:!1}}):"DRIVER"===I?Digit.Hooks.fsm.useDriverSearch({tenantId:v,filters:{...x,name:null==p?void 0:p.name,status:"ACTIVE,DISABLED",vendorId:w?k:null==p||null===(s=p.vendor)||void 0===s?void 0:s.id},config:{enabled:!1}}):"SUPERVISOR"===I?Digit.Hooks.fsm.useSupervisorSearch(v,{...x,status:"ACTIVE,DISABLED",vendorId:w?k:null==p||null===(u=p.vendor)||void 0===u?void 0:u.id,name:null==p?void 0:p.name},{enabled:!1}):"SURVEYOR"===I?Digit.Hooks.fsm.useSurveyorSearch(v,{...x,status:"ACTIVE,DISABLED",vendorId:w?k:null==p||null===(c=p.vendor)||void 0===c?void 0:c.id,name:null==p?void 0:p.name},{enabled:!1}):Digit.Hooks.fsm.useVendorSearch({tenantId:v,filters:{...x,name:null==p?void 0:p.name,status:"ACTIVE,DISABLED"},config:{enabled:!1}});Digit.Hooks.fsm.useVendorSearch({tenantId:v,filters:{...x,name:null==p?void 0:p.name,status:"ACTIVE,DISABLED"},config:{enabled:!1}});const{data:Y,isLoading:G,refetch:W}=Digit.Hooks.fsm.useDsoSearch(v,{vehicleIds:O,driverIds:h,status:"ACTIVE"},{enabled:!1}),K=(null==H?void 0:H.totalCount)||50;t.useEffect(()=>{B(),W()},[]),t.useEffect(()=>{B()},[p,R,N,y]),t.useEffect(()=>{if(null!=H&&H.vehicle&&"VEHICLE"===I){const e=H.vehicle.map(e=>e.id).filter(Boolean).join(",");A(e),V(H.vehicle)}if(null!=H&&H.driver&&"DRIVER"===I){const e=H.driver.map(e=>e.id).filter(Boolean).join(",");b(e),V(null==H?void 0:H.driver)}if(null!=H&&H.vendor&&"VENDOR"===I){const e=H.vendor.map(e=>{var t,l,n,i;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===(i=n.filter(e=>"ACTIVE"===e.status))||void 0===i?void 0:i.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}))}});V(e)}"SUPERVISOR"===I&&V((null==H?void 0:H.supervisors)||(null==H?void 0:H.supervisor)||[]),"SURVEYOR"===I&&V((null==H?void 0:H.surveyors)||(null==H?void 0:H.surveyor)||[])},[H,I]),t.useEffect(()=>{""===O&&""===h||W()},[O,h]),t.useEffect(()=>{let e=!0;if(Y&&e){if("VEHICLE"===I){const e=null==H?void 0:H.vehicle.map(e=>{let t=Y.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 i={...e,vendor:t.dsoDetails};const o=null===(l=t.dsoDetails)||void 0===l||null===(n=l.vehicles)||void 0===n?void 0:n.find(t=>t.id===e.id);return o&&(i.driverData=o.driverData||o.driver||i.driverData),i}return e});V(e),A("")}if("DRIVER"===I){const e=null==H?void 0:H.driver.map(e=>{let t=Y.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});V(e),b("")}}return()=>{e=!1}},[Y,H]);const $="VEHICLE"===I?[{label:m("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==P?void 0:P.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:m("ES_FSM_REGISTRY_SEARCH_FILLING_POINT"),name:"fillingPoint",type:"dropdown",options:null==F||null===(E=F.fillingPoints)||void 0===E?void 0:E.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:m("ES_VEHICLE_SEARCH_VEHICLE_NUMBER"),name:"registrationNumber",pattern:"[A-Z]{2}[- ]?[0-9]{2}[- ]?[A-Z]{1,2}[- ]?[0-9]{4}",title:m("ES_FSM_VEHICLE_FORMAT_TIP")}]:"DRIVER"===I?[{label:m("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==P?void 0:P.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:m("ES_DRIVER_SEARCH_DRIVER_NAME"),name:"name"}]:"SUPERVISOR"===I||"SURVEYOR"===I?[{label:m("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==P?void 0:P.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:m("SUPERVISOR"===I?"ES_SUPERVISOR_SEARCH_NAME":"ES_SURVEYOR_SEARCH_NAME"),name:"name"}]:[{label:m("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(L,{data:{table:f},isLoading:U||G,onSort:z,disableSort:!1,sortParams:R,userRole:"FSM_ADMIN",onFilterChange:()=>{},searchFields:$,onSearch:function(e){void 0===e&&(e={}),_({...e})},onNextPage:()=>{g(e=>e+y)},onPrevPage:()=>{g(e=>e-y)},currentPage:Math.floor(N/y),pageSizeLimit:y,onPageSizeChange:e=>{T(Number(e.target.value))},totalRecords:K||0,onTabChange:e=>{C(e)},selectedTab:I,refetchData:()=>{B()},refetchVendor:()=>{W()}})))},SelectServiceType:e=>{let{config:n,onSelect:o,t:a,userType:r,formData:d}=e;const s=Digit.ULBService.getCurrentTenantId(),[u,c]=t.useState(null==d?void 0:d.serviceType),[E,m]=t.useState([]),{data:v,isLoading:S}=Digit.Hooks.useCustomMDMS(s,"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&&o(n.key,t))}}},[v]),S?l.createElement(i.Loader,null):"employee"===r?l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,a(n.label)),l.createElement(i.Dropdown,{className:"payment-form-text-input-correction",isMandatory:n.isMandatory,selected:u,option:E,select:e=>{c(e),"employee"===r&&o(n.key,e)},optionKey:"i18nKey",disable:n.disable,t:a})):void 0},SelectVehicleType:e=>{var n;let{t:o,config:a,onSelect:r,formData:d}=e;const s=Digit.ULBService.getStateId(),u=Digit.ULBService.getCurrentTenantId(),{data:c,isLoading:E}=Digit.Hooks.wt.useWTMDMS(s,"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({}),[_,R]=t.useState([]),[D,N]=t.useState({}),[g,y]=t.useState([]),[T,I]=t.useState({}),[C,O]=t.useState(""),A=(null==d||null===(n=d.serviceType)||void 0===n?void 0:n.code)||(null==d?void 0:d.serviceType),h=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(h)},[h]),t.useEffect(()=>{if(!c)return;const e=S[A],t=e?c.filter(t=>e.includes(t.code)):c;R(t),N({}),y([]),I({}),O("")},[c,A,S]),t.useEffect(()=>{if(!c||null==D||!D.code)return;const e=c.filter(e=>e.make===D.code);y(e),I({}),O("")},[D,c]),t.useEffect(()=>{null!=T&&T.capacity&&O(T.capacity)},[T]),E||v?l.createElement(i.Loader,null):c&&m?l.createElement(l.Fragment,null,l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,o("ES_FSM_REGISTRY_VEHICLE_MODEL")),l.createElement(i.Dropdown,{className:"form-field",selected:D,option:_,select:e=>{N(e),r(a.key,{...(null==d?void 0:d[a.key])||{},modal:e,type:""})},optionKey:"name",t:o})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,o("ES_FSM_REGISTRY_VEHICLE_TYPE")),l.createElement(i.Dropdown,{className:"form-field",selected:T,option:g,select:e=>{I(e),O(e.capacity),r(a.key,{...d[a.key],type:e})},optionKey:"name",t:o})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,o("ES_FSM_REGISTRY_VEHICLE_CAPACITY")),l.createElement(i.TextInput,{className:"",textInputStyle:{width:"100%"},value:C,disable:!0}))):l.createElement("div",null,o("ERROR_FETCHING_DATA"))},BankDetailsComponent:e=>{let{t:n,config:o,onSelect:a,formData:r,...d}=e;const[s,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)||""),[_,R]=t.useState(null);return t.useEffect(()=>{11===s.length&&fetch("https://ifsc.razorpay.com/"+s).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH?(E(e.BANK),v(e.BRANCH),"function"==typeof a&&a(o.key,{bankName:e.BANK,branchName:e.BRANCH,ifscCode:s,accountNumber:S}),R({error:!1,label:n("VALID_IFSC_CODE")})):R({error:!0,label:n("INVALID_IFSC_CODE")})}).catch(()=>{R({error:!0,label:n("INVALID_IFSC_CODE")})})},[s]),t.useEffect(()=>{"function"==typeof a&&a(o.key,{bankName:c,branchName:m,ifscCode:s,accountNumber:S})},[S,c,m,s]),l.createElement(l.Fragment,null,l.createElement(i.CardLabel,null,n("ES_FSM_REGISTRY_IFSC_CODE")),l.createElement(i.TextInput,{t:n,type:"text",isMandatory:!1,name:"ifscCode",value:s,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(i.CardLabel,null,n("ES_FSM_REGISTRY_ACCOUNT_NUMBER")),l.createElement(i.TextInput,{t:n,type:"text",isMandatory:!1,name:"accountNumber",value:S,onChange:e=>p(e.target.value),style:{width:"100%"}}),l.createElement(i.CardLabel,null,n("ES_FSM_REGISTRY_BANK_NAME")),l.createElement(i.TextInput,{t:n,type:"text",isMandatory:!1,name:"bankName",value:c,onChange:e=>E(e.target.value),disabled:11===s.length&&c,style:{width:"100%"}}),l.createElement(i.CardLabel,null,n("ES_FSM_REGISTRY_BRANCH_NAME")),l.createElement(i.TextInput,{t:n,type:"text",isMandatory:!1,name:"branchName",value:m,onChange:e=>v(e.target.value),disabled:11===s.length&&m,style:{width:"100%"}}))},AddDriver:()=>{var e,a;const s=Digit.ULBService.getCurrentTenantId(),{t:u}=o.useTranslation(),c=Digit.ULBService.getStateId(),[E,m]=t.useState(null),v=r.useQueryClient(),S=n.useHistory(),[,p]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,_]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,R]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),D="WT_VENDOR"===Digit.UserService.getType()||Digit.UserService.hasAccess(["WT_VENDOR"]),{mutate:N}=Digit.Hooks.fsm.useDriverCreate(c),{mutate:g}=Digit.Hooks.fsm.useVendorUpdate("dl.djb"),y=null===(e=Digit.UserService.getUser())||void 0===e||null===(a=e.info)||void 0===a?void 0:a.mobileNumber,{data:T}=Digit.Hooks.fsm.useDsoSearch(s,{mobileNumber:y},{enabled:!(!D||!y)});t.useEffect(()=>{p(!1),R(),_()},[]);const I=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,d({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),[C,O]=t.useState(!1),A=()=>{m(null)};return console.log(D,"iscitizen"),l.createElement(l.Fragment,null,l.createElement(i.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(i.FormComposer,{isDisabled:!C,label:u("ES_COMMON_APPLICATION_SUBMIT"),config:I.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;const n=null==e?void 0:e.driverName,i=null==e?void 0:e.license,o=null==e||null===(t=e.selectGender)||void 0===t?void 0:t.code,a=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(),s=null==e||null===(l=e.serviceType)||void 0===l?void 0:l.code;N({driver:{tenantId:"dl.djb",name:n,licenseNumber:i,status:"ACTIVE",owner:{tenantId:c,name:n,fatherOrHusbandName:n,relationship:"OTHER",gender:o,dob:d,emailId:a||"abc@egov.com",mobileNumber:r},additionalDetails:{serviceType:s},vendorDriverStatus:"ACTIVE"}},{onError:(e,t)=>{m({key:"error",action:e}),setTimeout(A,5e3)},onSuccess:(e,t)=>{var l;if(m({key:"success",action:"ADD_DRIVER"}),setTimeout(A,5e3),v.invalidateQueries("FSM_DRIVER_SEARCH"),D&&null!=T&&null!==(l=T[0])&&void 0!==l&&l.dsoDetails){const t=e.driver.map(e=>({...e,vendorDriverStatus:"ACTIVE",status:"ACTIVE"})),l=T[0].dsoDetails,n={vendor:{...l,drivers:l.drivers?[...l.drivers,...t]:[...t]}};g(n,{onError:e=>{m({key:"error",action:e})},onSuccess:()=>{var e,t,l;m({key:"success",action:"ADD_DRIVER"}),v.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(()=>{A(),S.push(`/digit-ui/${n}/vendor/search-vendor?selectedTabs=DRIVER`)},3e3)}})}else{var n,i,o;const e=(null===(n=Digit.UserService.getUser())||void 0===n||null===(i=n.info)||void 0===i||null===(o=i.type)||void 0===o?void 0:o.toLowerCase())||"citizen";v.invalidateQueries("FSM_DRIVER_SEARCH"),setTimeout(()=>{A(),S.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 i=n.slice(0,18);t.license!==i&&e("license",i)}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)?O(!0):O(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(i.Toast,{error:"error"===E.key,label:u("success"===E.key?`ES_FSM_${E.action}_SUCCESS`:E.action),onClose:A})))},EditVendorDetails:e=>{var a,d,s,u,c,E,m,v,S,p,_;const R=Digit.ULBService.getCurrentTenantId(),{t:D}=o.useTranslation(),N=n.useHistory(),g=r.useQueryClient();let{id:y}=n.useParams();const[T,I]=t.useState(!1),[C,O]=t.useState(null),[A,h]=t.useState(!1),[b,f]=t.useState(null),[V,L]=t.useState([]),[M,P]=t.useState([]),[x,H]=t.useState({}),{data:U,isLoading:B,refetch:Y}=Digit.Hooks.fsm.useDsoSearch(R,{ids:y},{staleTime:Infinity}),{data:G,isLoading:W}=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:R,filters:{vendorId:y}},{enabled:!!y});let K=null==U||null===(a=U[0])||void 0===a||null===(d=a.dsoDetails)||void 0===d?void 0:d.additionalDetails;if("string"==typeof K)try{K=JSON.parse(K)}catch(e){console.error("Error parsing additional details",e)}const $=(null==G||null===(s=G.VendorDetails)||void 0===s||null===(u=s[0])||void 0===u||null===(c=u.vendorAdditionalDetails)||void 0===c?void 0:c.serviceType)||(null===(E=K)||void 0===E?void 0:E.serviceType),z="EKYC"===$||"ekyc"===$,{data:Z,refetch:q}=Digit.Hooks.fsm.useVehiclesSearch({tenantId:R,filters:{status:"ACTIVE",sortBy:"registrationNumber",sortOrder:"ASC",vehicleWithNoVendor:!0},config:{enabled:!z}}),{data:j,refetch:X}=Digit.Hooks.fsm.useDriverSearch({tenantId:R,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE",driverWithNoVendor:!0},config:{enabled:!z}}),{data:Q}=Digit.Hooks.fsm.useSupervisorSearch(R,{vendorId:y},{enabled:z}),{data:J}=Digit.Hooks.fsm.useSurveyorSearch(R,{vendorId:y},{enabled:z}),{mutate:ee}=Digit.Hooks.fsm.useVendorUpdate(R);function te(e){I(!1),O(e)}const le=null===(m=Digit.SessionStorage.get("User").info.type)||void 0===m?void 0:m.toLowerCase();t.useEffect(()=>{switch(C){case"DELETE":case"ADD_VEHICLE":case"ADD_DRIVER":return h(!0);case"EDIT":return N.push(`/digit-ui/${le}/fsm/registry/modify-vendor/${y}`);case"HOME":return N.push(`/digit-ui/${le}/fsm/registry?selectedTabs=VENDOR`)}},[C]),t.useEffect(()=>{Z&&L((null==Z?void 0:Z.vehicle)||[])},[Z]),t.useEffect(()=>{j&&P((null==j?void 0:j.driver)||[])},[j]);const ne=()=>{f(null)},ie=()=>{O(null),H({}),h(!1)},oe=window.Digit.Utils.browser.isMobile();if(B)return l.createElement(i.Loader,null);const ae=["vendorAdditionalDetailsId","vendorId","tenantId","code","lastModifiedTime","createdTime","lastModifiedBy","createdBy","active","status","vendorType","vendorGroup","narration","documents"];return l.createElement("div",{className:"employee-form-content"},B?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement(i.Card,null,null==U||null===(v=U[0])||void 0===v||null===(S=v.employeeResponse)||void 0===S?void 0:S.map((e,t)=>{var n,o;return z&&t>0?null:l.createElement(l.Fragment,{key:t},t>0&&l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},D(e.title)),l.createElement("div",null,null==e||null===(n=e.values)||void 0===n?void 0:n.map((t,n)=>{var o;if("ES_FSM_REGISTRY_DETAILS_ADDITIONAL_DETAILS"===t.title){var a,r;const e=null==G||null===(a=G.VendorDetails)||void 0===a||null===(r=a[0])||void 0===r?void 0:r.vendorAdditionalDetails,n=Object.entries(e||{}).filter(e=>{let[t]=e;return!ae.includes(t)});return l.createElement(l.Fragment,{key:t.title},l.createElement(i.Row,{label:D(t.title),text:"",className:"border-none flex-box"}),W?l.createElement(i.Loader,null):e?l.createElement(i.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 i=String(t);let o=null!=n&&""!==n?String(n):"N/A";var a,r;return"name"!==t||n&&""!==n||(o=(null==U||null===(a=U[0])||void 0===a||null===(r=a.dsoDetails)||void 0===r?void 0:r.name)||"N/A"),l.createElement(l.Fragment,{key:i},l.createElement("div",{className:"additional-label"},D((e=>{const t=e.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)})(i))),l.createElement("div",{className:"additional-value"},o))})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/additionaldetails/info?vendorId=${y}`)},D("Edit Details"))):l.createElement("div",{onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/additionaldetails/vendor-details?vendorId=${y}`),className:"add-details-link hover-button"},D("Add Additional Details")))}return l.createElement(i.Row,{key:D(String(t.title)),label:D(String(t.title)),text:t.value?D(String(t.value)):"N/A",last:n===(null==e||null===(o=e.values)||void 0===o?void 0:o.length)-1,caption:t.caption,className:"border-none flex-box "+(oe?"":"vendor-details-row")})}),null==e||null===(o=e.child)||void 0===o?void 0:o.map((t,n)=>{var o;return l.createElement(i.Card,{className:"card-with-background",key:t.id||n},l.createElement("div",{className:"card-head"},l.createElement("h2",null,D(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)N.push(`/digit-ui/${le}/fsm/registry/modify-driver/${l}`);else{var n,i;let t=null==e||null===(n=e.values)||void 0===n||null===(i=n.find(e=>"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.title))||void 0===i?void 0:i.value;N.push(`/digit-ui/${le}/fsm/registry/modify-vehicle/${t}`)}})(t,e.type,t.id)},l.createElement(i.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 i,o;let e=null==U||null===(i=U[0])||void 0===i?void 0:i.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===(o=e.owner)||void 0===o?void 0:o.gender)||"OTHERS"},drivers:t}}}else{var a,r,d,s;let t=null==U||null===(a=U[0])||void 0===a?void 0:a.dsoDetails,l=null==t?void 0:t.vehicles,i=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===i&&(e.vendorVehicleStatus="INACTIVE"),e)),n={vendor:{...t,owner:{...t.owner,gender:(null===(s=t.owner)||void 0===s?void 0:s.gender)||"OTHERS"},vehicles:l}}}ee(n,{onError:(e,t)=>{f({key:"error",action:e}),setTimeout(ne,5e3)},onSuccess:(e,l)=>{f({key:"success",action:"ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===t?"DELETE_DRIVER":"DELETE_VEHICLE"}),g.invalidateQueries("DSO_SEARCH"),Y(),q(),X(),setTimeout(()=>{ne()},5e3)}})})(t,e.type,t.id)},l.createElement(i.DeleteIcon,{style:{cursor:"pointer"},className:"delete",fill:"#a82227"})))),l.createElement("div",{className:"additional-grid",style:{padding:"8px 16px"}},null==t||null===(o=t.values)||void 0===o?void 0:o.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},D(String(e.title))),l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},e.value?D(String(e.value)):"N/A")))))}),e.type&&l.createElement("div",{className:"add-details-link hover-button",onClick:()=>te("ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===e.type?"ADD_DRIVER":"ADD_VEHICLE")},D(e.type+"_ADD"))))}),z&&l.createElement(l.Fragment,null,l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},D("ES_VENDOR_SUPERVISOR_DETAILS")),l.createElement("div",null,null==Q||null===(p=Q.supervisor)||void 0===p?void 0:p.map((e,t)=>{var n,o;return l.createElement(i.Card,{className:"card-with-background",key:e.id||t},l.createElement("div",{className:"card-head"},l.createElement("h2",null,D("ES_VENDOR_SUPERVISOR_DETAILS")," ",t+1),l.createElement("div",{style:{display:"flex"}},l.createElement("span",{onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/supervisor-details/${e.id}`)},l.createElement(i.EditIcon,{style:{cursor:"pointer",marginRight:"20px"},className:"edit",fill:"#a82227"})))),l.createElement("div",{className:"additional-grid",style:{padding:"8px 16px"}},l.createElement("div",{className:"additional-label"},D("ES_FSM_REGISTRY_NEW_OWNER_NAME")),l.createElement("div",{className:"additional-value"},null===(n=e.owner)||void 0===n?void 0:n.name),l.createElement("div",{className:"additional-label"},D("ES_FSM_REGISTRY_VENDOR_PHONE")),l.createElement("div",{className:"additional-value"},null===(o=e.owner)||void 0===o?void 0:o.mobileNumber),l.createElement("div",{className:"additional-label"},D("ES_VENDOR_STATUS")),l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.status?{color:"green"}:{}},e.status)))}),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/new-supervisor?vendorId=${y}`)},D("ES_VENDOR_ADD_SUPERVISOR"))),l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},D("ES_VENDOR_SURVEYOR_DETAILS")),l.createElement("div",null,null==J||null===(_=J.surveyor)||void 0===_?void 0:_.map((e,t)=>{var n,o;return l.createElement(i.Card,{className:"card-with-background",key:e.id||t},l.createElement("div",{className:"card-head"},l.createElement("h2",null,D("ES_VENDOR_SURVEYOR_DETAILS")," ",t+1),l.createElement("div",{style:{display:"flex"}},l.createElement("span",{onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/surveyor-details/${e.id}`)},l.createElement(i.EditIcon,{style:{cursor:"pointer",marginRight:"20px"},className:"edit",fill:"#a82227"})))),l.createElement("div",{className:"additional-grid",style:{padding:"8px 16px"}},l.createElement("div",{className:"additional-label"},D("ES_FSM_REGISTRY_NEW_OWNER_NAME")),l.createElement("div",{className:"additional-value"},null===(n=e.owner)||void 0===n?void 0:n.name),l.createElement("div",{className:"additional-label"},D("ES_FSM_REGISTRY_VENDOR_PHONE")),l.createElement("div",{className:"additional-value"},null===(o=e.owner)||void 0===o?void 0:o.mobileNumber),l.createElement("div",{className:"additional-label"},D("ES_VENDOR_STATUS")),l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.status?{color:"green"}:{}},e.status)))}),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>N.push(`/digit-ui/${le}/vendor/registry/new-surveyor?vendorId=${y}`)},D("ES_VENDOR_ADD_SURVEYOR"))))),A&&l.createElement(i.Modal,{headerBarMain:l.createElement(k,{label:D("DELETE"===C?"ES_FSM_REGISTRY_DELETE_POPUP_HEADER":"ADD_VEHICLE"===C?"ES_FSM_REGISTRY_ADD_VEHICLE_POPUP_HEADER":"ES_FSM_REGISTRY_ADD_DRIVER_POPUP_HEADER")}),headerBarEnd:l.createElement(F,{onClick:ie}),actionCancelLabel:D("CS_COMMON_CANCEL"),actionCancelOnSubmit:ie,actionSaveLabel:D("DELETE"===C?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{var e;let t=null==U||null===(e=U[0])||void 0===e?void 0:e.dsoDetails,l={};if("DELETE"===C&&(l={vendor:{...t,status:"INACTIVE"}}),"ADD_VEHICLE"===C){var n;let e=x;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"===C){var i;let e=x;e.vendorDriverStatus="ACTIVE",l={vendor:{...t,owner:{...t.owner,gender:(null===(i=t.owner)||void 0===i?void 0:i.gender)||"OTHERS"},drivers:t.drivers?[...t.drivers,e]:[e]}}}ee(l,{onError:(e,t)=>{f({key:"error",action:e}),setTimeout(ne,5e3)},onSuccess:(e,t)=>{f({key:"success",action:"DELETE"===C?"DELETE_VENDOR":C}),g.invalidateQueries("DSO_SEARCH"),Y(),q(),X(),setTimeout(()=>{ne(),"DELETE"===C&&N.push(`/digit-ui/${le}/fsm/registry`)},5e3)}}),h(!1),O(null)}},l.createElement(i.Card,{style:{boxShadow:"none"}},"DELETE"===C?l.createElement(w,{t:D,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VEHICLE"===C?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,D("ES_FSM_REGISTRY_SELECT_VEHICLE")),l.createElement(i.Dropdown,{t:D,option:V,value:x,selected:x,select:H,optionKey:"registrationNumber"})):"ADD_DRIVER"===C?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,D("ES_FSM_REGISTRY_SELECT_DRIVER")),l.createElement(i.Dropdown,{t:D,option:M,value:x,selected:x,select:H,optionKey:"name"})):void 0)),b&&l.createElement(i.Toast,{error:"error"===b.key,label:D("success"===b.key?`ES_FSM_REGISTRY_${b.action}_SUCCESS`:b.action),onClose:ne}),l.createElement(i.ActionBar,{style:{zIndex:"19"}},T?l.createElement(i.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE","HOME"],t:D,onSelect:te}):null,l.createElement(i.SubmitBar,{label:D("ES_COMMON_TAKE_ACTION"),onSubmit:()=>I(!T)}))))},AddVehicle:e=>{var a,s;const u=Digit.ULBService.getCurrentTenantId(),c=Digit.ULBService.getStateId(),[E,m]=t.useState(null),v=n.useHistory(),{t:S}=o.useTranslation(),p=r.useQueryClient(),[,_]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,R]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,D]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),N="WT_VENDOR"===Digit.UserService.getType()||Digit.UserService.hasAccess(["WT_VENDOR"]),{mutate:g}=Digit.Hooks.fsm.useVehicleCreate(c),{mutate:y}=Digit.Hooks.fsm.useVendorUpdate("dl.djb"),T=null===(a=Digit.UserService.getUser())||void 0===a||null===(s=a.info)||void 0===s?void 0:s.mobileNumber,{data:I}=Digit.Hooks.fsm.useDsoSearch(u,{mobileNumber:T},{enabled:!(!N||!T)});t.useEffect(()=>{_(!1),D(),R()},[]);const C=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(ne,d({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(ne,d({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(ne,d({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(ne,d({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(ne,d({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:""}}]}]}(S);C[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(i.InfoIcon,null),l.createElement("span",{className:"tooltiptext",style:{width:"320px",left:"230%",fontSize:"14px"}},e.populators.validation.title)))});const[O,A]=t.useState(!1),h=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{route:"vendor-details",timeLine:[{actions:S("ES_FSM_REGISTRY_TITLE_NEW_VEHICLE"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(i.FormComposer,{isDisabled:!O,label:S("ES_COMMON_APPLICATION_SUBMIT"),config:C.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,i,o,a,r,d;const s=null==e?void 0:e.registrationNumber,u=null==e||null===(t=e.vehicle)||void 0===t||null===(l=t.type)||void 0===l?void 0:l.code,E=null==e||null===(n=e.vehicle)||void 0===n||null===(i=n.modal)||void 0===i?void 0:i.code,S=null==e||null===(o=e.vehicle)||void 0===o||null===(a=o.type)||void 0===a?void 0:a.capacity,_=new Date(""+(null==e?void 0:e.pollutionCert)).getTime(),R=new Date(""+(null==e?void 0:e.insurance)).getTime(),D=new Date(""+(null==e?void 0:e.roadTax)).getTime(),T=new Date(""+(null==e?void 0:e.fitnessValidity)).getTime(),C=null==e?void 0:e.ownerName,O=null==e?void 0:e.phone,A=null==e||null===(r=e.serviceType)||void 0===r?void 0:r.code,b=null==e||null===(d=e.selectGender)||void 0===d?void 0:d.code,f=null==e?void 0:e.emailId,V=new Date(""+e.dob).getTime()||new Date("1/1/1970").getTime();g({vehicle:{tenantId:"dl.djb",registrationNumber:s,model:E,type:u,tankCapacity:S,suctionType:"SEWER_SUCTION_MACHINE",pollutionCertiValidTill:_,InsuranceCertValidTill:R,fitnessValidTill:T,roadTaxPaidTill:D,gpsEnabled:!0,source:"Municipal records",owner:{tenantId:c,name:C,fatherOrHusbandName:C,relationship:"OTHER",correspondenceAddress:"",mobileNumber:O,gender:b,dob:V,emailId:f||"abc@egov.com"},additionalDetails:{serviceType:A},vehicleOwner:"ULB"}},{onError:(e,t)=>{var l,n,i,o;const a=(null==e||null===(l=e.response)||void 0===l||null===(n=l.data)||void 0===n||null===(i=n.Errors)||void 0===i||null===(o=i[0])||void 0===o?void 0:o.message)||(null==e?void 0:e.message)||"An error occurred";m({key:"error",action:a}),setTimeout(h,5e3)},onSuccess:(e,t)=>{var l,n,i,o;if(!0===(null==e?void 0:e.error)||(null==e||null===(l=e.Errors)||void 0===l?void 0:l.length)>0||(null==e||null===(n=e.data)||void 0===n||null===(i=n.Errors)||void 0===i?void 0:i.length)>0){var a,r,d,s,u;const t=(null==e||null===(a=e.data)||void 0===a||null===(r=a.Errors)||void 0===r||null===(d=r[0])||void 0===d?void 0:d.message)||(null==e||null===(s=e.Errors)||void 0===s||null===(u=s[0])||void 0===u?void 0:u.message)||(null==e?void 0:e.message)||"An error occurred";return m({key:"error",action:t}),void setTimeout(h,5e3)}if(m({key:"success",action:"ADD_VEHICLE"}),p.invalidateQueries("FSM_VEICLES_SEARCH"),N&&null!=I&&null!==(o=I[0])&&void 0!==o&&o.dsoDetails){var c;const t=(null==e||null===(c=e.vehicle)||void 0===c?void 0:c.map(e=>({...e,vendorVehicleStatus:"ACTIVE",status:"ACTIVE"})))||[],l=I[0].dsoDetails,n={vendor:{...l,vehicles:l.vehicles?[...l.vehicles,...t]:[...t]}};y(n,{onError:e=>{var t,l,n,i;const o=(null==e||null===(t=e.response)||void 0===t||null===(l=t.data)||void 0===l||null===(n=l.Errors)||void 0===n||null===(i=n[0])||void 0===i?void 0:i.message)||(null==e?void 0:e.message)||"An error occurred";m({key:"error",action:o}),setTimeout(h,5e3)},onSuccess:e=>{var t,l,n,i,o,a;if(!0===(null==e?void 0:e.error)||(null==e||null===(t=e.Errors)||void 0===t?void 0:t.length)>0||(null==e||null===(l=e.data)||void 0===l||null===(n=l.Errors)||void 0===n?void 0:n.length)>0){var r,d,s,u,c;const t=(null==e||null===(r=e.data)||void 0===r||null===(d=r.Errors)||void 0===d||null===(s=d[0])||void 0===s?void 0:s.message)||(null==e||null===(u=e.Errors)||void 0===u||null===(c=u[0])||void 0===c?void 0:c.message)||(null==e?void 0:e.message)||"An error occurred";return m({key:"error",action:t}),void setTimeout(h,5e3)}m({key:"success",action:"ADD_VEHICLE"}),p.invalidateQueries("DSO_SEARCH");const E=(null===(i=Digit.UserService.getUser())||void 0===i||null===(o=i.info)||void 0===o||null===(a=o.type)||void 0===a?void 0:a.toLowerCase())||"citizen";setTimeout(()=>{h(),v.push(`/digit-ui/${E}/vendor/search-vendor?selectedTabs=VEHICLE`)},3e3)}})}else{var E,S,_;const e=(null===(E=Digit.UserService.getUser())||void 0===E||null===(S=E.info)||void 0===S||null===(_=S.type)||void 0===_?void 0:_.toLowerCase())||"citizen";p.invalidateQueries("FSM_VEICLES_SEARCH"),setTimeout(()=>{h(),v.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 i=n.match(/^(\d{1,2})/);if(!i)return l+"-"+n;const o=i[1],a=n.slice(o.length),r=a.match(/^([A-Z]*)/),d=r?r[1]:"",s=a.slice(d.length);if(!s)return l+"-"+o+d;if(d.length>=3){const e=d.length<=3?1:2;return l+"-"+o+d.slice(0,e)+"-"+d.slice(e)+"-"+s.slice(0,4)}return l+"-"+o+d+"-"+s.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)?A(!0):A(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(i.Toast,{error:"error"===E.key,label:S("success"===E.key?`ES_FSM_REGISTRY_${E.action}_SUCCESS`:E.action),onClose:h})))},VENDORCreate:e=>{var t,i,a,d;const s=r.useQueryClient(),u=n.useRouteMatch(),{t:c}=o.useTranslation(),{pathname:E}=n.useLocation(),m=n.useHistory();let v=[];const[S,p,_]=Digit.Hooks.useSessionStorage("VENDOR_Test",{});function R(e,t,l,n,i){if(void 0===i&&(i=!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 i,o=E.split("/").pop(),a=o.charAt(o.length-1),r=!1;Number(parseInt(o))||"0"===o||"-1"===o?"-1"===o||"-2"===o?(o=E.slice(0,-3),o=o.split("/").pop(),r=!0):(o=E.slice(0,-2),o=o.split("/").pop(),r=!0):r=!1,isNaN(a)||(r=!0);let{nextStep:d={}}=v.find(e=>e.route===(o||"0")),s=m.push;if(e&&(s=m.replace),l&&(d=n),null===d)return console.log("matchhhhh pathhhh",u.path),s(u.path+"/check");i=isNaN(d.split("/").pop())&&r&&"map"!==d?`${u.path}/${d}/${t}`:`${u.path}/${d}`,s(i)})(l,n,i,e)}S&&Object.keys(S).length>0&&window.location.href.includes("/info")&&"true"!==sessionStorage.getItem("docReqScreenByBack")&&(_(),s.invalidateQueries("VENDOR_CREATE"));const D=()=>{},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===(i=t.ComponentRegistryService)||void 0===i?void 0:i.getComponent("VENDORCheckPage"),y=null===(a=Digit)||void 0===a||null===(d=a.ComponentRegistryService)||void 0===d?void 0:d.getComponent("NewResponse");return l.createElement(l.Fragment,null,l.createElement(n.Switch,null,v.map((e,t)=>{const{component:i,texts:o,inputs:a,key:r}=e,d="string"==typeof i?Digit.ComponentRegistryService.getComponent(i):i;return l.createElement(n.Route,{path:`${u.path}/${e.route}`,key:t},l.createElement(d,{config:{texts:o,inputs:a,key:r},onSelect:R,onSkip:D,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:()=>{_(),s.invalidateQueries("VENDOR_CREATE")}})),l.createElement(n.Route,null,l.createElement(n.Redirect,{to:`${u.path}/${v.indexRoute}`}))))},VENDORCheckPage:e=>{var n,a,r,d;let{onSubmit:s,value:u={}}=e;const{t:E}=o.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(i.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(i.Card,null,l.createElement(i.CardHeader,null,E("VENDOR_CHECK_DETAILS")),l.createElement("div",null,l.createElement("br",null),l.createElement(i.CardSubHeader,null,E("VENDOR_ADDITIONAL_DETAILS")),l.createElement(i.StatusTable,null,l.createElement(l.Fragment,null,l.createElement(i.Row,{label:E("VENDOR_ID"),text:""+E(c(null==m?void 0:m.VendorId)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_BANK_IFSC_CODE"),text:""+E(c(null==m?void 0:m.IFSC)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_BANK_NAME"),text:""+E(c(null==m?void 0:m.Bank)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_BANK_BRANCH"),text:""+E(c(null==m?void 0:m.BankbranchName)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_MICR_NO"),text:""+E(c(null==m?void 0:m.micrNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("BANK_ACCONT_NO"),text:""+E(c(null==m?void 0:m.AccountNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("PAN_NO"),text:""+E(c(null==m?void 0:m.PanNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("GST_NO"),text:""+E(c(null==m?void 0:m.GstNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("GST_REGISTERED_STATE/UT"),text:""+E(c(null==m?void 0:m.GstState)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("REGISTRATION_NO"),text:""+E(c(null==m?void 0:m.RegistrationNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("EPF_NO"),text:""+E(c(null==m?void 0:m.EpfNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("ESI_NO"),text:""+E(c(null==m?void 0:m.EsiNo)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_TYPE"),text:""+E(c(null==m||null===(n=m.VendorType)||void 0===n?void 0:n.code)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_CATEGORY"),text:""+E(c(null==m||null===(a=m.VendorCategory)||void 0===a?void 0:a.code)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(i.Row,{label:E("VENDOR_STATUS"),text:""+E(c(null==m||null===(r=m.Status)||void 0===r?void 0:r.code)),actionButton:l.createElement(Z,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}))),l.createElement("br",null),l.createElement(i.CardSubHeader,null,E("VENDOR_DOCUMENTS_DETAILS")),l.createElement(i.StatusTable,null,l.createElement(i.StatusTable,null,l.createElement(i.Row,{label:E("VENDOR_DOCUMENTS"),text:(null==v||null===(d=v.documents)||void 0===d?void 0:d.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 i=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(i){const e=i.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(i.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(i.SubmitBar,{label:E("COMMON_BUTTON_SUBMIT"),onSubmit:s,disabled:!S})))))},NewResponse:e=>{let{data:a,onSuccess:r}=e;const{t:d}=o.useTranslation(),s=Digit.Hooks.vendor.useVendorAdditionaldetailsAPI(Digit.ULBService.getCurrentTenantId());return t.useEffect(()=>{try{var e,t;a.tenantId=null===(e=a.address)||void 0===e||null===(t=e.city)||void 0===t?void 0:t.code;let l=(e=>{var t,l,n,i,o,a,r,d,s,u,c,E,m,v,S,p,_,R,D,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===(i=e.vendordet)||void 0===i?void 0:i.ContactPerson,vendorMobileNumber:"9876543210",bankAccountNumber:null==e||null===(o=e.vendordet)||void 0===o?void 0:o.AccountNo,bank:null==e||null===(a=e.vendordet)||void 0===a?void 0:a.Bank,bankBranchName:null==e||null===(r=e.vendordet)||void 0===r?void 0:r.BankbranchName,micrNo:null==e||null===(d=e.vendordet)||void 0===d?void 0:d.micrNo,epfNo:null==e||null===(s=e.vendordet)||void 0===s?void 0:s.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===(R=_.VendorCategory)||void 0===R?void 0:R.code,vendorId:null==e||null===(D=e.vendordet)||void 0===D?void 0:D.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"}}})(a);console.log("formdata in acknowejkfdlgi ::: ",l),s.mutate(l,{onSuccess:r}),console.log("mutation in acknowejkfdlgi ::: ",s)}catch(e){}},[]),s.isLoading||s.isIdle?l.createElement(i.Loader,null):l.createElement(i.Card,{className:"vehicle-details-card"},l.createElement(X,{t:d,data:s.data,isSuccess:s.isSuccess,isLoading:s.isIdle||s.isLoading}),l.createElement(i.StatusTable,null,s.isSuccess&&l.createElement(i.Row,{rowContainerStyle:j,last:!0,textStyle:{whiteSpace:"pre",width:"60%"}})),l.createElement(n.Link,{to:"/digit-ui/employee"},l.createElement(i.LinkButton,{label:d("CORE_COMMON_GO_TO_HOME")})))},DriverDetails:()=>{var e,a;const d=Digit.ULBService.getCurrentTenantId(),{t:s}=o.useTranslation(),u=n.useHistory(),c=r.useQueryClient(),{id:E}=n.useParams(),[m,v]=t.useState(!1),[S,p]=t.useState(null),[_,R]=t.useState(!1),[D,N]=t.useState(null),[g,y]=t.useState([]),[T,I]=t.useState({}),{data:C,isLoading:O,refetch:A}=Digit.Hooks.fsm.useDriverDetails(d,{ids:E},{staleTime:Infinity}),{data:h}=Digit.Hooks.fsm.useDsoSearch(d,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{mutate:b}=Digit.Hooks.fsm.useDriverUpdate(d),{mutate:f}=Digit.Hooks.fsm.useVendorUpdate(d);function V(e){p(e),v(!1)}t.useEffect(()=>{if(h){let e=h.map(e=>e.dsoDetails);y(e)}},[h]),t.useEffect(()=>{A()},[]),t.useEffect(()=>{switch(S){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return R(!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 L=()=>{N(null)},M=()=>{p(null),I({}),R(!1)},k=()=>"DELETE"===S||"DELETE_VENDOR"===S?l.createElement(w,{t:s,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===S||"EDIT_VENDOR"===S?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,s("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(i.Dropdown,{t:s,option:g,value:T,selected:T,select:I,optionKey:"name"})):void 0;return O||O?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(i.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==C||null===(e=C[0])||void 0===e||null===(a=e.employeeResponse)||void 0===a?void 0:a.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},s(e.title)),l.createElement(i.Card,{className:"card-with-background"},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"},s(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},s(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(i.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(i.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(i.DeleteIcon,{className:"delete",fill:"#a82227"}))):l.createElement("div",{className:"additional-value"},s(e.value)||"N/A"))))))}))),_&&l.createElement(i.Modal,{headerBarMain:l.createElement(ee,{label:s((()=>{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(le,{onClick:M}),actionCancelLabel:s("CS_COMMON_CANCEL"),actionCancelOnSubmit:M,actionSaveLabel:s("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(L,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"DELETE_DRIVER"}),c.invalidateQueries("DSO_SEARCH"),setTimeout(()=>{L(),u.push("/digit-ui/employee/fsm/registry")},5e3)}}),R(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let i={},o=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],a=null==o?void 0:o.drivers;a=a.map(e=>(e.id===E&&(e.vendorDriverStatus="INACTIVE"),e)),i={vendor:{...o,owner:{...o.owner,gender:(null===(n=o.owner)||void 0===n?void 0:n.gender)||"OTHERS"},drivers:a}},f(i,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(L,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"DELETE_VENDOR"}),c.invalidateQueries("FSM_VENDOR_SEARCH"),A(),setTimeout(L,5e3)}}),R(!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 i={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]}};f(i,{onError:(e,t)=>{N({key:"error",action:e}),A(),setTimeout(L,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"ADD_VENDOR"}),c.invalidateQueries("DSO_SEARCH"),A(),setTimeout(L,5e3)}}),R(!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 i={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]}};f(i,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(L,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"EDIT_VENDOR"}),A(),c.invalidateQueries("DSO_SEARCH"),setTimeout(L,5e3)}}),R(!1),p(null)})()}},formId:"modal-action"},"DELETE"===S||"DELETE_VENDOR"===S?k():l.createElement(i.Card,{style:{boxShadow:"none"}},k())),D&&l.createElement(i.Toast,{error:"error"===D.key,label:s("success"===D.key?`ES_FSM_REGISTRY_${D.action}_SUCCESS`:D.action),onClose:L}),l.createElement(i.ActionBar,{style:{zIndex:"19"}},m?l.createElement(i.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:s,onSelect:V}):null,l.createElement(i.SubmitBar,{label:s("ES_COMMON_TAKE_ACTION"),onSubmit:()=>v(!m)})))},VehicleDetails:e=>{var a,d;const s=Digit.ULBService.getCurrentTenantId(),{t:u}=o.useTranslation(),c=n.useHistory(),E=r.useQueryClient();let{id:m}=n.useParams();const[v,S]=t.useState(!1),[p,_]=t.useState(null),[R,D]=t.useState(!1),[N,g]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),[O,A]=t.useState(null),{data:h,isLoading:b,refetch:f}=Digit.Hooks.fsm.useVehicleDetails(s,{registrationNumber:m},{staleTime:Infinity});t.useEffect(()=>{var e,t;!b&&h&&A(null==h||null===(e=h[0])||void 0===e||null===(t=e.vehicleData)||void 0===t?void 0:t.id)},[h,b]);const{data:V}=Digit.Hooks.fsm.useDsoSearch(s,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{});t.useEffect(()=>{if(V){let e=V.map(e=>e.dsoDetails);T(e)}},[V]);const{mutate:L}=Digit.Hooks.fsm.useUpdateVehicle(s),{mutate:M}=Digit.Hooks.fsm.useVendorUpdate(s);function k(e){S(!1),_(e)}t.useEffect(()=>{f()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return D(!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({}),D(!1)},x=()=>"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(w,{t:u,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(i.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0;return b?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,b?l.createElement(i.Loader,null):l.createElement("div",{className:"employee-form-content"},l.createElement(i.Card,{className:"vehicle-details-card",style:{position:"relative"}},null==h||null===(a=h[0])||void 0===a||null===(d=a.employeeResponse)||void 0===d?void 0:d.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(i.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(i.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(i.EditIcon,{fill:"#a82227"})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>k("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(i.DeleteIcon,{className:"delete",fill:"#a82227"})))):l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},u(e.value)||"N/A"))))))})),R&&l.createElement(i.Modal,{headerBarMain:l.createElement(ie,{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(ae,{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==h||null===(e=h[0])||void 0===e?void 0:e.vehicleData,status:"INACTIVE"}};L(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)}}),D(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let i={},o=null==h||null===(e=h[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],a=null==o?void 0:o.vehicles;a=a.map(e=>(e.id===O&&(e.vendorVehicleStatus="INACTIVE"),e)),i={vendor:{...o,owner:{...o.owner,gender:(null===(n=o.owner)||void 0===n?void 0:n.gender)||"OTHERS"},vehicles:a}},M(i,{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"),f(),setTimeout(P,5e3)}}),D(!1)})();case"ADD_VENDOR":return(()=>{var e,t;let l=I,n=null==h||null===(e=h[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const i={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]}};M(i,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"EDIT_VENDOR"}),f(),E.invalidateQueries("DSO_SEARCH"),setTimeout(P,5e3)}}),D(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e,t;let l=I,n=null==h||null===(e=h[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const i={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]}};M(i,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"EDIT_VENDOR"}),f(),E.invalidateQueries("DSO_SEARCH"),setTimeout(P,5e3)}}),D(!1),_(null)})()}}},"DELETE"===p||"DELETE_VENDOR"===p?x():l.createElement(i.Card,{style:{boxShadow:"none"}},x())),N&&l.createElement(i.Toast,{error:"error"===N.key,label:u("success"===N.key?`ES_FSM_REGISTRY_${N.action}_SUCCESS`:N.action),onClose:P}),l.createElement(i.ActionBar,{style:{zIndex:"19"}},v?l.createElement(i.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:u,onSelect:k}):null,l.createElement(i.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)}))))},AddSupervisor:e=>{var a;const{t:d}=o.useTranslation(),s=(n.useHistory(),null===(a=Digit.UserService.getUser())||void 0===a?void 0:a.info),u=Digit.ULBService.getCurrentTenantId(),c=null!=u&&u.includes(".")?u:u+".djb",[E,m]=t.useState(null),v=r.useQueryClient(),[S,p]=t.useState(!1),{mutate:_}=Digit.Hooks.fsm.useSupervisorCreate(c),{search:R}=n.useLocation(),D=(new URLSearchParams(R).get("vendorId"),H(d)),N=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(i.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(i.FormComposer,{isDisabled:!S,label:d("ES_COMMON_APPLICATION_SUBMIT"),config:D.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,i,o;const a=null==s||null===(t=s.roles)||void 0===t?void 0:t.some(e=>"EKYC_VENDOR"===e.code),r={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_create",msgId:Date.now()+"|en_IN",authToken:(null===(l=Digit.UserService.getUser())||void 0===l?void 0:l.access_token)||(null==s?void 0:s.authToken),...a&&{userInfo:{id:null==s?void 0:s.id,uuid:null==s?void 0:s.uuid,userName:null==s?void 0:s.userName,name:null==s?void 0:s.name,type:null==s?void 0:s.type,tenantId:(null==s?void 0:s.tenantId)||u,roles:null==s?void 0:s.roles}}},supervisor:{tenantId:c,assignedZoneId:(null==e||null===(n=e.assignedZone)||void 0===n?void 0:n.code)||(null==e?void 0:e.assignedZone)||null,description:(null==e?void 0:e.description)||"",owner:{tenantId:c,name:null==e?void 0:e.fullName,fatherOrHusbandName:null==e?void 0:e.fatherOrHusbandName,relationship:null==e||null===(i=e.relationship)||void 0===i?void 0:i.code,dob:null!=e&&e.dob?new Date(e.dob).getTime():null,gender:(null==e||null===(o=e.gender)||void 0===o?void 0:o.code)||"OTHERS",mobileNumber:null==e?void 0:e.mobileNumber,emailId:null==e?void 0:e.emailId,correspondenceAddress:null==e?void 0:e.correspondenceAddress}}};_(r,{onError:e=>{m({key:"error",action:e}),setTimeout(N,5e3)},onSuccess:()=>{m({key:"success",action:"ADD_SUPERVISOR"}),v.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(N,5e3)}})},defaultValues:{role:{code:"SUPERVISOR",name:"Supervisor"}},onFormValueChange:(e,t)=>{p(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.fatherOrHusbandName)&&(null==t?void 0:t.relationship)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.gender)&&(null==t?void 0:t.correspondenceAddress)&&(null==t?void 0:t.assignedZone)))},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(i.Toast,{error:"error"===E.key,label:d("success"===E.key?`ES_VENDOR_${E.action}_SUCCESS`:E.action),onClose:N})))},SupervisorDetails:e=>{var a,d;const s=Digit.ULBService.getCurrentTenantId(),{t:u}=o.useTranslation(),c=n.useHistory(),E=r.useQueryClient(),{id:m}=n.useParams(),[v,S]=t.useState(!1),[p,_]=t.useState(null),[R,D]=t.useState(!1),[N,g]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),{data:O}=Digit.Hooks.fsm.useDsoSearch(s,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{data:A,isLoading:h,refetch:b}=Digit.Hooks.fsm.useSupervisorSearch(s,{ids:m},{staleTime:Infinity}),f=l.useMemo(()=>{var e;return null!=A&&null!==(e=A.supervisors)&&void 0!==e&&e.length?A.supervisors.map(e=>{var t,l,n,i;const o=null==O?void 0:O.find(t=>{var l,n;return(null===(l=t.dsoDetails)||void 0===l?void 0:l.id)===e.vendorId||(null===(n=t.dsoDetails)||void 0===n?void 0:n.vendorId)===e.vendorId}),a=(null==o||null===(t=o.dsoDetails)||void 0===t?void 0:t.name)||e.vendorId||"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR";return{supervisorData:e,vendorDetails:{vendor:o?[o.dsoDetails]:[]},employeeResponse:[{title:"ES_VENDOR_SUPERVISOR_BASIC_DETAILS",values:[{title:"ES_VENDOR_SUPERVISOR_FULL_NAME",value:null==e?void 0:e.name},{title:"ES_VENDOR_SUPERVISOR_MOBILE_NUMBER",value:(null==e||null===(l=e.owner)||void 0===l?void 0:l.mobileNumber)||(null==e?void 0:e.mobileNo)},{title:"ES_VENDOR_SUPERVISOR_EMAIL_ID",value:null==e||null===(n=e.owner)||void 0===n?void 0:n.emailId},{title:"ES_VENDOR_SUPERVISOR_STAFF_CODE",value:(null==e?void 0:e.employeeId)||"N/A"},{title:"ES_VENDOR_SUPERVISOR_GENDER",value:null==e||null===(i=e.owner)||void 0===i?void 0:i.gender},{title:"ES_VENDOR_SUPERVISOR_AGENCY_NAME",value:a,type:"custom"}]},{title:"ES_VENDOR_SUPERVISOR_MAPPED_SURVEYORS",type:"ES_FSM_REGISTRY_DETAILS_TYPE_SURVEYOR",child:[]}]}}):[]},[A,O]),{mutate:V}=Digit.Hooks.fsm.useSupervisorUpdate(s),{mutate:L}=Digit.Hooks.fsm.useVendorUpdate(s);t.useEffect(()=>{if(O){let e=O.map(e=>e.dsoDetails);T(e)}},[O]),t.useEffect(()=>{b()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return D(!0);case"EDIT":return c.push("/digit-ui/employee/vendor/registry/modify-supervisor/"+m);case"HOME":return c.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SUPERVISOR")}},[p]);const M=()=>{g(null)},k=()=>{_(null),C({}),D(!1)};return h?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(i.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==f||null===(a=f[0])||void 0===a||null===(d=a.employeeResponse)||void 0===d?void 0:d.map((e,t)=>{var n,o;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(i.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(i.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(i.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>_("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(i.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},u(e.value)||"N/A"))))),null==e||null===(o=e.child)||void 0===o?void 0:o.map((t,n)=>{var o;return l.createElement(i.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(i.EditIcon,{fill:"#a82227",style:{cursor:"pointer"}})))),l.createElement("div",{className:"additional-grid"},null==t||null===(o=t.values)||void 0===o?void 0:o.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(i.AddIcon,{fill:"#a82227"}),u(e.type+"_ADD")))}))),R&&l.createElement(i.Modal,{headerBarMain:l.createElement(U,{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(Y,{onClick:k}),actionCancelLabel:u("CS_COMMON_CANCEL"),actionCancelOnSubmit:k,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==f||null===(e=f[0])||void 0===e?void 0:e.supervisorData,status:"INACTIVE"}};V(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)}}),D(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=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],i=(null==n?void 0:n.supervisors)||[];i=i.map(e=>(e.id===m&&(e.vendorSupervisorStatus="INACTIVE"),e));const o={vendor:{...n,supervisors:i}};L(o,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),b(),setTimeout(M,5e3)}}),D(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=I,l=null==f||null===(e=f[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:{...t,supervisors:t.supervisors?[...t.supervisors,l]:[l]}};L(n,{onError:e=>{g({key:"error",action:e}),b(),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"ADD_VENDOR"}),E.invalidateQueries("SUPERVISOR_SEARCH"),b(),setTimeout(M,5e3)}}),D(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=I,l=null==f||null===(e=f[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:{...t,supervisors:t.supervisors?[...t.supervisors,l]:[l]}};L(n,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"EDIT_VENDOR"}),b(),E.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(M,5e3)}}),D(!1),_(null)})()}}},l.createElement(i.Card,{style:{boxShadow:"none"}},"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(w,{t:u,title:"ES_VENDOR_SUPERVISOR_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(i.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0)),N&&l.createElement(i.Toast,{error:"error"===N.key,label:u("success"===N.key?`ES_VENDOR_${N.action}_SUCCESS`:N.action),onClose:M}),l.createElement(i.ActionBar,{style:{zIndex:"19"}},v?l.createElement(i.Menu,{localeKeyPrefix:"ES_VENDOR_SUPERVISOR_ACTION",options:["EDIT","DELETE"],t:u,onSelect:e=>{S(!1),_(e)}}):null,l.createElement(i.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)})))},EditSupervisor:()=>{var e;const{t:a}=o.useTranslation(),d=n.useHistory(),s=r.useQueryClient(),{id:u}=n.useParams(),c=null===(e=Digit.UserService.getUser())||void 0===e?void 0:e.info,E=Digit.ULBService.getCurrentTenantId(),m=null!=E&&E.includes(".")?E:E+".djb",[v,S]=t.useState(null),[p,_]=t.useState(!1),[R,D]=t.useState({}),[N,g]=t.useState({}),{data:y,isLoading:T}=Digit.Hooks.fsm.useSupervisorSearch(m,{ids:u},{staleTime:Infinity}),{mutate:I}=Digit.Hooks.fsm.useSupervisorUpdate(m),C=H(a);t.useEffect(()=>{if(y&&y.supervisors&&y.supervisors.length>0){var e,t,l,n,i,o,a,r,d;let s=y.supervisors[0];g(s);let u={fullName:(null==s||null===(e=s.owner)||void 0===e?void 0:e.name)||(null==s?void 0:s.name),mobileNumber:(null==s||null===(t=s.owner)||void 0===t?void 0:t.mobileNumber)||(null==s?void 0:s.mobileNo),emailId:null==s||null===(l=s.owner)||void 0===l?void 0:l.emailId,employeeId:null==s?void 0:s.employeeId,gender:null!=s&&null!==(n=s.owner)&&void 0!==n&&n.gender?{code:s.owner.gender,name:"COMMON_GENDER_"+s.owner.gender}:null,fatherOrHusbandName:null==s||null===(i=s.owner)||void 0===i?void 0:i.fatherOrHusbandName,relationship:null!=s&&null!==(o=s.owner)&&void 0!==o&&o.relationship?{code:s.owner.relationship,name:"ES_COMMON_RELATION_"+s.owner.relationship}:null,dob:(null==s||null===(a=s.owner)||void 0===a?void 0:a.dob)&&Digit.DateUtils.ConvertTimestampToDate(null==s||null===(r=s.owner)||void 0===r?void 0:r.dob,"yyyy-MM-dd"),correspondenceAddress:null==s||null===(d=s.owner)||void 0===d?void 0:d.correspondenceAddress,description:null==s?void 0:s.description,assignedZone:null!=s&&s.assignedZoneId?{code:s.assignedZoneId,name:s.assignedZoneId}:null};D(u)}},[y]);const O=()=>{S(null)};return T||0===Object.keys(R).length?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{timeLine:[{actions:a("ES_VENDOR_SUPERVISOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(i.FormComposer,{isDisabled:!p,label:a("ES_COMMON_APPLICATION_SUBMIT"),config:C.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,i,o,a,r,E,v,p,_;const R={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_update",msgId:Date.now()+"|en_IN",authToken:null==c?void 0:c.authToken,userInfo:{id:null==c?void 0:c.id,uuid:null==c?void 0:c.uuid,userName:null==c?void 0:c.userName,name:null==c?void 0:c.name,type:null==c?void 0:c.type,tenantId:m,roles:null==c?void 0:c.roles}},supervisor:{...N,description:(null==e?void 0:e.description)||(null==N?void 0:N.description)||"",assignedZoneId:(null==e||null===(t=e.assignedZone)||void 0===t?void 0:t.code)||(null==N?void 0:N.assignedZoneId)||null,owner:{...N.owner,name:(null==e?void 0:e.fullName)||(null===(l=N.owner)||void 0===l?void 0:l.name),fatherOrHusbandName:(null==e?void 0:e.fatherOrHusbandName)||(null===(n=N.owner)||void 0===n?void 0:n.fatherOrHusbandName),relationship:(null==e||null===(i=e.relationship)||void 0===i?void 0:i.code)||(null===(o=N.owner)||void 0===o?void 0:o.relationship),gender:(null==e||null===(a=e.gender)||void 0===a?void 0:a.code)||(null===(r=N.owner)||void 0===r?void 0:r.gender)||"OTHERS",dob:null!=e&&e.dob?new Date(e.dob).getTime():null===(E=N.owner)||void 0===E?void 0:E.dob,emailId:(null==e?void 0:e.emailId)||(null===(v=N.owner)||void 0===v?void 0:v.emailId),mobileNumber:(null==e?void 0:e.mobileNumber)||(null===(p=N.owner)||void 0===p?void 0:p.mobileNumber),correspondenceAddress:(null==e?void 0:e.correspondenceAddress)||(null===(_=N.owner)||void 0===_?void 0:_.correspondenceAddress)}}};I(R,{onError:e=>{S({key:"error",action:e}),setTimeout(O,5e3)},onSuccess:()=>{S({key:"success",action:"UPDATE_SUPERVISOR"}),s.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(()=>{O(),d.push("/digit-ui/employee/vendor/registry/supervisor-details/"+u)},5e3)}})},defaultValues:R,onFormValueChange:(e,t)=>{_(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.fatherOrHusbandName)&&(null==t?void 0:t.relationship)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.gender)&&(null==t?void 0:t.correspondenceAddress)&&(null==t?void 0:t.assignedZone)))},noBreakLine:!0,mode:"onChange",noCard:!0}),v&&l.createElement(i.Toast,{error:"error"===v.key,label:a("success"===v.key?`ES_VENDOR_${v.action}_SUCCESS`:v.action),onClose:O})))},SupervisorAreaAssignment:e=>{var n,o,a,r;let{config:d,onSelect:s,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===(o=c.areaAssignment)||void 0===o?void 0:o.cluster)||null),[_,R]=t.useState((null==c||null===(a=c.areaAssignment)||void 0===a?void 0:a.ward)||null),[D,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,h]=t.useState([]),{data:b,isLoading:f}=Digit.Hooks.useCommonMDMS(E,"egov-location",["TenantBoundary"]);t.useEffect(()=>{if(console.log("Boundary Data State:",{boundaryData:b,isLoading:f}),b){var e,t,l,n,i;const o=(null==b||null===(e=b["egov-location"])||void 0===e||null===(t=e.TenantBoundary)||void 0===t?void 0:t[0])||(null==b||null===(l=b.MdmsRes)||void 0===l||null===(n=l["egov-location"])||void 0===n||null===(i=n.TenantBoundary)||void 0===i?void 0:i[0]),a=(null==o?void 0:o.boundary)||(null==o?void 0:o.children)||[];Array.isArray(a)&&a.length>0?y(a):f||y([{code:"ZONE-01",name:"ZONE-01",children:[{code:"CLUSTER-01",name:"CLUSTER-01",children:[{code:"WARD-01",name:"WARD-01",children:[{code:"AREA-01",name:"AREA-01"},{code:"AREA-02",name:"AREA-02"}]}]}]},{code:"ZONE-02",name:"ZONE-02"}])}else f||y([{code:"ZONE-01",name:"ZONE-01",children:[{code:"CLUSTER-01",name:"CLUSTER-01",children:[{code:"WARD-01",name:"WARD-01",children:[{code:"AREA-01",name:"AREA-01"},{code:"AREA-02",name:"AREA-02"}]}]}]},{code:"ZONE-02",name:"ZONE-02"}])},[b,f]),t.useEffect(()=>{if(m){var e,t;const l=m.children||m.boundary||[];I(l.length>0?l:[{code:"CLUSTER-01",name:"CLUSTER-01",children:[{code:"WARD-01",name:"WARD-01",children:[{code:"AREA-01",name:"AREA-01"},{code:"AREA-02",name:"AREA-02"}]}]}]),m.code!==(null==c||null===(e=c.areaAssignment)||void 0===e||null===(t=e.zone)||void 0===t?void 0:t.code)&&(p(null),R(null),N([]))}else I([])},[m]),t.useEffect(()=>{if(S){var e,t;const l=S.children||S.boundary||[];O(l.length>0?l:[{code:"WARD-01",name:"WARD-01",children:[{code:"AREA-01",name:"AREA-01"},{code:"AREA-02",name:"AREA-02"}]}]),S.code!==(null==c||null===(e=c.areaAssignment)||void 0===e||null===(t=e.cluster)||void 0===t?void 0:t.code)&&(R(null),N([]))}else O([])},[S]),t.useEffect(()=>{if(_){var e,t;const l=_.children||_.localities||_.boundary||[];h(l.length>0?l:[{code:"AREA-01",name:"AREA-01"},{code:"AREA-02",name:"AREA-02"}]),_.code!==(null==c||null===(e=c.areaAssignment)||void 0===e||null===(t=e.ward)||void 0===t?void 0:t.code)&&N([])}else h([])},[_]);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=[]),s(d.key,l)};return f?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,u("ES_VENDOR_SUPERVISOR_ZONE")+" *"),l.createElement(i.Dropdown,{selected:m,option:g,select:e=>{v(e),V("zone",e)},optionKey:"name",t:u})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,u("ES_VENDOR_SUPERVISOR_CLUSTER")+" *"),l.createElement(i.Dropdown,{selected:S,option:T,select:e=>{p(e),V("cluster",e)},optionKey:"name",t:u,disable:!m})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,u("ES_VENDOR_SUPERVISOR_WARD")+" *"),l.createElement(i.Dropdown,{selected:_,option:C,select:e=>{R(e),V("ward",e)},optionKey:"name",t:u,disable:!S})),l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,u("ES_VENDOR_SUPERVISOR_AREA")+" *"),l.createElement(i.MultiSelectDropdown,{options:A,selected:D,onSelect:e=>{N(e),V("areas",e)},optionsKey:"name",t:u,disable:!_,ServerStyle:{backgroundColor:"#fff"}})))},AddSurveyor:e=>{var a;const{t:d}=o.useTranslation(),s=null===(a=Digit.UserService.getUser())||void 0===a?void 0:a.info,u=Digit.ULBService.getCurrentTenantId(),c=null!=u&&u.includes(".")?u:u+".djb",[E,m]=t.useState(null),v=r.useQueryClient(),[S,p]=t.useState(!1),{mutate:_}=Digit.Hooks.fsm.useSurveyorCreate(c),{search:R}=n.useLocation(),D=(new URLSearchParams(R).get("vendorId"),W(d)),N=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(i.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(i.FormComposer,{isDisabled:!S,label:d("ES_COMMON_APPLICATION_SUBMIT"),config:D.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,i;const o=null==s||null===(t=s.roles)||void 0===t?void 0:t.some(e=>"EKYC_SUPERVISOR"===e.code),a={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_create",msgId:Date.now()+"|en_IN",authToken:(null===(l=Digit.UserService.getUser())||void 0===l?void 0:l.access_token)||(null==s?void 0:s.authToken),...o&&{userInfo:{id:null==s?void 0:s.id,uuid:null==s?void 0:s.uuid,userName:null==s?void 0:s.userName,name:null==s?void 0:s.name,type:null==s?void 0:s.type,tenantId:(null==s?void 0:s.tenantId)||u,roles:null==s?void 0:s.roles}}},surveyor:{tenantId:c,description:(null==e?void 0:e.description)||"",additionalDetails:{serviceType:"ekyc"},owner:{tenantId:c,name:null==e?void 0:e.fullName,fatherOrHusbandName:null==e?void 0:e.fatherOrHusbandName,relationship:null==e||null===(n=e.relationship)||void 0===n?void 0:n.code,gender:(null==e||null===(i=e.gender)||void 0===i?void 0:i.code)||"OTHERS",dob:null!=e&&e.dob?new Date(e.dob).getTime():null,emailId:null==e?void 0:e.emailId,mobileNumber:null==e?void 0:e.mobileNumber,correspondenceAddress:null==e?void 0:e.correspondenceAddress}}};_(a,{onError:e=>{m({key:"error",action:e}),setTimeout(N,5e3)},onSuccess:()=>{m({key:"success",action:"ADD_SURVEYOR"}),v.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(N,5e3)}})},defaultValues:{role:{code:"SURVEYOR",name:"Surveyor"}},onFormValueChange:(e,t)=>{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.fatherOrHusbandName)&&(null==t?void 0:t.relationship)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.correspondenceAddress)))},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(i.Toast,{error:"error"===E.key,label:d("success"===E.key?`ES_VENDOR_${E.action}_SUCCESS`:E.action),onClose:N})))},SurveyorDetails:e=>{var a,d;const s=Digit.ULBService.getCurrentTenantId(),{t:u}=o.useTranslation(),c=n.useHistory(),E=r.useQueryClient(),{id:m}=n.useParams(),[v,S]=t.useState(!1),[p,_]=t.useState(null),[R,D]=t.useState(!1),[N,g]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),{data:O}=Digit.Hooks.fsm.useDsoSearch(s,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{data:A,isLoading:h,refetch:b}=Digit.Hooks.fsm.useSurveyorSearch(s,{ids:m},{staleTime:Infinity}),f=l.useMemo(()=>{var e;return null!=A&&null!==(e=A.surveyors)&&void 0!==e&&e.length?A.surveyors.map(e=>{var t,l,n,i;const o=null==O?void 0:O.find(t=>{var l,n;return(null===(l=t.dsoDetails)||void 0===l?void 0:l.id)===e.vendorId||(null===(n=t.dsoDetails)||void 0===n?void 0:n.vendorId)===e.vendorId}),a=(null==o||null===(t=o.dsoDetails)||void 0===t?void 0:t.name)||e.vendorId||"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR";return{surveyorData:e,vendorDetails:{vendor:o?[o.dsoDetails]:[]},employeeResponse:[{title:"ES_VENDOR_SURVEYOR_BASIC_DETAILS",values:[{title:"ES_VENDOR_SURVEYOR_FULL_NAME",value:null==e?void 0:e.name},{title:"ES_VENDOR_SURVEYOR_MOBILE_NUMBER",value:(null==e||null===(l=e.owner)||void 0===l?void 0:l.mobileNumber)||(null==e?void 0:e.mobileNo)},{title:"ES_VENDOR_SURVEYOR_EMAIL_ID",value:null==e||null===(n=e.owner)||void 0===n?void 0:n.emailId},{title:"ES_VENDOR_SURVEYOR_STAFF_CODE",value:(null==e?void 0:e.employeeId)||"N/A"},{title:"ES_VENDOR_SURVEYOR_GENDER",value:null==e||null===(i=e.owner)||void 0===i?void 0:i.gender},{title:"ES_VENDOR_SURVEYOR_AGENCY_NAME",value:a,type:"custom"}]}]}}):[]},[A,O]),{mutate:V}=Digit.Hooks.fsm.useSurveyorUpdate(s),{mutate:L}=Digit.Hooks.fsm.useVendorUpdate(s);t.useEffect(()=>{if(O){let e=O.map(e=>e.dsoDetails);T(e)}},[O]),t.useEffect(()=>{b()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return D(!0);case"EDIT":return c.push("/digit-ui/employee/vendor/registry/modify-surveyor/"+m);case"HOME":return c.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SURVEYOR")}},[p]);const M=()=>{g(null)},k=()=>{_(null),C({}),D(!1)};return h?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(i.Card,null,null==f||null===(a=f[0])||void 0===a||null===(d=a.employeeResponse)||void 0===d?void 0:d.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(i.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(i.Card,{className:"card-with-background"},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(i.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(i.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>_("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(i.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},u(e.value)||"N/A"))))))}))),R&&l.createElement(i.Modal,{headerBarMain:l.createElement(K,{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(z,{onClick:k}),actionCancelLabel:u("CS_COMMON_CANCEL"),actionCancelOnSubmit:k,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==f||null===(e=f[0])||void 0===e?void 0:e.surveyorData,status:"INACTIVE"}};V(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)}}),D(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=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],i=(null==n?void 0:n.surveyors)||[];i=i.map(e=>(e.id===m&&(e.vendorSurveyorStatus="INACTIVE"),e));const o={vendor:{...n,surveyors:i}};L(o,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),b(),setTimeout(M,5e3)}}),D(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=I,l=null==f||null===(e=f[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:{...t,surveyors:t.surveyors?[...t.surveyors,l]:[l]}};L(n,{onError:e=>{g({key:"error",action:e}),b(),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"ADD_VENDOR"}),E.invalidateQueries("SURVEYOR_SEARCH"),b(),setTimeout(M,5e3)}}),D(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=I,l=null==f||null===(e=f[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:{...t,surveyors:t.surveyors?[...t.surveyors,l]:[l]}};L(n,{onError:e=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:()=>{g({key:"success",action:"EDIT_VENDOR"}),b(),E.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(M,5e3)}}),D(!1),_(null)})()}}},l.createElement(i.Card,{style:{boxShadow:"none"}},"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(w,{t:u,title:"ES_VENDOR_SURVEYOR_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(i.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(i.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0)),N&&l.createElement(i.Toast,{error:"error"===N.key,label:u("success"===N.key?`ES_VENDOR_${N.action}_SUCCESS`:N.action),onClose:M}),l.createElement(i.ActionBar,{style:{zIndex:"19"}},v?l.createElement(i.Menu,{localeKeyPrefix:"ES_VENDOR_SURVEYOR_ACTION",options:["EDIT","DELETE"],t:u,onSelect:e=>{S(!1),_(e)}}):null,l.createElement(i.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)})))},EditSurveyor:()=>{var e;const{t:a}=o.useTranslation(),d=n.useHistory(),s=r.useQueryClient(),{id:u}=n.useParams(),c=null===(e=Digit.UserService.getUser())||void 0===e?void 0:e.info,E=Digit.ULBService.getCurrentTenantId(),m=null!=E&&E.includes(".")?E:E+".djb",[v,S]=t.useState(null),[p,_]=t.useState(!1),[R,D]=t.useState({}),[N,g]=t.useState({}),{data:y,isLoading:T}=Digit.Hooks.fsm.useSurveyorSearch(m,{ids:u},{staleTime:Infinity}),{mutate:I}=Digit.Hooks.fsm.useSurveyorUpdate(m),C=W(a);t.useEffect(()=>{if(y&&y.surveyors&&y.surveyors.length>0){var e,t,l,n,i,o,a,r,d;let s=y.surveyors[0];g(s);let u={fullName:(null==s||null===(e=s.owner)||void 0===e?void 0:e.name)||(null==s?void 0:s.name),mobileNumber:(null==s||null===(t=s.owner)||void 0===t?void 0:t.mobileNumber)||(null==s?void 0:s.mobileNo),emailId:null==s||null===(l=s.owner)||void 0===l?void 0:l.emailId,employeeId:null==s?void 0:s.employeeId,gender:null!=s&&null!==(n=s.owner)&&void 0!==n&&n.gender?{code:s.owner.gender,name:"COMMON_GENDER_"+s.owner.gender}:null,fatherOrHusbandName:null==s||null===(i=s.owner)||void 0===i?void 0:i.fatherOrHusbandName,relationship:null!=s&&null!==(o=s.owner)&&void 0!==o&&o.relationship?{code:s.owner.relationship,name:"ES_COMMON_RELATION_"+s.owner.relationship}:null,dob:(null==s||null===(a=s.owner)||void 0===a?void 0:a.dob)&&Digit.DateUtils.ConvertTimestampToDate(null==s||null===(r=s.owner)||void 0===r?void 0:r.dob,"yyyy-MM-dd"),correspondenceAddress:null==s||null===(d=s.owner)||void 0===d?void 0:d.correspondenceAddress,description:null==s?void 0:s.description};D(u)}},[y]);const O=()=>{S(null)};return T||0===Object.keys(R).length?l.createElement(i.Loader,null):l.createElement(l.Fragment,null,l.createElement(i.VerticalTimeline,{config:[{timeLine:[{actions:a("ES_VENDOR_SURVEYOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(i.FormComposer,{isDisabled:!p,label:a("ES_COMMON_APPLICATION_SUBMIT"),config:C.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,i,o,a,r,E,v,p;const _={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_update",msgId:Date.now()+"|en_IN",authToken:null==c?void 0:c.authToken,userInfo:{id:null==c?void 0:c.id,uuid:null==c?void 0:c.uuid,userName:null==c?void 0:c.userName,name:null==c?void 0:c.name,type:null==c?void 0:c.type,tenantId:m,roles:null==c?void 0:c.roles}},surveyor:{...N,description:(null==e?void 0:e.description)||(null==N?void 0:N.description)||"",name:(null==e?void 0:e.fullName)||(null==N?void 0:N.name),mobileNo:(null==e?void 0:e.mobileNumber)||(null==N?void 0:N.mobileNo),employeeId:(null==e?void 0:e.employeeId)||(null==N?void 0:N.employeeId),owner:{...N.owner,name:(null==e?void 0:e.fullName)||(null===(t=N.owner)||void 0===t?void 0:t.name),fatherOrHusbandName:(null==e?void 0:e.fatherOrHusbandName)||(null===(l=N.owner)||void 0===l?void 0:l.fatherOrHusbandName),relationship:(null==e||null===(n=e.relationship)||void 0===n?void 0:n.code)||(null===(i=N.owner)||void 0===i?void 0:i.relationship),gender:(null==e||null===(o=e.gender)||void 0===o?void 0:o.code)||(null===(a=N.owner)||void 0===a?void 0:a.gender)||"OTHERS",dob:null!=e&&e.dob?new Date(e.dob).getTime():null===(r=N.owner)||void 0===r?void 0:r.dob,emailId:(null==e?void 0:e.emailId)||(null===(E=N.owner)||void 0===E?void 0:E.emailId),mobileNumber:(null==e?void 0:e.mobileNumber)||(null===(v=N.owner)||void 0===v?void 0:v.mobileNumber),correspondenceAddress:(null==e?void 0:e.correspondenceAddress)||(null===(p=N.owner)||void 0===p?void 0:p.correspondenceAddress)}}};I(_,{onError:e=>{S({key:"error",action:e}),setTimeout(O,5e3)},onSuccess:()=>{S({key:"success",action:"UPDATE_SURVEYOR"}),s.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(()=>{O(),d.push("/digit-ui/employee/vendor/registry/surveyor-details/"+u)},5e3)}})},defaultValues:R,onFormValueChange:(e,t)=>{_(!!((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.fatherOrHusbandName)&&(null==t?void 0:t.relationship)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.correspondenceAddress)))},noBreakLine:!0,mode:"onChange",noCard:!0}),v&&l.createElement(i.Toast,{error:"error"===v.key,label:a("success"===v.key?`ES_VENDOR_${v.action}_SUCCESS`:v.action),onClose:O})))},SelectEkycZones:e=>{let{config:n,onSelect:o,t:a,formData:r}=e;const d=Digit.ULBService.getCurrentTenantId(),[s,u]=t.useState([]),[c,E]=t.useState(Array.isArray(null==r?void 0:r.zoneIds)?r.zoneIds:[]),{data:m,isLoading:v}=Digit.Hooks.useCommonMDMS(d,"egov-location",["TenantBoundary"]);return t.useEffect(()=>{var e,t,l,n,i;const o=(null==m||null===(e=m["egov-location"])||void 0===e||null===(t=e.TenantBoundary)||void 0===t?void 0:t[0])||(null==m||null===(l=m.MdmsRes)||void 0===l||null===(n=l["egov-location"])||void 0===n||null===(i=n.TenantBoundary)||void 0===i?void 0:i[0]),a=(null==o?void 0:o.boundary)||(null==o?void 0:o.children)||[];if(Array.isArray(null==a?void 0:a.children)&&(null==a?void 0:a.children.length)>0){const e=null==a?void 0:a.children.map(e=>({code:e.code,name:e.name}));u(e)}else v||u([{code:"ZONE-01",name:"ZONE-01"},{code:"ZONE-02",name:"ZONE-02"},{code:"ZONE-03",name:"ZONE-03"},{code:"ZONE-04",name:"ZONE-04"},{code:"ZONE-05",name:"ZONE-05"}])},[m,v]),v?l.createElement(i.Loader,null):l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,a(n.label)+(n.isMandatory?" *":"")),l.createElement("div",{className:"field",style:{position:"relative",zIndex:10}},l.createElement(i.MultiSelectDropdown,{options:s,selected:c,onSelect:e=>{const t=Array.isArray(e)?e.map(e=>Array.isArray(e)?e[1]:e).filter(Boolean):e;E(t),o(n.key,t)},optionsKey:"name",t:a,ServerStyle:{backgroundColor:"#fff"}})))},SelectEkycClusters:e=>{let{config:n,onSelect:o,t:a,formData:r}=e;const d=Digit.ULBService.getCurrentTenantId(),[s,u]=t.useState([]),[c,E]=t.useState(Array.isArray(null==r?void 0:r.clusterIds)?r.clusterIds:[]),m=l.useMemo(()=>Array.isArray(null==r?void 0:r.zoneIds)?r.zoneIds:[],[null==r?void 0:r.zoneIds]),{data:v}=Digit.Hooks.useCommonMDMS(d,"egov-location",["TenantBoundary"]);t.useEffect(()=>{var e,t,l,n,i;const o=(null==v||null===(e=v["egov-location"])||void 0===e||null===(t=e.TenantBoundary)||void 0===t?void 0:t[0])||(null==v||null===(l=v.MdmsRes)||void 0===l||null===(n=l["egov-location"])||void 0===n||null===(i=n.TenantBoundary)||void 0===i?void 0:i[0]),a=(null==o?void 0:o.boundary)||(null==o?void 0:o.children)||[];let r=[];if(m.length>0&&Array.isArray(a)&&a.length>0&&m.forEach(e=>{const t=a.find(t=>t.code===e.code),l=(null==t?void 0:t.children)||(null==t?void 0:t.boundary)||[];Array.isArray(l)&&l.forEach(e=>{r.push({code:e.code,name:e.name})})}),0===r.length){const e={"ZONE-01":[{code:"CLUSTER-01",name:"CLUSTER-01"}],"ZONE-02":[{code:"CLUSTER-02",name:"CLUSTER-02"}],"ZONE-03":[{code:"CLUSTER-03",name:"CLUSTER-03"}],"ZONE-04":[{code:"CLUSTER-04",name:"CLUSTER-04"}],"ZONE-05":[{code:"CLUSTER-05",name:"CLUSTER-05"}]};m.length>0?m.forEach(t=>{e[t.code]?r=[...r,...e[t.code]]:r.push({code:t.code+"-C1",name:t.name+" Cluster 1"})}):r=[{code:"CLUSTER-01",name:"CLUSTER-01"},{code:"CLUSTER-02",name:"CLUSTER-02"},{code:"CLUSTER-03",name:"CLUSTER-03"}]}r.length>0&&(r=Array.from(new Map(r.map(e=>[e.code,e])).values())),u(r)},[m,v]);const S=0===m.length;return l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,a(n.label)+(n.isMandatory?" *":"")),l.createElement("div",{className:"field",style:{position:"relative",zIndex:9}},l.createElement(i.MultiSelectDropdown,{options:s,selected:c,onSelect:e=>{const t=Array.isArray(e)?e.map(e=>Array.isArray(e)?e[1]:e).filter(Boolean):e;E(t),o(n.key,t)},optionsKey:"name",t:a,ServerStyle:{backgroundColor:"#fff"},disable:S})))},SelectEkycDropdown:e=>{var t,n;let{config:o,onSelect:a,t:r,formData:d}=e;const s=(null==o||null===(t=o.populators)||void 0===t?void 0:t.options)||[],u=(null==o||null===(n=o.populators)||void 0===n?void 0:n.optionsKey)||"name",c=null==d?void 0:d[o.key];return l.createElement(i.LabelFieldPair,null,l.createElement(i.CardLabel,null,r(o.label)),l.createElement("div",{className:"field"},l.createElement(i.Dropdown,{selected:c,option:s,select:e=>{a(o.key,e)},optionKey:u,t:r})))}},de=e=>{let{stateCode:i,userType:o,tenants:a}=e;const{path:r,url:d}=n.useRouteMatch(),u=Digit.StoreData.getCurrentLanguage();return Digit.Services.useStore({stateCode:i,moduleCode:"VENDOR",language:u}),Object.entries(re).forEach(e=>{let[t,l]=e;Digit.ComponentRegistryService.setComponent(t,l)}),Digit.SessionStorage.set("VENDOR_TENANTS",a),t.useEffect(()=>"employee"===o&&Digit.LocalizationService.getLocale({modules:["rainmaker-"+Digit.ULBService.getCurrentTenantId()],locale:Digit.StoreData.getCurrentLanguage(),tenantId:Digit.ULBService.getCurrentTenantId()}),[]),l.createElement("employee"===o?s:M,{path:r,url:d,userType:o})},se=e=>{const[,,l]=Digit.Hooks.useSessionStorage("VENDOR",{});return t.useEffect(()=>{l()},[]),null};exports.VENDORComponents={VENDORCard:()=>{const{t:e}=o.useTranslation(),t=n.useHistory(),a=window.location.pathname.toLowerCase().includes("citizen");let r=Digit.Utils.vendorAccess()||Digit.UserService.hasAccess(["WT_VENDOR","MT_VENDOR"]);if(a&&(r=Digit.UserService.hasAccess(["WT_VENDOR","EKYC_VENDOR","EKYC_SUPERVISOR"])),!r)return null;const d=[{label:e("VENDOR_NEW_REGISTERATION"),link:a?"/digit-ui/citizen/vendor/registry/new-vendor":"/digit-ui/employee/vendor/registry/new-vendor"},{label:e("SEARCH_VENDOR"),link:a?"/digit-ui/citizen/vendor/search-vendor":"/digit-ui/employee/vendor/search-vendor"}],s=Digit.UserService.hasAccess(["WT_VENDOR"]),u={Icon:l.createElement(i.PropertyHouse,null),moduleName:e("TITLE_VENDOR_MANAGEMENT"),kpis:[{count:0,label:e("Inbox"),link:a?"/digit-ui/citizen/vendor/search-vendor":"/digit-ui/employee/vendor/search-vendor"}],links:d.filter(e=>!(null!=e&&e.role)||s),...a?{onDetailsClick:()=>t.push("/digit-ui/citizen/vendor/search-vendor")}:{}};return a?l.createElement("div",{className:"wt-citizen-card-premium"},l.createElement(i.EmployeeModuleCard,u)):l.createElement(i.EmployeeModuleCard,u)},VENDORModule:de,VENDORLinks:se},exports.VENDORLinks=se,exports.VENDORModule=de;