@djb25/digit-ui-module-vendor 1.0.47 → 1.0.48

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
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"),o=require("@djb25/digit-ui-react-components"),i=require("react-i18next"),a=require("react-query"),r=require("react-hook-form");function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var n in l)({}).hasOwnProperty.call(l,n)&&(e[n]=l[n])}return e}).apply(null,arguments)}function d(e,t){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{DatePicker:u}=require("@djb25/digit-ui-react-components"),c=function(e,t,n,o){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_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(u,s({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"}}]}]},E=e=>{var r;const{t:s}=i.useTranslation(),u=n.useHistory(),E=null===(r=Digit.UserService.getUser())||void 0===r?void 0:r.info,m=null==E?void 0:E.type,v=Digit.ULBService.getCurrentTenantId(),S=null!=v&&v.includes(".")?v:v+".djb",[p,_]=t.useState(null),D=a.useQueryClient(),[R,g]=t.useState(!1),{mutateAsync:N}=Digit.Hooks.fsm.useSurveyorCreate(S),y=c(s);return l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{route:"surveyor-details",timeLine:[{actions:s("ES_VENDOR_SURVEYOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(o.FormComposer,{isDisabled:!R,label:s("ES_COMMON_APPLICATION_SUBMIT"),config:y.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:function(e){try{var t,l,n;const o=null==E||null===(t=E.roles)||void 0===t?void 0:t.some(e=>"EKYC_SUPERVISOR"===e.code),i={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==E?void 0:E.authToken),...o&&{userInfo:{id:null==E?void 0:E.id,uuid:null==E?void 0:E.uuid,userName:null==E?void 0:E.userName,name:null==E?void 0:E.name,type:m,tenantId:(null==E?void 0:E.tenantId)||v,roles:null==E?void 0:E.roles}}},surveyor:{tenantId:S,description:(null==e?void 0:e.description)||"",additionalDetails:{serviceType:"ekyc"},owner:{tenantId:S,name:null==e?void 0:e.fullName,fatherOrHusbandName:"Static Father",relationship:"FATHER",gender:(null==e||null===(n=e.gender)||void 0===n?void 0:n.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=d(function(){return Promise.resolve(N(i)).then(function(){D.invalidateQueries("SURVEYOR_SEARCH"),u.push({pathname:`/digit-ui/${m}/vendor/search-vendor`,state:{showSuccessToast:!0,message:{key:"success",action:"ES_VENDOR_ADD_SURVEYOR_SUCCESS"}}})})},function(e){_({key:"error",action:(null==e?void 0:e.message)||e})});return Promise.resolve(a&&a.then?a.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},defaultValues:{role:{code:"SURVEYOR",name:"Surveyor"},mobileNumber:""},onFormValueChange:(e,t)=>{g(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.correspondenceAddress)))},noBreakLine:!0,mode:"onChange",noCard:!0}),p&&l.createElement(o.Toast,{error:"error"===p.key,label:s("success"===p.key?`ES_VENDOR_${p.action}_SUCCESS`:p.action),onClose:()=>{_(null)}})))},m=e=>{let{parentRoute:a}=e;const{t:r}=i.useTranslation(),s=[{text:r("ES_TITLE_NEW_DESULDGING_APPLICATION"),link:"/digit-ui/employee/fsm/new-application",roles:["FSM_CREATOR_EMP"]},{text:r("ES_TITILE_SEARCH_APPLICATION"),link:a+"/search"},{text:r("ES_TITLE_REPORTS"),link:"/employee/report/fsm/FSMDailyDesludingReport",roles:["FSM_ADMIN"],hyperlink:!0}],[d,u]=t.useState([]),{roles:c}=Digit.UserService.getUser().info;return t.useEffect(()=>{let e=s.filter(e=>{let{roles:t}=e;return(null==t?void 0:t.some(e=>null==c?void 0:c.map(e=>{let{code:t}=e;return t}).includes(e)))||!(null!=t&&t.length)});u(e)},[]),l.createElement(o.Card,{className:"employeeCard inboxLinksFSM"},l.createElement("div",{className:"complaint-links-container"},l.createElement("div",{className:"header"},l.createElement("span",{className:"logo"},l.createElement(o.ShippingTruck,null))," ",l.createElement("span",{className:"text"},r("ES_TITLE_FAECAL_SLUDGE_MGMT"))),l.createElement("div",{className:"body"},d.map((e,t)=>{let{link:o,text:i,hyperlink:a=!1,accessTo:s=[]}=e;return l.createElement("span",{className:"link",key:t},a?l.createElement("a",{href:o},r(i)):l.createElement(n.Link,{to:o},r(i)))}))))},v=e=>{let{className:t="table",t:n,currentPage:i,columns:a,data:r,getCellProps:d,disableSort:u,onSort:c,onNextPage:E,onPrevPage:m,onPageSizeChange:v,pageSizeLimit:S,sortParams:p,totalRecords:_,isPaginationRequired:D,showCSVExport:R,csvExportFileName:g,csvExportData:N,getCSVExportData:y,csvExportColumns:T,csvExportButtonLabel:I,...C}=e;return l.createElement(o.Card,null,l.createElement(o.Table,s({className:t,t:n,data:r,currentPage:i,columns:a,getCellProps:d,onNextPage:E,onPrevPage:m,pageSizeLimit:S,disableSort:u,onPageSizeChange:v,onSort:c,sortParams:p,totalRecords:_,isPaginationRequired:D,showCSVExport:R,csvExportFileName:g,csvExportData:N,getCSVExportData:y,csvExportColumns:T,csvExportButtonLabel:I},C)))},S=e=>{var t;let{status:n,searchParams:a,onAssignmentChange:r,statusMap:s}=e;return i.useTranslation(),l.createElement(o.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==s||null===(t=s.find(e=>e.statusid===n.uuid))||void 0===t?void 0:t.count)||"-"})`})},p=e=>{var n,a,r,s,d;let{onAssignmentChange:u,searchParams:c,businessServices:E,statusMap:m}=e;const{t:v}=i.useTranslation(),[p,_]=t.useState(!1),{data:D,isLoading:R}=Digit.Hooks.useApplicationStatusGeneral({businessServices:E},{}),{userRoleStates:g}=D||{},N=(e,t)=>t(map[e.stateBusinessService])+" - "+t("ES_PTR_COMMON_STATUS_"+(e.state||"CREATED"));return R?l.createElement(o.Loader,null):null!=g&&g.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==g||null===(n=g.filter(e=>!e.isTerminateState))||void 0===n||null===(a=n.slice(0,4))||void 0===a?void 0:a.map((e,t)=>l.createElement(S,{businessServices:E,key:t,onAssignmentChange:u,status:{name:N(e,v),code:e.applicationStatus,...e},searchParams:c,statusMap:m})),(null==g||null===(r=g.filter(e=>!e.isTerminateState))||void 0===r?void 0:r.slice(4).length)>0?l.createElement(l.Fragment,null,p&&(null==g||null===(s=g.filter(e=>!e.isTerminateState))||void 0===s||null===(d=s.slice(4))||void 0===d?void 0:d.map((e,t)=>l.createElement(S,{businessServices:E,key:e.uuid,onAssignmentChange:u,status:{name:N(e,v),code:e.applicationStatus,...e},searchParams:c,statusMap:m}))),l.createElement("div",{className:"filter-button",onClick:()=>_(!p)}," ",v(p?"ES_COMMON_LESS":"ES_COMMON_MORE")," ")):null):null},_=e=>{let{onFilterChange:t,searchParams:n,paginationParms:i,tenantId:a,t:r}=e;const{data:s}=Digit.Hooks.fsm.useInbox(a,{...n,...i,fromDate:null!=n&&n.fromDate?new Date(null==n?void 0:n.fromDate).getTime():void 0,toDate:null!=n&&n.toDate?new Date(null==n?void 0:n.toDate).getTime():void 0,total:!0,uuid:{code:"ASSIGNED_TO_ALL",name:r("ES_INBOX_ASSIGNED_TO_ALL")}}),d=[{code:"ASSIGNED_TO_ME",name:r("ES_INBOX_ASSIGNED_TO_ME")+" (0)"},{code:"ASSIGNED_TO_ALL",name:`${r("ES_INBOX_ASSIGNED_TO_ALL")} (${(null==s?void 0:s.totalCount)||0})`}];return l.createElement(l.Fragment,null,l.createElement(o.RadioButtons,{onSelect:e=>t({uuid:{code:e.code}}),selectedOption:d.filter(e=>{var t;return e.code===(null==n||null===(t=n.uuid)||void 0===t?void 0:t.code)})[0],optionsKey:"name",options:d}))},D=e=>{var t,a,r,s;let{searchParams:d,paginationParms:u,onFilterChange:c,onSearch:E,...m}=e;const{t:v}=i.useTranslation(),S=n.useLocation(),D=Digit.UserService.hasAccess(["FSM_DSO"])||!1,R=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1,g=Digit.UserService.hasAccess("FSM_EMP_FSTPO")&&S.pathname.includes("fstp-fsm-request")||!1,N=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),A=null==T?void 0:T.filter(e=>C.filter(t=>t===e.userRole)[0]),O=null==A?void 0:A.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:[]}),b=()=>{if(R)return c()};return l.createElement(l.Fragment,null,(!D&&!R&&d||(null==O||null===(t=O.statuses)||void 0===t?void 0:t.length)>0||g)&&l.createElement("div",{className:"filter",style:{marginTop:R?"-0px":"revert"}},l.createElement("div",{className:"filter-card"},l.createElement("div",{className:"heading"},l.createElement("div",{className:"filter-label"},v("ES_COMMON_FILTER_BY"),":"),l.createElement("div",{className:"clearAll",onClick:b},v("ES_COMMON_CLEAR_ALL")),"desktop"===m.type&&l.createElement("span",{className:"clear-search",onClick:b},v("ES_COMMON_CLEAR_ALL")),"mobile"===m.type&&l.createElement("span",{onClick:m.onClose},l.createElement(o.CloseSvg,null))),l.createElement("div",null,!D&&!R&&d&&l.createElement(_,{onFilterChange:c,searchParams:d,paginationParms:u,tenantId:N,t:v}),l.createElement("div",null)),(null==O||null===(a=O.statuses)||void 0===a?void 0:a.length)>0||g?l.createElement("div",null,l.createElement("div",{className:"filter-label"},v("ES_INBOX_LOCALITY")),l.createElement(o.Localities,{selectLocality:e=>{c(R?{locality:[e]}:{locality:[...null==d?void 0:d.locality,e]})},tenantId:N,boundaryType:"revenue"}),l.createElement("div",{className:"tag-container"},null==d?void 0:d.locality.map((e,t)=>l.createElement(o.RemoveableTag,{key:t,text:e.i18nkey,onClick:()=>{c({locality:null==d?void 0:d.locality.filter(t=>t.code!==e.code)})}})))):null,l.createElement("div",null,I&&O&&null!=m&&null!==(r=m.applications)&&void 0!==r&&r.statuses?l.createElement(p,{onAssignmentChange:(e,t)=>{c(e.target.checked?{applicationStatus:[...null==d?void 0:d.applicationStatus,t]}:{applicationStatus:null==d?void 0:d.applicationStatus.filter(e=>t.name!==e.name)})},fsmfilters:d,mergedRoleDetails:O,statusMap:null==m||null===(s=m.applications)||void 0===s?void 0:s.statuses}):S.pathname.includes("fstp-fsm-request")?"":l.createElement(o.Loader,null)))),"mobile"===m.type&&m.onClose&&l.createElement(o.ActionBar,null,l.createElement(o.ApplyFilterBar,{submit:!1,labelLink:v("ES_COMMON_CLEAR_ALL"),buttonLink:v("ES_COMMON_FILTER"),onClear:b,onSubmit:()=>{"mobile"===m.type?E({delete:["applicationNos"]}):E()},style:{flex:1}})))},R=e=>{let{onAssignmentChange:t,value:n,applicationStatuses:i,areApplicationStatus:a}=e;return a?l.createElement(o.Dropdown,{option:i,optionKey:"name",selected:n,select:t}):l.createElement(o.Loader,null)},g=e=>{var a,d,u,c,E,m,v,S,p,_,D,g;let{onSearch:N,type:y,onClose:T,onTabChange:I,searchFields:C,searchParams:A,isInboxPage:O,selectedTab:b,matchedRoles:f}=e;const h=O?Digit.SessionStorage.get("vendor/inbox/searchParams"):Digit.SessionStorage.get("vendor/search/searchParams"),{t:V}=i.useTranslation(),L=n.useHistory(),{register:M,handleSubmit:w,reset:k,watch:P,control:F}=r.useForm({defaultValues:h||A}),[x,H]=t.useState(!1),U=window.Digit.Utils.browser.isMobile(),B=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1;function Y(){const e=C.reduce((e,t)=>({...e,[null==t?void 0:t.name]:""}),{});k(e),O?Digit.SessionStorage.del("fsm/inbox/searchParams"):Digit.SessionStorage.del("fsm/search/searchParams"),N({})}const G=e=>null,W=Digit.SessionStorage.get("User").info.type,K=[...null!=f&&null!==(a=f.wt)&&void 0!==a&&a.includes("WT_VENDOR")?["VENDOR"]:[],...null!=f&&null!==(d=f.wt)&&void 0!==d&&d.includes("WT_VENDOR")?["DRIVER","VEHICLE"]:[],...null!=f&&null!==(u=f.ekyc)&&void 0!==u&&u.includes("EKYC_VENDOR")?["SUPERVISOR"]:[],...null!=f&&null!==(c=f.ekyc)&&void 0!==c&&c.includes("EKYC_SUPERVISOR")?["SURVEYOR"]:[]];return l.createElement(l.Fragment,null,l.createElement("div",{className:"search-container"},l.createElement("div",{className:"search-complaint-container"},("mobile"===y||U)&&l.createElement("div",{className:"complaint-header"},l.createElement("h2",null,V("ES_COMMON_SEARCH_BY")),l.createElement("span",{style:{position:"absolute",top:"2%",right:"8px"},onClick:T},l.createElement(o.CloseSvg,null))),l.createElement("div",{className:"search-tabs-container"},l.createElement("div",null,((null==f||null===(E=f.wt)||void 0===E?void 0:E.includes("WT_VENDOR"))||(null==f||null===(m=f.ekyc)||void 0===m?void 0:m.includes("EKYC_VENDOR")))&&l.createElement("button",{className:"VENDOR"===b?"search-tab-head-selected":"search-tab-head",onClick:()=>{Y(),I("VENDOR")}},V("ES_FSM_REGISTRY_INBOX_TAB_VENDOR")),(null==f||null===(v=f.wt)||void 0===v?void 0:v.includes("WT_VENDOR"))&&l.createElement("button",{className:"VEHICLE"===b?"search-tab-head-selected":"search-tab-head",onClick:()=>{Y(),I("VEHICLE")}},V("ES_FSM_REGISTRY_INBOX_TAB_VEHICLE")),(null==f||null===(S=f.wt)||void 0===S?void 0:S.includes("WT_VENDOR"))&&l.createElement("button",{className:"DRIVER"===b?"search-tab-head-selected":"search-tab-head",onClick:()=>{Y(),I("DRIVER")}},V("ES_FSM_REGISTRY_INBOX_TAB_DRIVER")),((null==f||null===(p=f.ekyc)||void 0===p?void 0:p.includes("EKYC_VENDOR"))||(null==f||null===(_=f.ekyc)||void 0===_?void 0:_.includes("EKYC_SUPERVISOR")))&&l.createElement("button",{className:"SUPERVISOR"===b?"search-tab-head-selected":"search-tab-head",onClick:()=>{Y(),I("SUPERVISOR")}},V("ES_FSM_REGISTRY_INBOX_TAB_SUPERVISOR")),((null==f||null===(D=f.ekyc)||void 0===D?void 0:D.includes("EKYC_SUPERVISOR"))||(null==f||null===(g=f.ekyc)||void 0===g?void 0:g.includes("EKYC_VENDOR")))&&l.createElement("button",{className:"SURVEYOR"===b?"search-tab-head-selected":"search-tab-head",onClick:()=>{Y(),I("SURVEYOR")}},V("ES_FSM_REGISTRY_INBOX_TAB_SURVEYOR"))),l.createElement("div",{className:"action-bar-wrap-registry"},l.createElement("div",{className:"search-add",onClick:()=>{H(!x)}},V("ES_VENDOR_REGISTRY_INBOX_HEADER_ADD"),l.createElement("div",{className:"search-add-icon"},l.createElement(o.AddIcon,{className:""}))),x&&l.createElement(o.Menu,{localeKeyPrefix:"ES_FSM_ACTION_CREATE",options:K,t:V,onSelect:function(e){const t=null==W?void 0:W.toLowerCase();switch(e){case"VENDOR":return L.push(`/digit-ui/${t}/vendor/registry/new-vendor`);case"VEHICLE":return L.push(`/digit-ui/${t}/vendor/registry/new-vehicle`);case"DRIVER":return L.push(`/digit-ui/${t}/vendor/registry/new-driver`);case"SUPERVISOR":return L.push(`/digit-ui/${t}/vendor/registry/new-supervisor`);case"SURVEYOR":return L.push(`/digit-ui/${t}/vendor/registry/new-surveyor`)}}}))),l.createElement("form",{onSubmit:w(e=>{e.mobileNumber||delete e.mobileNumber,N(e),"mobile"===y&&T()})},l.createElement("div",{className:B?"for-pt for-search flex-box":"flex-box",style:{gap:"16px"}},null==C?void 0:C.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(r.Controller,{render:e=>l.createElement(o.DatePicker,{date:e.value,onChange:e.onChange}),name:e.name,control:F,defaultValue:null});case"status":return l.createElement(r.Controller,{render:e=>l.createElement(R,{onAssignmentChange:e.onChange,value:e.value}),name:e.name,control:F,defaultValue:null});case"dropdown":return l.createElement(r.Controller,{render:t=>l.createElement(o.Dropdown,{option:e.options,optionKey:e.optionsKey,value:t.value,selected:t.value,select:t.onChange,t:V,placeholder:e.label}),name:e.name,control:F,defaultValue:null});default:return l.createElement(o.TextInput,s({},e,{inputRef:M},M(e.name,{validate:G}),{watch:P,shouldUpdate:!0,placeholder:e.label}))}})(e))),l.createElement("div",{style:{display:"flex",justifyContent:"end",gap:"16px",alignItems:"center"}},"desktop"===y&&!U&&l.createElement("span",{className:"clear-search generic-button"},l.createElement(o.LinkLabel,{style:{},onClick:Y},V("ES_COMMON_CLEAR_SEARCH"))),"desktop"===y&&!U&&l.createElement(o.SubmitBar,{className:"submit-bar-search",label:V("ES_COMMON_SEARCH"),submit:!0})))))))},N=e=>{if(!e)return{};if("object"==typeof e)return e;if("string"!=typeof e)return{};try{return JSON.parse(e)}catch(e){return{}}},y=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):[]},T=function(e,t){void 0===t&&(t=[]);const l=function(e){var t,l,n,o,i,a,r,s,d,u,c,E,m;void 0===e&&(e={});const v=e=>Array.isArray(e)?e.flatMap(y):y(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===(o=e)||void 0===o||null===(i=o.fillingpointmetadata)||void 0===i?void 0:i.fillingPointId,null===(a=e)||void 0===a?void 0:a.fillingPtName,null===(r=e)||void 0===r?void 0:r.filling_pt_name,null===(s=e)||void 0===s||null===(d=s.fillingPoint)||void 0===d?void 0:d.fillingPointId].filter(e=>null!=e&&""!==e).map(String),...v(null===(u=e)||void 0===u?void 0:u.fillingPoint),...v(null===(c=e)||void 0===c||null===(E=c.dsoDetails)||void 0===E?void 0:E.fillingPoint),...v(null===(m=e)||void 0===m?void 0:m.fillingPointDetail)]))}(e);return l.length&&t.find(e=>y(e).some(e=>l.includes(e)))||null},I=function(e){var t,l,n,o,i,a,r,s,d,u,c,E,m,v,S,p,_,D,R,g,N,y;if(void 0===e&&(e={}),Array.isArray(null===(t=e)||void 0===t?void 0:t.fillingPoint)){const t=e.fillingPoint.map(e=>(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.fillingPointId)).filter(Boolean);if(t.length>0)return t.join(", ")}return(null===(l=e)||void 0===l||null===(n=l.fillingPoint)||void 0===n?void 0:n.fillingPointName)||(null===(o=e)||void 0===o||null===(i=o.dsoDetails)||void 0===i||null===(a=i.fillingPoint)||void 0===a?void 0:a.fillingPointName)||(null===(r=e)||void 0===r?void 0:r.fillingPointName)||(null===(s=e)||void 0===s||null===(d=s.dsoDetails)||void 0===d?void 0:d.fillingPointName)||(null===(u=e)||void 0===u?void 0:u.fillingPointId)||(null===(c=e)||void 0===c||null===(E=c.dsoDetails)||void 0===E?void 0:E.fillingPointId)||("string"==typeof(null===(m=e)||void 0===m?void 0:m.fillingPoint)?null===(v=e)||void 0===v?void 0:v.fillingPoint:null)||("string"==typeof(null===(S=e)||void 0===S||null===(p=S.dsoDetails)||void 0===p?void 0:p.fillingPoint)?null===(_=e)||void 0===_||null===(D=_.dsoDetails)||void 0===D?void 0:D.fillingPoint:null)||(null===(R=e)||void 0===R||null===(g=R.fillingpointmetadata)||void 0===g?void 0:g.fillingPointId)||(null===(N=e)||void 0===N?void 0:N.filling_pt_name)||(null===(y=e)||void 0===y?void 0:y.fillingPtName)||"NA"},C=function(e,t){var l,n,o,i,a,r,s;void 0===e&&(e={}),void 0===t&&(t=[]);const d=(null===(l=e)||void 0===l||null===(n=l.vendor)||void 0===n?void 0:n.id)||(null===(o=e)||void 0===o||null===(i=o.vendorData)||void 0===i?void 0:i.id)||(null===(a=e)||void 0===a?void 0:a.vendorId);return d&&(t.find(e=>(null==e?void 0:e.id)===d)||(null===(r=e)||void 0===r?void 0:r.vendor)||(null===(s=e)||void 0===s?void 0:s.vendorData))||null},A=function(e){var t,l,n,o;void 0===e&&(e={});const i=[...Array.isArray(null===(t=e)||void 0===t?void 0:t.fillingPoint)?e.fillingPoint:[null===(l=e)||void 0===l?void 0:l.fillingPoint],...Array.isArray(null===(n=e)||void 0===n?void 0:n.fillingPoints)?e.fillingPoints:[null===(o=e)||void 0===o?void 0:o.fillingPoints]].filter(Boolean),a=new Map;return i.forEach(e=>{const t=y(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())},O=(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=y(t);return n.length?l.filter(e=>{const t=function(e){var t,l,n,o,i,a,r,s,d,u,c;return void 0===e&&(e={}),Array.from(new Set([null===(t=e)||void 0===t?void 0:t.fillingPointId,null===(l=e)||void 0===l?void 0:l.fillingStationId,null===(n=e)||void 0===n||null===(o=n.additionalDetails)||void 0===o?void 0:o.fillingPointId,null===(i=e)||void 0===i||null===(a=i.additionalDetails)||void 0===a?void 0:a.fillingStationId,null===(r=e)||void 0===r||null===(s=r.fillingpointmetadata)||void 0===s?void 0:s.fillingPointId].filter(e=>null!=e&&""!==e).map(String).concat(y(null===(d=e)||void 0===d?void 0:d.fillingPoint),y(null===(u=e)||void 0===u?void 0:u.fillingPointDetail),y(null===(c=e)||void 0===c?void 0:c.fillingPointDetails))))}(e);return!t.length||t.some(e=>n.includes(e))}):l},b=function(e,t){var l,n,o,i;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===(o=e)||void 0===o||null===(i=o.driver)||void 0===i?void 0:i.id);return a&&t.find(e=>(null==e?void 0:e.id)===a)||null},f=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)}},h=e=>{var r,s,u;const c=Digit.ULBService.getCurrentTenantId(),{t:E}=i.useTranslation(),S=n.useHistory(),p=e=>l.createElement("span",{className:"cell-text"},e),_=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1,[R,y]=t.useState([]),[h,V]=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===(r=U.info.type)||void 0===r?void 0:r.toLowerCase(),G=["EKYC_VENDOR","EKYC_SUPERVISOR","EKYC_SURVEYOR"],W=null==B?void 0:B.some(e=>G.includes((null==e?void 0:e.code)||e)),K=()=>{H(null),F(!1)},$=l.useMemo(()=>[{Header:E("WT_NAME"),accessor:"name",Cell:e=>{let{row:t}=e;return p(t.original.name)}},{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{let{row:t}=e;return p(t.original.mobileNumber)}},{Header:E("WT_EMAIL_ID"),accessor:"emailId",Cell:e=>{let{row:t}=e;return p(t.original.emailId)}},{Header:E("WT_VALID_FROM"),accessor:"validFrom",Cell:e=>{let{row:t}=e;return t.original.validFrom?Digit.DateUtils.ConvertEpochToDate(t.original.validFrom):E("CS_NA")}},{Header:E("WT_VALID_TO"),accessor:"validTo",Cell:e=>{let{row:t}=e;return t.original.validTo?Digit.DateUtils.ConvertEpochToDate(t.original.validTo):E("CS_NA")}},{Header:E("WT_DOCUMENT"),accessor:"fileStoreId",Cell:e=>{let{row:t}=e;return t.original.fileStoreId?l.createElement("div",{style:{color:"#f47738",cursor:"pointer",textDecoration:"underline"},onClick:()=>function(e){try{if(!e)return Promise.resolve();const t=d(function(){return Promise.resolve(Digit.UploadServices.Filefetch([e],"dl")).then(function(t){var l;if(null!=t&&null!==(l=t.data)&&void 0!==l&&l[e]){const l=t.data[e].split(",")[0];window.open(l,"_blank")}})},function(e){console.error(e),V({key:"error",action:"Failed to fetch document."}),setTimeout(te,5e3)});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}(t.original.fileStoreId)},l.createElement(o.ViewsIcon,null)):E("CS_NA")}}],[E]),z=a.useQueryClient(),{data:q,refetch:Z}=Digit.Hooks.fsm.useDsoSearch(c,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{enabled:!1}),{data:j,refetch:X}=Digit.Hooks.fsm.useDriverSearch({tenantId:c,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"}}),{mutate:Q}=Digit.Hooks.fsm.useVendorUpdate(c),{mutate:J}=Digit.Hooks.fsm.useUpdateVehicle(c),{mutate:ee}=Digit.Hooks.fsm.useDriverUpdate(c);t.useEffect(()=>{var t;y((null==e||null===(t=e.data)||void 0===t?void 0:t.table)||[])},[e]),t.useEffect(()=>{"DRIVER"!==e.selectedTab&&"VEHICLE"!==e.selectedTab||(Z(),X())},[e.selectedTab]),t.useEffect(()=>{if(q){let e=q.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)}},[q]),t.useEffect(()=>{j&&k((j.driver||[]).map(e=>{var t;return{...e,displayName:`${e.name} (${(null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"N/A"})`}}))},[j]);const te=()=>{V(null)},le=(e,t)=>{y(l=>l.map(l=>(null==l?void 0:l.id)===e?{...l,...t}:l))},ne=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:f(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}},oe=(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}}},ie=()=>{switch(e.selectedTab){case"VENDOR":return S.push(`/digit-ui/${Y}/vendor/registry/new-vendor`);case"VEHICLE":return S.push(`/digit-ui/${Y}/vendor/registry/new-vehicle`);case"DRIVER":return S.push(`/digit-ui/${Y}/vendor/registry/new-driver`);case"SUPERVISOR":return S.push(`/digit-ui/${Y}/vendor/registry/new-supervisor`);case"SURVEYOR":return S.push(`/digit-ui/${Y}/vendor/registry/new-surveyor`)}},ae=l.useMemo(()=>"VENDOR"===e.selectedTab?(null==R?void 0:R.map(e=>e.id))||[]:(null==q?void 0:q.map(e=>{var t;return null===(t=e.dsoDetails)||void 0===t?void 0:t.id}))||[],[e.selectedTab,R,q]),{data:re}=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:c,filters:{vendorIds:null==ae?void 0:ae.join(","),vendorId:null==ae?void 0:ae.join(",")}},{enabled:(null==ae?void 0:ae.length)>0}),{data:se,isLoading:de}=Digit.Hooks.wt.useFillPointSearch({tenantId:c,filters:{limit:1e3}},{enabled:!0}),ue=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,o;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(o=n.auditDetails)||void 0===o?void 0:o.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:o}=e,i=null===(t=o.original.dsoDetails)||void 0===t?void 0:t.additionalDetails;if("string"==typeof i)try{i=JSON.parse(i)}catch(e){console.error("Error parsing additionalDetails:",e),i={}}const a=(null===(n=i)||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,i;let{row:a}=t;return l.createElement(o.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=a.original)||void 0===n||null===(i=n.dsoDetails)||void 0===i?void 0:i.status),onChange:()=>(t=>{var l,n,o,i;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===(o=a.owner)||void 0===o?void 0:o.emailId)||"abc@egov.com",relationship:(null==a||null===(i=a.owner)||void 0===i?void 0:i.relationship)||"OTHER"}}};Q(r,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"VENDOR"}),z.invalidateQueries("DSO_SEARCH"),e.refetchData(),setTimeout(te,3e3)}})})(a),name:"switch-"+a.id})}},{Header:E("ES_VENDOR_ADDITIONAL_DETAILS"),disableSortBy:!0,Cell:e=>{var t,o;let{row:i}=e;const a=null===(t=i.original)||void 0===t?void 0:t.id;if(!re)return l.createElement("span",null,"Loading...");const r=null!==(null===(o=i.original)||void 0===o?void 0:o.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"))}},...W?[]:[{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:o}=e;return l.createElement("div",null,(null===(t=o.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,o;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(o=n.auditDetails)||void 0===o?void 0:o.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(o.Dropdown,{className:"fsm-registry-dropdown",selected:C(n.original,L),option:L,select:t=>((t,l)=>{const n=t.original,o=null==n?void 0:n.vendor;if(null==l||!l.id||(null==o?void 0:o.id)===(null==l?void 0:l.id))return;const i={...n,vendorVehicleStatus:"ACTIVE",fillingPoint:null,driverData:null,driver:null};delete i.vendor,delete i.popup,delete i.driver;const a=()=>{const t=Array.isArray(null==l?void 0:l.vehicles)?[...l.vehicles]:[],o=t.findIndex(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id));o>-1?t[o]={...t[o],...i,vendorVehicleStatus:"ACTIVE"}:t.push(i);const a={...l,vehicles:t};Q(oe(l,t),{onError:e=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:()=>{le(null==n?void 0:n.id,{vendor:a,fillingPoint:null,driverData:null,driver:null}),V({key:"success",action:"VEHICLE"}),z.invalidateQueries("DSO_SEARCH"),z.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchData(),e.refetchVendor&&e.refetchVendor(),setTimeout(te,3e3)}})};if(null!=o&&o.id){const e=Array.isArray(null==o?void 0:o.vehicles)?o.vehicles.map(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id)?{...e,vendorVehicleStatus:"INACTIVE"}:e):[];Q(oe(o,e),{onError:e=>{V({key:"error",action:e}),setTimeout(te,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,o=n.original.additionalDetails;if("string"==typeof o)try{o=JSON.parse(o)}catch(e){console.error("Error parsing additionalDetails:",e),o={}}const i=(null===(t=o)||void 0===t?void 0:t.serviceType)||"N/A";return l.createElement("div",null,i)}},{Header:E("WT_FILLING_POINT"),accessor:e=>I(e),id:"fillingPoint",minWidth:250,Cell:t=>{let{row:n}=t;const i=C(n.original,L),a=A(i);return l.createElement(o.Dropdown,{className:"fsm-registry-dropdown",selected:T(n.original,a),option:a,select:t=>((t,l)=>{const n=ne(t.original,{fillingPoint:l});J(n,{onError:e=>{var t,l,n,o;V({key:"error",label:(null==e?void 0:e.message)||(null==e||null===(t=e.response)||void 0===t||null===(l=t.data)||void 0===l||null===(n=l.Errors)||void 0===n||null===(o=n[0])||void 0===o?void 0:o.message)||"Failed to map filling point"}),setTimeout(te,5e3)},onSuccess:()=>{var n;const o=C(t.original,L),i=O(o,l),a=b(t.original,i);le(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}}),V({key:"success",label:"Filling point mapped successfully"}),z.invalidateQueries("FSM_VEICLES_SEARCH"),z.invalidateQueries("DSO_SEARCH"),e.refetchData(),e.refetchVendor&&e.refetchVendor(),setTimeout(te,3e3)}})})(n,t),style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"fillingPointName",t:E,disable:!i||!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 i=C(n.original,L),a=T(n.original,A(i)),r=O(i,a);return l.createElement(o.Dropdown,{className:"fsm-registry-dropdown",selected:b(n.original,r),option:r,select:t=>((t,l)=>{const n=ne(t.original,{driverData:l});J(n,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:(n,o)=>{var i;le(null===(i=t.original)||void 0===i?void 0:i.id,{driverData:l}),V({key:"success",action:"VEHICLE"}),z.invalidateQueries("FSM_VEICLES_SEARCH"),z.invalidateQueries("DSO_SEARCH"),e.refetchData(),e.refetchVendor(),setTimeout(te,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:i}=t;return l.createElement(o.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>(t=>{var l;const n=ne(t.original,{status:"ACTIVE"===(null===(l=t.original)||void 0===l?void 0:l.status)?"DISABLED":"ACTIVE"});J(n,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"VEHICLE"}),z.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(te,3e3)}})})(i),name:"switch-"+i.id})}}];case"DRIVER":return[{Header:E("ES_FSM_REGISTRY_INBOX_USERNAME"),id:"userName",accessor:e=>{var t;return(null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"},Cell:e=>{var t;let{row:o}=e;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/driver-details/`+o.original.id},l.createElement("div",null,(null===(t=o.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:o}=e;return l.createElement("div",null,(null===(t=o.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,o;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(o=n.auditDetails)||void 0===o?void 0:o.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(o.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,o=null==n?void 0:n.vendor,i=l;if(delete n.vendor,n.vendorDriverStatus="ACTIVE",o){const e=null==o?void 0:o.drivers;e.splice(e.findIndex(e=>e.id===n.id),1)}const a={vendor:{...i,drivers:i.drivers?[...i.drivers,n]:[n]}};Q(a,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"VENDOR"}),z.invalidateQueries("DSO_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(te,3e3)}})})(n,t),style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"displayName",t:E})}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let{row:i}=t;return l.createElement(o.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>(t=>{var l,n,o,i;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===(o=a.owner)||void 0===o?void 0:o.emailId)||"abc@egov.com",relationship:(null==a||null===(i=a.owner)||void 0===i?void 0:i.relationship)||"OTHER"}}};ee(r,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"DRIVER"}),z.invalidateQueries("FSM_DRIVER_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(te,3e3)}})})(i),name:"switch-"+i.id})}}];case"SUPERVISOR":case"SURVEYOR":return[{Header:E("SUPERVISOR"===e.selectedTab?"ES_FSM_REGISTRY_INBOX_SUPERVISOR_NAME":"ES_FSM_REGISTRY_INBOX_SURVEYOR_NAME"),accessor:"name",Cell:t=>{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,""+(o.original.name||"N/A")))))}},{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 o;let{row:i}=t;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/${"SUPERVISOR"===e.selectedTab?"supervisor-details":"surveyor-details"}/`+i.original.id},l.createElement("div",null,(null===(o=i.original.owner)||void 0===o?void 0:o.userName)||"NA"))))}},..."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:o}=e;return l.createElement("div",null,(null===(t=o.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:o}=e;return l.createElement("div",null,(null===(t=o.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,o;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(o=n.auditDetails)||void 0===o?void 0:o.createdTime):"")}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let{row:i}=t;return l.createElement(o.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>{console.log("Updating status for",e.selectedTab,i.original.id)},name:"switch-"+i.id})}}];default:return[]}},[e.selectedTab,L,w,R,re,(null==se?void 0:se.fillingPoints)||[],E]),ce=l.useMemo(()=>{switch(e.selectedTab){case"VENDOR":return[{Header:E("ES_VENDOR_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,o,i;return`${(null==e?void 0:e.name)||(null==e||null===(t=e.dsoDetails)||void 0===t?void 0:t.name)||"NA"} (${(null==e?void 0:e.mobileNumber)||(null==e||null===(l=e.owner)||void 0===l?void 0:l.mobileNumber)||(null==e||null===(n=e.dsoDetails)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.dsoDetails)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||"NA"})`}},{Header:E("ES_VENDOR_INBOX_DATE_VENDOR_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:E("WT_FILLING_POINT"),exportAccessor:e=>I(e)},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t,l;return(null===(t=N(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,o,i,a,r,s;return`${(null==e||null===(t=e.vendor)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendorData)||void 0===l?void 0:l.name)||"NA"} (${(null==e||null===(n=e.vendor)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.vendor)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(a=e.vendorData)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendorData)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"})`}},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t;return(null===(t=N(null==e?void 0:e.additionalDetails))||void 0===t?void 0:t.serviceType)||"N/A"}},{Header:E("WT_FILLING_POINT"),exportAccessor:e=>I(e)},{Header:E("ES_FSM_REGISTRY_SELECT_DRIVER"),exportAccessor:e=>{var t,l,n,o,i,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===(o=n.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(i=e.driver)||void 0===i||null===(a=i.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,o,i,a,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} (${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.vendorData)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];case"SURVEYOR":return[{Header:E("ES_FSM_REGISTRY_INBOX_USERNAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"}},{Header:E("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),exportAccessor:e=>{var t;return`${(null==e?void 0:e.name)||"NA"} (${(null==e||null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_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,o,i,a,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} ${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.vendorData)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"}`}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];case"SUPERVISOR":return[{Header:E("ES_FSM_REGISTRY_INBOX_USERNAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"}},{Header:E("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),exportAccessor:e=>{var t;return`${(null==e?void 0:e.name)||"NA"} (${(null==e||null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:E("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,o,i,a,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} ${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.vendorData)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"}`}},{Header:E("ES_VENDOR_SUPERVISOR_AGENCY_NAME"),exportAccessor:e=>{var t,l,n,o,i,a,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} ${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.vendorData)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"}`}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];default:return[]}},[e.selectedTab,E]),Ee=l.useCallback(function(){return Promise.resolve(R)},[R]);let me;if(e.isLoading||de)me=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(o.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":"SURVEYOR"===e.selectedTab?t="ES_FSM_REGISTRY_EMPTY_CARD_SURVEYOR":(t="ES_FSM_REGISTRY_EMPTY_CARD_DRIVER",n="ES_FSM_REGISTRY_EMPTY_BUTTON_DRIVER"),me=l.createElement(o.Card,{className:"flex-center flex-box"},l.createElement("div",{style:{marginTop:"50px",marginBottom:"25px"}},E(t)),n&&l.createElement(o.SubmitBar,{className:"",label:E(n),onSubmit:ie}))}else R.length>0&&(me=l.createElement(v,{className:"table registryTable",t:E,data:R,columns:ue,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:Ee,csvExportColumns:ce,csvExportFileName:`vendor-${String(e.selectedTab||"registry").toLowerCase()}-inbox`}));const ve=B.map(e=>e.code),Se={ekyc:Object.values({ekycVendor:"EKYC_VENDOR",supervisor:"EKYC_SUPERVISOR"}).filter(e=>ve.includes(e)),wt:Object.values({wtVendor:"WT_VENDOR"}).filter(e=>ve.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(m,{parentRoute:e.parentRoute}),l.createElement("div",{style:{marginTop:"24px"}},l.createElement(D,{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(g,{onSearch:e.onSearch,type:"desktop",searchFields:e.searchFields,isInboxPage:!(null!=e&&e.isSearch),searchParams:e.searchParams,onTabChange:e.onTabChange,selectedTab:e.selectedTab,matchedRoles:Se}),l.createElement("div",{className:"result",style:{marginLeft:_||"FSM_ADMIN"===e.userRole||null!=e&&e.isSearch?"":"24px",flex:1}},me)),h&&l.createElement(o.Toast,{error:"error"===h.key,label:E(h.label?h.label:"success"===h.key?`ES_FSM_REGISTRY_${h.action}_DISABLE_SUCCESS`:h.action),onClose:te}),P&&l.createElement(o.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:K,style:{cursor:"pointer"}},l.createElement(o.MdClose,null)),actionCancelLabel:E("CS_COMMON_CLOSE"),actionCancelOnSubmit:K,hideSubmit:!0,formId:"modal-action"},l.createElement("div",{style:{padding:"16px"}},(null==x||null===(s=x.dsoDetails)||void 0===s||null===(u=s.vendorWorkOrder)||void 0===u?void 0:u.length)>0?l.createElement(o.Table,{t:E,data:x.dsoDetails.vendorWorkOrder,columns:$,getCellProps:e=>({style:{minWidth:"150px",padding:"8px 12px",fontSize:"13.5px"}})}):l.createElement("p",{style:{textAlign:"center",marginTop:"20px"}},E("ES_VENDOR_NO_WORKORDERS")))))},V=()=>{var e,a,r,s,d,u,c,E,m,v,S;const{t:p}=i.useTranslation(),_=Digit.ULBService.getCurrentTenantId(),D=Digit.UserService.getUser(),R=(null===(e=Digit.UserService.getUser())||void 0===e||null===(a=e.info)||void 0===a||null===(r=a.roles)||void 0===r?void 0:r.map(e=>e.code))||[],g=n.useLocation(),N=R.includes("EKYC_VENDOR")||R.includes("WT_VENDOR")?"VENDOR":R.includes("EKYC_SUPERVISOR")?"SUPERVISOR":R.includes("EKYC_SURVEYOR")?"SURVEYOR":"",{selectedTabs:y}=Digit.Hooks.useQueryParams(),[T,I]=t.useState(y||N),[C,A]=t.useState({}),[O,b]=t.useState([{id:"createdTime",desc:!0}]),[f,V]=t.useState(0),[L,M]=t.useState(10),[w,k]=t.useState(""),[P,F]=t.useState(""),[x,H]=t.useState([]),[U,B]=t.useState(null),Y="CITIZEN"===(null==D||null===(s=D.info)||void 0===s?void 0:s.type),G=null==D||null===(d=D.info)||void 0===d?void 0:d.uuid,{data:W}=Digit.Hooks.fsm.useDsoSearch(_,{status:"ACTIVE"},{staleTime:Infinity}),{data:K}=Digit.Hooks.wt.useFillPointSearch({tenantId:_,filters:{limit:1e3}},{staleTime:Infinity});let $={limit:L,offset:f,sortBy:null==O||null===(u=O[0])||void 0===u?void 0:u.id,sortOrder:null!=O&&null!==(c=O[0])&&void 0!==c&&c.desc?"DESC":"ASC"};const{data:z,isLoading:q,refetch:Z}="VEHICLE"===T?Digit.Hooks.fsm.useVehiclesSearch({tenantId:_,filters:{...$,registrationNumber:null==C?void 0:C.registrationNumber,status:"ACTIVE,DISABLED",vendorId:Y?G:null==C||null===(E=C.vendor)||void 0===E?void 0:E.id,fillingPointId:null==C||null===(m=C.fillingPoint)||void 0===m?void 0:m.id},config:{enabled:!1}}):"DRIVER"===T?Digit.Hooks.fsm.useDriverSearch({tenantId:_,filters:{...$,name:null==C?void 0:C.name,status:"ACTIVE,DISABLED",vendorId:Y?G:null==C||null===(v=C.vendor)||void 0===v?void 0:v.id},config:{enabled:!1}}):"SUPERVISOR"===T?Digit.Hooks.fsm.useSupervisorSearch(_,{...$,status:"ACTIVE,DISABLED",name:null==C?void 0:C.name},{enabled:!1}):"SURVEYOR"===T?Digit.Hooks.fsm.useSurveyorSearch(_,{...$,status:"ACTIVE,DISABLED",name:null==C?void 0:C.name},{enabled:!1}):Digit.Hooks.fsm.useVendorSearch({tenantId:_,filters:{...$,name:null==C?void 0:C.name,status:"ACTIVE,DISABLED"},config:{enabled:!1}});Digit.Hooks.fsm.useVendorSearch({tenantId:_,filters:{...$,name:null==C?void 0:C.name,status:"ACTIVE,DISABLED"},config:{enabled:!1}});const{data:j,isLoading:X,refetch:Q}=Digit.Hooks.fsm.useDsoSearch(_,{vehicleIds:w,driverIds:P,status:"ACTIVE"},{enabled:!1}),J=(null==z?void 0:z.totalCount)||50;t.useEffect(()=>{var e,t;Z(),Q(),null!==(e=g.state)&&void 0!==e&&e.showSuccessToast&&B(null===(t=g.state)||void 0===t?void 0:t.message)},[]),t.useEffect(()=>{Z()},[C,O,f,L]),t.useEffect(()=>{if(null!=z&&z.vehicle&&"VEHICLE"===T){const e=z.vehicle.map(e=>e.id).filter(Boolean).join(",");k(e),H(z.vehicle)}if(null!=z&&z.driver&&"DRIVER"===T){const e=z.driver.map(e=>e.id).filter(Boolean).join(",");F(e),H(null==z?void 0:z.driver)}if(null!=z&&z.vendor&&"VENDOR"===T){const e=z.vendor.map(e=>{var t,l,n,o;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===(o=n.filter(e=>"ACTIVE"===e.status))||void 0===o?void 0:o.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}))}});H(e)}"SUPERVISOR"===T&&H((null==z?void 0:z.supervisors)||(null==z?void 0:z.supervisor)||[]),"SURVEYOR"===T&&H((null==z?void 0:z.surveyors)||(null==z?void 0:z.surveyor)||[])},[z,T]),t.useEffect(()=>{""===w&&""===P||Q()},[w,P]),t.useEffect(()=>{let e=!0;if(j&&e){if("VEHICLE"===T){var t;const e=null==z||null===(t=z.vehicle)||void 0===t?void 0:t.map(e=>{let t=j.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 o={...e,vendor:t.dsoDetails};const i=null===(l=t.dsoDetails)||void 0===l||null===(n=l.vehicles)||void 0===n?void 0:n.find(t=>t.id===e.id);return i&&(o.driverData=i.driverData||i.driver||o.driverData),o}return e});H(e),k("")}if("DRIVER"===T){var l;const e=null==z||null===(l=z.driver)||void 0===l?void 0:l.map(e=>{let t=j.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});H(e),F("")}}return()=>{e=!1}},[j,z]);const ee="VEHICLE"===T?[{label:p("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==W?void 0:W.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:p("ES_FSM_REGISTRY_SEARCH_FILLING_POINT"),name:"fillingPoint",type:"dropdown",options:null==K||null===(S=K.fillingPoints)||void 0===S?void 0:S.map(e=>({...e,name:(null==e?void 0:e.name)||(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.fillingStationId)})),optionsKey:"name"},{label:p("ES_VEHICLE_SEARCH_VEHICLE_NUMBER"),name:"registrationNumber",pattern:"[A-Z]{2}[- ]?[0-9]{2}[- ]?[A-Z]{1,2}[- ]?[0-9]{4}",title:p("ES_FSM_VEHICLE_FORMAT_TIP")}]:"DRIVER"===T?[{label:p("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==W?void 0:W.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:p("ES_DRIVER_SEARCH_DRIVER_NAME"),name:"name"}]:"SUPERVISOR"===T||"SURVEYOR"===T?[{label:p("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==W?void 0:W.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:p("SUPERVISOR"===T?"ES_SUPERVISOR_SEARCH_NAME":"ES_SURVEYOR_SEARCH_NAME"),name:"name"}]:[{label:p("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"name"}],te=t.useCallback(e=>{0!==(null==e?void 0:e.length)&&b(e)},[]);return l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(h,{data:{table:x},isLoading:q||X,onSort:te,disableSort:!1,sortParams:O,userRole:"FSM_ADMIN",onFilterChange:()=>{},searchFields:ee,onSearch:function(e){void 0===e&&(e={}),A({...e})},onNextPage:()=>{V(e=>e+L)},onPrevPage:()=>{V(e=>e-L)},currentPage:Math.floor(f/L),pageSizeLimit:L,onPageSizeChange:e=>{M(Number(e.target.value))},totalRecords:J||0,onTabChange:e=>{I(e)},selectedTab:T,refetchData:()=>{Z()},refetchVendor:()=>{Q()}}),U&&l.createElement(o.Toast,{error:"error"===U.key,label:p(U.action),onClose:()=>{B(null)},duration:5e3})))},L=e=>{let{t:t,title:n}=e;return l.createElement("div",{className:"confirmation_box"},l.createElement("span",null,t(""+n)," "))};function M(e,t){switch(t.action){case"mutateSearchForm":return Digit.SessionStorage.set("EKYC.SW.INBOX",{...e,searchForm:t.data}),{...e,searchForm:t.data};case"mutateFilterForm":return Digit.SessionStorage.set("EKYC.SW.INBOX",{...e,filterForm:t.data}),{...e,filterForm:t.data};case"mutateTableForm":return Digit.SessionStorage.set("EKYC.SW.INBOX",{...e,tableForm:t.data}),{...e,tableForm:t.data};default:return e}}const w={filterForm:{},searchForm:{},tableForm:{limit:10,offset:0,sortBy:"createdTime",sortOrder:"DESC"}},k=(e,t)=>[{Header:e("SURVEYOR_NAME"),accessor:"surveyorName",Cell:e=>{var n,o,i;let{row:a}=e;const r=null===(n=a.original)||void 0===n?void 0:n.id;return l.createElement("span",{className:"ekyc-application-link",style:{color:"#add8f7",cursor:"pointer",fontWeight:"bold"},onClick:()=>t(r)},(null===(o=a.original)||void 0===o?void 0:o.surveyorName)||(null===(i=a.original)||void 0===i?void 0:i.name)||"NA")}},{Header:e("MOBILE_NUMBER"),accessor:"mobileNo",Cell:e=>{var t,n,o;let{row:i}=e;return l.createElement("span",null,(null===(t=i.original)||void 0===t?void 0:t.mobileNo)||(null===(n=i.original)||void 0===n||null===(o=n.owner)||void 0===o?void 0:o.mobileNumber)||"NA")}},{Header:e("STATUS"),accessor:"status",Cell:t=>{var n;let{row:o}=t;const i=(null===(n=o.original)||void 0===n?void 0:n.status)||"DEFAULT";return l.createElement("span",{className:"ekyc-status-tag "+i},e(i))}},{Header:e("SERVICE_TYPE"),accessor:"serviceType",Cell:e=>{var t;let{row:n}=e;return l.createElement("span",null,(null===(t=n.original)||void 0===t?void 0:t.serviceType)||"NA")}}],P=e=>l.createElement("h1",{className:"heading-m"},e.label),F=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(o.CloseSvg,null)),x=e=>{var r,s,d,u,c,E,m,v,S,p,_,D,R;const g=Digit.ULBService.getCurrentTenantId(),{t:N}=i.useTranslation(),y=n.useHistory(),T=n.useLocation(),I=a.useQueryClient(),{id:C}=n.useParams(),A=null===(r=Digit.SessionStorage.get("User"))||void 0===r?void 0:r.info,O=null==A||null===(s=A.type)||void 0===s?void 0:s.toLowerCase(),[b,f]=t.useState(!1),[h,V]=t.useState(null),[x,H]=t.useState(!1),[U,B]=t.useState(null),[Y,G]=t.useState([]),[W,K]=t.useState({}),{data:$}=Digit.Hooks.fsm.useDsoSearch(g,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{data:z,isLoading:q,refetch:Z}=Digit.Hooks.fsm.useSupervisorSearch(g,{ids:C},{staleTime:Infinity}),j=l.useMemo(()=>{var e;return null!=z&&null!==(e=z.supervisors)&&void 0!==e&&e.length?z.supervisors.map(e=>{var t,l,n,o;const i=null==$?void 0:$.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==i||null===(t=i.dsoDetails)||void 0===t?void 0:t.name)||e.vendorId||"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR";return{supervisorData:e,vendorDetails:{vendor:i?[i.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===(o=e.owner)||void 0===o?void 0:o.gender},{title:"ES_VENDOR_SUPERVISOR_AGENCY_NAME",value:a,type:"custom"}]}]}}):[]},[z,$]),{mutate:X}=Digit.Hooks.fsm.useSupervisorUpdate(g),{mutate:Q}=Digit.Hooks.fsm.useVendorUpdate(g);t.useEffect(()=>{if($){let e=$.map(e=>e.dsoDetails);G(e)}},[$]),t.useEffect(()=>{var e;Z(),null!==(e=T.state)&&void 0!==e&&e.showSuccessToast&&B({key:"success",action:"UPDATE_SUPERVISOR"})},[]),t.useEffect(()=>{switch(h){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return H(!0);case"EDIT":return y.push(`/digit-ui/${O}/vendor/registry/modify-supervisor/${C}`);case"HOME":return y.push(`/digit-ui/${O}/vendor/search-vendor?selectedTabs=SUPERVISOR`)}},[h]);const[J,ee]=t.useReducer(M,w);let te={limit:(null==J||null===(d=J.tableForm)||void 0===d?void 0:d.limit)||10,offset:(null==J||null===(u=J.tableForm)||void 0===u?void 0:u.offset)||0,sortBy:(null==J||null===(c=J.tableForm)||void 0===c?void 0:c.sortBy)||"createdTime",sortOrder:(null==J||null===(E=J.tableForm)||void 0===E?void 0:E.sortOrder)||"DESC"};const{data:le,isLoading:ne}=Digit.Hooks.fsm.useSurveyorSearch(g,{...te,status:"ACTIVE,DISABLED"},{enabled:!!g,keepPreviousData:!0}),oe=()=>{B(null)},ie=()=>{V(null),K({}),H(!1)},ae=l.useMemo(()=>((null==le?void 0:le.surveyors)||[]).map(e=>{var t,l,n,o,i;const a=(null==e?void 0:e.owner)||{},r=(null==a||null===(t=a.roles)||void 0===t||null===(l=t.map(e=>e.code))||void 0===l?void 0:l.join(", "))||"";return{...e,id:(null==e?void 0:e.id)||"",surveyorName:(null==e?void 0:e.name)||(null==a?void 0:a.name)||"",mobileNo:(null==e?void 0:e.mobileNo)||(null==a?void 0:a.mobileNumber)||"",email:(null==a?void 0:a.emailId)||"",vendorId:(null==e?void 0:e.vendorId)||"",tenantId:(null==e?void 0:e.tenantId)||"",supervisorId:(null==e?void 0:e.supervisorId)||"",status:(null==e?void 0:e.status)||"",roleCodes:r,userName:(null==a?void 0:a.userName)||"",gender:(null==a?void 0:a.gender)||"",serviceType:(null==e||null===(n=e.additionalDetails)||void 0===n?void 0:n.serviceType)||"",createdTime:(null==e||null===(o=e.auditDetails)||void 0===o?void 0:o.createdTime)||0,lastModifiedTime:(null==e||null===(i=e.auditDetails)||void 0===i?void 0:i.lastModifiedTime)||0}}),[null==le?void 0:le.surveyors]);if(q)return l.createElement(o.Loader,null);const re=(null==le||null===(m=le.dashboardInfo)||void 0===m?void 0:m.totalRecords)||(null==le?void 0:le.totalCount)||0,se={onPageSizeChange:e=>{const t=Number(e.target.value);ee({action:"mutateTableForm",data:{...J.tableForm,limit:t,offset:0}})},onNextPage:()=>{var e,t;return ee({action:"mutateTableForm",data:{...J.tableForm,offset:Number(null==J||null===(e=J.tableForm)||void 0===e?void 0:e.offset)+Number(null==J||null===(t=J.tableForm)||void 0===t?void 0:t.limit)}})},onPrevPage:()=>{var e,t;return ee({action:"mutateTableForm",data:{...J.tableForm,offset:Number(null==J||null===(e=J.tableForm)||void 0===e?void 0:e.offset)-Number(null==J||null===(t=J.tableForm)||void 0===t?void 0:t.limit)}})},onLastPage:()=>{var e,t,l;return ee({action:"mutateTableForm",data:{...J.tableForm,offset:Math.ceil(re/(null==J||null===(e=J.tableForm)||void 0===e?void 0:e.limit))*(null==J||null===(t=J.tableForm)||void 0===t?void 0:t.limit)-Number(null==J||null===(l=J.tableForm)||void 0===l?void 0:l.limit)}})},onFirstPage:()=>ee({action:"mutateTableForm",data:{...J.tableForm,offset:0}}),onSortingByData:e=>{if(e.length>0){const[{id:t,desc:l}]=e,n=l?"DESC":"ASC";J.tableForm.sortBy===t&&J.tableForm.sortOrder===n||ee({action:"mutateTableForm",data:{...J.tableForm,sortBy:t,sortOrder:l?"DESC":"ASC"}})}}};return console.log(null==A||null===(v=A.roles)||void 0===v||null===(S=v.map(e=>e.code))||void 0===S?void 0:S.includes("SUPERVISOR")),l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(o.Card,{className:"flex-box flex-box-col flex-gap-5"},null==j||null===(p=j[0])||void 0===p||null===(_=p.employeeResponse)||void 0===_?void 0:_.map((e,t)=>{var n,i,a;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},N(e.title)),l.createElement(o.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"},N(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},N(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(o.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:()=>V("EDIT_VENDOR"),style:{cursor:"pointer"}},l.createElement(o.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>V("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(o.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},N(e.value)||"N/A"))))),(null==A||null===(i=A.roles)||void 0===i||null===(a=i.map(e=>e.code))||void 0===a?void 0:a.includes("SUPERVISOR"))&&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:()=>y.push(`/digit-ui/${O}/vendor/registry/new-surveyor`)},l.createElement(o.AddIcon,{fill:"#a82227"}),N("ES_FSM_REGISTRY_DETAILS_TYPE_SURVEYOR_ADD")))}),l.createElement(o.Table,{t:N,disableSort:!1,autoSort:!1,manualPagination:!0,currentPage:Math.floor((null==J||null===(D=J.tableForm)||void 0===D?void 0:D.offset)/(null==J||null===(R=J.tableForm)||void 0===R?void 0:R.limit)),onPageSizeChange:se.onPageSizeChange,onNextPage:se.onNextPage,onPrevPage:se.onPrevPage,onLastPage:se.onLastPage,onFirstPage:se.onFirstPage,totalRecords:re,onSort:se.onSortingByData,data:ae,columns:k(N,e=>{y.push(`/digit-ui/${O}/ekyc/assign/surveyor-details/${e}`)}),inboxStyles:{overflowX:"scroll",overflowY:"hidden"},tableStyle:{width:"70%"},isLoading:ne}))),x&&l.createElement(o.Modal,{headerBarMain:l.createElement(P,{label:N((()=>{switch(h){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(F,{onClick:ie}),actionCancelLabel:N("CS_COMMON_CANCEL"),actionCancelOnSubmit:ie,actionSaveLabel:N("DELETE"===h||"DELETE_VENDOR"===h?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(h){case"DELETE":return(()=>{var e;const t={supervisor:{...null==j||null===(e=j[0])||void 0===e?void 0:e.supervisorData,status:"INACTIVE"}};X(t,{onError:e=>{B({key:"error",action:e}),setTimeout(oe,5e3)},onSuccess:()=>{B({key:"success",action:"DELETE_SUPERVISOR"}),I.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(()=>{oe(),y.push(`/digit-ui/${O}/vendor/search-vendor`)},5e3)}}),H(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=null==j||null===(e=j[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],o=(null==n?void 0:n.supervisors)||[];o=o.map(e=>(e.id===C&&(e.vendorSupervisorStatus="INACTIVE"),e));const i={vendor:{...n,supervisors:o}};Q(i,{onError:e=>{B({key:"error",action:e}),setTimeout(oe,5e3)},onSuccess:()=>{B({key:"success",action:"DELETE_VENDOR"}),I.invalidateQueries("FSM_VENDOR_SEARCH"),Z(),setTimeout(oe,5e3)}}),H(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=W,l=null==j||null===(e=j[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:{...t,supervisors:t.supervisors?[...t.supervisors,l]:[l]}};Q(n,{onError:e=>{B({key:"error",action:e}),Z(),setTimeout(oe,5e3)},onSuccess:()=>{B({key:"success",action:"ADD_VENDOR"}),I.invalidateQueries("SUPERVISOR_SEARCH"),Z(),setTimeout(oe,5e3)}}),H(!1),V(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=W,l=null==j||null===(e=j[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:{...t,supervisors:t.supervisors?[...t.supervisors,l]:[l]}};Q(n,{onError:e=>{B({key:"error",action:e}),setTimeout(oe,5e3)},onSuccess:()=>{B({key:"success",action:"EDIT_VENDOR"}),Z(),I.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(oe,5e3)}}),H(!1),V(null)})()}}},l.createElement(o.Card,{style:{boxShadow:"none"}},"DELETE"===h||"DELETE_VENDOR"===h?l.createElement(L,{t:N,title:"ES_VENDOR_SUPERVISOR_DELETE_TEXT"}):"ADD_VENDOR"===h||"EDIT_VENDOR"===h?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,N("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(o.Dropdown,{t:N,option:Y,value:W,selected:W,select:K,optionKey:"name"})):void 0)),U&&l.createElement(o.Toast,{error:"error"===U.key,label:N("success"===U.key?`ES_VENDOR_${U.action}_SUCCESS`:U.action),onClose:oe,duration:5e3}),l.createElement(o.ActionBar,{style:{zIndex:"19"}},b?l.createElement(o.Menu,{localeKeyPrefix:"ES_VENDOR_SUPERVISOR_ACTION",options:["EDIT","DELETE"],t:N,onSelect:e=>{f(!1),V(e)}}):null,l.createElement(o.SubmitBar,{label:N("ES_COMMON_TAKE_ACTION"),onSubmit:()=>f(!b)})))},H=e=>{let{path:t}=e;const{t:a}=i.useTranslation(),r=n.useLocation();sessionStorage.removeItem("revalidateddone");const d=Digit.ComponentRegistryService.getComponent("AddVendor"),u=Digit.ComponentRegistryService.getComponent("SearchApp"),c=Digit.ComponentRegistryService.getComponent("AddDriver"),m=Digit.ComponentRegistryService.getComponent("EditVendorDetails"),v=Digit.ComponentRegistryService.getComponent("AddVehicle"),S=Digit.ComponentRegistryService.getComponent("VENDORCreate"),p=Digit.ComponentRegistryService.getComponent("DriverDetails"),_=Digit.ComponentRegistryService.getComponent("VehicleDetails"),D=Digit.ComponentRegistryService.getComponent("AddSupervisor"),R=Digit.ComponentRegistryService.getComponent("EditSupervisor"),g=Digit.ComponentRegistryService.getComponent("SurveyorDetails"),N=Digit.ComponentRegistryService.getComponent("EditSurveyor"),y=Digit.ComponentRegistryService.getComponent("EditDriver"),T=Digit.ComponentRegistryService.getComponent("EditVehicle");return l.createElement(n.Switch,null,l.createElement(o.AppContainer,null,l.createElement(l.Fragment,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(o.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(o.ArrowLeft,{className:"icon"}),"Back"),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const e=r.pathname;let t=[{icon:o.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(o.PrivateRoute,{path:t+"/search-vendor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"normal"},l.createElement(V,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/new-driver",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(c,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/new-vehicle",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(v,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/additionaldetails",component:e=>{const n=e.location.pathname.includes("/info");return l.createElement(o.LayoutWrapper,{layoutClass:n?"action":"normal"},l.createElement(S,s({},e,{parentRoute:t})))}}),l.createElement(o.PrivateRoute,{path:t+"/registry/driver-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(p,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/modify-driver/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(y,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/common-search/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"normal"},l.createElement(u,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/new-vendor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(d,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/vendor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(m,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/vehicle-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(_,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/modify-vehicle/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(T,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/new-supervisor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(D,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/supervisor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(x,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/modify-supervisor/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(R,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/new-surveyor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(E,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/surveyor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(g,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/modify-surveyor/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(N,s({},e,{parentRoute:t})))})))))},U=function(e){return void 0===e&&(e=""),function(e){return void 0===e&&(e=""),!(!e||null==e||void 0===e||""===e)}(e)?e:"NA"},B=(e,t)=>{const l=new Date(e);if(e){let e=l.getMonth()+1,n=l.getDate(),o=l.getFullYear();return e=(e>9?"":"0")+e,n=(n>9?"":"0")+n,"asset-create"===t?`${n}-${e}-${o}`:`${n}/${e}/${o}`}return null},Y=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},G=e=>{var n,i;let{isLoading:a,t:s,onSubmit:d,data:u,count:c,setShowToast:E,vendorData:m}=e;const v=window.Digit.Utils.browser.isMobile(),S=new Date,p=S.toISOString().split("T")[0],_=new Date(S);_.setDate(S.getDate()-7);const D=_.toISOString().split("T")[0],{register:R,control:g,handleSubmit:N,setValue:y,getValues:T,reset:I,formState:C}=r.useForm({defaultValues:{offset:0,limit:!v&&10,sortBy:"commencementDate",sortOrder:"DESC",fromDate:D,toDate:p}});t.useEffect(()=>{R("offset",0),R("limit",10),R("sortBy","commencementDate"),R("sortOrder","DESC"),y("fromDate",D),y("toDate",p)},[R,N,y,p,D]),t.useEffect(()=>{var e;if(console.log("Fetched Vendor Data:"),null!=m&&null!==(e=m.vendor)&&void 0!==e&&e.length){const e=m.vendor.map(e=>e.name);console.log("Vendor Names:",e)}},[m]);const A=t.useMemo(()=>[{Header:s("VENDOR_REGISTRATION_NO"),accessor:"requestId",disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const o=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.registrationNo;return l.createElement("div",null,o||"N/A")}},{Header:s("CONTACT_PERSON_NAME"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const o=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.contactPerson;return l.createElement("div",null,o||"N/A")}},{Header:s("VENDOR_MOBILE_NUMBER"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const o=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.vendorMobileNumber;return l.createElement("div",null,o||"N/A")}},{Header:s("VENDOR_BANK_NAME"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const o=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.bank;return l.createElement("div",null,o||"N/A")}},{Header:s("VENDOR_STATUS"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const o=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.status;return l.createElement("div",null,o||"N/A")}}],[]),O=t.useCallback(e=>{0!==e.length&&(y("sortBy",e.id),y("sortOrder",e.desc?"DESC":"ASC"))},[]);function b(){y("offset",T("offset")-T("limit")),N(d)()}return l.createElement(l.Fragment,null,l.createElement("div",null,l.createElement(o.Header,null,s("VENDOR_COMMON_SEARCH_ADDITIONAL_DETAILS")),l.createElement(o.SearchForm,{onSubmit:d,handleSubmit:N},l.createElement(o.SearchField,null,l.createElement("label",null,s("VENDOR_NAME")),l.createElement(r.Controller,{control:g,name:"vendorName",render:e=>{var t;return l.createElement(o.Dropdown,{selected:e.value||"",select:e.onChange,onBlur:e.onBlur,option:(null==m||null===(t=m.vendor)||void 0===t?void 0:t.map(e=>({name:e.name,i18nKey:e.name})))||[],optionKey:"i18nKey",t:s,disable:!1})}})),l.createElement(o.SearchField,null,l.createElement("label",null,s("VENDOR_MOBILE_NO")),l.createElement(o.MobileNumber,{name:"mobileNumber",inputRef:R({minLength:{value:10,message:s("CORE_COMMON_MOBILE_ERROR")},maxLength:{value:10,message:s("CORE_COMMON_MOBILE_ERROR")},pattern:{value:/[6789][0-9]{9}/,message:s("CORE_COMMON_MOBILE_ERROR")}}),type:"number",componentInFront:l.createElement("div",{className:"employee-card-input employee-card-input--front"},"+91")}),l.createElement(o.CardLabelError,null,null==C||null===(n=C.errors)||void 0===n||null===(i=n.mobileNumber)||void 0===i?void 0:i.message)),l.createElement(o.SearchField,null,l.createElement("label",null,s("VENDOR_FROM_DATE")),l.createElement(r.Controller,{render:e=>l.createElement(o.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"fromDate",control:g})),l.createElement(o.SearchField,null,l.createElement("label",null,s("VENDOR_TO_DATE")),l.createElement(r.Controller,{render:e=>l.createElement(o.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"toDate",control:g})),l.createElement(o.SearchField,{className:"submit"},l.createElement(o.SubmitBar,{label:s("ES_COMMON_SEARCH"),submit:!0}),l.createElement("p",{style:{marginTop:"10px"},onClick:()=>{I({fromDate:D,toDate:"",mobileNumber:"",vendorName:"",offset:0,limit:10,sortBy:"commencementDate",sortOrder:"DESC"}),E(null),b()}},s("ES_COMMON_CLEAR_ALL")))),!a&&null!=u&&u.display?l.createElement(o.Card,{style:{marginTop:20}},s(u.display).split("\\n").map((e,t)=>l.createElement("p",{key:t,style:{textAlign:"center"}},e))):a||""===u?""!==u||a&&l.createElement(o.Loader,null):l.createElement(o.Table,{t:s,data:u,totalRecords:c,columns:A,getCellProps:e=>({style:{minWidth:e.column.Header===s("EW_INBOX_APPLICATION_NO")?"240px":"",padding:"20px 18px",fontSize:"16px"}}),onPageSizeChange:function(e){y("limit",Number(e.target.value)),N(d)()},currentPage:T("offset")/T("limit"),onNextPage:function(){y("offset",T("offset")+T("limit")),N(d)()},onPrevPage:b,pageSizeLimit:T("limit"),onSort:O,disableSort:!1,sortParams:[{id:T("sortBy"),desc:"DESC"===T("sortOrder")}]})))},W=()=>{var e,r,s;const{t:d}=i.useTranslation(),u=n.useHistory(),E=a.useQueryClient(),{id:m}=n.useParams(),v=null===(e=Digit.UserService.getUser())||void 0===e||null===(r=e.info)||void 0===r?void 0:r.type,S=null===(s=Digit.UserService.getUser())||void 0===s?void 0:s.info,p=Digit.ULBService.getCurrentTenantId(),_=null!=p&&p.includes(".")?p:p+".djb",[D,R]=t.useState(null),[g,N]=t.useState(!1),[y,T]=t.useState({}),[I,C]=t.useState({}),{data:A,isLoading:O}=Digit.Hooks.fsm.useSurveyorSearch(_,{ids:m},{staleTime:Infinity}),{mutate:b}=Digit.Hooks.fsm.useSurveyorUpdate(_),f=c(d);return t.useEffect(()=>{if(A&&A.surveyors&&A.surveyors.length>0){var e,t,l,n,o,i,a,r,s;let d=A.surveyors[0];C(d);let u={fullName:(null==d||null===(e=d.owner)||void 0===e?void 0:e.name)||(null==d?void 0:d.name),mobileNumber:(null==d||null===(t=d.owner)||void 0===t?void 0:t.mobileNumber)||(null==d?void 0:d.mobileNo),emailId:null==d||null===(l=d.owner)||void 0===l?void 0:l.emailId,employeeId:null==d?void 0:d.employeeId,gender:null!=d&&null!==(n=d.owner)&&void 0!==n&&n.gender?{code:d.owner.gender,name:"COMMON_GENDER_"+d.owner.gender}:null,fatherOrHusbandName:null==d||null===(o=d.owner)||void 0===o?void 0:o.fatherOrHusbandName,relationship:null!=d&&null!==(i=d.owner)&&void 0!==i&&i.relationship?{code:d.owner.relationship,name:"ES_COMMON_RELATION_"+d.owner.relationship}:null,dob:(null==d||null===(a=d.owner)||void 0===a?void 0:a.dob)&&Digit.DateUtils.ConvertTimestampToDate(null==d||null===(r=d.owner)||void 0===r?void 0:r.dob,"yyyy-MM-dd"),correspondenceAddress:null==d||null===(s=d.owner)||void 0===s?void 0:s.correspondenceAddress,description:null==d?void 0:d.description};T(u)}},[A]),O||0===Object.keys(y).length?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{timeLine:[{actions:d("ES_VENDOR_SURVEYOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(o.FormComposer,{isDisabled:!g,label:d("ES_COMMON_APPLICATION_SUBMIT"),config:f.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,o,i,a,r,s,d,c;const p={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_update",msgId:Date.now()+"|en_IN",authToken:null==S?void 0:S.authToken,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:_,roles:null==S?void 0:S.roles}},surveyor:{...I,description:(null==e?void 0:e.description)||(null==I?void 0:I.description)||"",name:(null==e?void 0:e.fullName)||(null==I?void 0:I.name),mobileNo:(null==e?void 0:e.mobileNumber)||(null==I?void 0:I.mobileNo),employeeId:(null==e?void 0:e.employeeId)||(null==I?void 0:I.employeeId),owner:{...I.owner,name:(null==e?void 0:e.fullName)||(null===(t=I.owner)||void 0===t?void 0:t.name),fatherOrHusbandName:(null==e?void 0:e.fatherOrHusbandName)||(null===(l=I.owner)||void 0===l?void 0:l.fatherOrHusbandName),relationship:(null==e||null===(n=e.relationship)||void 0===n?void 0:n.code)||(null===(o=I.owner)||void 0===o?void 0:o.relationship),gender:(null==e||null===(i=e.gender)||void 0===i?void 0:i.code)||(null===(a=I.owner)||void 0===a?void 0:a.gender)||"OTHERS",dob:null!=e&&e.dob?new Date(e.dob).getTime():null===(r=I.owner)||void 0===r?void 0:r.dob,emailId:(null==e?void 0:e.emailId)||(null===(s=I.owner)||void 0===s?void 0:s.emailId),mobileNumber:(null==e?void 0:e.mobileNumber)||(null===(d=I.owner)||void 0===d?void 0:d.mobileNumber),correspondenceAddress:(null==e?void 0:e.correspondenceAddress)||(null===(c=I.owner)||void 0===c?void 0:c.correspondenceAddress)}}};b(p,{onError:e=>{R({key:"error",action:e})},onSuccess:()=>{R({key:"success",action:"UPDATE_SURVEYOR"}),E.invalidateQueries("SURVEYOR_SEARCH"),u.push({pathname:`/digit-ui/${v}/vendor/registry/surveyor-details/${m}`,state:{showSuccessToast:!0}})}})},defaultValues:y,onFormValueChange:(e,t)=>{N(!!((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}),D&&l.createElement(o.Toast,{error:"error"===D.key,label:d("success"===D.key?`ES_VENDOR_${D.action}_SUCCESS`:D.action),onClose:()=>{R(null)}})))},{DatePicker:K}=require("@djb25/digit-ui-react-components"),$=function(e,t,n,o){return void 0===o&&(o=!1),[{head:e("ES_VENDOR_SUPERVISOR_BASIC_DETAILS"),body:[{label:e("ES_VENDOR_SUPERVISOR_FULL_NAME"),isMandatory:!0,type:"text",disable:o,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:o,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_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(K,s({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:"ES_VENDOR_ZONE",isMandatory:!0,type:"component",key:"zoneIds",props:{isMultiSelect:!1},component:"SelectEkycZones"},{label:e("ES_VENDOR_SUPERVISOR_DESCRIPTION"),isMandatory:!1,type:"text",populators:{name:"description",className:"payment-form-text-input-correction"}}]}]},z=()=>{var e;const{t:r}=i.useTranslation(),s=n.useHistory(),d=a.useQueryClient(),{id:u}=n.useParams(),c=null===(e=Digit.UserService.getUser())||void 0===e?void 0:e.info,E=null==c?void 0:c.type,m=Digit.ULBService.getCurrentTenantId(),v=null!=m&&m.includes(".")?m:m+".djb",[S,p]=t.useState(null),[_,D]=t.useState(!1),[R,g]=t.useState({}),[N,y]=t.useState({}),{data:T,isLoading:I}=Digit.Hooks.fsm.useSupervisorSearch(v,{ids:u},{staleTime:Infinity}),{mutate:C}=Digit.Hooks.fsm.useSupervisorUpdate(v),A=$(r);return t.useEffect(()=>{if(T&&T.supervisors&&T.supervisors.length>0){var e,t,l,n,o,i,a;let r=T.supervisors[0];y(r);let s={fullName:(null==r||null===(e=r.owner)||void 0===e?void 0:e.name)||(null==r?void 0:r.name),mobileNumber:(null==r||null===(t=r.owner)||void 0===t?void 0:t.mobileNumber)||(null==r?void 0:r.mobileNo),emailId:null==r||null===(l=r.owner)||void 0===l?void 0:l.emailId,employeeId:null==r?void 0:r.employeeId,gender:null!=r&&null!==(n=r.owner)&&void 0!==n&&n.gender?{code:r.owner.gender,active:!0,i18nKey:"COMMON_GENDER_"+r.owner.gender}:null,dob:(null==r||null===(o=r.owner)||void 0===o?void 0:o.dob)&&Digit.DateUtils.ConvertTimestampToDate(null==r||null===(i=r.owner)||void 0===i?void 0:i.dob,"yyyy-MM-dd"),correspondenceAddress:null==r||null===(a=r.owner)||void 0===a?void 0:a.correspondenceAddress,description:null==r?void 0:r.description,zoneIds:null==r?void 0:r.assignedZoneId};g(s)}},[T]),I||0===Object.keys(R).length?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{timeLine:[{actions:r("ES_VENDOR_SUPERVISOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(o.FormComposer,{isDisabled:!_,label:r("ES_COMMON_APPLICATION_SUBMIT"),config:A.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,o,i,a,r;const m={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:E,tenantId:v,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?void 0:e.zoneIds)||(null==N?void 0:N.assignedZoneId)||null,owner:{...N.owner,name:(null==e?void 0:e.fullName)||(null===(t=N.owner)||void 0===t?void 0:t.name),fatherOrHusbandName:"Static Father",relationship:"FATHER",gender:(null==e||null===(l=e.gender)||void 0===l?void 0:l.code)||(null===(n=N.owner)||void 0===n?void 0:n.gender)||"OTHERS",dob:null!=e&&e.dob?new Date(e.dob).getTime():null===(o=N.owner)||void 0===o?void 0:o.dob,emailId:(null==e?void 0:e.emailId)||(null===(i=N.owner)||void 0===i?void 0:i.emailId),mobileNumber:(null==e?void 0:e.mobileNumber)||(null===(a=N.owner)||void 0===a?void 0:a.mobileNumber),correspondenceAddress:(null==e?void 0:e.correspondenceAddress)||(null===(r=N.owner)||void 0===r?void 0:r.correspondenceAddress)}}};C(m,{onError:e=>{p({key:"error",action:e})},onSuccess:()=>{p({key:"success",action:"UPDATE_SUPERVISOR"}),d.invalidateQueries("SUPERVISOR_SEARCH"),s.push({pathname:`/digit-ui/${E}/vendor/registry/supervisor-details/${u}`,state:{showSuccessToast:!0}})}})},defaultValues:R,onFormValueChange:(e,t)=>{D(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.gender)&&(null==t?void 0:t.correspondenceAddress)&&(null==t?void 0:t.zoneIds)))},noBreakLine:!0,mode:"onChange",noCard:!0}),S&&l.createElement(o.Toast,{error:"error"===S.key,label:r("success"===S.key?`ES_VENDOR_${S.action}_SUCCESS`:S.action),onClose:()=>{p(null)},duration:5e3})))},q=()=>{const{t:e}=i.useTranslation(),t=n.useLocation(),{path:a}=n.useRouteMatch(),r=Digit.ComponentRegistryService.getComponent("EditVendorDetails"),d=Digit.ComponentRegistryService.getComponent("AddSupervisor"),u=Digit.ComponentRegistryService.getComponent("SurveyorDetails"),c=Digit.ComponentRegistryService.getComponent("VENDORCreate"),m=Digit.ComponentRegistryService.getComponent("AddDriver"),v=Digit.ComponentRegistryService.getComponent("DriverDetails"),S=Digit.ComponentRegistryService.getComponent("AddVehicle"),p=Digit.ComponentRegistryService.getComponent("VehicleDetails"),_=Digit.ComponentRegistryService.getComponent("EditDriver"),D=Digit.ComponentRegistryService.getComponent("EditVehicle");return l.createElement(n.Switch,null,l.createElement(o.AppContainer,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(o.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(o.ArrowLeft,{className:"icon"}),e("CS_COMMON_BACK")),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const l=t.pathname;let n=[{icon:o.HomeIcon,path:"/digit-ui/citizen"},{label:e("CITIZEN_VENDOR"),path:"/digit-ui/citizen/vendor"}];if(l.includes("/inbox")){let t="ES_COMMON_INBOX";l.includes("/mt/inbox")&&(n=[{icon:o.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 i=[{match:"/registry/new-vendor",label:"ES_FSM_REGISTRY_TITLE_NEW_VENDOR"},{match:"/search-vendor",label:"SEARCH_VENDOR"},{match:"/registry/new-driver",label:"ES_FSM_REGISTRY_TITLE_NEW_DRIVER"},{match:["/registry/vendor-details","/registry/modify-vendor/"],label:"VENDOR_VENDOR_DETAILS"},{match:["/registry/vehicle-details","/registry/modify-vehicle/"],label:"VENDOR_VEHICLE_DETAILS"},{match:"/registry/new-vehicle",label:"ES_FSM_REGISTRY_TITLE_NEW_VEHICLE"},{match:["/registry/driver-details","/registry/modify-driver/"],label:"VENDOR_DRIVER_DETAILS"},{match:"/registry/additionaldetails",label:"VENDOR_ADDITIONAL_DETAILS"},{match:"/registry/new-supervisor",label:"ES_FSM_REGISTRY_TITLE_NEW_SUPERVISOR"},{match:["/registry/supervisor-details","/registry/modify-supervisor/"],label:"VENDOR_SUPERVISOR_DETAILS"},{match:"/registry/new-surveyor",label:"ES_FSM_REGISTRY_TITLE_NEW_SURVEYOR"},{match:["/registry/surveyor-details","/registry/modify-surveyor/"],label:"VENDOR_SURVEYOR_DETAILS"}].find(e=>{let{match:t}=e;return Array.isArray(t)?t.some(e=>l.includes(e)):l.includes(t)});return i&&n.push({label:e(i.label)}),n})()}),l.createElement(o.PrivateRoute,{path:a+"/search-vendor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"normal"},l.createElement(V,s({},e,{parentRoute:a}))),exact:!0}),l.createElement(o.PrivateRoute,{path:a+"/registry/vendor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(r,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/driver-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(v,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/modify-driver/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(_,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/vehicle-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(p,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/modify-vehicle/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(D,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/new-driver",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(m,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/new-vehicle",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(S,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/new-supervisor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(d,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/additionaldetails",component:e=>{const t=e.location.pathname.includes("/info");return l.createElement(o.LayoutWrapper,{layoutClass:t?"action":"normal"},l.createElement(c,s({},e,{parentRoute:a})))}}),l.createElement(o.PrivateRoute,{path:a+"/registry/supervisor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(x,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/new-surveyor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(E,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/modify-surveyor/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(W,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/modify-supervisor/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(z,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/surveyor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(u,s({},e,{parentRoute:a})))}),l.createElement(o.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(o.CitizenHomeCard,{header:e("TITLE_VENDOR_MANAGEMENT"),links:[{i18nKey:e("SEARCH_VENDOR"),link:"/digit-ui/citizen/vendor/search-vendor"}],Icon:()=>l.createElement(o.PropertyHouse,{className:"fill-path-primary-main"})})):l.createElement(n.Redirect,{to:{pathname:"/digit-ui/citizen/login",state:{from:""+a,role:"CITIZEN_VENDOR"}}}),exact:!0}))))},Z=e=>l.createElement("h1",{className:"heading-m"},e.label),j=()=>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"})),X=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(j,null)),Q=e=>l.createElement("h1",{className:"heading-m"},e.label),J=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(o.CloseSvg,null)),ee=e=>{let{jumpTo:t}=e;const{t:a}=i.useTranslation(),r=n.useHistory();return l.createElement(o.LinkButton,{label:a("CS_COMMON_CHANGE"),className:"check-page-link-button",onClick:function(){r.push(t)}})},te=e=>{const{t:t}=i.useTranslation();return e.isSuccess?window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_SUCCESS"):t("ES_VENDOR_RESPONSE_CREATE_ACTION"):e.isLoading?window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_PENDING"):t("CS_VENDOR_APPLICATION_PENDING"):e.isSuccess?void 0:window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_FAILED"):t("CS_VENDOR_APPLICATION_FAILED")},le={padding:"4px 0px",justifyContent:"space-between"},ne=e=>{var t,n;return l.createElement(o.Banner,{message:te(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%"}})},oe=[{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:ie}=require("@djb25/digit-ui-react-components"),ae=e=>l.createElement("h1",{className:"heading-m"},e.label),re=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),se=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(re,null)),{DatePicker:de}=require("@djb25/digit-ui-react-components"),ue=e=>l.createElement("h1",{className:"heading-m"},e.label),ce=()=>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"})),Ee=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(ce,null)),me={VendorDetails:e=>{var n,i,a,s;let{t:d,config:u,onSelect:c,userType:E,formData:m}=e;const v=Digit.UserService.getUser().info,S=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].applicantName||(null==m||null===(n=m.ownerKey)||void 0===n?void 0:n.applicantName)||"",p=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].emailId||(null==m||null===(i=m.ownerKey)||void 0===i?void 0:i.emailId)||"",_=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].mobileNumber||(null==m||null===(a=m.ownerKey)||void 0===a?void 0:a.mobileNumber)||(null==v?void 0:v.mobileNumber),D=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].altMobileNumber||(null==m||null===(s=m.ownerKey)||void 0===s?void 0:s.altmobileNumber)||"",[R,g]=t.useState(""),[N,y]=t.useState(""),[T,I]=t.useState(""),[C,A]=t.useState(""),[O,b]=t.useState(),[f,h]=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,q]=t.useState(""),[Z,j]=t.useState(""),[X,Q]=t.useState(""),[J,ee]=t.useState("");t.useEffect(()=>{11!==f.length||C||O||Z?11===f.length&&C&&O?(A(C),b(O),j(Z)):(A(""),b(""),j("")):fetch("https://ifsc.razorpay.com/"+f).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH&&e.MICR&&(A(e.BANK),b(e.BRANCH),j(e.MICR))}).catch(()=>{})},[f]);const te=Digit.ULBService.getCurrentTenantId(),{control:le}=r.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 oe=()=>{let e,t=m.ownerKey&&m.ownerKey[0];"citizen"===E?(e={...t,applicantName:S,mobileNumber:_,altMobileNumber:D,emailId:p},c(u.key,{...m[u.key],...e},!1,0)):(e={...t,VendorCategory:R,name:T,VendorId:N,Bank:C,BankbranchName:O,IFSC:f,AccountNo:V,PanNo:M,GstNo:k,GstState:F,RegistrationNo:H,EpfNo:B,EsiNo:G,VendorType:K,Status:z,micrNo:Z,PhoneNo:X,ContactPerson:J},c(u.key,e,!1,0))};return t.useEffect(()=>{"citizen"===E&&oe()},[R,N,T,C,O,f,V,M,k,F,H,B,G,K,z,Z,X,J,E]),l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{timeLine:[{actions:d("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:d("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:d("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(o.FormStep,{config:u,onSelect:oe,t:d,className:"formcomposer-grid-container-form"},l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,{className:"card-label-smaller"},l.createElement(o.CustomTooltip,{label:""+d("IFSC_CODE"),isMandatory:!1,message:d("INVALID_IFSC_CODE_ERROR_MESSAGE")})),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"IFSC",value:f,placeholder:"Enter IFSC Code",onChange:function(e){const t=e.target.value.replace(/[^a-zA-Z0-9]/g,"");t.length<=11&&h(t)},style:{width:"100%"},maxLength:11,ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[A-Z]{4}0[A-Z0-9]{6}$",type:"text",title:d("INVALID_IFSC_CODE_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("VENDOR_BANK_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"bankName",placeholder:"Bank Name Auto Select",style:{width:"100%"},value:C,onChange:function(e){A(e.target.value)},disabled:!0})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("VENDOR_BANK_BRANCH_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"BankbranchName",value:O,style:{width:"100%"},placeholder:"Bank Branch Name Auto Select",onChange:function(e){b(e.target.value)},disabled:!1})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("VENDOR_MICR_NO")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"MicrNo",value:Z,style:{width:"100%"},placeholder:"MICR No",onChange:j,disabled:!1})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("ACCOUNT_NO")),l.createElement(o.TextInput,{t:d,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:d("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("PHONE_NO")),l.createElement(o.MobileNumber,{value:X,name:"PhoneNo",onChange:Q,style:{width:"100%"}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("CONTACT_PERSON")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"ContactPerson",value:J,onChange:function(e){ee(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:d("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("PAN_NO")),l.createElement(o.TextInput,{t:d,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:d("INVALID_PAN_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("GST_NO")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"GstNo",value:k,onChange:function(e){P(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[A-Z0-9]{1}[Z]{1}[A-Z0-9]{1}$",type:"text",title:d("INVALID_GST_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("GST_REGISTERED_STATE/UT")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"GstState",value:F,onChange:function(e){x(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:d("PT_NAME_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("REGISTRATION_NO")),l.createElement(o.TextInput,{t:d,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:d("INVALID_REGISTRATION_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("EPF_NO")),l.createElement(o.TextInput,{t:d,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:d("INVALID_EPF_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("ESI_NO")),l.createElement(o.TextInput,{t:d,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:d("INVALID_ESI_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement("div",null,d("VENDOR_TYPE"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}},""+d("AST_CLASSIFICATION_ASSET")))),l.createElement(r.Controller,{control:le,name:"VendorType",defaultValue:K,rules:{required:d("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(o.Dropdown,{selected:K,select:$,option:[{i18nKey:"Supplier",code:"SUPPLIER"},{i18nKey:"Contractor",code:"CONTRACTOR"}],optionKey:"i18nKey",placeholder:"Select",t:d})})),l.createElement(o.LabelFieldPair,null,l.createElement("div",null,d("VENOR_CATEGORY"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}}))),l.createElement(r.Controller,{control:le,name:"VendorCategory",defaultValue:R,rules:{required:d("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(o.Dropdown,{selected:R,select:g,option:[{i18nKey:"Firm",code:"FIRM"},{i18nKey:"Individual",code:"Individual"}],optionKey:"i18nKey",placeholder:"Select",t:d})})),l.createElement(o.LabelFieldPair,null,l.createElement("div",null,d("STATUS"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}},""+d("AST_CLASSIFICATION_ASSET")))),l.createElement(r.Controller,{control:le,name:"Status",defaultValue:z,rules:{required:d("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(o.Dropdown,{selected:z,select:q,option:[{i18nKey:"Active",code:"ACTIVE"},{i18nKey:"Inactive",code:"INACTIVE"}],optionKey:"i18nKey",placeholder:"Select",t:d})})))))},VendorDocuments:e=>{var n;let{t:i,config:a,onSelect:r,formData:s}=e;const[u,c]=t.useState([null]),[E,m]=t.useState([null]),[v,S]=t.useState(null),[p,_]=t.useState(1),[D,R]=(Digit.ULBService.getStateId(),Digit.ULBService.getStateId(),t.useState((null==s||null===(n=s.documents)||void 0===n?void 0:n.documents)||[]));return t.useEffect(()=>{var e;null!=s&&null!==(e=s.documents)&&void 0!==e&&e.documents&&(m(s.documents.documents),_(s.documents.documents.length),c(new Array(s.documents.documents.length).fill(null)))},[s]),l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{timeLine:[{actions:i("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:i("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:i("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:1,showFinalStep:!1}),l.createElement(o.FormStep,{t:i,config:a,onSelect:()=>{let e;e={...s.documents,documents:E.filter(e=>null!==e)},r(a.key,e)},onSkip:()=>r(),isDisabled:E.some(e=>null===e)&&u.some(e=>null===e)},u.map((e,t)=>l.createElement(o.LabelFieldPair,{key:t},l.createElement(o.CardLabel,{className:"card-label-smaller"},i("VENDOR_ID")+(0!==t?t:"")),l.createElement("div",{className:"field",style:{display:"flex",alignItems:"center",paddingBottom:"10px"}},l.createElement(o.UploadFile,{onUpload:e=>((e,t)=>{const l=e.target.files[0];c(e=>{const n=[...e];return n[t]=l,n}),function(e,t){try{const l=function(){if(e.size>=5242880)S(i("CS_MAXIMUM_UPLOAD_SIZE_EXCEEDED"));else{const l=d(function(){return Promise.resolve(Digit.UploadServices.Filestorage("EWASTE",e,Digit.ULBService.getStateId())).then(function(e){var l,n;if((null==e||null===(l=e.data)||void 0===l||null===(n=l.files)||void 0===n?void 0:n.length)>0){const l=e.data.files[0].fileStoreId;m(e=>{const n=[...e];return n[t]={filestoreId:l,documentuuid:l,documentType:"Photo"+(t+1)},n})}else S(i("CS_FILE_UPLOAD_ERROR"))})},function(){S(i("CS_FILE_UPLOAD_ERROR"))});if(l&&l.then)return l.then(function(){})}}();Promise.resolve(l&&l.then?l.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}(l,t)})(e,t),onDelete:()=>m(e=>{const l=[...e];return l[t]=null,l}),id:"file-upload-"+t,message:E[t]?"1 "+i("CS_ACTION_FILEUPLOADED"):i("CS_ACTION_NO_FILEUPLOADED"),textStyles:{width:"100%"},inputStyles:{width:"280px"},accept:".pdf, .jpeg, .jpg, .png",buttonType:"button",error:!E[t]})))),v&&l.createElement(o.Toast,{label:v,onClose:()=>S(null),error:!0})))},ServiceDoc:e=>{var t;let{t:n,config:i,onSelect:a}=e;const r=Digit.ULBService.getStateId(),s=null!=i&&i.isMutation?["MutationDocuments"]:"Documents",{isLoading:d,data:u={}}=Digit.Hooks.asset.useAssetDocumentsMDMS(r,"ASSET",s);let c=null==u||null===(t=u.ASSET)||void 0===t?void 0:t.Documents;return l.createElement("div",{className:"employee-form-content"},d&&l.createElement(o.Loader,null),Array.isArray(c)&&c.map((e,t)=>{let{code:i,dropdownData:a}=e;return l.createElement(o.Card,{key:t},l.createElement("div",null,l.createElement("h3",{style:{margin:0}},t+1,". ",n(Y(i,".","_")))),a.map((e,t)=>l.createElement("div",{key:t,style:{paddingLeft:"10px",marginBottom:"6px",fontSize:"14px"}},t+1,". ",n(Y(null==e?void 0:e.code,".","_")))))}),l.createElement(o.ActionBar,null,l.createElement(o.SubmitBar,{label:n("COMMON_NEXT"),onSubmit:a})))},AddVendor:e=>{const a=Digit.ULBService.getCurrentTenantId(),{t:r}=i.useTranslation(),d=n.useHistory(),[u,c]=t.useState(1),[E,m]=t.useState(null),[,v]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,S]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,p]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),{mutate:_}=Digit.Hooks.fsm.useVendorCreate(a);t.useEffect(()=>{v(!1),p(),S()},[]);const D={serviceType:{code:"WT",name:"WT",i18nKey:"WT"},tripData:{noOfTrips:1,amountPerTrip:null,amount:null}},[R,g]=t.useState(D),N=function(e,t,n){var i,a;void 0===t&&(t=!1),void 0===n&&(n={});const r="EKYC"===(null===(i=n)||void 0===i||null===(a=i.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(o.DatePicker,s({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(o.DatePicker,s({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(o.DatePicker,s({onChange:e.onChange,date:e.value},t,{max:B((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,R),y=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(o.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(o.FormComposer,{config:N,userType:"employee",onFormValueChange:(e,t)=>{var l,n,o,i;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}))||[],s=(null==R?void 0:R.zoneIds)||[],d=a.join(",")!==s.join(",");((null==t||null===(n=t.serviceType)||void 0===n?void 0:n.code)!==(null==R||null===(o=R.serviceType)||void 0===o?void 0:o.code)||d)&&g(e=>({...e,serviceType:null==t?void 0:t.serviceType})),d&&g(e=>({...e,zoneIds:a})),(null==t?void 0:t.vendorName)&&(null==t?void 0:t.phone)&&(null==t||null===(i=t.serviceType)||void 0===i?void 0:i.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,o,i,r,s,u,c,E,v,S,p,D,R,g;const N=e,T=null==N?void 0:N.propertyAddress,I=null==T?void 0:T.pincode,C=null==T?void 0:T.streetName,A=null==T?void 0:T.houseNo,O=null==T?void 0:T.landmark,b=null==T||null===(t=T.city)||void 0===t?void 0:t.name,f=null==T||null===(l=T.city)||void 0===l?void 0:l.name,h=null==T||null===(n=T.city)||void 0===n?void 0:n.name,V=null==T||null===(o=T.city)||void 0===o?void 0:o.name,L=null==T||null===(i=T.locality)||void 0===i?void 0:i.code,M=null==T||null===(r=T.locality)||void 0===r?void 0:r.name,w=null==T?void 0:T.subLocality,k=null==T||null===(s=T.ward)||void 0===s?void 0:s.code,P=null==T||null===(u=T.ward)||void 0===u?void 0:u.name,F=null==N?void 0:N.vendorName,x=null==N||null===(c=N.plotNo)||void 0===c?void 0:c.trim(),H=null==N||null===(E=N.buildingName)||void 0===E?void 0:E.trim(),U=null==N?void 0:N.emailId,B=null==N?void 0:N.phone,Y="EKYC"===(null==N||null===(v=N.serviceType)||void 0===v?void 0:v.code);let G={tenantId:a,name:F,agencyType:"ULB",paymentPreference:"post-service",address:{tenantId:a,landmark:O,doorNo:A,plotNo:x,street:C,city:b,district:h,region:V,state:f,country:"india",pincode:I,buildingName:H,locality:{code:L||"",name:M||"",label:"Locality",area:w||""},ward:k?{code:k,name:P}:void 0,geoLocation:{latitude:(null==N||null===(S=N.address)||void 0===S?void 0:S.latitude)||28.6139,longitude:(null==N||null===(p=N.address)||void 0===p?void 0:p.longitude)||77.209}},owner:{tenantId:"dl",name:(null==N?void 0:N.ownerName)||F,fatherOrHusbandName:(null==N?void 0:N.fatherOrHusbandName)||F,relationship:(null==N||null===(D=N.relationship)||void 0===D?void 0:D.code)||"OTHER",gender:(null==N||null===(R=N.gender)||void 0===R?void 0:R.code)||"MALE",dob:null!=N&&N.dob?new Date(N.dob).getTime():new Date("1/1/1970").getTime(),emailId:U||"",mobileNumber:B},additionalDetails:{serviceType:Y?"ekyc":null==N||null===(g=N.serviceType)||void 0===g?void 0:g.code},vehicles:[],drivers:[],source:Y?"eKYC Portal":"WhatsApp"};var W,K;Y&&(G={...G,zoneIds:(null==N||null===(W=N.zoneIds)||void 0===W?void 0:W.map(e=>{var t;return null==e||null===(t=e[1])||void 0===t?void 0:t.code}))||[],clusterIds:(null==N||null===(K=N.clusterIds)||void 0===K?void 0:K.map(e=>{var t;return null==e||null===(t=e[1])||void 0===t?void 0:t.code}))||[],contractStartDate:N.contractStartDate?new Date(N.contractStartDate).getTime():null,contractEndDate:N.contractEndDate?new Date(N.contractEndDate).getTime():null});const $={vendor:G};Y&&($.RequestInfo={apiId:"Rainmaker",msgId:"ekyc-vendor-create"}),_($,{onError:e=>{m({key:"error",action:e}),setTimeout(y,5e3)},onSuccess:(e,t)=>{m({key:"success",action:"ADD_VENDOR"}),setTimeout(()=>{y(),d.push("/digit-ui/employee/vendor/search-vendor")},2e3)}})},defaultValues:D,noCard:!0,noBreakLine:!0}),E&&l.createElement(o.Toast,{error:"error"===E.key,label:r("success"===E.key?`ES_FSM_REGISTRY_${E.action}_SUCCESS`:E.action),onClose:y})))},VendorSelectAddress:e=>{var n,i,a;let{t:r,config:s,onSelect:d,userType:u,formData:c}=e;const E=Digit.Hooks.vendor.useTenants();let m=Digit.ULBService.getCurrentTenantId();const{pincode:v}=(null==c?void 0:c.address)||"",S="employee"===u?E.filter(e=>e.code===m):v?E.filter(e=>{var t;return null==e||null===(t=e.pincode)||void 0===t?void 0:t.some(e=>e==v)}):E;let p=null===(n=sessionStorage)||void 0===n?void 0:n.getItem("Digit_FSM_PT");var _;"undefined"!==p&&(p=JSON.parse(null===(_=sessionStorage)||void 0===_?void 0:_.getItem("Digit_FSM_PT")));let D={};p&&(D=S.filter(e=>{var t,l,n;return e.code==(null===(t=p)||void 0===t||null===(l=t.propertyDetails)||void 0===l||null===(n=l.address)||void 0===n?void 0:n.tenantId)}));const[R,g]=t.useState(()=>{var e,t;return(null==c||null===(e=c.address)||void 0===e?void 0:e.city)||(null===(t=D)||void 0===t?void 0:t[0])||null}),{data:N}=Digit.Hooks.useBoundaryLocalities(null==R?void 0:R.code,"revenue",{enabled:!!R},r),{data:y}=Digit.Hooks.useBoundaryLocalities(null==R?void 0:R.code,"admin",{enabled:!!R},r),[T,I]=t.useState(),[C,A]=t.useState(()=>{var e,t,l,n,o,i,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===(o=n.details)||void 0===o||null===(i=o.address)||void 0===i?void 0:i.locality)||(null==c||null===(a=c.address)||void 0===a?void 0:a.locality)}),[O,b]=t.useState(),[f,h]=t.useState(()=>{var e;return null==c||null===(e=c.address)||void 0===e?void 0:e.ward});function V(e){A(null),I(null),h(null),b(null),Digit.SessionStorage.set("fsm.file.address.city",e),g(e)}function L(e){A(e),"employee"===u&&d(s.key,{...c[s.key],locality:e,ward:f})}function M(e){h(e),"employee"===u&&d(s.key,{...c[s.key],ward:e,locality:C})}return t.useEffect(()=>{S&&1===S.length&&g(S[0])},[S]),t.useEffect(()=>{if(R&&N){var e,t,l,n,o,i,a,r;let _=N,D=[];if(null!=c&&null!==(e=c.address)&&void 0!==e&&e.locality)A(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)A(c.cpt.details.address.locality);else if(null!==(o=p)&&void 0!==o&&null!==(i=o.propertyDetails)&&void 0!==i&&null!==(a=i.address)&&void 0!==a&&a.locality){var E,m,v;A(null===(E=p)||void 0===E||null===(m=E.propertyDetails)||void 0===m||null===(v=m.address)||void 0===v?void 0:v.locality)}var S;null!=c&&null!==(r=c.address)&&void 0!==r&&r.pincode&&(D=_.filter(e=>{var t;return null===(t=e.pincode)||void 0===t?void 0:t.find(e=>e==c.address.pincode)}),null!=c&&null!==(S=c.address)&&void 0!==S&&S.locality||A()),"employee"===u&&d(s.key,{...c[s.key],city:R}),I(()=>D.length>0?D:_),1===D.length&&(A(D[0]),"employee"===u&&d(s.key,{...c[s.key],locality:D[0]}))}},[R,null==c||null===(i=c.cpt)||void 0===i||null===(a=i.details)||void 0===a?void 0:a.address,N]),t.useEffect(()=>{var e;R&&y&&(null!=c&&null!==(e=c.address)&&void 0!==e&&e.ward&&h(c.address.ward),b(y))},[R,y]),"employee"===u?l.createElement(l.Fragment,null,l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,r("MYCITY_CODE_LABEL"),s.isMandatory?" * ":null),l.createElement(o.Dropdown,{className:"",isMandatory:!0,selected:1===(null==S?void 0:S.length)?S[0]:R,disable:1===(null==S?void 0:S.length),option:S,select:V,optionKey:"code",t:r})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_WARD"),s.isMandatory?" * ":null),l.createElement(o.Dropdown,{className:"",isMandatory:!0,selected:f,option:O,select:M,optionKey:"name",t:r})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_MOHALLA"),s.isMandatory?" * ":null),l.createElement(o.Dropdown,{className:"",isMandatory:!0,selected:C,option:T,select:L,optionKey:"name",t:r}))):l.createElement(l.Fragment,null,l.createElement(o.FormStep,{config:s,onSelect:function(){d(s.key,{city:R,locality:C,ward:f})},t:r,isDisabled:!C||!f},l.createElement(o.CardLabel,null,r("MYCITY_CODE_LABEL")+" *"),l.createElement(o.RadioOrSelect,{options:S,selectedOption:R,optionKey:"i18nKey",onSelect:V,t:r}),R&&O&&l.createElement(o.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_WARD")+" *"),R&&O&&l.createElement(o.RadioOrSelect,{isMandatory:s.isMandatory,options:O,selectedOption:f,optionKey:"name",onSelect:M,t:r}),R&&T&&l.createElement(o.CardLabel,null,r("CS_CREATECOMPLAINT_MOHALLA")+" *"),R&&T&&l.createElement(o.RadioOrSelect,{isMandatory:s.isMandatory,options:T,selectedOption:C,optionKey:"name",onSelect:L,t:r})))},SearchApp:e=>{n.useParams();const{t:a}=i.useTranslation(),r=Digit.ULBService.getCurrentTenantId(),[s,d]=t.useState({}),[u,c]=t.useState(null),E={enabled:!!(s&&Object.keys(s).length>0)},{isLoading:m,isSuccess:v,data:{EwasteApplication:S,Count:p}={}}=Digit.Hooks.ew.useEWSearch({tenantId:r,filters:s},E);return l.createElement(l.Fragment,null,l.createElement(G,{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"}):d(n):c({warning:!0,label:"ERR_PROVIDE_MORE_PARAM_WITH_TYPE_STATUS"}):c({warning:!0,label:"ERR_VENDOR_FILL_VALID_FIELDS"})},data:v&&!m?S.length>0?S:{display:"ES_COMMON_NO_DATA"}:"",count:p}),u&&l.createElement(o.Toast,{error:u.error,warning:u.warning,label:a(u.label),isDleteBtn:!0,onClose:()=>{c(null)}}))},SelectServiceType:e=>{let{config:n,onSelect:i,t:a,userType:r,formData:s}=e;const d=Digit.ULBService.getCurrentTenantId(),[u,c]=t.useState(null==s?void 0:s.serviceType),[E,m]=t.useState([]),{data:v,isLoading:S}=Digit.Hooks.useCustomMDMS(d,"tenant",[{name:"citymodule"}],{select:e=>{var t;return null==e||null===(t=e.tenant)||void 0===t?void 0:t.citymodule}});return t.useEffect(()=>{if(v){const e=v.map(e=>({i18nKey:""+e.code,code:""+e.code,value:""+e.name}));if(m(e),!u||"WT"===u.code){const t=e.find(e=>"WT"===e.code);t&&(c(t),"employee"===r&&i(n.key,t))}}},[v]),S?l.createElement(o.Loader,null):"employee"===r?l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,a(n.label)),l.createElement(o.Dropdown,{className:"payment-form-text-input-correction",isMandatory:n.isMandatory,selected:u,option:E,select:e=>{c(e),"employee"===r&&i(n.key,e)},optionKey:"i18nKey",disable:n.disable,t:a})):void 0},SelectVehicleType:e=>{var n;let{t:i,config:a,onSelect:r,formData:s}=e;const d=Digit.ULBService.getStateId(),u=Digit.ULBService.getCurrentTenantId(),{data:c,isLoading:E}=Digit.Hooks.wt.useWTMDMS(d,"Vehicle","VehicleMakeModel"),{data:m,isLoading:v}=Digit.Hooks.useCustomMDMS(u,"tenant",[{name:"citymodule"}],{select:e=>{var t;return null==e||null===(t=e.tenant)||void 0===t?void 0:t.citymodule}}),[S,p]=t.useState({}),[_,D]=t.useState([]),[R,g]=t.useState({}),[N,y]=t.useState([]),[T,I]=t.useState({}),[C,A]=t.useState(""),O=(null==s||null===(n=s.serviceType)||void 0===n?void 0:n.code)||(null==s?void 0:s.serviceType),b=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(b)},[b]),t.useEffect(()=>{if(!c)return;const e=S[O],t=e?c.filter(t=>e.includes(t.code)):c;D(t),g({}),y([]),I({}),A("")},[c,O,S]),t.useEffect(()=>{if(!c||null==R||!R.code)return;const e=c.filter(e=>e.make===R.code);y(e),I({}),A("")},[R,c]),t.useEffect(()=>{null!=T&&T.capacity&&A(T.capacity)},[T]),E||v?l.createElement(o.Loader,null):c&&m?l.createElement(l.Fragment,null,l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_MODEL")),l.createElement(o.Dropdown,{className:"form-field",selected:R,option:_,select:e=>{g(e),r(a.key,{...(null==s?void 0:s[a.key])||{},modal:e,type:""})},optionKey:"name",t:i})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_TYPE")),l.createElement(o.Dropdown,{className:"form-field",selected:T,option:N,select:e=>{I(e),A(e.capacity),r(a.key,{...s[a.key],type:e})},optionKey:"name",t:i})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_CAPACITY")),l.createElement(o.TextInput,{className:"",textInputStyle:{width:"100%"},value:C,disable:!0}))):l.createElement("div",null,i("ERROR_FETCHING_DATA"))},BankDetailsComponent:e=>{let{t:n,config:i,onSelect:a,formData:r,...s}=e;const[d,u]=t.useState((null==r?void 0:r.ifscCode)||""),[c,E]=t.useState((null==r?void 0:r.bankName)||""),[m,v]=t.useState((null==r?void 0:r.branchName)||""),[S,p]=t.useState((null==r?void 0:r.accountNumber)||""),[_,D]=t.useState(null);return t.useEffect(()=>{11===d.length&&fetch("https://ifsc.razorpay.com/"+d).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH?(E(e.BANK),v(e.BRANCH),"function"==typeof a&&a(i.key,{bankName:e.BANK,branchName:e.BRANCH,ifscCode:d,accountNumber:S}),D({error:!1,label:n("VALID_IFSC_CODE")})):D({error:!0,label:n("INVALID_IFSC_CODE")})}).catch(()=>{D({error:!0,label:n("INVALID_IFSC_CODE")})})},[d]),t.useEffect(()=>{"function"==typeof a&&a(i.key,{bankName:c,branchName:m,ifscCode:d,accountNumber:S})},[S,c,m,d]),l.createElement(l.Fragment,null,l.createElement(o.CardLabel,null,n("ES_FSM_REGISTRY_IFSC_CODE")),l.createElement(o.TextInput,{t:n,type:"text",isMandatory:!1,name:"ifscCode",value:d,onChange:e=>{const t=e.target.value.replace(/[^a-zA-Z0-9]/g,"");t.length<=11&&u(t)},style:{width:"100%"},maxLength:11}),l.createElement(o.CardLabel,null,n("ES_FSM_REGISTRY_ACCOUNT_NUMBER")),l.createElement(o.TextInput,{t:n,type:"text",isMandatory:!1,name:"accountNumber",value:S,onChange:e=>p(e.target.value),style:{width:"100%"}}),l.createElement(o.CardLabel,null,n("ES_FSM_REGISTRY_BANK_NAME")),l.createElement(o.TextInput,{t:n,type:"text",isMandatory:!1,name:"bankName",value:c,onChange:e=>E(e.target.value),disabled:11===d.length&&c,style:{width:"100%"}}),l.createElement(o.CardLabel,null,n("ES_FSM_REGISTRY_BRANCH_NAME")),l.createElement(o.TextInput,{t:n,type:"text",isMandatory:!1,name:"branchName",value:m,onChange:e=>v(e.target.value),disabled:11===d.length&&m,style:{width:"100%"}}))},AddDriver:()=>{var e,r;const d=Digit.ULBService.getCurrentTenantId(),{t:u}=i.useTranslation(),c=Digit.ULBService.getStateId(),[E,m]=t.useState(null),v=a.useQueryClient(),S=n.useHistory(),[,p]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,_]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,D]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),R="WT_VENDOR"===Digit.UserService.getType()||Digit.UserService.hasAccess(["WT_VENDOR"]),{mutate:g}=Digit.Hooks.fsm.useDriverCreate(c),{mutate:N}=Digit.Hooks.fsm.useVendorUpdate("dl.djb"),y=null===(e=Digit.UserService.getUser())||void 0===e||null===(r=e.info)||void 0===r?void 0:r.mobileNumber,{data:T}=Digit.Hooks.fsm.useDsoSearch(d,{mobileNumber:y},{enabled:!(!R||!y)});t.useEffect(()=>{p(!1),D(),_()},[]);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(ie,s({onChange:e.onChange,date:e.value},t,{max:(()=>{const e=new Date;return e.setFullYear(e.getFullYear()-18),e.toISOString().split("T")[0]})()}))}},{label:"ES_FSM_REGISTRY_NEW_EMAIL",isMandatory:!1,type:"text",key:"emailId",populators:{name:"emailId",validation:{required:!1,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("FSM_REGISTRY_INVALID_EMAIL"),defaultValue:"",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,A]=t.useState(!1),O=()=>{m(null)};return console.log(R,"iscitizen"),l.createElement(l.Fragment,null,l.createElement(o.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(o.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,o=null==e?void 0:e.license,i=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,s=new Date(""+e.dob).getTime()||new Date("1/1/1970").getTime(),d=null==e||null===(l=e.serviceType)||void 0===l?void 0:l.code;g({driver:{tenantId:"dl.djb",name:n,licenseNumber:o,status:"ACTIVE",owner:{tenantId:c,name:n,fatherOrHusbandName:n,relationship:"OTHER",gender:i,dob:s,emailId:a||"abc@egov.com",mobileNumber:r},additionalDetails:{serviceType:d},vendorDriverStatus:"ACTIVE"}},{onError:(e,t)=>{m({key:"error",action:e}),setTimeout(O,5e3)},onSuccess:(e,t)=>{var l;if(m({key:"success",action:"ADD_DRIVER"}),setTimeout(O,5e3),v.invalidateQueries("FSM_DRIVER_SEARCH"),R&&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]}};N(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(()=>{O(),S.push(`/digit-ui/${n}/vendor/search-vendor?selectedTabs=DRIVER`)},3e3)}})}else{var n,o,i;const e=(null===(n=Digit.UserService.getUser())||void 0===n||null===(o=n.info)||void 0===o||null===(i=o.type)||void 0===i?void 0:i.toLowerCase())||"citizen";v.invalidateQueries("FSM_DRIVER_SEARCH"),setTimeout(()=>{O(),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 o=n.slice(0,18);t.license!==o&&e("license",o)}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)?A(!0):A(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(o.Toast,{error:"error"===E.key,label:u("success"===E.key?`ES_FSM_${E.action}_SUCCESS`:E.action),onClose:O})))},EditVendorDetails:e=>{var r,s,d,u,c,E,m,v,S,p,_;const D=Digit.ULBService.getCurrentTenantId(),{t:R}=i.useTranslation(),g=n.useHistory(),N=a.useQueryClient();let{id:y}=n.useParams();const[T,I]=t.useState(!1),[C,A]=t.useState(null),[O,b]=t.useState(!1),[f,h]=t.useState(null),[V,M]=t.useState([]),[w,k]=t.useState([]),[P,F]=t.useState({}),{data:x,isLoading:H,refetch:U}=Digit.Hooks.fsm.useDsoSearch(D,{ids:y},{staleTime:Infinity}),{data:B,isLoading:Y}=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:D,filters:{vendorId:y}},{enabled:!!y});let G=null==x||null===(r=x[0])||void 0===r||null===(s=r.dsoDetails)||void 0===s?void 0:s.additionalDetails;if("string"==typeof G)try{G=JSON.parse(G)}catch(e){console.error("Error parsing additional details",e)}const W=(null==B||null===(d=B.VendorDetails)||void 0===d||null===(u=d[0])||void 0===u||null===(c=u.vendorAdditionalDetails)||void 0===c?void 0:c.serviceType)||(null===(E=G)||void 0===E?void 0:E.serviceType),K="EKYC"===W||"ekyc"===W,{data:$,refetch:z}=Digit.Hooks.fsm.useVehiclesSearch({tenantId:D,filters:{status:"ACTIVE",sortBy:"registrationNumber",sortOrder:"ASC",vehicleWithNoVendor:!0},config:{enabled:!K}}),{data:q,refetch:j}=Digit.Hooks.fsm.useDriverSearch({tenantId:D,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE",driverWithNoVendor:!0},config:{enabled:!K}}),{data:Q}=Digit.Hooks.fsm.useSupervisorSearch(D,{vendorId:y},{enabled:K}),{data:J}=Digit.Hooks.fsm.useSurveyorSearch(D,{vendorId:y},{enabled:K}),{mutate:ee}=Digit.Hooks.fsm.useVendorUpdate(D);function te(e){I(!1),A(e)}const le=null===(m=Digit.SessionStorage.get("User").info.type)||void 0===m?void 0:m.toLowerCase();console.log(Q,J),t.useEffect(()=>{switch(C){case"DELETE":case"ADD_VEHICLE":case"ADD_DRIVER":return b(!0);case"EDIT":return g.push(`/digit-ui/${le}/fsm/registry/modify-vendor/${y}`);case"HOME":return g.push(`/digit-ui/${le}/fsm/registry?selectedTabs=VENDOR`)}},[C]),t.useEffect(()=>{$&&M((null==$?void 0:$.vehicle)||[])},[$]),t.useEffect(()=>{q&&k((null==q?void 0:q.driver)||[])},[q]);const ne=()=>{h(null)},oe=()=>{A(null),F({}),b(!1)},ie=window.Digit.Utils.browser.isMobile(),ae=l.useMemo(()=>[{Header:"Supervisor Name",accessor:"name"},{Header:"Mobile Number",accessor:"mobileNo"},{Header:"Zone",accessor:"assignedZoneId"},{Header:"Description",accessor:"description"},{Header:"Status",accessor:"status"},{Header:"Email",accessor:"owner.emailId"},{Header:"Gender",accessor:"owner.gender"}],[Q]),re=l.useMemo(()=>[{Header:"Surveyor Name",accessor:"name"},{Header:"Mobile Number",accessor:"mobileNo"},{Header:"Email",accessor:"owner.emailId"},{Header:"Gender",accessor:"owner.gender"},{Header:"Service Type",accessor:"additionalDetails.serviceType"},{Header:"Description",accessor:"description"},{Header:"Status",accessor:"status"}],[J]);if(H)return l.createElement(o.Loader,null);const se=["vendorAdditionalDetailsId","vendorId","tenantId","code","lastModifiedTime","createdTime","lastModifiedBy","createdBy","active","status","vendorType","vendorGroup","narration","documents"];return l.createElement("div",{className:"employee-form-content"},H?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement(o.Card,null,null==x||null===(v=x[0])||void 0===v||null===(S=v.employeeResponse)||void 0===S?void 0:S.map((e,t)=>{var n,i;return K&&t>0?null:l.createElement(l.Fragment,{key:t},t>0&&l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},R(e.title)),l.createElement("div",null,null==e||null===(n=e.values)||void 0===n?void 0:n.map((t,n)=>{var i;if("ES_FSM_REGISTRY_DETAILS_ADDITIONAL_DETAILS"===t.title){var a,r;const e=null==B||null===(a=B.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!se.includes(t)});return l.createElement(l.Fragment,{key:t.title},l.createElement(o.Row,{label:R(t.title),text:"",className:"border-none flex-box"}),Y?l.createElement(o.Loader,null):e?l.createElement(o.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 o=String(t);let i=null!=n&&""!==n?String(n):"N/A";var a,r;return"name"!==t||n&&""!==n||(i=(null==x||null===(a=x[0])||void 0===a||null===(r=a.dsoDetails)||void 0===r?void 0:r.name)||"N/A"),l.createElement(l.Fragment,{key:o},l.createElement("div",{className:"additional-label"},R((e=>{const t=e.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)})(o))),l.createElement("div",{className:"additional-value"},i))})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>g.push(`/digit-ui/${le}/vendor/registry/additionaldetails/info?vendorId=${y}`)},R("Edit Details"))):l.createElement("div",{onClick:()=>g.push(`/digit-ui/${le}/vendor/registry/additionaldetails/vendor-details?vendorId=${y}`),className:"add-details-link hover-button"},R("Add Additional Details")))}return l.createElement(o.Row,{key:R(String(t.title)),label:R(String(t.title)),text:t.value?R(String(t.value)):"N/A",last:n===(null==e||null===(i=e.values)||void 0===i?void 0:i.length)-1,caption:t.caption,className:"border-none flex-box "+(ie?"":"vendor-details-row")})}),null==e||null===(i=e.child)||void 0===i?void 0:i.map((t,n)=>{var i;return l.createElement(o.Card,{className:"card-with-background",key:t.id||n},l.createElement("div",{className:"card-head"},l.createElement("h2",null,R(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)g.push(`/digit-ui/${le}/fsm/registry/modify-driver/${l}`);else{var n,o;let t=null==e||null===(n=e.values)||void 0===n||null===(o=n.find(e=>"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.title))||void 0===o?void 0:o.value;g.push(`/digit-ui/${le}/fsm/registry/modify-vehicle/${t}`)}})(t,e.type,t.id)},l.createElement(o.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 o,i;let e=null==x||null===(o=x[0])||void 0===o?void 0:o.dsoDetails,t=null==e?void 0:e.drivers;t=t.map(e=>(e.id===l&&(e.vendorDriverStatus="INACTIVE"),e)),n={vendor:{...e,owner:{...e.owner,gender:(null===(i=e.owner)||void 0===i?void 0:i.gender)||"OTHERS"},drivers:t}}}else{var a,r,s,d;let t=null==x||null===(a=x[0])||void 0===a?void 0:a.dsoDetails,l=null==t?void 0:t.vehicles,o=null==e||null===(r=e.values)||void 0===r||null===(s=r.find(e=>"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.title))||void 0===s?void 0:s.value;l=l.map(e=>(e.registrationNumber===o&&(e.vendorVehicleStatus="INACTIVE"),e)),n={vendor:{...t,owner:{...t.owner,gender:(null===(d=t.owner)||void 0===d?void 0:d.gender)||"OTHERS"},vehicles:l}}}ee(n,{onError:(e,t)=>{h({key:"error",action:e}),setTimeout(ne,5e3)},onSuccess:(e,l)=>{h({key:"success",action:"ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===t?"DELETE_DRIVER":"DELETE_VEHICLE"}),N.invalidateQueries("DSO_SEARCH"),U(),z(),j(),setTimeout(()=>{ne()},5e3)}})})(t,e.type,t.id)},l.createElement(o.DeleteIcon,{style:{cursor:"pointer"},className:"delete",fill:"#a82227"})))),l.createElement("div",{className:"additional-grid",style:{padding:"8px 16px"}},null==t||null===(i=t.values)||void 0===i?void 0:i.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},R(String(e.title))),l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},e.value?R(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")},R(e.type+"_ADD"))))}),K&&l.createElement(l.Fragment,null,l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},R("ES_VENDOR_SUPERVISOR_DETAILS")),l.createElement("div",null,l.createElement(o.Table,{data:(null==Q?void 0:Q.supervisors)||[],columns:ae,tableTitle:"Supervisors",totalRecords:(null==Q||null===(p=Q.supervisors)||void 0===p?void 0:p.length)||0,manualPagination:!1,pageSizeLimit:10,t:R}),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>g.push(`/digit-ui/${le}/vendor/registry/new-supervisor?vendorId=${y}`)},R("ES_VENDOR_ADD_SUPERVISOR"))),l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},R("ES_VENDOR_SURVEYOR_DETAILS")),l.createElement("div",null,l.createElement(o.Table,{data:(null==J?void 0:J.surveyors)||[],columns:re,tableTitle:"Surveyors",totalRecords:(null==J||null===(_=J.surveyors)||void 0===_?void 0:_.length)||0,manualPagination:!1,pageSizeLimit:10,t:R}),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>g.push(`/digit-ui/${le}/vendor/registry/new-surveyor?vendorId=${y}`)},R("ES_VENDOR_ADD_SURVEYOR"))))),O&&l.createElement(o.Modal,{headerBarMain:l.createElement(Z,{label:R("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(X,{onClick:oe}),actionCancelLabel:R("CS_COMMON_CANCEL"),actionCancelOnSubmit:oe,actionSaveLabel:R("DELETE"===C?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{var e;let t=null==x||null===(e=x[0])||void 0===e?void 0:e.dsoDetails,l={};if("DELETE"===C&&(l={vendor:{...t,status:"INACTIVE"}}),"ADD_VEHICLE"===C){var n;let e=P;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 o;let e=P;e.vendorDriverStatus="ACTIVE",l={vendor:{...t,owner:{...t.owner,gender:(null===(o=t.owner)||void 0===o?void 0:o.gender)||"OTHERS"},drivers:t.drivers?[...t.drivers,e]:[e]}}}ee(l,{onError:(e,t)=>{h({key:"error",action:e}),setTimeout(ne,5e3)},onSuccess:(e,t)=>{h({key:"success",action:"DELETE"===C?"DELETE_VENDOR":C}),N.invalidateQueries("DSO_SEARCH"),U(),z(),j(),setTimeout(()=>{ne(),"DELETE"===C&&g.push(`/digit-ui/${le}/fsm/registry`)},5e3)}}),b(!1),A(null)}},l.createElement(o.Card,{style:{boxShadow:"none"}},"DELETE"===C?l.createElement(L,{t:R,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VEHICLE"===C?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,R("ES_FSM_REGISTRY_SELECT_VEHICLE")),l.createElement(o.Dropdown,{t:R,option:V,value:P,selected:P,select:F,optionKey:"registrationNumber"})):"ADD_DRIVER"===C?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,R("ES_FSM_REGISTRY_SELECT_DRIVER")),l.createElement(o.Dropdown,{t:R,option:w,value:P,selected:P,select:F,optionKey:"name"})):void 0)),f&&l.createElement(o.Toast,{error:"error"===f.key,label:R("success"===f.key?`ES_FSM_REGISTRY_${f.action}_SUCCESS`:f.action),onClose:ne}),l.createElement(o.ActionBar,{style:{zIndex:"19"}},T?l.createElement(o.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE","HOME"],t:R,onSelect:te}):null,l.createElement(o.SubmitBar,{label:R("ES_COMMON_TAKE_ACTION"),onSubmit:()=>I(!T)}))))},AddVehicle:e=>{var r,d;const u=Digit.ULBService.getCurrentTenantId(),c=Digit.ULBService.getStateId(),[E,m]=t.useState(null),v=n.useHistory(),{t:S}=i.useTranslation(),p=a.useQueryClient(),[,_]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,D]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,R]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),g="WT_VENDOR"===Digit.UserService.getType()||Digit.UserService.hasAccess(["WT_VENDOR"]),{mutate:N}=Digit.Hooks.fsm.useVehicleCreate(c),{mutate:y}=Digit.Hooks.fsm.useVendorUpdate("dl.djb"),T=null===(r=Digit.UserService.getUser())||void 0===r||null===(d=r.info)||void 0===d?void 0:d.mobileNumber,{data:I}=Digit.Hooks.fsm.useDsoSearch(u,{mobileNumber:T},{enabled:!(!g||!T)});t.useEffect(()=>{_(!1),R(),D()},[]);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(de,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_VEHICLE_INSURANCE",isMandatory:!1,type:"custom",key:"insurance",populators:{name:"insurance",validation:{required:!0},component:(e,t)=>l.createElement(de,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_VEHICLE_ROAD_TAX",isMandatory:!1,type:"custom",key:"roadTax",populators:{name:"roadTax",validation:{required:!0},component:(e,t)=>l.createElement(de,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_NEW_FITNESS",isMandatory:!1,type:"custom",key:"fitnessValidity",populators:{name:"fitnessValidity",validation:{required:!0},component:(e,t)=>l.createElement(de,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_NEW_VEHICLE_OWNER_NAME",isMandatory:!0,type:"text",disable:t,populators:{name:"ownerName",validation:{required:!0,pattern:{value:/^[A-Za-z\s.,/]+$/,message:e("FSM_REGISTRY_INVALID_NAME")}},error:e("FSM_REGISTRY_INVALID_NAME"),defaultValue:""}},{label:"ES_FSM_REGISTRY_NEW_VEHICLE_OWNER_PHONE",isMandatory:!0,type:"mobileNumber",key:"phone",disable:t,populators:{name:"phone",validation:{required:!0,pattern:/^[6-9]\d{9}$/},error:e("FSM_REGISTRY_INVALID_PHONE"),defaultValue:""}},{label:"ES_FSM_REGISTRY_NEW_GENDER",isMandatory:!0,type:"component",route:"select-gender",hideInEmployee:!1,key:"selectGender",component:"SelectGender"},{label:e("ES_FSM_REGISTRY_NEW_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(de,s({onChange:e.onChange,date:e.value},t,{max:(()=>{const e=new Date;return e.setFullYear(e.getFullYear()-18),e.toISOString().split("T")[0]})()}))}},{label:"ES_FSM_REGISTRY_NEW_EMAIL",isMandatory:!1,type:"text",key:"emailId",populators:{name:"emailId",validation:{required:!1,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("FSM_REGISTRY_INVALID_EMAIL"),defaultValue:""}}]}]}(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(o.InfoIcon,null),l.createElement("span",{className:"tooltiptext",style:{width:"320px",left:"230%",fontSize:"14px"}},e.populators.validation.title)))});const[A,O]=t.useState(!1),b=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(o.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(o.FormComposer,{isDisabled:!A,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,o,i,a,r,s;const d=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===(o=n.modal)||void 0===o?void 0:o.code,S=null==e||null===(i=e.vehicle)||void 0===i||null===(a=i.type)||void 0===a?void 0:a.capacity,_=new Date(""+(null==e?void 0:e.pollutionCert)).getTime(),D=new Date(""+(null==e?void 0:e.insurance)).getTime(),R=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,A=null==e?void 0:e.phone,O=null==e||null===(r=e.serviceType)||void 0===r?void 0:r.code,f=null==e||null===(s=e.selectGender)||void 0===s?void 0:s.code,h=null==e?void 0:e.emailId,V=new Date(""+e.dob).getTime()||new Date("1/1/1970").getTime();N({vehicle:{tenantId:"dl.djb",registrationNumber:d,model:E,type:u,tankCapacity:S,suctionType:"SEWER_SUCTION_MACHINE",pollutionCertiValidTill:_,InsuranceCertValidTill:D,fitnessValidTill:T,roadTaxPaidTill:R,gpsEnabled:!0,source:"Municipal records",owner:{tenantId:c,name:C,fatherOrHusbandName:C,relationship:"OTHER",correspondenceAddress:"",mobileNumber:A,gender:f,dob:V,emailId:h||"abc@egov.com"},additionalDetails:{serviceType:O},vehicleOwner:"ULB"}},{onError:(e,t)=>{var l,n,o,i;const a=(null==e||null===(l=e.response)||void 0===l||null===(n=l.data)||void 0===n||null===(o=n.Errors)||void 0===o||null===(i=o[0])||void 0===i?void 0:i.message)||(null==e?void 0:e.message)||"An error occurred";m({key:"error",action:a}),setTimeout(b,5e3)},onSuccess:(e,t)=>{var l,n,o,i;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===(o=n.Errors)||void 0===o?void 0:o.length)>0){var a,r,s,d,u;const t=(null==e||null===(a=e.data)||void 0===a||null===(r=a.Errors)||void 0===r||null===(s=r[0])||void 0===s?void 0:s.message)||(null==e||null===(d=e.Errors)||void 0===d||null===(u=d[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(b,5e3)}if(m({key:"success",action:"ADD_VEHICLE"}),p.invalidateQueries("FSM_VEICLES_SEARCH"),g&&null!=I&&null!==(i=I[0])&&void 0!==i&&i.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,o;const i=(null==e||null===(t=e.response)||void 0===t||null===(l=t.data)||void 0===l||null===(n=l.Errors)||void 0===n||null===(o=n[0])||void 0===o?void 0:o.message)||(null==e?void 0:e.message)||"An error occurred";m({key:"error",action:i}),setTimeout(b,5e3)},onSuccess:e=>{var t,l,n,o,i,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,s,d,u,c;const t=(null==e||null===(r=e.data)||void 0===r||null===(s=r.Errors)||void 0===s||null===(d=s[0])||void 0===d?void 0:d.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(b,5e3)}m({key:"success",action:"ADD_VEHICLE"}),p.invalidateQueries("DSO_SEARCH");const E=(null===(o=Digit.UserService.getUser())||void 0===o||null===(i=o.info)||void 0===i||null===(a=i.type)||void 0===a?void 0:a.toLowerCase())||"citizen";setTimeout(()=>{b(),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(()=>{b(),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 o=n.match(/^(\d{1,2})/);if(!o)return l+"-"+n;const i=o[1],a=n.slice(i.length),r=a.match(/^([A-Z]*)/),s=r?r[1]:"",d=a.slice(s.length);if(!d)return l+"-"+i+s;if(s.length>=3){const e=s.length<=3?1:2;return l+"-"+i+s.slice(0,e)+"-"+s.slice(e)+"-"+d.slice(0,4)}return l+"-"+i+s+"-"+d.slice(0,4)})(t.registrationNumber);l.length>15&&(l=l.slice(0,15)),l!==t.registrationNumber&&e("registrationNumber",l)}null!=t&&t.registrationNumber&&null!=t&&t.ownerName&&null!=t&&t.phone&&null!=t&&null!==(l=t.vehicle)&&void 0!==l&&l.modal&&null!=t&&null!==(n=t.vehicle)&&void 0!==n&&n.type&&null!=t&&t.selectGender&&null!=t&&t.dob&&new Date(null==t?void 0:t.dob).getTime()<=(new Date).setFullYear((new Date).getFullYear()-18)?O(!0):O(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(o.Toast,{error:"error"===E.key,label:S("success"===E.key?`ES_FSM_REGISTRY_${E.action}_SUCCESS`:E.action),onClose:b})))},VENDORCreate:e=>{var t,o,r,s;const d=a.useQueryClient(),u=n.useRouteMatch(),{t:c}=i.useTranslation(),{pathname:E,search:m}=n.useLocation(),v=n.useHistory();let S=[];const[p,_,D]=Digit.Hooks.useSessionStorage("VENDOR_Test",{});function R(e,t,l,n,o){if(void 0===o&&(o=!1),"owners"===e){let l=p.owners||[];l[n]=t,_({...p,[e]:[...l]})}else if("units"===e){let e=p.units||[];e=t,_({...p,units:e})}else _({...p,[e]:{...p[e],...t}});((e,t,l,n)=>{let o,i=E.split("/").pop(),a=i.charAt(i.length-1),r=!1;Number(parseInt(i))||"0"===i||"-1"===i?"-1"===i||"-2"===i?(i=E.slice(0,-3),i=i.split("/").pop(),r=!0):(i=E.slice(0,-2),i=i.split("/").pop(),r=!0):r=!1,isNaN(a)||(r=!0);let{nextStep:s={}}=S.find(e=>e.route===(i||"0")),d=v.push;if(e&&(d=v.replace),l&&(s=n),null===s)return console.log("matchhhhh pathhhh",u.path),d(u.path+"/check");o=isNaN(s.split("/").pop())&&r&&"map"!==s?`${u.path}/${s}/${t}`:`${u.path}/${s}`,d(o)})(l,n,o,e)}l.useEffect(()=>{const e=new URLSearchParams(m||window.location.search).get("vendorId");e&&p.vendor_id!==e&&_({...p,vendor_id:e})},[m,window.location.search,p,_]),p&&Object.keys(p).length>0&&window.location.href.includes("/info")&&"true"!==sessionStorage.getItem("docReqScreenByBack")&&(D(),d.invalidateQueries("VENDOR_CREATE"));const g=()=>{},N=()=>{};oe.forEach(e=>{S=S.concat(e.body.filter(e=>!e.hideInCitizen))}),S.indexRoute="info";const y=null===(t=Digit)||void 0===t||null===(o=t.ComponentRegistryService)||void 0===o?void 0:o.getComponent("VENDORCheckPage"),T=null===(r=Digit)||void 0===r||null===(s=r.ComponentRegistryService)||void 0===s?void 0:s.getComponent("NewResponse");return l.createElement(l.Fragment,null,l.createElement(n.Switch,null,S.map((e,t)=>{const{component:o,texts:i,inputs:a,key:r}=e,s="string"==typeof o?Digit.ComponentRegistryService.getComponent(o):o;return l.createElement(n.Route,{path:`${u.path}/${e.route}`,key:t},l.createElement(s,{config:{texts:i,inputs:a,key:r},onSelect:R,onSkip:g,t:c,formData:p,onAdd:N}))}),l.createElement(n.Route,{path:u.path+"/check"},l.createElement(y,{onSubmit:function(){try{return v.push(u.path+"/acknowledgement"),Promise.resolve()}catch(e){return Promise.reject(e)}},value:p})),l.createElement(n.Route,{path:u.path+"/acknowledgement"},l.createElement(T,{data:p,onSuccess:()=>{D(),d.invalidateQueries("VENDOR_CREATE")}})),l.createElement(n.Route,null,l.createElement(n.Redirect,{to:`${u.path}/${S.indexRoute}`}))))},VENDORCheckPage:e=>{var n,a,r,s;let{onSubmit:d,value:u={}}=e;const{t:c}=i.useTranslation(),{vendordet:E,documents:m}=u;console.log("vendordetailssppsss",E),console.log("documents",m);const[v,S]=t.useState(!1);return l.createElement(l.Fragment,null,window.location.href.includes("/employee")?l.createElement(o.VerticalTimeline,{config:[{timeLine:[{actions:c("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:c("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:c("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:2,showFinalStep:!1}):null,l.createElement("div",{style:{flex:"1",overflowY:"auto",marginBottom:"20px"}},l.createElement(o.Card,null,l.createElement(o.CardHeader,null,c("VENDOR_CHECK_DETAILS")),l.createElement("div",null,l.createElement("br",null),l.createElement(o.CardSubHeader,null,c("VENDOR_ADDITIONAL_DETAILS")),l.createElement(o.StatusTable,null,l.createElement(l.Fragment,null,l.createElement(o.Row,{label:c("VENDOR_ID"),text:""+c(U(null==E?void 0:E.VendorId)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_BANK_IFSC_CODE"),text:""+c(U(null==E?void 0:E.IFSC)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_BANK_NAME"),text:""+c(U(null==E?void 0:E.Bank)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_BANK_BRANCH"),text:""+c(U(null==E?void 0:E.BankbranchName)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_MICR_NO"),text:""+c(U(null==E?void 0:E.micrNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("BANK_ACCONT_NO"),text:""+c(U(null==E?void 0:E.AccountNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("PAN_NO"),text:""+c(U(null==E?void 0:E.PanNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("GST_NO"),text:""+c(U(null==E?void 0:E.GstNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("GST_REGISTERED_STATE/UT"),text:""+c(U(null==E?void 0:E.GstState)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("REGISTRATION_NO"),text:""+c(U(null==E?void 0:E.RegistrationNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("EPF_NO"),text:""+c(U(null==E?void 0:E.EpfNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("ESI_NO"),text:""+c(U(null==E?void 0:E.EsiNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_TYPE"),text:""+c(U(null==E||null===(n=E.VendorType)||void 0===n?void 0:n.code)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_CATEGORY"),text:""+c(U(null==E||null===(a=E.VendorCategory)||void 0===a?void 0:a.code)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_STATUS"),text:""+c(U(null==E||null===(r=E.Status)||void 0===r?void 0:r.code)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}))),l.createElement("br",null),l.createElement(o.CardSubHeader,null,c("VENDOR_DOCUMENTS_DETAILS")),l.createElement(o.StatusTable,null,l.createElement(o.StatusTable,null,l.createElement(o.Row,{label:c("VENDOR_DOCUMENTS"),text:(null==m||null===(s=m.documents)||void 0===s?void 0:s.length)>0?m.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 o=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(o){const e=o.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!")}},c(e.documentType)))):c("CS_NA")}))),l.createElement("br",null),l.createElement(o.CheckBox,{label:c("AST_FINAL_DECLARATION_MESSAGE"),onChange:()=>{S(!v)},styles:{height:"auto"},checked:v})),l.createElement("br",null),l.createElement("div",{className:"formcomposer-section-button"},l.createElement(o.SubmitBar,{label:c("COMMON_BUTTON_SUBMIT"),onSubmit:d,disabled:!v})))))},NewResponse:e=>{let{data:a,onSuccess:r}=e;const{t:s}=i.useTranslation(),d=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,o,i,a,r,s,d,u,c,E,m,v,S,p,_,D,R,g,N,y,T,I;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===(o=e.vendordet)||void 0===o?void 0:o.ContactPerson,vendorMobileNumber:"9876543210",bankAccountNumber:null==e||null===(i=e.vendordet)||void 0===i?void 0:i.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===(s=e.vendordet)||void 0===s?void 0:s.micrNo,epfNo:null==e||null===(d=e.vendordet)||void 0===d?void 0:d.EpfNo,esiNo:null==e||null===(u=e.vendordet)||void 0===u?void 0:u.EsiNo,gstRegisteredState:null==e||null===(c=e.vendordet)||void 0===c?void 0:c.GstState,ifscCode:null==e||null===(E=e.vendordet)||void 0===E?void 0:E.IFSC,panNo:null==e||null===(m=e.vendordet)||void 0===m?void 0:m.PanNo,registrationNo:null==e||null===(v=e.vendordet)||void 0===v?void 0:v.RegistrationNo,status:null==e||null===(S=e.vendordet)||void 0===S||null===(p=S.Status)||void 0===p?void 0:p.code,vendorCategory:null==e||null===(_=e.vendordet)||void 0===_||null===(D=_.VendorCategory)||void 0===D?void 0:D.code,vendorId:null==e?void 0:e.vendor_id,gstTinNo:null==e||null===(R=e.vendordet)||void 0===R?void 0:R.GstNo,serviceType:null==e||null===(g=e.vendordet)||void 0===g||null===(N=g.VendorType)||void 0===N?void 0:N.code,documents:null==e||null===(y=e.documents)||void 0===y?void 0:y.documents,active:null,vendorAdditionalDetailsId:null,vendorGroup:(null==e||null===(T=e.vendordet)||void 0===T?void 0:T.vendorGroup)||"N/A",vendorType:(null==e||null===(I=e.vendordet)||void 0===I?void 0:I.vendorType)||"N/A"}}})(a);console.log("formdata in acknowejkfdlgi ::: ",l),d.mutate(l,{onSuccess:r}),console.log("mutation in acknowejkfdlgi ::: ",d)}catch(e){}},[]),d.isLoading||d.isIdle?l.createElement(o.Loader,null):l.createElement(o.Card,{className:"vehicle-details-card"},l.createElement(ne,{t:s,data:d.data,isSuccess:d.isSuccess,isLoading:d.isIdle||d.isLoading}),l.createElement(o.StatusTable,null,d.isSuccess&&l.createElement(o.Row,{rowContainerStyle:le,last:!0,textStyle:{whiteSpace:"pre",width:"60%"}})),l.createElement(n.Link,{to:"/digit-ui/employee"},l.createElement(o.LinkButton,{label:s("CORE_COMMON_GO_TO_HOME")})))},DriverDetails:()=>{var e,r;const s=Digit.ULBService.getCurrentTenantId(),{t:d}=i.useTranslation(),u=n.useHistory(),c=a.useQueryClient(),{id:E}=n.useParams(),[m,v]=t.useState(!1),[S,p]=t.useState(null),[_,D]=t.useState(!1),[R,g]=t.useState(null),[N,y]=t.useState([]),[T,I]=t.useState({}),{data:C,isLoading:A,refetch:O}=Digit.Hooks.fsm.useDriverDetails(s,{ids:E},{staleTime:Infinity}),{data:b}=Digit.Hooks.fsm.useDsoSearch(s,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{mutate:f}=Digit.Hooks.fsm.useDriverUpdate(s),{mutate:h}=Digit.Hooks.fsm.useVendorUpdate(s);function V(e){p(e),v(!1)}t.useEffect(()=>{if(b){let e=b.map(e=>e.dsoDetails);y(e)}},[b]),t.useEffect(()=>{O()},[]),t.useEffect(()=>{switch(S){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return D(!0);case"EDIT":return u.push("/digit-ui/employee/fsm/registry/modify-driver/"+E);case"HOME":return u.push("/digit-ui/employee/fsm/registry?selectedTabs=DRIVER")}},[S]);const M=()=>{g(null)},w=()=>{p(null),I({}),D(!1)},k=()=>"DELETE"===S||"DELETE_VENDOR"===S?l.createElement(L,{t:d,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===S||"EDIT_VENDOR"===S?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,d("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(o.Dropdown,{t:d,option:N,value:T,selected:T,select:I,optionKey:"name"})):void 0;return A||A?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(o.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==C||null===(e=C[0])||void 0===e||null===(r=e.employeeResponse)||void 0===r?void 0:r.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},d(e.title)),l.createElement(o.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"},d(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},d(e.value)||"N/A","ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"===e.value&&l.createElement("span",{className:"add-details-link hover-button",onClick:()=>V("ADD_VENDOR"),style:{cursor:"pointer"}},l.createElement(o.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(o.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(o.DeleteIcon,{className:"delete",fill:"#a82227"}))):l.createElement("div",{className:"additional-value"},d(e.value)||"N/A"))))))}))),_&&l.createElement(o.Modal,{headerBarMain:l.createElement(ae,{label:d((()=>{switch(S){case"DELETE":case"DELETE_VENDOR":return"ES_FSM_REGISTRY_DELETE_POPUP_HEADER";case"ADD_VENDOR":case"EDIT_VENDOR":return"ES_FSM_REGISTRY_ADD_VENDOR_POPUP_HEADER"}})())}),headerBarEnd:l.createElement(se,{onClick:w}),actionCancelLabel:d("CS_COMMON_CANCEL"),actionCancelOnSubmit:w,actionSaveLabel:d("DELETE"===S||"DELETE_VENDOR"===S?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(S){case"DELETE":return(()=>{var e;const t={driver:{...null==C||null===(e=C[0])||void 0===e?void 0:e.driverData,status:"INACTIVE"}};f(t,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"DELETE_DRIVER"}),c.invalidateQueries("DSO_SEARCH"),setTimeout(()=>{M(),u.push("/digit-ui/employee/fsm/registry")},5e3)}}),D(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let o={},i=null==C||null===(e=C[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],a=null==i?void 0:i.drivers;a=a.map(e=>(e.id===E&&(e.vendorDriverStatus="INACTIVE"),e)),o={vendor:{...i,owner:{...i.owner,gender:(null===(n=i.owner)||void 0===n?void 0:n.gender)||"OTHERS"},drivers:a}},h(o,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"DELETE_VENDOR"}),c.invalidateQueries("FSM_VENDOR_SEARCH"),O(),setTimeout(M,5e3)}}),D(!1)})();case"ADD_VENDOR":return(()=>{var e,t;let l=T,n=null==C||null===(e=C[0])||void 0===e?void 0:e.driverData;n.vendorDriverStatus="ACTIVE";const o={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},drivers:l.drivers?[...l.drivers,n]:[n]}};h(o,{onError:(e,t)=>{g({key:"error",action:e}),O(),setTimeout(M,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"ADD_VENDOR"}),c.invalidateQueries("DSO_SEARCH"),O(),setTimeout(M,5e3)}}),D(!1),p(null)})();case"EDIT_VENDOR":return(()=>{var e,t;let l=T,n=null==C||null===(e=C[0])||void 0===e?void 0:e.driverData;n.vendorDriverStatus="ACTIVE";const o={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},drivers:l.drivers?[...l.drivers,n]:[n]}};h(o,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"EDIT_VENDOR"}),O(),c.invalidateQueries("DSO_SEARCH"),setTimeout(M,5e3)}}),D(!1),p(null)})()}},formId:"modal-action"},"DELETE"===S||"DELETE_VENDOR"===S?k():l.createElement(o.Card,{style:{boxShadow:"none"}},k())),R&&l.createElement(o.Toast,{error:"error"===R.key,label:d("success"===R.key?`ES_FSM_REGISTRY_${R.action}_SUCCESS`:R.action),onClose:M}),l.createElement(o.ActionBar,{style:{zIndex:"19"}},m?l.createElement(o.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:d,onSelect:V}):null,l.createElement(o.SubmitBar,{label:d("ES_COMMON_TAKE_ACTION"),onSubmit:()=>v(!m)})))},VehicleDetails:e=>{var r,s;const d=Digit.ULBService.getCurrentTenantId(),{t:u}=i.useTranslation(),c=n.useHistory(),E=a.useQueryClient();let{id:m}=n.useParams();const[v,S]=t.useState(!1),[p,_]=t.useState(null),[D,R]=t.useState(!1),[g,N]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),[A,O]=t.useState(null),{data:b,isLoading:f,refetch:h}=Digit.Hooks.fsm.useVehicleDetails(d,{registrationNumber:m},{staleTime:Infinity});t.useEffect(()=>{var e,t;!f&&b&&O(null==b||null===(e=b[0])||void 0===e||null===(t=e.vehicleData)||void 0===t?void 0:t.id)},[b,f]);const{data:V}=Digit.Hooks.fsm.useDsoSearch(d,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{});t.useEffect(()=>{if(V){let e=V.map(e=>e.dsoDetails);T(e)}},[V]);const{mutate:M}=Digit.Hooks.fsm.useUpdateVehicle(d),{mutate:w}=Digit.Hooks.fsm.useVendorUpdate(d);function k(e){S(!1),_(e)}t.useEffect(()=>{h()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return R(!0);case"EDIT":return c.push("/digit-ui/employee/fsm/registry/modify-vehicle/"+m);case"HOME":return c.push("/digit-ui/employee/fsm/registry?selectedTabs=VEHICLE")}},[p]);const P=()=>{N(null)},F=()=>{_(null),C({}),R(!1)},x=()=>"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(L,{t:u,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(o.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0;return f?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,f?l.createElement(o.Loader,null):l.createElement("div",{className:"employee-form-content"},l.createElement(o.Card,{className:"vehicle-details-card",style:{position:"relative"}},null==b||null===(r=b[0])||void 0===r||null===(s=r.employeeResponse)||void 0===s?void 0:s.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(o.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(o.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(o.EditIcon,{fill:"#a82227"})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>k("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(o.DeleteIcon,{className:"delete",fill:"#a82227"})))):l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},u(e.value)||"N/A"))))))})),D&&l.createElement(o.Modal,{headerBarMain:l.createElement(ue,{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(Ee,{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==b||null===(e=b[0])||void 0===e?void 0:e.vehicleData,status:"INACTIVE"}};M(t,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"DELETE_VEHICLE"}),E.invalidateQueries("FSM_VEICLES_SEARCH"),setTimeout(()=>{P(),c.push("/digit-ui/employee/fsm/registry")},5e3)}}),R(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let o={},i=null==b||null===(e=b[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],a=null==i?void 0:i.vehicles;a=a.map(e=>(e.id===A&&(e.vendorVehicleStatus="INACTIVE"),e)),o={vendor:{...i,owner:{...i.owner,gender:(null===(n=i.owner)||void 0===n?void 0:n.gender)||"OTHERS"},vehicles:a}},w(o,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),h(),setTimeout(P,5e3)}}),R(!1)})();case"ADD_VENDOR":return(()=>{var e,t;let l=I,n=null==b||null===(e=b[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const o={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},vehicles:l.vehicles?[...l.vehicles,n]:[n]}};w(o,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"EDIT_VENDOR"}),h(),E.invalidateQueries("DSO_SEARCH"),setTimeout(P,5e3)}}),R(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e,t;let l=I,n=null==b||null===(e=b[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const o={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},vehicles:l.vehicles?[...l.vehicles,n]:[n]}};w(o,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"EDIT_VENDOR"}),h(),E.invalidateQueries("DSO_SEARCH"),setTimeout(P,5e3)}}),R(!1),_(null)})()}}},"DELETE"===p||"DELETE_VENDOR"===p?x():l.createElement(o.Card,{style:{boxShadow:"none"}},x())),g&&l.createElement(o.Toast,{error:"error"===g.key,label:u("success"===g.key?`ES_FSM_REGISTRY_${g.action}_SUCCESS`:g.action),onClose:P}),l.createElement(o.ActionBar,{style:{zIndex:"19"}},v?l.createElement(o.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:u,onSelect:k}):null,l.createElement(o.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)}))))},AddSupervisor:e=>{var r;const{t:s}=i.useTranslation(),u=null===(r=Digit.UserService.getUser())||void 0===r?void 0:r.info,c=Digit.ULBService.getCurrentTenantId(),E=null!=c&&c.includes(".")?c:c+".djb",[m,v]=t.useState(null),S=a.useQueryClient(),[p,_]=t.useState(!1),{mutate:D}=Digit.Hooks.fsm.useSupervisorCreate(E),R=n.useHistory(),g=$(s),N=()=>{v(null)};return l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{route:"supervisor-details",timeLine:[{actions:s("ES_VENDOR_SUPERVISOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(o.FormComposer,{isDisabled:!p,label:s("ES_COMMON_APPLICATION_SUBMIT"),config:g.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:function(e){try{var t,l,n,o;const i=null==u||null===(t=u.roles)||void 0===t?void 0:t.some(e=>"EKYC_VENDOR"===e.code),a=Array.isArray(null==e?void 0:e.zoneIds)?(null==e||null===(l=e.zoneIds)||void 0===l?void 0:l.map(e=>e.code).join(","))||"":null==e?void 0:e.zoneIds,r={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_create",msgId:Date.now()+"|en_IN",authToken:(null===(n=Digit.UserService.getUser())||void 0===n?void 0:n.access_token)||(null==u?void 0:u.authToken),...i&&{userInfo:{id:null==u?void 0:u.id,uuid:null==u?void 0:u.uuid,userName:null==u?void 0:u.userName,name:null==u?void 0:u.name,type:null==u?void 0:u.type,tenantId:(null==u?void 0:u.tenantId)||c,roles:null==u?void 0:u.roles}}},supervisor:{tenantId:E,assignedZoneId:a,description:(null==e?void 0:e.description)||"",owner:{tenantId:E,name:null==e?void 0:e.fullName,fatherOrHusbandName:"Static Father",relationship:"FATHER",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}}},s=d(function(){return Promise.resolve(D(r)).then(function(){v({key:"success",action:"ADD_SUPERVISOR"}),S.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(()=>{N(),R.push("/digit-ui/citizen/vendor/search-vendor")},3e3)})},function(e){v({key:"error",action:(null==e?void 0:e.message)||e}),setTimeout(N,5e3)});return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},defaultValues:{role:{code:"SUPERVISOR",name:"Supervisor"}},onFormValueChange:(e,t)=>{var l;const n=[null==t?void 0:t.fullName,null==t?void 0:t.mobileNumber,null==t?void 0:t.emailId,null==t?void 0:t.gender,null==t?void 0:t.dob,null==t?void 0:t.correspondenceAddress].every(Boolean)&&(null==t||null===(l=t.zoneIds)||void 0===l?void 0:l.length)>0;_(n)},noBreakLine:!0,mode:"onChange",noCard:!0}),m&&l.createElement(o.Toast,{error:"error"===m.key,label:s("success"===m.key?`ES_VENDOR_${m.action}_SUCCESS`:m.action),onClose:N})))},EditSupervisor:z,SupervisorAreaAssignment:e=>{var n,i,a,r;let{config:s,onSelect:d,t:u,formData:c}=e;const E=Digit.ULBService.getCurrentTenantId(),[m,v]=t.useState((null==c||null===(n=c.areaAssignment)||void 0===n?void 0:n.zone)||null),[S,p]=t.useState((null==c||null===(i=c.areaAssignment)||void 0===i?void 0:i.cluster)||null),[_,D]=t.useState((null==c||null===(a=c.areaAssignment)||void 0===a?void 0:a.ward)||null),[R,g]=t.useState((null==c||null===(r=c.areaAssignment)||void 0===r?void 0:r.areas)||[]),[N,y]=t.useState([]),[T,I]=t.useState([]),[C,A]=t.useState([]),[O,b]=t.useState([]),{data:f,isLoading:h}=Digit.Hooks.useCommonMDMS(E,"egov-location",["TenantBoundary"]);t.useEffect(()=>{if(console.log("Boundary Data State:",{boundaryData:f,isLoading:h}),f){var e,t,l,n,o;const i=(null==f||null===(e=f["egov-location"])||void 0===e||null===(t=e.TenantBoundary)||void 0===t?void 0:t[0])||(null==f||null===(l=f.MdmsRes)||void 0===l||null===(n=l["egov-location"])||void 0===n||null===(o=n.TenantBoundary)||void 0===o?void 0:o[0]),a=(null==i?void 0:i.boundary)||(null==i?void 0:i.children)||[];Array.isArray(a)&&a.length>0?y(a):h||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 h||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"}])},[f,h]),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),D(null),g([]))}else I([])},[m]),t.useEffect(()=>{if(S){var e,t;const l=S.children||S.boundary||[];A(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)&&(D(null),g([]))}else A([])},[S]),t.useEffect(()=>{if(_){var e,t;const l=_.children||_.localities||_.boundary||[];b(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)&&g([])}else b([])},[_]);const V=(e,t)=>{const l={...null==c?void 0:c.areaAssignment,[e]:t};"zone"===e?(l.cluster=null,l.ward=null,l.areas=[]):"cluster"===e?(l.ward=null,l.areas=[]):"ward"===e&&(l.areas=[]),d(s.key,l)};return h?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,u("ES_VENDOR_SUPERVISOR_ZONE")+" *"),l.createElement(o.Dropdown,{selected:m,option:N,select:e=>{v(e),V("zone",e)},optionKey:"name",t:u})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,u("ES_VENDOR_SUPERVISOR_CLUSTER")+" *"),l.createElement(o.Dropdown,{selected:S,option:T,select:e=>{p(e),V("cluster",e)},optionKey:"name",t:u,disable:!m})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,u("ES_VENDOR_SUPERVISOR_WARD")+" *"),l.createElement(o.Dropdown,{selected:_,option:C,select:e=>{D(e),V("ward",e)},optionKey:"name",t:u,disable:!S})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,u("ES_VENDOR_SUPERVISOR_AREA")+" *"),l.createElement(o.MultiSelectDropdown,{options:O,selected:R,onSelect:e=>{g(e),V("areas",e)},optionsKey:"name",t:u,disable:!_,ServerStyle:{backgroundColor:"#fff"}})))},SurveyorDetails:e=>{var r,s;const d=Digit.ULBService.getCurrentTenantId(),{t:u}=i.useTranslation(),c=n.useHistory(),E=a.useQueryClient(),{id:m}=n.useParams(),[v,S]=t.useState(!1),[p,_]=t.useState(null),[D,R]=t.useState(!1),[g,N]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),{data:A}=Digit.Hooks.fsm.useDsoSearch(d,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{data:O,isLoading:b,refetch:f}=Digit.Hooks.fsm.useSurveyorSearch(d,{ids:m},{staleTime:Infinity}),h=l.useMemo(()=>{var e;return null!=O&&null!==(e=O.surveyors)&&void 0!==e&&e.length?O.surveyors.map(e=>{var t,l,n,o;const i=null==A?void 0:A.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==i||null===(t=i.dsoDetails)||void 0===t?void 0:t.name)||e.vendorId||"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR";return{surveyorData:e,vendorDetails:{vendor:i?[i.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===(o=e.owner)||void 0===o?void 0:o.gender},{title:"ES_VENDOR_SURVEYOR_AGENCY_NAME",value:a,type:"custom"}]}]}}):[]},[O,A]),{mutate:V}=Digit.Hooks.fsm.useSurveyorUpdate(d),{mutate:M}=Digit.Hooks.fsm.useVendorUpdate(d);t.useEffect(()=>{if(A){let e=A.map(e=>e.dsoDetails);T(e)}},[A]),t.useEffect(()=>{f()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return R(!0);case"EDIT":return c.push("/digit-ui/employee/vendor/registry/modify-surveyor/"+m);case"HOME":return c.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SURVEYOR")}},[p]);const w=()=>{N(null)},k=()=>{_(null),C({}),R(!1)};return b?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(o.Card,null,null==h||null===(r=h[0])||void 0===r||null===(s=r.employeeResponse)||void 0===s?void 0:s.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(o.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(o.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(o.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>_("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(o.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},u(e.value)||"N/A"))))))}))),D&&l.createElement(o.Modal,{headerBarMain:l.createElement(Q,{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(J,{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==h||null===(e=h[0])||void 0===e?void 0:e.surveyorData,status:"INACTIVE"}};V(t,{onError:e=>{N({key:"error",action:e}),setTimeout(w,5e3)},onSuccess:()=>{N({key:"success",action:"DELETE_SURVEYOR"}),E.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(()=>{w(),c.push("/digit-ui/employee/vendor/search-vendor")},5e3)}}),R(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=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],o=(null==n?void 0:n.surveyors)||[];o=o.map(e=>(e.id===m&&(e.vendorSurveyorStatus="INACTIVE"),e));const i={vendor:{...n,surveyors:o}};M(i,{onError:e=>{N({key:"error",action:e}),setTimeout(w,5e3)},onSuccess:()=>{N({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),f(),setTimeout(w,5e3)}}),R(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=I,l=null==h||null===(e=h[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:{...t,surveyors:t.surveyors?[...t.surveyors,l]:[l]}};M(n,{onError:e=>{N({key:"error",action:e}),f(),setTimeout(w,5e3)},onSuccess:()=>{N({key:"success",action:"ADD_VENDOR"}),E.invalidateQueries("SURVEYOR_SEARCH"),f(),setTimeout(w,5e3)}}),R(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=I,l=null==h||null===(e=h[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:{...t,surveyors:t.surveyors?[...t.surveyors,l]:[l]}};M(n,{onError:e=>{N({key:"error",action:e}),setTimeout(w,5e3)},onSuccess:()=>{N({key:"success",action:"EDIT_VENDOR"}),f(),E.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(w,5e3)}}),R(!1),_(null)})()}}},l.createElement(o.Card,{style:{boxShadow:"none"}},"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(L,{t:u,title:"ES_VENDOR_SURVEYOR_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(o.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0)),g&&l.createElement(o.Toast,{error:"error"===g.key,label:u("success"===g.key?`ES_VENDOR_${g.action}_SUCCESS`:g.action),onClose:w}),l.createElement(o.ActionBar,{style:{zIndex:"19"}},v?l.createElement(o.Menu,{localeKeyPrefix:"ES_VENDOR_SURVEYOR_ACTION",options:["EDIT","DELETE"],t:u,onSelect:e=>{S(!1),_(e)}}):null,l.createElement(o.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)})))},EditSurveyor:W,SelectEkycZones:e=>{let{config:n,onSelect:i,t:a,formData:r,isMultiSelect:s=!0}=e;const d=Digit.ULBService.getCurrentTenantId(),[u,c]=t.useState([]),[E,m]=t.useState([]),{data:v,isLoading:S}=Digit.Hooks.useCommonMDMS(d,"egov-location",["TenantBoundary"]);return t.useEffect(()=>{if(u.length)if(s)m(Array.isArray(null==r?void 0:r.zoneIds)?u.filter(e=>r.zoneIds.includes(e.code)):[]);else{const e=u.find(e=>e.code===(null==r?void 0:r.zoneIds));m(e?[e]:[])}},[u,null==r?void 0:r.zoneIds,s]),t.useEffect(()=>{var e,t,l,n,o;const i=(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===(o=n.TenantBoundary)||void 0===o?void 0:o[0]),a=(null==i?void 0:i.boundary)||(null==i?void 0:i.children)||[];if(Array.isArray(null==a?void 0:a.children)&&(null==a?void 0:a.children.length)>0){const e=a.children.flatMap(e=>((null==e?void 0:e.children)||[]).map(e=>({code:e.code,name:e.name}))),t=[...new Map(e.map(e=>[e.code,e])).values()];c(t)}},[v]),S?l.createElement(o.Loader,null):l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,a(n.label)+(n.isMandatory?" *":"")),l.createElement("div",{className:"field",style:{position:"relative",zIndex:10}},l.createElement(o.MultiSelectDropdown,{options:u,selected:E,onSelect:e=>{if(s){const t=Array.isArray(e)?e.map(e=>Array.isArray(e)?e[1]:e).filter(Boolean):[];m(t),i(n.key,t)}else{const t=Array.isArray(e)?Array.isArray(e[0])?e[0][1]:e[0]:e;m(t?[t]:[]),i(n.key,(null==t?void 0:t.code)||"")}},optionsKey:"name",t:a,multiple:s,ServerStyle:{backgroundColor:"#fff"},isMultiSelect:s,showSelectedLabels:!0})))},SelectEkycClusters:e=>{let{config:n,onSelect:i,t:a,formData:r}=e;const s=Digit.ULBService.getCurrentTenantId(),[d,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(s,"egov-location",["TenantBoundary"]);t.useEffect(()=>{var e,t,l,n,o;const i=(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===(o=n.TenantBoundary)||void 0===o?void 0:o[0]),a=(null==i?void 0:i.boundary)||(null==i?void 0:i.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(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,a(n.label)+(n.isMandatory?" *":"")),l.createElement("div",{className:"field",style:{position:"relative",zIndex:9}},l.createElement(o.MultiSelectDropdown,{options:d,selected:c,onSelect:e=>{const t=Array.isArray(e)?e.map(e=>Array.isArray(e)?e[1]:e).filter(Boolean):e;E(t),i(n.key,t)},optionsKey:"name",t:a,ServerStyle:{backgroundColor:"#fff"},disable:S})))},SelectEkycDropdown:e=>{var t,n;let{config:i,onSelect:a,t:r,formData:s}=e;const d=(null==i||null===(t=i.populators)||void 0===t?void 0:t.options)||[],u=(null==i||null===(n=i.populators)||void 0===n?void 0:n.optionsKey)||"name",c=null==s?void 0:s[i.key];return l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,r(i.label)),l.createElement("div",{className:"field"},l.createElement(o.Dropdown,{selected:c,option:d,select:e=>{a(i.key,e)},optionKey:u,t:r})))}},ve=e=>{let{userType:o,tenants:i}=e;const{path:a,url:r}=n.useRouteMatch(),s=Digit.StoreData.getCurrentLanguage(),d=Digit.ULBService.getCurrentTenantId();return t.useEffect(()=>{Digit.LocalizationService.getLocale({modules:["rainmaker-vendor"],locale:s,tenantId:"dl"})},[s,d]),Object.entries(me).forEach(e=>{let[t,l]=e;Digit.ComponentRegistryService.setComponent(t,l)}),Digit.SessionStorage.set("VENDOR_TENANTS",i),t.useEffect(()=>{"employee"===o&&Digit.LocalizationService.getLocale({modules:["rainmaker-"+d],locale:s,tenantId:d})},[]),l.createElement("employee"===o?H:q,{path:a,url:r,userType:o})},Se=e=>{const[,,l]=Digit.Hooks.useSessionStorage("VENDOR",{});return t.useEffect(()=>{l()},[]),null};exports.VENDORComponents={VENDORCard:()=>{const{t:e}=i.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 s=[{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"}],d=Digit.UserService.hasAccess(["WT_VENDOR"]),u={Icon:l.createElement(o.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:s.filter(e=>!(null!=e&&e.role)||d),...a?{onDetailsClick:()=>t.push("/digit-ui/citizen/vendor/search-vendor")}:{}};return a?l.createElement("div",{className:"wt-citizen-card-premium"},l.createElement(o.EmployeeModuleCard,u)):l.createElement(o.EmployeeModuleCard,u)},VENDORModule:ve,VENDORLinks:Se},exports.VENDORLinks=Se,exports.VENDORModule=ve;
1
+ var e,t=require("react"),l=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=require("react-router-dom"),o=require("@djb25/digit-ui-react-components"),i=require("react-i18next"),a=require("react-query"),r=require("react-hook-form");function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var n in l)({}).hasOwnProperty.call(l,n)&&(e[n]=l[n])}return e}).apply(null,arguments)}function d(e,t){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{DatePicker:u}=require("@djb25/digit-ui-react-components"),c=function(e,t,n,o){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_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(u,s({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"}}]}]},E=e=>{var r;const{t:s}=i.useTranslation(),u=n.useHistory(),E=null===(r=Digit.UserService.getUser())||void 0===r?void 0:r.info,m=null==E?void 0:E.type,v=Digit.ULBService.getCurrentTenantId(),S=null!=v&&v.includes(".")?v:v+".djb",[p,_]=t.useState(null),D=a.useQueryClient(),[R,g]=t.useState(!1),{mutateAsync:N}=Digit.Hooks.fsm.useSurveyorCreate(S),y=c(s);return l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{route:"surveyor-details",timeLine:[{actions:s("ES_VENDOR_SURVEYOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(o.FormComposer,{isDisabled:!R,label:s("ES_COMMON_APPLICATION_SUBMIT"),config:y.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:function(e){try{var t,l,n;const o=null==E||null===(t=E.roles)||void 0===t?void 0:t.some(e=>"EKYC_SUPERVISOR"===e.code),i={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==E?void 0:E.authToken),...o&&{userInfo:{id:null==E?void 0:E.id,uuid:null==E?void 0:E.uuid,userName:null==E?void 0:E.userName,name:null==E?void 0:E.name,type:m,tenantId:(null==E?void 0:E.tenantId)||v,roles:null==E?void 0:E.roles}}},surveyor:{tenantId:S,description:(null==e?void 0:e.description)||"",additionalDetails:{serviceType:"ekyc"},owner:{tenantId:S,name:null==e?void 0:e.fullName,fatherOrHusbandName:"Static Father",relationship:"FATHER",gender:(null==e||null===(n=e.gender)||void 0===n?void 0:n.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=d(function(){return Promise.resolve(N(i)).then(function(){D.invalidateQueries("SURVEYOR_SEARCH"),u.push({pathname:`/digit-ui/${m}/vendor/search-vendor`,state:{showSuccessToast:!0,message:{key:"success",action:"ES_VENDOR_ADD_SURVEYOR_SUCCESS"}}})})},function(e){_({key:"error",action:(null==e?void 0:e.message)||e})});return Promise.resolve(a&&a.then?a.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},defaultValues:{role:{code:"SURVEYOR",name:"Surveyor"},mobileNumber:""},onFormValueChange:(e,t)=>{g(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.correspondenceAddress)))},noBreakLine:!0,mode:"onChange",noCard:!0}),p&&l.createElement(o.Toast,{error:"error"===p.key,label:s("success"===p.key?`ES_VENDOR_${p.action}_SUCCESS`:p.action),onClose:()=>{_(null)}})))},m=e=>{let{parentRoute:a}=e;const{t:r}=i.useTranslation(),s=[{text:r("ES_TITLE_NEW_DESULDGING_APPLICATION"),link:"/digit-ui/employee/fsm/new-application",roles:["FSM_CREATOR_EMP"]},{text:r("ES_TITILE_SEARCH_APPLICATION"),link:a+"/search"},{text:r("ES_TITLE_REPORTS"),link:"/employee/report/fsm/FSMDailyDesludingReport",roles:["FSM_ADMIN"],hyperlink:!0}],[d,u]=t.useState([]),{roles:c}=Digit.UserService.getUser().info;return t.useEffect(()=>{let e=s.filter(e=>{let{roles:t}=e;return(null==t?void 0:t.some(e=>null==c?void 0:c.map(e=>{let{code:t}=e;return t}).includes(e)))||!(null!=t&&t.length)});u(e)},[]),l.createElement(o.Card,{className:"employeeCard inboxLinksFSM"},l.createElement("div",{className:"complaint-links-container"},l.createElement("div",{className:"header"},l.createElement("span",{className:"logo"},l.createElement(o.ShippingTruck,null))," ",l.createElement("span",{className:"text"},r("ES_TITLE_FAECAL_SLUDGE_MGMT"))),l.createElement("div",{className:"body"},d.map((e,t)=>{let{link:o,text:i,hyperlink:a=!1,accessTo:s=[]}=e;return l.createElement("span",{className:"link",key:t},a?l.createElement("a",{href:o},r(i)):l.createElement(n.Link,{to:o},r(i)))}))))},v=e=>{let{className:t="table",t:n,currentPage:i,columns:a,data:r,getCellProps:d,disableSort:u,onSort:c,onNextPage:E,onPrevPage:m,onPageSizeChange:v,pageSizeLimit:S,sortParams:p,totalRecords:_,isPaginationRequired:D,showCSVExport:R,csvExportFileName:g,csvExportData:N,getCSVExportData:y,csvExportColumns:T,csvExportButtonLabel:I,...C}=e;return l.createElement(o.Card,null,l.createElement(o.Table,s({className:t,t:n,data:r,currentPage:i,columns:a,getCellProps:d,onNextPage:E,onPrevPage:m,pageSizeLimit:S,disableSort:u,onPageSizeChange:v,onSort:c,sortParams:p,totalRecords:_,isPaginationRequired:D,showCSVExport:R,csvExportFileName:g,csvExportData:N,getCSVExportData:y,csvExportColumns:T,csvExportButtonLabel:I},C)))},S=e=>{var t;let{status:n,searchParams:a,onAssignmentChange:r,statusMap:s}=e;return i.useTranslation(),l.createElement(o.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==s||null===(t=s.find(e=>e.statusid===n.uuid))||void 0===t?void 0:t.count)||"-"})`})},p=e=>{var n,a,r,s,d;let{onAssignmentChange:u,searchParams:c,businessServices:E,statusMap:m}=e;const{t:v}=i.useTranslation(),[p,_]=t.useState(!1),{data:D,isLoading:R}=Digit.Hooks.useApplicationStatusGeneral({businessServices:E},{}),{userRoleStates:g}=D||{},N=(e,t)=>t(map[e.stateBusinessService])+" - "+t("ES_PTR_COMMON_STATUS_"+(e.state||"CREATED"));return R?l.createElement(o.Loader,null):null!=g&&g.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==g||null===(n=g.filter(e=>!e.isTerminateState))||void 0===n||null===(a=n.slice(0,4))||void 0===a?void 0:a.map((e,t)=>l.createElement(S,{businessServices:E,key:t,onAssignmentChange:u,status:{name:N(e,v),code:e.applicationStatus,...e},searchParams:c,statusMap:m})),(null==g||null===(r=g.filter(e=>!e.isTerminateState))||void 0===r?void 0:r.slice(4).length)>0?l.createElement(l.Fragment,null,p&&(null==g||null===(s=g.filter(e=>!e.isTerminateState))||void 0===s||null===(d=s.slice(4))||void 0===d?void 0:d.map((e,t)=>l.createElement(S,{businessServices:E,key:e.uuid,onAssignmentChange:u,status:{name:N(e,v),code:e.applicationStatus,...e},searchParams:c,statusMap:m}))),l.createElement("div",{className:"filter-button",onClick:()=>_(!p)}," ",v(p?"ES_COMMON_LESS":"ES_COMMON_MORE")," ")):null):null},_=e=>{let{onFilterChange:t,searchParams:n,paginationParms:i,tenantId:a,t:r}=e;const{data:s}=Digit.Hooks.fsm.useInbox(a,{...n,...i,fromDate:null!=n&&n.fromDate?new Date(null==n?void 0:n.fromDate).getTime():void 0,toDate:null!=n&&n.toDate?new Date(null==n?void 0:n.toDate).getTime():void 0,total:!0,uuid:{code:"ASSIGNED_TO_ALL",name:r("ES_INBOX_ASSIGNED_TO_ALL")}}),d=[{code:"ASSIGNED_TO_ME",name:r("ES_INBOX_ASSIGNED_TO_ME")+" (0)"},{code:"ASSIGNED_TO_ALL",name:`${r("ES_INBOX_ASSIGNED_TO_ALL")} (${(null==s?void 0:s.totalCount)||0})`}];return l.createElement(l.Fragment,null,l.createElement(o.RadioButtons,{onSelect:e=>t({uuid:{code:e.code}}),selectedOption:d.filter(e=>{var t;return e.code===(null==n||null===(t=n.uuid)||void 0===t?void 0:t.code)})[0],optionsKey:"name",options:d}))},D=e=>{var t,a,r,s;let{searchParams:d,paginationParms:u,onFilterChange:c,onSearch:E,...m}=e;const{t:v}=i.useTranslation(),S=n.useLocation(),D=Digit.UserService.hasAccess(["FSM_DSO"])||!1,R=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1,g=Digit.UserService.hasAccess("FSM_EMP_FSTPO")&&S.pathname.includes("fstp-fsm-request")||!1,N=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),A=null==T?void 0:T.filter(e=>C.filter(t=>t===e.userRole)[0]),O=null==A?void 0:A.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:[]}),b=()=>{if(R)return c()};return l.createElement(l.Fragment,null,(!D&&!R&&d||(null==O||null===(t=O.statuses)||void 0===t?void 0:t.length)>0||g)&&l.createElement("div",{className:"filter",style:{marginTop:R?"-0px":"revert"}},l.createElement("div",{className:"filter-card"},l.createElement("div",{className:"heading"},l.createElement("div",{className:"filter-label"},v("ES_COMMON_FILTER_BY"),":"),l.createElement("div",{className:"clearAll",onClick:b},v("ES_COMMON_CLEAR_ALL")),"desktop"===m.type&&l.createElement("span",{className:"clear-search",onClick:b},v("ES_COMMON_CLEAR_ALL")),"mobile"===m.type&&l.createElement("span",{onClick:m.onClose},l.createElement(o.CloseSvg,null))),l.createElement("div",null,!D&&!R&&d&&l.createElement(_,{onFilterChange:c,searchParams:d,paginationParms:u,tenantId:N,t:v}),l.createElement("div",null)),(null==O||null===(a=O.statuses)||void 0===a?void 0:a.length)>0||g?l.createElement("div",null,l.createElement("div",{className:"filter-label"},v("ES_INBOX_LOCALITY")),l.createElement(o.Localities,{selectLocality:e=>{c(R?{locality:[e]}:{locality:[...null==d?void 0:d.locality,e]})},tenantId:N,boundaryType:"revenue"}),l.createElement("div",{className:"tag-container"},null==d?void 0:d.locality.map((e,t)=>l.createElement(o.RemoveableTag,{key:t,text:e.i18nkey,onClick:()=>{c({locality:null==d?void 0:d.locality.filter(t=>t.code!==e.code)})}})))):null,l.createElement("div",null,I&&O&&null!=m&&null!==(r=m.applications)&&void 0!==r&&r.statuses?l.createElement(p,{onAssignmentChange:(e,t)=>{c(e.target.checked?{applicationStatus:[...null==d?void 0:d.applicationStatus,t]}:{applicationStatus:null==d?void 0:d.applicationStatus.filter(e=>t.name!==e.name)})},fsmfilters:d,mergedRoleDetails:O,statusMap:null==m||null===(s=m.applications)||void 0===s?void 0:s.statuses}):S.pathname.includes("fstp-fsm-request")?"":l.createElement(o.Loader,null)))),"mobile"===m.type&&m.onClose&&l.createElement(o.ActionBar,null,l.createElement(o.ApplyFilterBar,{submit:!1,labelLink:v("ES_COMMON_CLEAR_ALL"),buttonLink:v("ES_COMMON_FILTER"),onClear:b,onSubmit:()=>{"mobile"===m.type?E({delete:["applicationNos"]}):E()},style:{flex:1}})))},R=e=>{let{onAssignmentChange:t,value:n,applicationStatuses:i,areApplicationStatus:a}=e;return a?l.createElement(o.Dropdown,{option:i,optionKey:"name",selected:n,select:t}):l.createElement(o.Loader,null)},g=e=>{var a,d,u,c,E,m,v,S,p,_,D,g;let{onSearch:N,type:y,onClose:T,onTabChange:I,searchFields:C,searchParams:A,isInboxPage:O,selectedTab:b,matchedRoles:f}=e;const h=O?Digit.SessionStorage.get("vendor/inbox/searchParams"):Digit.SessionStorage.get("vendor/search/searchParams"),{t:V}=i.useTranslation(),L=n.useHistory(),{register:M,handleSubmit:w,reset:k,watch:P,control:F}=r.useForm({defaultValues:h||A}),[x,H]=t.useState(!1),U=window.Digit.Utils.browser.isMobile(),B=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1;function Y(){const e=C.reduce((e,t)=>({...e,[null==t?void 0:t.name]:""}),{});k(e),O?Digit.SessionStorage.del("fsm/inbox/searchParams"):Digit.SessionStorage.del("fsm/search/searchParams"),N({})}const G=e=>null,W=Digit.SessionStorage.get("User").info.type,K=[...null!=f&&null!==(a=f.wt)&&void 0!==a&&a.includes("WT_VENDOR")?["VENDOR"]:[],...null!=f&&null!==(d=f.wt)&&void 0!==d&&d.includes("WT_VENDOR")?["DRIVER","VEHICLE"]:[],...null!=f&&null!==(u=f.ekyc)&&void 0!==u&&u.includes("EKYC_VENDOR")?["SUPERVISOR"]:[],...null!=f&&null!==(c=f.ekyc)&&void 0!==c&&c.includes("EKYC_SUPERVISOR")?["SURVEYOR"]:[]];return l.createElement(l.Fragment,null,l.createElement("div",{className:"search-container"},l.createElement("div",{className:"search-complaint-container"},("mobile"===y||U)&&l.createElement("div",{className:"complaint-header"},l.createElement("h2",null,V("ES_COMMON_SEARCH_BY")),l.createElement("span",{style:{position:"absolute",top:"2%",right:"8px"},onClick:T},l.createElement(o.CloseSvg,null))),l.createElement("div",{className:"search-tabs-container"},l.createElement("div",null,((null==f||null===(E=f.wt)||void 0===E?void 0:E.includes("WT_VENDOR"))||(null==f||null===(m=f.ekyc)||void 0===m?void 0:m.includes("EKYC_VENDOR")))&&l.createElement("button",{className:"VENDOR"===b?"search-tab-head-selected":"search-tab-head",onClick:()=>{Y(),I("VENDOR")}},V("ES_FSM_REGISTRY_INBOX_TAB_VENDOR")),(null==f||null===(v=f.wt)||void 0===v?void 0:v.includes("WT_VENDOR"))&&l.createElement("button",{className:"VEHICLE"===b?"search-tab-head-selected":"search-tab-head",onClick:()=>{Y(),I("VEHICLE")}},V("ES_FSM_REGISTRY_INBOX_TAB_VEHICLE")),(null==f||null===(S=f.wt)||void 0===S?void 0:S.includes("WT_VENDOR"))&&l.createElement("button",{className:"DRIVER"===b?"search-tab-head-selected":"search-tab-head",onClick:()=>{Y(),I("DRIVER")}},V("ES_FSM_REGISTRY_INBOX_TAB_DRIVER")),((null==f||null===(p=f.ekyc)||void 0===p?void 0:p.includes("EKYC_VENDOR"))||(null==f||null===(_=f.ekyc)||void 0===_?void 0:_.includes("EKYC_SUPERVISOR")))&&l.createElement("button",{className:"SUPERVISOR"===b?"search-tab-head-selected":"search-tab-head",onClick:()=>{Y(),I("SUPERVISOR")}},V("ES_FSM_REGISTRY_INBOX_TAB_SUPERVISOR")),((null==f||null===(D=f.ekyc)||void 0===D?void 0:D.includes("EKYC_SUPERVISOR"))||(null==f||null===(g=f.ekyc)||void 0===g?void 0:g.includes("EKYC_VENDOR")))&&l.createElement("button",{className:"SURVEYOR"===b?"search-tab-head-selected":"search-tab-head",onClick:()=>{Y(),I("SURVEYOR")}},V("ES_FSM_REGISTRY_INBOX_TAB_SURVEYOR"))),l.createElement("div",{className:"action-bar-wrap-registry"},l.createElement("div",{className:"search-add",onClick:()=>{H(!x)}},V("ES_VENDOR_REGISTRY_INBOX_HEADER_ADD"),l.createElement("div",{className:"search-add-icon"},l.createElement(o.AddIcon,{className:""}))),x&&l.createElement(o.Menu,{localeKeyPrefix:"ES_FSM_ACTION_CREATE",options:K,t:V,onSelect:function(e){const t=null==W?void 0:W.toLowerCase();switch(e){case"VENDOR":return L.push(`/digit-ui/${t}/vendor/registry/new-vendor`);case"VEHICLE":return L.push(`/digit-ui/${t}/vendor/registry/new-vehicle`);case"DRIVER":return L.push(`/digit-ui/${t}/vendor/registry/new-driver`);case"SUPERVISOR":return L.push(`/digit-ui/${t}/vendor/registry/new-supervisor`);case"SURVEYOR":return L.push(`/digit-ui/${t}/vendor/registry/new-surveyor`)}}}))),l.createElement("form",{onSubmit:w(e=>{e.mobileNumber||delete e.mobileNumber,N(e),"mobile"===y&&T()})},l.createElement("div",{className:B?"for-pt for-search flex-box":"flex-box",style:{gap:"16px"}},null==C?void 0:C.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(r.Controller,{render:e=>l.createElement(o.DatePicker,{date:e.value,onChange:e.onChange}),name:e.name,control:F,defaultValue:null});case"status":return l.createElement(r.Controller,{render:e=>l.createElement(R,{onAssignmentChange:e.onChange,value:e.value}),name:e.name,control:F,defaultValue:null});case"dropdown":return l.createElement(r.Controller,{render:t=>l.createElement(o.Dropdown,{option:e.options,optionKey:e.optionsKey,value:t.value,selected:t.value,select:t.onChange,t:V,placeholder:e.label}),name:e.name,control:F,defaultValue:null});default:return l.createElement(o.TextInput,s({},e,{inputRef:M},M(e.name,{validate:G}),{watch:P,shouldUpdate:!0,placeholder:e.label}))}})(e))),l.createElement("div",{style:{display:"flex",justifyContent:"end",gap:"16px",alignItems:"center"}},"desktop"===y&&!U&&l.createElement("span",{className:"clear-search generic-button"},l.createElement(o.LinkLabel,{style:{},onClick:Y},V("ES_COMMON_CLEAR_SEARCH"))),"desktop"===y&&!U&&l.createElement(o.SubmitBar,{className:"submit-bar-search",label:V("ES_COMMON_SEARCH"),submit:!0})))))))},N=e=>{if(!e)return{};if("object"==typeof e)return e;if("string"!=typeof e)return{};try{return JSON.parse(e)}catch(e){return{}}},y=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):[]},T=function(e,t){void 0===t&&(t=[]);const l=function(e){var t,l,n,o,i,a,r,s,d,u,c,E,m;void 0===e&&(e={});const v=e=>Array.isArray(e)?e.flatMap(y):y(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===(o=e)||void 0===o||null===(i=o.fillingpointmetadata)||void 0===i?void 0:i.fillingPointId,null===(a=e)||void 0===a?void 0:a.fillingPtName,null===(r=e)||void 0===r?void 0:r.filling_pt_name,null===(s=e)||void 0===s||null===(d=s.fillingPoint)||void 0===d?void 0:d.fillingPointId].filter(e=>null!=e&&""!==e).map(String),...v(null===(u=e)||void 0===u?void 0:u.fillingPoint),...v(null===(c=e)||void 0===c||null===(E=c.dsoDetails)||void 0===E?void 0:E.fillingPoint),...v(null===(m=e)||void 0===m?void 0:m.fillingPointDetail)]))}(e);return l.length&&t.find(e=>y(e).some(e=>l.includes(e)))||null},I=function(e){var t,l,n,o,i,a,r,s,d,u,c,E,m,v,S,p,_,D,R,g,N,y;if(void 0===e&&(e={}),Array.isArray(null===(t=e)||void 0===t?void 0:t.fillingPoint)){const t=e.fillingPoint.map(e=>(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.fillingPointId)).filter(Boolean);if(t.length>0)return t.join(", ")}return(null===(l=e)||void 0===l||null===(n=l.fillingPoint)||void 0===n?void 0:n.fillingPointName)||(null===(o=e)||void 0===o||null===(i=o.dsoDetails)||void 0===i||null===(a=i.fillingPoint)||void 0===a?void 0:a.fillingPointName)||(null===(r=e)||void 0===r?void 0:r.fillingPointName)||(null===(s=e)||void 0===s||null===(d=s.dsoDetails)||void 0===d?void 0:d.fillingPointName)||(null===(u=e)||void 0===u?void 0:u.fillingPointId)||(null===(c=e)||void 0===c||null===(E=c.dsoDetails)||void 0===E?void 0:E.fillingPointId)||("string"==typeof(null===(m=e)||void 0===m?void 0:m.fillingPoint)?null===(v=e)||void 0===v?void 0:v.fillingPoint:null)||("string"==typeof(null===(S=e)||void 0===S||null===(p=S.dsoDetails)||void 0===p?void 0:p.fillingPoint)?null===(_=e)||void 0===_||null===(D=_.dsoDetails)||void 0===D?void 0:D.fillingPoint:null)||(null===(R=e)||void 0===R||null===(g=R.fillingpointmetadata)||void 0===g?void 0:g.fillingPointId)||(null===(N=e)||void 0===N?void 0:N.filling_pt_name)||(null===(y=e)||void 0===y?void 0:y.fillingPtName)||"NA"},C=function(e,t){var l,n,o,i,a,r,s;void 0===e&&(e={}),void 0===t&&(t=[]);const d=(null===(l=e)||void 0===l||null===(n=l.vendor)||void 0===n?void 0:n.id)||(null===(o=e)||void 0===o||null===(i=o.vendorData)||void 0===i?void 0:i.id)||(null===(a=e)||void 0===a?void 0:a.vendorId);return d&&(t.find(e=>(null==e?void 0:e.id)===d)||(null===(r=e)||void 0===r?void 0:r.vendor)||(null===(s=e)||void 0===s?void 0:s.vendorData))||null},A=function(e){var t,l,n,o;void 0===e&&(e={});const i=[...Array.isArray(null===(t=e)||void 0===t?void 0:t.fillingPoint)?e.fillingPoint:[null===(l=e)||void 0===l?void 0:l.fillingPoint],...Array.isArray(null===(n=e)||void 0===n?void 0:n.fillingPoints)?e.fillingPoints:[null===(o=e)||void 0===o?void 0:o.fillingPoints]].filter(Boolean),a=new Map;return i.forEach(e=>{const t=y(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())},O=(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=y(t);return n.length?l.filter(e=>{const t=function(e){var t,l,n,o,i,a,r,s,d,u,c;return void 0===e&&(e={}),Array.from(new Set([null===(t=e)||void 0===t?void 0:t.fillingPointId,null===(l=e)||void 0===l?void 0:l.fillingStationId,null===(n=e)||void 0===n||null===(o=n.additionalDetails)||void 0===o?void 0:o.fillingPointId,null===(i=e)||void 0===i||null===(a=i.additionalDetails)||void 0===a?void 0:a.fillingStationId,null===(r=e)||void 0===r||null===(s=r.fillingpointmetadata)||void 0===s?void 0:s.fillingPointId].filter(e=>null!=e&&""!==e).map(String).concat(y(null===(d=e)||void 0===d?void 0:d.fillingPoint),y(null===(u=e)||void 0===u?void 0:u.fillingPointDetail),y(null===(c=e)||void 0===c?void 0:c.fillingPointDetails))))}(e);return!t.length||t.some(e=>n.includes(e))}):l},b=function(e,t){var l,n,o,i;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===(o=e)||void 0===o||null===(i=o.driver)||void 0===i?void 0:i.id);return a&&t.find(e=>(null==e?void 0:e.id)===a)||null},f=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)}},h=e=>{var r,s,u;const c=Digit.ULBService.getCurrentTenantId(),{t:E}=i.useTranslation(),S=n.useHistory(),p=e=>l.createElement("span",{className:"cell-text"},e),_=Digit.UserService.hasAccess("FSM_EMP_FSTPO")||!1,[R,y]=t.useState([]),[h,V]=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===(r=U.info.type)||void 0===r?void 0:r.toLowerCase(),G=["EKYC_VENDOR","EKYC_SUPERVISOR","EKYC_SURVEYOR"],W=null==B?void 0:B.some(e=>G.includes((null==e?void 0:e.code)||e)),K=()=>{H(null),F(!1)},$=l.useMemo(()=>[{Header:E("WT_NAME"),accessor:"name",Cell:e=>{let{row:t}=e;return p(t.original.name)}},{Header:E("WT_MOBILE_NUMBER"),accessor:"mobileNumber",Cell:e=>{let{row:t}=e;return p(t.original.mobileNumber)}},{Header:E("WT_EMAIL_ID"),accessor:"emailId",Cell:e=>{let{row:t}=e;return p(t.original.emailId)}},{Header:E("WT_VALID_FROM"),accessor:"validFrom",Cell:e=>{let{row:t}=e;return t.original.validFrom?Digit.DateUtils.ConvertEpochToDate(t.original.validFrom):E("CS_NA")}},{Header:E("WT_VALID_TO"),accessor:"validTo",Cell:e=>{let{row:t}=e;return t.original.validTo?Digit.DateUtils.ConvertEpochToDate(t.original.validTo):E("CS_NA")}},{Header:E("WT_DOCUMENT"),accessor:"fileStoreId",Cell:e=>{let{row:t}=e;return t.original.fileStoreId?l.createElement("div",{style:{color:"#f47738",cursor:"pointer",textDecoration:"underline"},onClick:()=>function(e){try{if(!e)return Promise.resolve();const t=d(function(){return Promise.resolve(Digit.UploadServices.Filefetch([e],"dl")).then(function(t){var l;if(null!=t&&null!==(l=t.data)&&void 0!==l&&l[e]){const l=t.data[e].split(",")[0];window.open(l,"_blank")}})},function(e){console.error(e),V({key:"error",action:"Failed to fetch document."}),setTimeout(te,5e3)});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}(t.original.fileStoreId)},l.createElement(o.ViewsIcon,null)):E("CS_NA")}}],[E]),z=a.useQueryClient(),{data:q,refetch:Z}=Digit.Hooks.fsm.useDsoSearch(c,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{enabled:!1}),{data:j,refetch:X}=Digit.Hooks.fsm.useDriverSearch({tenantId:c,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"}}),{mutate:Q}=Digit.Hooks.fsm.useVendorUpdate(c),{mutate:J}=Digit.Hooks.fsm.useUpdateVehicle(c),{mutate:ee}=Digit.Hooks.fsm.useDriverUpdate(c);t.useEffect(()=>{var t;y((null==e||null===(t=e.data)||void 0===t?void 0:t.table)||[])},[e]),t.useEffect(()=>{"DRIVER"!==e.selectedTab&&"VEHICLE"!==e.selectedTab||(Z(),X())},[e.selectedTab]),t.useEffect(()=>{if(q){let e=q.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)}},[q]),t.useEffect(()=>{j&&k((j.driver||[]).map(e=>{var t;return{...e,displayName:`${e.name} (${(null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"N/A"})`}}))},[j]);const te=()=>{V(null)},le=(e,t)=>{y(l=>l.map(l=>(null==l?void 0:l.id)===e?{...l,...t}:l))},ne=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:f(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}},oe=(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}}},ie=()=>{switch(e.selectedTab){case"VENDOR":return S.push(`/digit-ui/${Y}/vendor/registry/new-vendor`);case"VEHICLE":return S.push(`/digit-ui/${Y}/vendor/registry/new-vehicle`);case"DRIVER":return S.push(`/digit-ui/${Y}/vendor/registry/new-driver`);case"SUPERVISOR":return S.push(`/digit-ui/${Y}/vendor/registry/new-supervisor`);case"SURVEYOR":return S.push(`/digit-ui/${Y}/vendor/registry/new-surveyor`)}},ae=l.useMemo(()=>"VENDOR"===e.selectedTab?(null==R?void 0:R.map(e=>e.id))||[]:(null==q?void 0:q.map(e=>{var t;return null===(t=e.dsoDetails)||void 0===t?void 0:t.id}))||[],[e.selectedTab,R,q]),{data:re}=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:c,filters:{vendorIds:null==ae?void 0:ae.join(","),vendorId:null==ae?void 0:ae.join(",")}},{enabled:(null==ae?void 0:ae.length)>0}),{data:se,isLoading:de}=Digit.Hooks.wt.useFillPointSearch({tenantId:c,filters:{limit:1e3}},{enabled:!0}),ue=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,o;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(o=n.auditDetails)||void 0===o?void 0:o.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:o}=e,i=null===(t=o.original.dsoDetails)||void 0===t?void 0:t.additionalDetails;if("string"==typeof i)try{i=JSON.parse(i)}catch(e){console.error("Error parsing additionalDetails:",e),i={}}const a=(null===(n=i)||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,i;let{row:a}=t;return l.createElement(o.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=a.original)||void 0===n||null===(i=n.dsoDetails)||void 0===i?void 0:i.status),onChange:()=>(t=>{var l,n,o,i;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===(o=a.owner)||void 0===o?void 0:o.emailId)||"abc@egov.com",relationship:(null==a||null===(i=a.owner)||void 0===i?void 0:i.relationship)||"OTHER"}}};Q(r,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"VENDOR"}),z.invalidateQueries("DSO_SEARCH"),e.refetchData(),setTimeout(te,3e3)}})})(a),name:"switch-"+a.id})}},{Header:E("ES_VENDOR_ADDITIONAL_DETAILS"),disableSortBy:!0,Cell:e=>{var t,o;let{row:i}=e;const a=null===(t=i.original)||void 0===t?void 0:t.id;if(!re)return l.createElement("span",null,"Loading...");const r=null!==(null===(o=i.original)||void 0===o?void 0:o.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"))}},...W?[]:[{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:o}=e;return l.createElement("div",null,(null===(t=o.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,o;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(o=n.auditDetails)||void 0===o?void 0:o.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(o.Dropdown,{className:"fsm-registry-dropdown",selected:C(n.original,L),option:L,select:t=>((t,l)=>{const n=t.original,o=null==n?void 0:n.vendor;if(null==l||!l.id||(null==o?void 0:o.id)===(null==l?void 0:l.id))return;const i={...n,vendorVehicleStatus:"ACTIVE",fillingPoint:null,driverData:null,driver:null};delete i.vendor,delete i.popup,delete i.driver;const a=()=>{const t=Array.isArray(null==l?void 0:l.vehicles)?[...l.vehicles]:[],o=t.findIndex(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id));o>-1?t[o]={...t[o],...i,vendorVehicleStatus:"ACTIVE"}:t.push(i);const a={...l,vehicles:t};Q(oe(l,t),{onError:e=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:()=>{le(null==n?void 0:n.id,{vendor:a,fillingPoint:null,driverData:null,driver:null}),V({key:"success",action:"VEHICLE"}),z.invalidateQueries("DSO_SEARCH"),z.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchData(),e.refetchVendor&&e.refetchVendor(),setTimeout(te,3e3)}})};if(null!=o&&o.id){const e=Array.isArray(null==o?void 0:o.vehicles)?o.vehicles.map(e=>(null==e?void 0:e.id)===(null==n?void 0:n.id)?{...e,vendorVehicleStatus:"INACTIVE"}:e):[];Q(oe(o,e),{onError:e=>{V({key:"error",action:e}),setTimeout(te,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,o=n.original.additionalDetails;if("string"==typeof o)try{o=JSON.parse(o)}catch(e){console.error("Error parsing additionalDetails:",e),o={}}const i=(null===(t=o)||void 0===t?void 0:t.serviceType)||"N/A";return l.createElement("div",null,i)}},{Header:E("WT_FILLING_POINT"),accessor:e=>I(e),id:"fillingPoint",minWidth:250,Cell:t=>{let{row:n}=t;const i=C(n.original,L),a=A(i);return l.createElement(o.Dropdown,{className:"fsm-registry-dropdown",selected:T(n.original,a),option:a,select:t=>((t,l)=>{const n=ne(t.original,{fillingPoint:l});J(n,{onError:e=>{var t,l,n,o;V({key:"error",label:(null==e?void 0:e.message)||(null==e||null===(t=e.response)||void 0===t||null===(l=t.data)||void 0===l||null===(n=l.Errors)||void 0===n||null===(o=n[0])||void 0===o?void 0:o.message)||"Failed to map filling point"}),setTimeout(te,5e3)},onSuccess:()=>{var n;const o=C(t.original,L),i=O(o,l),a=b(t.original,i);le(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}}),V({key:"success",label:"Filling point mapped successfully"}),z.invalidateQueries("FSM_VEICLES_SEARCH"),z.invalidateQueries("DSO_SEARCH"),e.refetchData(),e.refetchVendor&&e.refetchVendor(),setTimeout(te,3e3)}})})(n,t),style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"fillingPointName",t:E,disable:!i||!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 i=C(n.original,L),a=T(n.original,A(i)),r=O(i,a);return l.createElement(o.Dropdown,{className:"fsm-registry-dropdown",selected:b(n.original,r),option:r,select:t=>((t,l)=>{const n=ne(t.original,{driverData:l});J(n,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:(n,o)=>{var i;le(null===(i=t.original)||void 0===i?void 0:i.id,{driverData:l}),V({key:"success",action:"VEHICLE"}),z.invalidateQueries("FSM_VEICLES_SEARCH"),z.invalidateQueries("DSO_SEARCH"),e.refetchData(),e.refetchVendor(),setTimeout(te,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:i}=t;return l.createElement(o.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>(t=>{var l;const n=ne(t.original,{status:"ACTIVE"===(null===(l=t.original)||void 0===l?void 0:l.status)?"DISABLED":"ACTIVE"});J(n,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"VEHICLE"}),z.invalidateQueries("FSM_VEICLES_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(te,3e3)}})})(i),name:"switch-"+i.id})}}];case"DRIVER":return[{Header:E("ES_FSM_REGISTRY_INBOX_USERNAME"),id:"userName",accessor:e=>{var t;return(null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"},Cell:e=>{var t;let{row:o}=e;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/driver-details/`+o.original.id},l.createElement("div",null,(null===(t=o.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:o}=e;return l.createElement("div",null,(null===(t=o.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,o;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(o=n.auditDetails)||void 0===o?void 0:o.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(o.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,o=null==n?void 0:n.vendor,i=l;if(delete n.vendor,n.vendorDriverStatus="ACTIVE",o){const e=null==o?void 0:o.drivers;e.splice(e.findIndex(e=>e.id===n.id),1)}const a={vendor:{...i,drivers:i.drivers?[...i.drivers,n]:[n]}};Q(a,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"VENDOR"}),z.invalidateQueries("DSO_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(te,3e3)}})})(n,t),style:{textAlign:"left",width:"100%",minWidth:"250px"},optionKey:"displayName",t:E})}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let{row:i}=t;return l.createElement(o.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>(t=>{var l,n,o,i;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===(o=a.owner)||void 0===o?void 0:o.emailId)||"abc@egov.com",relationship:(null==a||null===(i=a.owner)||void 0===i?void 0:i.relationship)||"OTHER"}}};ee(r,{onError:(e,t)=>{V({key:"error",action:e}),setTimeout(te,5e3)},onSuccess:(t,l)=>{V({key:"success",action:"DRIVER"}),z.invalidateQueries("FSM_DRIVER_SEARCH"),e.refetchVendor(),e.refetchData(),setTimeout(te,3e3)}})})(i),name:"switch-"+i.id})}}];case"SUPERVISOR":case"SURVEYOR":return[{Header:E("SUPERVISOR"===e.selectedTab?"ES_FSM_REGISTRY_INBOX_SUPERVISOR_NAME":"ES_FSM_REGISTRY_INBOX_SURVEYOR_NAME"),accessor:"name",Cell:t=>{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,""+(o.original.name||"N/A")))))}},{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 o;let{row:i}=t;return l.createElement("div",null,l.createElement("span",{className:"link"},l.createElement(n.Link,{to:`/digit-ui/${Y}/vendor/registry/${"SUPERVISOR"===e.selectedTab?"supervisor-details":"surveyor-details"}/`+i.original.id},l.createElement("div",null,(null===(o=i.original.owner)||void 0===o?void 0:o.userName)||"NA"))))}},..."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:o}=e;return l.createElement("div",null,(null===(t=o.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:o}=e;return l.createElement("div",null,(null===(t=o.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,o;let{row:i}=e;return p(null!==(t=i.original)&&void 0!==t&&null!==(l=t.auditDetails)&&void 0!==l&&l.createdTime?Digit.DateUtils.ConvertEpochToDate(null===(n=i.original)||void 0===n||null===(o=n.auditDetails)||void 0===o?void 0:o.createdTime):"")}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),id:"status",accessor:e=>e.status||"",Cell:t=>{var n;let{row:i}=t;return l.createElement(o.ToggleSwitch,{style:{display:"flex",justifyContent:"left"},value:"DISABLED"!==(null===(n=i.original)||void 0===n?void 0:n.status),onChange:()=>{console.log("Updating status for",e.selectedTab,i.original.id)},name:"switch-"+i.id})}}];default:return[]}},[e.selectedTab,L,w,R,re,(null==se?void 0:se.fillingPoints)||[],E]),ce=l.useMemo(()=>{switch(e.selectedTab){case"VENDOR":return[{Header:E("ES_VENDOR_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,o,i;return`${(null==e?void 0:e.name)||(null==e||null===(t=e.dsoDetails)||void 0===t?void 0:t.name)||"NA"} (${(null==e?void 0:e.mobileNumber)||(null==e||null===(l=e.owner)||void 0===l?void 0:l.mobileNumber)||(null==e||null===(n=e.dsoDetails)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.dsoDetails)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||"NA"})`}},{Header:E("ES_VENDOR_INBOX_DATE_VENDOR_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:E("WT_FILLING_POINT"),exportAccessor:e=>I(e)},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t,l;return(null===(t=N(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,o,i,a,r,s;return`${(null==e||null===(t=e.vendor)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendorData)||void 0===l?void 0:l.name)||"NA"} (${(null==e||null===(n=e.vendor)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.vendor)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(a=e.vendorData)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendorData)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"})`}},{Header:E("ES_VENDOR_INBOX_SERVICE_TYPE"),exportAccessor:e=>{var t;return(null===(t=N(null==e?void 0:e.additionalDetails))||void 0===t?void 0:t.serviceType)||"N/A"}},{Header:E("WT_FILLING_POINT"),exportAccessor:e=>I(e)},{Header:E("ES_FSM_REGISTRY_SELECT_DRIVER"),exportAccessor:e=>{var t,l,n,o,i,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===(o=n.owner)||void 0===o?void 0:o.mobileNumber)||(null==e||null===(i=e.driver)||void 0===i||null===(a=i.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,o,i,a,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} (${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.vendorData)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];case"SURVEYOR":return[{Header:E("ES_FSM_REGISTRY_INBOX_USERNAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"}},{Header:E("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),exportAccessor:e=>{var t;return`${(null==e?void 0:e.name)||"NA"} (${(null==e||null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_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,o,i,a,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} ${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.vendorData)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"}`}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];case"SUPERVISOR":return[{Header:E("ES_FSM_REGISTRY_INBOX_USERNAME"),exportAccessor:e=>{var t;return(null==e||null===(t=e.owner)||void 0===t?void 0:t.userName)||"NA"}},{Header:E("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),exportAccessor:e=>{var t;return`${(null==e?void 0:e.name)||"NA"} (${(null==e||null===(t=e.owner)||void 0===t?void 0:t.mobileNumber)||"NA"})`}},{Header:E("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),exportAccessor:e=>{var t,l;return null!=e&&null!==(t=e.auditDetails)&&void 0!==t&&t.createdTime?Digit.DateUtils.ConvertEpochToDate(null==e||null===(l=e.auditDetails)||void 0===l?void 0:l.createdTime):""}},{Header:E("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),exportAccessor:e=>{var t,l,n,o,i,a,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} ${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.vendorData)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"}`}},{Header:E("ES_VENDOR_SUPERVISOR_AGENCY_NAME"),exportAccessor:e=>{var t,l,n,o,i,a,r,s;return`${(null==e||null===(t=e.vendorData)||void 0===t?void 0:t.name)||(null==e||null===(l=e.vendor)||void 0===l?void 0:l.name)||"NA"} ${(null==e||null===(n=e.vendorData)||void 0===n?void 0:n.mobileNumber)||(null==e||null===(o=e.vendorData)||void 0===o||null===(i=o.owner)||void 0===i?void 0:i.mobileNumber)||(null==e||null===(a=e.vendor)||void 0===a?void 0:a.mobileNumber)||(null==e||null===(r=e.vendor)||void 0===r||null===(s=r.owner)||void 0===s?void 0:s.mobileNumber)||"NA"}`}},{Header:E("ES_FSM_REGISTRY_INBOX_ENABLED"),exportAccessor:e=>(null==e?void 0:e.status)||"NA"}];default:return[]}},[e.selectedTab,E]),Ee=l.useCallback(function(){return Promise.resolve(R)},[R]);let me;if(e.isLoading||de)me=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(o.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":"SURVEYOR"===e.selectedTab?t="ES_FSM_REGISTRY_EMPTY_CARD_SURVEYOR":(t="ES_FSM_REGISTRY_EMPTY_CARD_DRIVER",n="ES_FSM_REGISTRY_EMPTY_BUTTON_DRIVER"),me=l.createElement(o.Card,{className:"flex-center flex-box"},l.createElement("div",{style:{marginTop:"50px",marginBottom:"25px"}},E(t)),n&&l.createElement(o.SubmitBar,{className:"",label:E(n),onSubmit:ie}))}else R.length>0&&(me=l.createElement(v,{className:"table registryTable",t:E,data:R,columns:ue,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:Ee,csvExportColumns:ce,csvExportFileName:`vendor-${String(e.selectedTab||"registry").toLowerCase()}-inbox`}));const ve=B.map(e=>e.code),Se={ekyc:Object.values({ekycVendor:"EKYC_VENDOR",supervisor:"EKYC_SUPERVISOR"}).filter(e=>ve.includes(e)),wt:Object.values({wtVendor:"WT_VENDOR"}).filter(e=>ve.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(m,{parentRoute:e.parentRoute}),l.createElement("div",{style:{marginTop:"24px"}},l.createElement(D,{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(g,{onSearch:e.onSearch,type:"desktop",searchFields:e.searchFields,isInboxPage:!(null!=e&&e.isSearch),searchParams:e.searchParams,onTabChange:e.onTabChange,selectedTab:e.selectedTab,matchedRoles:Se}),l.createElement("div",{className:"result",style:{marginLeft:_||"FSM_ADMIN"===e.userRole||null!=e&&e.isSearch?"":"24px",flex:1}},me)),h&&l.createElement(o.Toast,{error:"error"===h.key,label:E(h.label?h.label:"success"===h.key?`ES_FSM_REGISTRY_${h.action}_DISABLE_SUCCESS`:h.action),onClose:te}),P&&l.createElement(o.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:K,style:{cursor:"pointer"}},l.createElement(o.MdClose,null)),actionCancelLabel:E("CS_COMMON_CLOSE"),actionCancelOnSubmit:K,hideSubmit:!0,formId:"modal-action"},l.createElement("div",{style:{padding:"16px"}},(null==x||null===(s=x.dsoDetails)||void 0===s||null===(u=s.vendorWorkOrder)||void 0===u?void 0:u.length)>0?l.createElement(o.Table,{t:E,data:x.dsoDetails.vendorWorkOrder,columns:$,getCellProps:e=>({style:{minWidth:"150px",padding:"8px 12px",fontSize:"13.5px"}})}):l.createElement("p",{style:{textAlign:"center",marginTop:"20px"}},E("ES_VENDOR_NO_WORKORDERS")))))},V=()=>{var e,a,r,s,d,u,c,E,m,v,S;const{t:p}=i.useTranslation(),_=Digit.ULBService.getCurrentTenantId(),D=Digit.UserService.getUser(),R=(null===(e=Digit.UserService.getUser())||void 0===e||null===(a=e.info)||void 0===a||null===(r=a.roles)||void 0===r?void 0:r.map(e=>e.code))||[],g=n.useLocation(),N=R.includes("EKYC_VENDOR")||R.includes("WT_VENDOR")?"VENDOR":R.includes("EKYC_SUPERVISOR")?"SUPERVISOR":R.includes("EKYC_SURVEYOR")?"SURVEYOR":"",{selectedTabs:y}=Digit.Hooks.useQueryParams(),[T,I]=t.useState(y||N),[C,A]=t.useState({}),[O,b]=t.useState([{id:"createdTime",desc:!0}]),[f,V]=t.useState(0),[L,M]=t.useState(10),[w,k]=t.useState(""),[P,F]=t.useState(""),[x,H]=t.useState([]),[U,B]=t.useState(null),Y="CITIZEN"===(null==D||null===(s=D.info)||void 0===s?void 0:s.type),G=null==D||null===(d=D.info)||void 0===d?void 0:d.uuid,{data:W}=Digit.Hooks.fsm.useDsoSearch(_,{status:"ACTIVE"},{staleTime:Infinity}),{data:K}=Digit.Hooks.wt.useFillPointSearch({tenantId:_,filters:{limit:1e3}},{staleTime:Infinity});let $={limit:L,offset:f,sortBy:null==O||null===(u=O[0])||void 0===u?void 0:u.id,sortOrder:null!=O&&null!==(c=O[0])&&void 0!==c&&c.desc?"DESC":"ASC"};const{data:z,isLoading:q,refetch:Z}="VEHICLE"===T?Digit.Hooks.fsm.useVehiclesSearch({tenantId:_,filters:{...$,registrationNumber:null==C?void 0:C.registrationNumber,status:"ACTIVE,DISABLED",vendorId:Y?G:null==C||null===(E=C.vendor)||void 0===E?void 0:E.id,fillingPointId:null==C||null===(m=C.fillingPoint)||void 0===m?void 0:m.id},config:{enabled:!1}}):"DRIVER"===T?Digit.Hooks.fsm.useDriverSearch({tenantId:_,filters:{...$,name:null==C?void 0:C.name,status:"ACTIVE,DISABLED",vendorId:Y?G:null==C||null===(v=C.vendor)||void 0===v?void 0:v.id},config:{enabled:!1}}):"SUPERVISOR"===T?Digit.Hooks.fsm.useSupervisorSearch(_,{...$,status:"ACTIVE,DISABLED",name:null==C?void 0:C.name},{enabled:!1}):"SURVEYOR"===T?Digit.Hooks.fsm.useSurveyorSearch(_,{...$,status:"ACTIVE,DISABLED",name:null==C?void 0:C.name},{enabled:!1}):Digit.Hooks.fsm.useVendorSearch({tenantId:_,filters:{...$,name:null==C?void 0:C.name,status:"ACTIVE,DISABLED"},config:{enabled:!1}});Digit.Hooks.fsm.useVendorSearch({tenantId:_,filters:{...$,name:null==C?void 0:C.name,status:"ACTIVE,DISABLED"},config:{enabled:!1}});const{data:j,isLoading:X,refetch:Q}=Digit.Hooks.fsm.useDsoSearch(_,{vehicleIds:w,driverIds:P,status:"ACTIVE"},{enabled:!1}),J=(null==z?void 0:z.totalCount)||50;t.useEffect(()=>{var e,t;Z(),Q(),null!==(e=g.state)&&void 0!==e&&e.showSuccessToast&&B(null===(t=g.state)||void 0===t?void 0:t.message)},[]),t.useEffect(()=>{Z()},[C,O,f,L]),t.useEffect(()=>{if(null!=z&&z.vehicle&&"VEHICLE"===T){const e=z.vehicle.map(e=>e.id).filter(Boolean).join(",");k(e),H(z.vehicle)}if(null!=z&&z.driver&&"DRIVER"===T){const e=z.driver.map(e=>e.id).filter(Boolean).join(",");F(e),H(null==z?void 0:z.driver)}if(null!=z&&z.vendor&&"VENDOR"===T){const e=z.vendor.map(e=>{var t,l,n,o;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===(o=n.filter(e=>"ACTIVE"===e.status))||void 0===o?void 0:o.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}))}});H(e)}"SUPERVISOR"===T&&H((null==z?void 0:z.supervisors)||(null==z?void 0:z.supervisor)||[]),"SURVEYOR"===T&&H((null==z?void 0:z.surveyors)||(null==z?void 0:z.surveyor)||[])},[z,T]),t.useEffect(()=>{""===w&&""===P||Q()},[w,P]),t.useEffect(()=>{let e=!0;if(j&&e){if("VEHICLE"===T){var t;const e=null==z||null===(t=z.vehicle)||void 0===t?void 0:t.map(e=>{let t=j.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 o={...e,vendor:t.dsoDetails};const i=null===(l=t.dsoDetails)||void 0===l||null===(n=l.vehicles)||void 0===n?void 0:n.find(t=>t.id===e.id);return i&&(o.driverData=i.driverData||i.driver||o.driverData),o}return e});H(e),k("")}if("DRIVER"===T){var l;const e=null==z||null===(l=z.driver)||void 0===l?void 0:l.map(e=>{let t=j.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});H(e),F("")}}return()=>{e=!1}},[j,z]);const ee="VEHICLE"===T?[{label:p("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==W?void 0:W.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:p("ES_FSM_REGISTRY_SEARCH_FILLING_POINT"),name:"fillingPoint",type:"dropdown",options:null==K||null===(S=K.fillingPoints)||void 0===S?void 0:S.map(e=>({...e,name:(null==e?void 0:e.name)||(null==e?void 0:e.fillingPointName)||(null==e?void 0:e.fillingStationId)})),optionsKey:"name"},{label:p("ES_VEHICLE_SEARCH_VEHICLE_NUMBER"),name:"registrationNumber",pattern:"[A-Z]{2}[- ]?[0-9]{2}[- ]?[A-Z]{1,2}[- ]?[0-9]{4}",title:p("ES_FSM_VEHICLE_FORMAT_TIP")}]:"DRIVER"===T?[{label:p("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==W?void 0:W.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:p("ES_DRIVER_SEARCH_DRIVER_NAME"),name:"name"}]:"SUPERVISOR"===T||"SURVEYOR"===T?[{label:p("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"vendor",type:"dropdown",options:null==W?void 0:W.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:p("SUPERVISOR"===T?"ES_SUPERVISOR_SEARCH_NAME":"ES_SURVEYOR_SEARCH_NAME"),name:"name"}]:[{label:p("ES_VENDOR_SEARCH_VENDOR_NAME"),name:"name"}],te=t.useCallback(e=>{0!==(null==e?void 0:e.length)&&b(e)},[]);return l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(h,{data:{table:x},isLoading:q||X,onSort:te,disableSort:!1,sortParams:O,userRole:"FSM_ADMIN",onFilterChange:()=>{},searchFields:ee,onSearch:function(e){void 0===e&&(e={}),A({...e})},onNextPage:()=>{V(e=>e+L)},onPrevPage:()=>{V(e=>e-L)},currentPage:Math.floor(f/L),pageSizeLimit:L,onPageSizeChange:e=>{M(Number(e.target.value))},totalRecords:J||0,onTabChange:e=>{I(e)},selectedTab:T,refetchData:()=>{Z()},refetchVendor:()=>{Q()}}),U&&l.createElement(o.Toast,{error:"error"===U.key,label:p(U.action),onClose:()=>{B(null)},duration:5e3})))},L=e=>{let{t:t,title:n}=e;return l.createElement("div",{className:"confirmation_box"},l.createElement("span",null,t(""+n)," "))};function M(e,t){switch(t.action){case"mutateSearchForm":return Digit.SessionStorage.set("EKYC.SW.INBOX",{...e,searchForm:t.data}),{...e,searchForm:t.data};case"mutateFilterForm":return Digit.SessionStorage.set("EKYC.SW.INBOX",{...e,filterForm:t.data}),{...e,filterForm:t.data};case"mutateTableForm":return Digit.SessionStorage.set("EKYC.SW.INBOX",{...e,tableForm:t.data}),{...e,tableForm:t.data};default:return e}}const w={filterForm:{},searchForm:{},tableForm:{limit:10,offset:0,sortBy:"createdTime",sortOrder:"DESC"}},k=(e,t)=>[{Header:e("SURVEYOR_NAME"),accessor:"surveyorName",Cell:e=>{var n,o,i;let{row:a}=e;const r=null===(n=a.original)||void 0===n?void 0:n.id;return l.createElement("span",{className:"ekyc-application-link",style:{color:"#318ED0",cursor:"pointer",fontSize:"16px"},onClick:()=>t(r)},(null===(o=a.original)||void 0===o?void 0:o.surveyorName)||(null===(i=a.original)||void 0===i?void 0:i.name)||"NA")}},{Header:e("MOBILE_NUMBER"),accessor:"mobileNo",Cell:e=>{var t,n,o;let{row:i}=e;return l.createElement("span",null,(null===(t=i.original)||void 0===t?void 0:t.mobileNo)||(null===(n=i.original)||void 0===n||null===(o=n.owner)||void 0===o?void 0:o.mobileNumber)||"NA")}},{Header:e("STATUS"),accessor:"status",Cell:t=>{var n;let{row:o}=t;const i=(null===(n=o.original)||void 0===n?void 0:n.status)||"DEFAULT";return l.createElement("span",{className:"ekyc-status-tag "+i},e(i))}},{Header:e("SERVICE_TYPE"),accessor:"serviceType",Cell:e=>{var t;let{row:n}=e;return l.createElement("span",null,(null===(t=n.original)||void 0===t?void 0:t.serviceType)||"NA")}}],P=e=>l.createElement("h1",{className:"heading-m"},e.label),F=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(o.CloseSvg,null)),x=e=>{var r,s,d,u,c,E,m,v,S,p,_,D,R;const g=Digit.ULBService.getCurrentTenantId(),{t:N}=i.useTranslation(),y=n.useHistory(),T=n.useLocation(),I=a.useQueryClient(),{id:C}=n.useParams(),A=null===(r=Digit.SessionStorage.get("User"))||void 0===r?void 0:r.info,O=null==A||null===(s=A.type)||void 0===s?void 0:s.toLowerCase(),[b,f]=t.useState(!1),[h,V]=t.useState(null),[x,H]=t.useState(!1),[U,B]=t.useState(null),[Y,G]=t.useState([]),[W,K]=t.useState({}),{data:$}=Digit.Hooks.fsm.useDsoSearch(g,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{data:z,isLoading:q,refetch:Z}=Digit.Hooks.fsm.useSupervisorSearch(g,{ids:C},{staleTime:Infinity}),j=l.useMemo(()=>{var e;return null!=z&&null!==(e=z.supervisors)&&void 0!==e&&e.length?z.supervisors.map(e=>{var t,l,n,o;const i=null==$?void 0:$.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==i||null===(t=i.dsoDetails)||void 0===t?void 0:t.name)||e.vendorId||"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR";return{supervisorData:e,vendorDetails:{vendor:i?[i.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===(o=e.owner)||void 0===o?void 0:o.gender},{title:"ES_VENDOR_SUPERVISOR_AGENCY_NAME",value:a,type:"custom"}]}]}}):[]},[z,$]),{mutate:X}=Digit.Hooks.fsm.useSupervisorUpdate(g),{mutate:Q}=Digit.Hooks.fsm.useVendorUpdate(g);t.useEffect(()=>{if($){let e=$.map(e=>e.dsoDetails);G(e)}},[$]),t.useEffect(()=>{var e;Z(),null!==(e=T.state)&&void 0!==e&&e.showSuccessToast&&B({key:"success",action:"UPDATE_SUPERVISOR"})},[]),t.useEffect(()=>{switch(h){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return H(!0);case"EDIT":return y.push(`/digit-ui/${O}/vendor/registry/modify-supervisor/${C}`);case"HOME":return y.push(`/digit-ui/${O}/vendor/search-vendor?selectedTabs=SUPERVISOR`)}},[h]);const[J,ee]=t.useReducer(M,w);let te={limit:(null==J||null===(d=J.tableForm)||void 0===d?void 0:d.limit)||10,offset:(null==J||null===(u=J.tableForm)||void 0===u?void 0:u.offset)||0,sortBy:(null==J||null===(c=J.tableForm)||void 0===c?void 0:c.sortBy)||"createdTime",sortOrder:(null==J||null===(E=J.tableForm)||void 0===E?void 0:E.sortOrder)||"DESC"};const{data:le,isLoading:ne}=Digit.Hooks.fsm.useSurveyorSearch(g,{...te,status:"ACTIVE,DISABLED"},{enabled:!!g,keepPreviousData:!0}),oe=()=>{B(null)},ie=()=>{V(null),K({}),H(!1)},ae=l.useMemo(()=>((null==le?void 0:le.surveyors)||[]).map(e=>{var t,l,n,o,i;const a=(null==e?void 0:e.owner)||{},r=(null==a||null===(t=a.roles)||void 0===t||null===(l=t.map(e=>e.code))||void 0===l?void 0:l.join(", "))||"";return{...e,id:(null==e?void 0:e.id)||"",surveyorName:(null==e?void 0:e.name)||(null==a?void 0:a.name)||"",mobileNo:(null==e?void 0:e.mobileNo)||(null==a?void 0:a.mobileNumber)||"",email:(null==a?void 0:a.emailId)||"",vendorId:(null==e?void 0:e.vendorId)||"",tenantId:(null==e?void 0:e.tenantId)||"",supervisorId:(null==e?void 0:e.supervisorId)||"",status:(null==e?void 0:e.status)||"",roleCodes:r,userName:(null==a?void 0:a.userName)||"",gender:(null==a?void 0:a.gender)||"",serviceType:(null==e||null===(n=e.additionalDetails)||void 0===n?void 0:n.serviceType)||"",createdTime:(null==e||null===(o=e.auditDetails)||void 0===o?void 0:o.createdTime)||0,lastModifiedTime:(null==e||null===(i=e.auditDetails)||void 0===i?void 0:i.lastModifiedTime)||0}}),[null==le?void 0:le.surveyors]);if(q)return l.createElement(o.Loader,null);const re=(null==le||null===(m=le.dashboardInfo)||void 0===m?void 0:m.totalRecords)||(null==le?void 0:le.totalCount)||0,se={onPageSizeChange:e=>{const t=Number(e.target.value);ee({action:"mutateTableForm",data:{...J.tableForm,limit:t,offset:0}})},onNextPage:()=>{var e,t;return ee({action:"mutateTableForm",data:{...J.tableForm,offset:Number(null==J||null===(e=J.tableForm)||void 0===e?void 0:e.offset)+Number(null==J||null===(t=J.tableForm)||void 0===t?void 0:t.limit)}})},onPrevPage:()=>{var e,t;return ee({action:"mutateTableForm",data:{...J.tableForm,offset:Number(null==J||null===(e=J.tableForm)||void 0===e?void 0:e.offset)-Number(null==J||null===(t=J.tableForm)||void 0===t?void 0:t.limit)}})},onLastPage:()=>{var e,t,l;return ee({action:"mutateTableForm",data:{...J.tableForm,offset:Math.ceil(re/(null==J||null===(e=J.tableForm)||void 0===e?void 0:e.limit))*(null==J||null===(t=J.tableForm)||void 0===t?void 0:t.limit)-Number(null==J||null===(l=J.tableForm)||void 0===l?void 0:l.limit)}})},onFirstPage:()=>ee({action:"mutateTableForm",data:{...J.tableForm,offset:0}}),onSortingByData:e=>{if(e.length>0){const[{id:t,desc:l}]=e,n=l?"DESC":"ASC";J.tableForm.sortBy===t&&J.tableForm.sortOrder===n||ee({action:"mutateTableForm",data:{...J.tableForm,sortBy:t,sortOrder:l?"DESC":"ASC"}})}}};return console.log(null==A||null===(v=A.roles)||void 0===v||null===(S=v.map(e=>e.code))||void 0===S?void 0:S.includes("SUPERVISOR")),l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(o.Card,{className:"flex-box flex-box-col flex-gap-5"},null==j||null===(p=j[0])||void 0===p||null===(_=p.employeeResponse)||void 0===_?void 0:_.map((e,t)=>{var n,i,a;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},N(e.title)),l.createElement(o.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"},N(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},N(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(o.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:()=>V("EDIT_VENDOR"),style:{cursor:"pointer"}},l.createElement(o.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>V("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(o.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},N(e.value)||"N/A"))))),(null==A||null===(i=A.roles)||void 0===i||null===(a=i.map(e=>e.code))||void 0===a?void 0:a.includes("SUPERVISOR"))&&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:()=>y.push(`/digit-ui/${O}/vendor/registry/new-surveyor`)},l.createElement(o.AddIcon,{fill:"#a82227"}),N("ES_FSM_REGISTRY_DETAILS_TYPE_SURVEYOR_ADD")))}),l.createElement(o.Table,{t:N,disableSort:!1,autoSort:!1,manualPagination:!0,currentPage:Math.floor((null==J||null===(D=J.tableForm)||void 0===D?void 0:D.offset)/(null==J||null===(R=J.tableForm)||void 0===R?void 0:R.limit)),onPageSizeChange:se.onPageSizeChange,onNextPage:se.onNextPage,onPrevPage:se.onPrevPage,onLastPage:se.onLastPage,onFirstPage:se.onFirstPage,totalRecords:re,onSort:se.onSortingByData,data:ae,columns:k(N,e=>{y.push(`/digit-ui/${O}/ekyc/assign/surveyor-details/${e}`)}),inboxStyles:{overflowX:"scroll",overflowY:"hidden"},tableStyle:{width:"70%"},isLoading:ne}))),x&&l.createElement(o.Modal,{headerBarMain:l.createElement(P,{label:N((()=>{switch(h){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(F,{onClick:ie}),actionCancelLabel:N("CS_COMMON_CANCEL"),actionCancelOnSubmit:ie,actionSaveLabel:N("DELETE"===h||"DELETE_VENDOR"===h?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(h){case"DELETE":return(()=>{var e;const t={supervisor:{...null==j||null===(e=j[0])||void 0===e?void 0:e.supervisorData,status:"INACTIVE"}};X(t,{onError:e=>{B({key:"error",action:e}),setTimeout(oe,5e3)},onSuccess:()=>{B({key:"success",action:"DELETE_SUPERVISOR"}),I.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(()=>{oe(),y.push(`/digit-ui/${O}/vendor/search-vendor`)},5e3)}}),H(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=null==j||null===(e=j[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],o=(null==n?void 0:n.supervisors)||[];o=o.map(e=>(e.id===C&&(e.vendorSupervisorStatus="INACTIVE"),e));const i={vendor:{...n,supervisors:o}};Q(i,{onError:e=>{B({key:"error",action:e}),setTimeout(oe,5e3)},onSuccess:()=>{B({key:"success",action:"DELETE_VENDOR"}),I.invalidateQueries("FSM_VENDOR_SEARCH"),Z(),setTimeout(oe,5e3)}}),H(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=W,l=null==j||null===(e=j[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:{...t,supervisors:t.supervisors?[...t.supervisors,l]:[l]}};Q(n,{onError:e=>{B({key:"error",action:e}),Z(),setTimeout(oe,5e3)},onSuccess:()=>{B({key:"success",action:"ADD_VENDOR"}),I.invalidateQueries("SUPERVISOR_SEARCH"),Z(),setTimeout(oe,5e3)}}),H(!1),V(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=W,l=null==j||null===(e=j[0])||void 0===e?void 0:e.supervisorData;l.vendorSupervisorStatus="ACTIVE";const n={vendor:{...t,supervisors:t.supervisors?[...t.supervisors,l]:[l]}};Q(n,{onError:e=>{B({key:"error",action:e}),setTimeout(oe,5e3)},onSuccess:()=>{B({key:"success",action:"EDIT_VENDOR"}),Z(),I.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(oe,5e3)}}),H(!1),V(null)})()}}},l.createElement(o.Card,{style:{boxShadow:"none"}},"DELETE"===h||"DELETE_VENDOR"===h?l.createElement(L,{t:N,title:"ES_VENDOR_SUPERVISOR_DELETE_TEXT"}):"ADD_VENDOR"===h||"EDIT_VENDOR"===h?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,N("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(o.Dropdown,{t:N,option:Y,value:W,selected:W,select:K,optionKey:"name"})):void 0)),U&&l.createElement(o.Toast,{error:"error"===U.key,label:N("success"===U.key?`ES_VENDOR_${U.action}_SUCCESS`:U.action),onClose:oe,duration:5e3}),l.createElement(o.ActionBar,{style:{zIndex:"19"}},b?l.createElement(o.Menu,{localeKeyPrefix:"ES_VENDOR_SUPERVISOR_ACTION",options:["EDIT","DELETE"],t:N,onSelect:e=>{f(!1),V(e)}}):null,l.createElement(o.SubmitBar,{label:N("ES_COMMON_TAKE_ACTION"),onSubmit:()=>f(!b)})))},H=e=>{let{path:t}=e;const{t:a}=i.useTranslation(),r=n.useLocation();sessionStorage.removeItem("revalidateddone");const d=Digit.ComponentRegistryService.getComponent("AddVendor"),u=Digit.ComponentRegistryService.getComponent("SearchApp"),c=Digit.ComponentRegistryService.getComponent("AddDriver"),m=Digit.ComponentRegistryService.getComponent("EditVendorDetails"),v=Digit.ComponentRegistryService.getComponent("AddVehicle"),S=Digit.ComponentRegistryService.getComponent("VENDORCreate"),p=Digit.ComponentRegistryService.getComponent("DriverDetails"),_=Digit.ComponentRegistryService.getComponent("VehicleDetails"),D=Digit.ComponentRegistryService.getComponent("AddSupervisor"),R=Digit.ComponentRegistryService.getComponent("EditSupervisor"),g=Digit.ComponentRegistryService.getComponent("SurveyorDetails"),N=Digit.ComponentRegistryService.getComponent("EditSurveyor"),y=Digit.ComponentRegistryService.getComponent("EditDriver"),T=Digit.ComponentRegistryService.getComponent("EditVehicle");return l.createElement(n.Switch,null,l.createElement(o.AppContainer,null,l.createElement(l.Fragment,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(o.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(o.ArrowLeft,{className:"icon"}),"Back"),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const e=r.pathname;let t=[{icon:o.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(o.PrivateRoute,{path:t+"/search-vendor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"normal"},l.createElement(V,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/new-driver",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(c,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/new-vehicle",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(v,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/additionaldetails",component:e=>{const n=e.location.pathname.includes("/info");return l.createElement(o.LayoutWrapper,{layoutClass:n?"action":"normal"},l.createElement(S,s({},e,{parentRoute:t})))}}),l.createElement(o.PrivateRoute,{path:t+"/registry/driver-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(p,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/modify-driver/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(y,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/common-search/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"normal"},l.createElement(u,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/new-vendor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(d,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/vendor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(m,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/vehicle-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(_,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/modify-vehicle/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(T,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/new-supervisor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(D,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/supervisor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(x,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/modify-supervisor/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(R,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/new-surveyor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(E,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/surveyor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(g,s({},e,{parentRoute:t})))}),l.createElement(o.PrivateRoute,{path:t+"/registry/modify-surveyor/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(N,s({},e,{parentRoute:t})))})))))},U=function(e){return void 0===e&&(e=""),function(e){return void 0===e&&(e=""),!(!e||null==e||void 0===e||""===e)}(e)?e:"NA"},B=(e,t)=>{const l=new Date(e);if(e){let e=l.getMonth()+1,n=l.getDate(),o=l.getFullYear();return e=(e>9?"":"0")+e,n=(n>9?"":"0")+n,"asset-create"===t?`${n}-${e}-${o}`:`${n}/${e}/${o}`}return null},Y=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},G=e=>{var n,i;let{isLoading:a,t:s,onSubmit:d,data:u,count:c,setShowToast:E,vendorData:m}=e;const v=window.Digit.Utils.browser.isMobile(),S=new Date,p=S.toISOString().split("T")[0],_=new Date(S);_.setDate(S.getDate()-7);const D=_.toISOString().split("T")[0],{register:R,control:g,handleSubmit:N,setValue:y,getValues:T,reset:I,formState:C}=r.useForm({defaultValues:{offset:0,limit:!v&&10,sortBy:"commencementDate",sortOrder:"DESC",fromDate:D,toDate:p}});t.useEffect(()=>{R("offset",0),R("limit",10),R("sortBy","commencementDate"),R("sortOrder","DESC"),y("fromDate",D),y("toDate",p)},[R,N,y,p,D]),t.useEffect(()=>{var e;if(console.log("Fetched Vendor Data:"),null!=m&&null!==(e=m.vendor)&&void 0!==e&&e.length){const e=m.vendor.map(e=>e.name);console.log("Vendor Names:",e)}},[m]);const A=t.useMemo(()=>[{Header:s("VENDOR_REGISTRATION_NO"),accessor:"requestId",disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const o=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.registrationNo;return l.createElement("div",null,o||"N/A")}},{Header:s("CONTACT_PERSON_NAME"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const o=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.contactPerson;return l.createElement("div",null,o||"N/A")}},{Header:s("VENDOR_MOBILE_NUMBER"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const o=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.vendorMobileNumber;return l.createElement("div",null,o||"N/A")}},{Header:s("VENDOR_BANK_NAME"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const o=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.bank;return l.createElement("div",null,o||"N/A")}},{Header:s("VENDOR_STATUS"),disableSortBy:!0,Cell:e=>{var t;let{row:n}=e;const o=null===(t=n.original.vendorAdditionalDetails)||void 0===t?void 0:t.status;return l.createElement("div",null,o||"N/A")}}],[]),O=t.useCallback(e=>{0!==e.length&&(y("sortBy",e.id),y("sortOrder",e.desc?"DESC":"ASC"))},[]);function b(){y("offset",T("offset")-T("limit")),N(d)()}return l.createElement(l.Fragment,null,l.createElement("div",null,l.createElement(o.Header,null,s("VENDOR_COMMON_SEARCH_ADDITIONAL_DETAILS")),l.createElement(o.SearchForm,{onSubmit:d,handleSubmit:N},l.createElement(o.SearchField,null,l.createElement("label",null,s("VENDOR_NAME")),l.createElement(r.Controller,{control:g,name:"vendorName",render:e=>{var t;return l.createElement(o.Dropdown,{selected:e.value||"",select:e.onChange,onBlur:e.onBlur,option:(null==m||null===(t=m.vendor)||void 0===t?void 0:t.map(e=>({name:e.name,i18nKey:e.name})))||[],optionKey:"i18nKey",t:s,disable:!1})}})),l.createElement(o.SearchField,null,l.createElement("label",null,s("VENDOR_MOBILE_NO")),l.createElement(o.MobileNumber,{name:"mobileNumber",inputRef:R({minLength:{value:10,message:s("CORE_COMMON_MOBILE_ERROR")},maxLength:{value:10,message:s("CORE_COMMON_MOBILE_ERROR")},pattern:{value:/[6789][0-9]{9}/,message:s("CORE_COMMON_MOBILE_ERROR")}}),type:"number",componentInFront:l.createElement("div",{className:"employee-card-input employee-card-input--front"},"+91")}),l.createElement(o.CardLabelError,null,null==C||null===(n=C.errors)||void 0===n||null===(i=n.mobileNumber)||void 0===i?void 0:i.message)),l.createElement(o.SearchField,null,l.createElement("label",null,s("VENDOR_FROM_DATE")),l.createElement(r.Controller,{render:e=>l.createElement(o.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"fromDate",control:g})),l.createElement(o.SearchField,null,l.createElement("label",null,s("VENDOR_TO_DATE")),l.createElement(r.Controller,{render:e=>l.createElement(o.DatePicker,{date:e.value,disabled:!1,onChange:e.onChange}),name:"toDate",control:g})),l.createElement(o.SearchField,{className:"submit"},l.createElement(o.SubmitBar,{label:s("ES_COMMON_SEARCH"),submit:!0}),l.createElement("p",{style:{marginTop:"10px"},onClick:()=>{I({fromDate:D,toDate:"",mobileNumber:"",vendorName:"",offset:0,limit:10,sortBy:"commencementDate",sortOrder:"DESC"}),E(null),b()}},s("ES_COMMON_CLEAR_ALL")))),!a&&null!=u&&u.display?l.createElement(o.Card,{style:{marginTop:20}},s(u.display).split("\\n").map((e,t)=>l.createElement("p",{key:t,style:{textAlign:"center"}},e))):a||""===u?""!==u||a&&l.createElement(o.Loader,null):l.createElement(o.Table,{t:s,data:u,totalRecords:c,columns:A,getCellProps:e=>({style:{minWidth:e.column.Header===s("EW_INBOX_APPLICATION_NO")?"240px":"",padding:"20px 18px",fontSize:"16px"}}),onPageSizeChange:function(e){y("limit",Number(e.target.value)),N(d)()},currentPage:T("offset")/T("limit"),onNextPage:function(){y("offset",T("offset")+T("limit")),N(d)()},onPrevPage:b,pageSizeLimit:T("limit"),onSort:O,disableSort:!1,sortParams:[{id:T("sortBy"),desc:"DESC"===T("sortOrder")}]})))},W=()=>{var e,r,s;const{t:d}=i.useTranslation(),u=n.useHistory(),E=a.useQueryClient(),{id:m}=n.useParams(),v=null===(e=Digit.UserService.getUser())||void 0===e||null===(r=e.info)||void 0===r?void 0:r.type,S=null===(s=Digit.UserService.getUser())||void 0===s?void 0:s.info,p=Digit.ULBService.getCurrentTenantId(),_=null!=p&&p.includes(".")?p:p+".djb",[D,R]=t.useState(null),[g,N]=t.useState(!1),[y,T]=t.useState({}),[I,C]=t.useState({}),{data:A,isLoading:O}=Digit.Hooks.fsm.useSurveyorSearch(_,{ids:m},{staleTime:Infinity}),{mutate:b}=Digit.Hooks.fsm.useSurveyorUpdate(_),f=c(d);return t.useEffect(()=>{if(A&&A.surveyors&&A.surveyors.length>0){var e,t,l,n,o,i,a,r,s;let d=A.surveyors[0];C(d);let u={fullName:(null==d||null===(e=d.owner)||void 0===e?void 0:e.name)||(null==d?void 0:d.name),mobileNumber:(null==d||null===(t=d.owner)||void 0===t?void 0:t.mobileNumber)||(null==d?void 0:d.mobileNo),emailId:null==d||null===(l=d.owner)||void 0===l?void 0:l.emailId,employeeId:null==d?void 0:d.employeeId,gender:null!=d&&null!==(n=d.owner)&&void 0!==n&&n.gender?{code:d.owner.gender,name:"COMMON_GENDER_"+d.owner.gender}:null,fatherOrHusbandName:null==d||null===(o=d.owner)||void 0===o?void 0:o.fatherOrHusbandName,relationship:null!=d&&null!==(i=d.owner)&&void 0!==i&&i.relationship?{code:d.owner.relationship,name:"ES_COMMON_RELATION_"+d.owner.relationship}:null,dob:(null==d||null===(a=d.owner)||void 0===a?void 0:a.dob)&&Digit.DateUtils.ConvertTimestampToDate(null==d||null===(r=d.owner)||void 0===r?void 0:r.dob,"yyyy-MM-dd"),correspondenceAddress:null==d||null===(s=d.owner)||void 0===s?void 0:s.correspondenceAddress,description:null==d?void 0:d.description};T(u)}},[A]),O||0===Object.keys(y).length?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{timeLine:[{actions:d("ES_VENDOR_SURVEYOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(o.FormComposer,{isDisabled:!g,label:d("ES_COMMON_APPLICATION_SUBMIT"),config:f.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,o,i,a,r,s,d,c;const p={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_update",msgId:Date.now()+"|en_IN",authToken:null==S?void 0:S.authToken,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:_,roles:null==S?void 0:S.roles}},surveyor:{...I,description:(null==e?void 0:e.description)||(null==I?void 0:I.description)||"",name:(null==e?void 0:e.fullName)||(null==I?void 0:I.name),mobileNo:(null==e?void 0:e.mobileNumber)||(null==I?void 0:I.mobileNo),employeeId:(null==e?void 0:e.employeeId)||(null==I?void 0:I.employeeId),owner:{...I.owner,name:(null==e?void 0:e.fullName)||(null===(t=I.owner)||void 0===t?void 0:t.name),fatherOrHusbandName:(null==e?void 0:e.fatherOrHusbandName)||(null===(l=I.owner)||void 0===l?void 0:l.fatherOrHusbandName),relationship:(null==e||null===(n=e.relationship)||void 0===n?void 0:n.code)||(null===(o=I.owner)||void 0===o?void 0:o.relationship),gender:(null==e||null===(i=e.gender)||void 0===i?void 0:i.code)||(null===(a=I.owner)||void 0===a?void 0:a.gender)||"OTHERS",dob:null!=e&&e.dob?new Date(e.dob).getTime():null===(r=I.owner)||void 0===r?void 0:r.dob,emailId:(null==e?void 0:e.emailId)||(null===(s=I.owner)||void 0===s?void 0:s.emailId),mobileNumber:(null==e?void 0:e.mobileNumber)||(null===(d=I.owner)||void 0===d?void 0:d.mobileNumber),correspondenceAddress:(null==e?void 0:e.correspondenceAddress)||(null===(c=I.owner)||void 0===c?void 0:c.correspondenceAddress)}}};b(p,{onError:e=>{R({key:"error",action:e})},onSuccess:()=>{R({key:"success",action:"UPDATE_SURVEYOR"}),E.invalidateQueries("SURVEYOR_SEARCH"),u.push({pathname:`/digit-ui/${v}/vendor/registry/surveyor-details/${m}`,state:{showSuccessToast:!0}})}})},defaultValues:y,onFormValueChange:(e,t)=>{N(!!((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}),D&&l.createElement(o.Toast,{error:"error"===D.key,label:d("success"===D.key?`ES_VENDOR_${D.action}_SUCCESS`:D.action),onClose:()=>{R(null)}})))},{DatePicker:K}=require("@djb25/digit-ui-react-components"),$=function(e,t,n,o){return void 0===o&&(o=!1),[{head:e("ES_VENDOR_SUPERVISOR_BASIC_DETAILS"),body:[{label:e("ES_VENDOR_SUPERVISOR_FULL_NAME"),isMandatory:!0,type:"text",disable:o,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:o,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_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(K,s({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:"ES_VENDOR_ZONE",isMandatory:!0,type:"component",key:"zoneIds",props:{isMultiSelect:!1},component:"SelectEkycZones"},{label:e("ES_VENDOR_SUPERVISOR_DESCRIPTION"),isMandatory:!1,type:"text",populators:{name:"description",className:"payment-form-text-input-correction"}}]}]},z=()=>{var e;const{t:r}=i.useTranslation(),s=n.useHistory(),d=a.useQueryClient(),{id:u}=n.useParams(),c=null===(e=Digit.UserService.getUser())||void 0===e?void 0:e.info,E=null==c?void 0:c.type,m=Digit.ULBService.getCurrentTenantId(),v=null!=m&&m.includes(".")?m:m+".djb",[S,p]=t.useState(null),[_,D]=t.useState(!1),[R,g]=t.useState({}),[N,y]=t.useState({}),{data:T,isLoading:I}=Digit.Hooks.fsm.useSupervisorSearch(v,{ids:u},{staleTime:Infinity}),{mutate:C}=Digit.Hooks.fsm.useSupervisorUpdate(v),A=$(r);return t.useEffect(()=>{if(T&&T.supervisors&&T.supervisors.length>0){var e,t,l,n,o,i,a;let r=T.supervisors[0];y(r);let s={fullName:(null==r||null===(e=r.owner)||void 0===e?void 0:e.name)||(null==r?void 0:r.name),mobileNumber:(null==r||null===(t=r.owner)||void 0===t?void 0:t.mobileNumber)||(null==r?void 0:r.mobileNo),emailId:null==r||null===(l=r.owner)||void 0===l?void 0:l.emailId,employeeId:null==r?void 0:r.employeeId,gender:null!=r&&null!==(n=r.owner)&&void 0!==n&&n.gender?{code:r.owner.gender,active:!0,i18nKey:"COMMON_GENDER_"+r.owner.gender}:null,dob:(null==r||null===(o=r.owner)||void 0===o?void 0:o.dob)&&Digit.DateUtils.ConvertTimestampToDate(null==r||null===(i=r.owner)||void 0===i?void 0:i.dob,"yyyy-MM-dd"),correspondenceAddress:null==r||null===(a=r.owner)||void 0===a?void 0:a.correspondenceAddress,description:null==r?void 0:r.description,zoneIds:null==r?void 0:r.assignedZoneId};g(s)}},[T]),I||0===Object.keys(R).length?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{timeLine:[{actions:r("ES_VENDOR_SUPERVISOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(o.FormComposer,{isDisabled:!_,label:r("ES_COMMON_APPLICATION_SUBMIT"),config:A.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:e=>{var t,l,n,o,i,a,r;const m={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:E,tenantId:v,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?void 0:e.zoneIds)||(null==N?void 0:N.assignedZoneId)||null,owner:{...N.owner,name:(null==e?void 0:e.fullName)||(null===(t=N.owner)||void 0===t?void 0:t.name),fatherOrHusbandName:"Static Father",relationship:"FATHER",gender:(null==e||null===(l=e.gender)||void 0===l?void 0:l.code)||(null===(n=N.owner)||void 0===n?void 0:n.gender)||"OTHERS",dob:null!=e&&e.dob?new Date(e.dob).getTime():null===(o=N.owner)||void 0===o?void 0:o.dob,emailId:(null==e?void 0:e.emailId)||(null===(i=N.owner)||void 0===i?void 0:i.emailId),mobileNumber:(null==e?void 0:e.mobileNumber)||(null===(a=N.owner)||void 0===a?void 0:a.mobileNumber),correspondenceAddress:(null==e?void 0:e.correspondenceAddress)||(null===(r=N.owner)||void 0===r?void 0:r.correspondenceAddress)}}};C(m,{onError:e=>{p({key:"error",action:e})},onSuccess:()=>{p({key:"success",action:"UPDATE_SUPERVISOR"}),d.invalidateQueries("SUPERVISOR_SEARCH"),s.push({pathname:`/digit-ui/${E}/vendor/registry/supervisor-details/${u}`,state:{showSuccessToast:!0}})}})},defaultValues:R,onFormValueChange:(e,t)=>{D(!!((null==t?void 0:t.fullName)&&(null==t?void 0:t.mobileNumber)&&(null==t?void 0:t.emailId)&&(null==t?void 0:t.dob)&&(null==t?void 0:t.gender)&&(null==t?void 0:t.correspondenceAddress)&&(null==t?void 0:t.zoneIds)))},noBreakLine:!0,mode:"onChange",noCard:!0}),S&&l.createElement(o.Toast,{error:"error"===S.key,label:r("success"===S.key?`ES_VENDOR_${S.action}_SUCCESS`:S.action),onClose:()=>{p(null)},duration:5e3})))},q=()=>{const{t:e}=i.useTranslation(),t=n.useLocation(),{path:a}=n.useRouteMatch(),r=Digit.ComponentRegistryService.getComponent("EditVendorDetails"),d=Digit.ComponentRegistryService.getComponent("AddSupervisor"),u=Digit.ComponentRegistryService.getComponent("SurveyorDetails"),c=Digit.ComponentRegistryService.getComponent("VENDORCreate"),m=Digit.ComponentRegistryService.getComponent("AddDriver"),v=Digit.ComponentRegistryService.getComponent("DriverDetails"),S=Digit.ComponentRegistryService.getComponent("AddVehicle"),p=Digit.ComponentRegistryService.getComponent("VehicleDetails"),_=Digit.ComponentRegistryService.getComponent("EditDriver"),D=Digit.ComponentRegistryService.getComponent("EditVehicle");return l.createElement(n.Switch,null,l.createElement(o.AppContainer,null,l.createElement("div",{className:"ground-container employee-app-container form-container"},l.createElement(o.ModuleHeader,{leftContent:l.createElement(l.Fragment,null,l.createElement(o.ArrowLeft,{className:"icon"}),e("CS_COMMON_BACK")),onLeftClick:()=>window.history.back(),breadcrumbs:(()=>{const l=t.pathname;let n=[{icon:o.HomeIcon,path:"/digit-ui/citizen"},{label:e("CITIZEN_VENDOR"),path:"/digit-ui/citizen/vendor"}];if(l.includes("/inbox")){let t="ES_COMMON_INBOX";l.includes("/mt/inbox")&&(n=[{icon:o.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 i=[{match:"/registry/new-vendor",label:"ES_FSM_REGISTRY_TITLE_NEW_VENDOR"},{match:"/search-vendor",label:"SEARCH_VENDOR"},{match:"/registry/new-driver",label:"ES_FSM_REGISTRY_TITLE_NEW_DRIVER"},{match:["/registry/vendor-details","/registry/modify-vendor/"],label:"VENDOR_VENDOR_DETAILS"},{match:["/registry/vehicle-details","/registry/modify-vehicle/"],label:"VENDOR_VEHICLE_DETAILS"},{match:"/registry/new-vehicle",label:"ES_FSM_REGISTRY_TITLE_NEW_VEHICLE"},{match:["/registry/driver-details","/registry/modify-driver/"],label:"VENDOR_DRIVER_DETAILS"},{match:"/registry/additionaldetails",label:"VENDOR_ADDITIONAL_DETAILS"},{match:"/registry/new-supervisor",label:"ES_FSM_REGISTRY_TITLE_NEW_SUPERVISOR"},{match:["/registry/supervisor-details","/registry/modify-supervisor/"],label:"VENDOR_SUPERVISOR_DETAILS"},{match:"/registry/new-surveyor",label:"ES_FSM_REGISTRY_TITLE_NEW_SURVEYOR"},{match:["/registry/surveyor-details","/registry/modify-surveyor/"],label:"VENDOR_SURVEYOR_DETAILS"}].find(e=>{let{match:t}=e;return Array.isArray(t)?t.some(e=>l.includes(e)):l.includes(t)});return i&&n.push({label:e(i.label)}),n})()}),l.createElement(o.PrivateRoute,{path:a+"/search-vendor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"normal"},l.createElement(V,s({},e,{parentRoute:a}))),exact:!0}),l.createElement(o.PrivateRoute,{path:a+"/registry/vendor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(r,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/driver-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(v,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/modify-driver/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(_,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/vehicle-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(p,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/modify-vehicle/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(D,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/new-driver",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(m,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/new-vehicle",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(S,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/new-supervisor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(d,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/additionaldetails",component:e=>{const t=e.location.pathname.includes("/info");return l.createElement(o.LayoutWrapper,{layoutClass:t?"action":"normal"},l.createElement(c,s({},e,{parentRoute:a})))}}),l.createElement(o.PrivateRoute,{path:a+"/registry/supervisor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(x,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/new-surveyor",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(E,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/modify-surveyor/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(W,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/modify-supervisor/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(z,s({},e,{parentRoute:a})))}),l.createElement(o.PrivateRoute,{path:a+"/registry/surveyor-details/:id",component:e=>l.createElement(o.LayoutWrapper,{layoutClass:"action"},l.createElement(u,s({},e,{parentRoute:a})))}),l.createElement(o.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(o.CitizenHomeCard,{header:e("TITLE_VENDOR_MANAGEMENT"),links:[{i18nKey:e("SEARCH_VENDOR"),link:"/digit-ui/citizen/vendor/search-vendor"}],Icon:()=>l.createElement(o.PropertyHouse,{className:"fill-path-primary-main"})})):l.createElement(n.Redirect,{to:{pathname:"/digit-ui/citizen/login",state:{from:""+a,role:"CITIZEN_VENDOR"}}}),exact:!0}))))},Z=e=>l.createElement("h1",{className:"heading-m"},e.label),j=()=>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"})),X=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(j,null)),Q=e=>l.createElement("h1",{className:"heading-m"},e.label),J=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(o.CloseSvg,null)),ee=e=>{let{jumpTo:t}=e;const{t:a}=i.useTranslation(),r=n.useHistory();return l.createElement(o.LinkButton,{label:a("CS_COMMON_CHANGE"),className:"check-page-link-button",onClick:function(){r.push(t)}})},te=e=>{const{t:t}=i.useTranslation();return e.isSuccess?window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_SUCCESS"):t("ES_VENDOR_RESPONSE_CREATE_ACTION"):e.isLoading?window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_PENDING"):t("CS_VENDOR_APPLICATION_PENDING"):e.isSuccess?void 0:window.location.href.includes("edit-application")?t("CS_AST_UPDATE_APPLICATION_FAILED"):t("CS_VENDOR_APPLICATION_FAILED")},le={padding:"4px 0px",justifyContent:"space-between"},ne=e=>{var t,n;return l.createElement(o.Banner,{message:te(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%"}})},oe=[{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:ie}=require("@djb25/digit-ui-react-components"),ae=e=>l.createElement("h1",{className:"heading-m"},e.label),re=()=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FFFFFF"},l.createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),l.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"})),se=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(re,null)),{DatePicker:de}=require("@djb25/digit-ui-react-components"),ue=e=>l.createElement("h1",{className:"heading-m"},e.label),ce=()=>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"})),Ee=e=>l.createElement("div",{className:"icon-bg-secondary",onClick:e.onClick},l.createElement(ce,null)),me={VendorDetails:e=>{var n,i,a,s;let{t:d,config:u,onSelect:c,userType:E,formData:m}=e;const v=Digit.UserService.getUser().info,S=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].applicantName||(null==m||null===(n=m.ownerKey)||void 0===n?void 0:n.applicantName)||"",p=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].emailId||(null==m||null===(i=m.ownerKey)||void 0===i?void 0:i.emailId)||"",_=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].mobileNumber||(null==m||null===(a=m.ownerKey)||void 0===a?void 0:a.mobileNumber)||(null==v?void 0:v.mobileNumber),D=m.ownerKey&&m.ownerKey[0]&&m.ownerKey[0].altMobileNumber||(null==m||null===(s=m.ownerKey)||void 0===s?void 0:s.altmobileNumber)||"",[R,g]=t.useState(""),[N,y]=t.useState(""),[T,I]=t.useState(""),[C,A]=t.useState(""),[O,b]=t.useState(),[f,h]=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,q]=t.useState(""),[Z,j]=t.useState(""),[X,Q]=t.useState(""),[J,ee]=t.useState("");t.useEffect(()=>{11!==f.length||C||O||Z?11===f.length&&C&&O?(A(C),b(O),j(Z)):(A(""),b(""),j("")):fetch("https://ifsc.razorpay.com/"+f).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH&&e.MICR&&(A(e.BANK),b(e.BRANCH),j(e.MICR))}).catch(()=>{})},[f]);const te=Digit.ULBService.getCurrentTenantId(),{control:le}=r.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 oe=()=>{let e,t=m.ownerKey&&m.ownerKey[0];"citizen"===E?(e={...t,applicantName:S,mobileNumber:_,altMobileNumber:D,emailId:p},c(u.key,{...m[u.key],...e},!1,0)):(e={...t,VendorCategory:R,name:T,VendorId:N,Bank:C,BankbranchName:O,IFSC:f,AccountNo:V,PanNo:M,GstNo:k,GstState:F,RegistrationNo:H,EpfNo:B,EsiNo:G,VendorType:K,Status:z,micrNo:Z,PhoneNo:X,ContactPerson:J},c(u.key,e,!1,0))};return t.useEffect(()=>{"citizen"===E&&oe()},[R,N,T,C,O,f,V,M,k,F,H,B,G,K,z,Z,X,J,E]),l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{timeLine:[{actions:d("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:d("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:d("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(o.FormStep,{config:u,onSelect:oe,t:d,className:"formcomposer-grid-container-form"},l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,{className:"card-label-smaller"},l.createElement(o.CustomTooltip,{label:""+d("IFSC_CODE"),isMandatory:!1,message:d("INVALID_IFSC_CODE_ERROR_MESSAGE")})),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"IFSC",value:f,placeholder:"Enter IFSC Code",onChange:function(e){const t=e.target.value.replace(/[^a-zA-Z0-9]/g,"");t.length<=11&&h(t)},style:{width:"100%"},maxLength:11,ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[A-Z]{4}0[A-Z0-9]{6}$",type:"text",title:d("INVALID_IFSC_CODE_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("VENDOR_BANK_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"bankName",placeholder:"Bank Name Auto Select",style:{width:"100%"},value:C,onChange:function(e){A(e.target.value)},disabled:!0})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("VENDOR_BANK_BRANCH_NAME")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"BankbranchName",value:O,style:{width:"100%"},placeholder:"Bank Branch Name Auto Select",onChange:function(e){b(e.target.value)},disabled:!1})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("VENDOR_MICR_NO")," ",l.createElement("span",{className:"check-page-link-button"},"*")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"MicrNo",value:Z,style:{width:"100%"},placeholder:"MICR No",onChange:j,disabled:!1})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("ACCOUNT_NO")),l.createElement(o.TextInput,{t:d,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:d("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("PHONE_NO")),l.createElement(o.MobileNumber,{value:X,name:"PhoneNo",onChange:Q,style:{width:"100%"}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("CONTACT_PERSON")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"ContactPerson",value:J,onChange:function(e){ee(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:d("INVALID_ACCOUNT_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("PAN_NO")),l.createElement(o.TextInput,{t:d,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:d("INVALID_PAN_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("GST_NO")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"GstNo",value:k,onChange:function(e){P(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[A-Z0-9]{1}[Z]{1}[A-Z0-9]{1}$",type:"text",title:d("INVALID_GST_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("GST_REGISTERED_STATE/UT")),l.createElement(o.TextInput,{t:d,type:"text",isMandatory:!1,optionKey:"i18nKey",name:"GstState",value:F,onChange:function(e){x(e.target.value)},style:{width:"100%"},ValidationRequired:!0,validation:{isRequired:!0,pattern:"^[a-zA-Z0-9/-]{1,20}$",type:"text",title:d("PT_NAME_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("REGISTRATION_NO")),l.createElement(o.TextInput,{t:d,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:d("INVALID_REGISTRATION_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("EPF_NO")),l.createElement(o.TextInput,{t:d,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:d("INVALID_EPF_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,""+d("ESI_NO")),l.createElement(o.TextInput,{t:d,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:d("INVALID_ESI_NO_ERROR_MESSAGE")}})),l.createElement(o.LabelFieldPair,null,l.createElement("div",null,d("VENDOR_TYPE"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}},""+d("AST_CLASSIFICATION_ASSET")))),l.createElement(r.Controller,{control:le,name:"VendorType",defaultValue:K,rules:{required:d("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(o.Dropdown,{selected:K,select:$,option:[{i18nKey:"Supplier",code:"SUPPLIER"},{i18nKey:"Contractor",code:"CONTRACTOR"}],optionKey:"i18nKey",placeholder:"Select",t:d})})),l.createElement(o.LabelFieldPair,null,l.createElement("div",null,d("VENOR_CATEGORY"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}}))),l.createElement(r.Controller,{control:le,name:"VendorCategory",defaultValue:R,rules:{required:d("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(o.Dropdown,{selected:R,select:g,option:[{i18nKey:"Firm",code:"FIRM"},{i18nKey:"Individual",code:"Individual"}],optionKey:"i18nKey",placeholder:"Select",t:d})})),l.createElement(o.LabelFieldPair,null,l.createElement("div",null,d("STATUS"),l.createElement("div",{className:"tooltip",style:{width:"12px",height:"5px",marginLeft:"10px",display:"inline-flex",alignItems:"center"}},l.createElement("span",{className:"tooltiptext",style:{whiteSpace:"pre-wrap",fontSize:"small",wordWrap:"break-word",width:"300px",marginLeft:"15px",marginBottom:"-10px"}},""+d("AST_CLASSIFICATION_ASSET")))),l.createElement(r.Controller,{control:le,name:"Status",defaultValue:z,rules:{required:d("CORE_COMMON_REQUIRED_ERRMSG")},render:e=>l.createElement(o.Dropdown,{selected:z,select:q,option:[{i18nKey:"Active",code:"ACTIVE"},{i18nKey:"Inactive",code:"INACTIVE"}],optionKey:"i18nKey",placeholder:"Select",t:d})})))))},VendorDocuments:e=>{var n;let{t:i,config:a,onSelect:r,formData:s}=e;const[u,c]=t.useState([null]),[E,m]=t.useState([null]),[v,S]=t.useState(null),[p,_]=t.useState(1),[D,R]=(Digit.ULBService.getStateId(),Digit.ULBService.getStateId(),t.useState((null==s||null===(n=s.documents)||void 0===n?void 0:n.documents)||[]));return t.useEffect(()=>{var e;null!=s&&null!==(e=s.documents)&&void 0!==e&&e.documents&&(m(s.documents.documents),_(s.documents.documents.length),c(new Array(s.documents.documents.length).fill(null)))},[s]),l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{timeLine:[{actions:i("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:i("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:i("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:1,showFinalStep:!1}),l.createElement(o.FormStep,{t:i,config:a,onSelect:()=>{let e;e={...s.documents,documents:E.filter(e=>null!==e)},r(a.key,e)},onSkip:()=>r(),isDisabled:E.some(e=>null===e)&&u.some(e=>null===e)},u.map((e,t)=>l.createElement(o.LabelFieldPair,{key:t},l.createElement(o.CardLabel,{className:"card-label-smaller"},i("VENDOR_ID")+(0!==t?t:"")),l.createElement("div",{className:"field",style:{display:"flex",alignItems:"center",paddingBottom:"10px"}},l.createElement(o.UploadFile,{onUpload:e=>((e,t)=>{const l=e.target.files[0];c(e=>{const n=[...e];return n[t]=l,n}),function(e,t){try{const l=function(){if(e.size>=5242880)S(i("CS_MAXIMUM_UPLOAD_SIZE_EXCEEDED"));else{const l=d(function(){return Promise.resolve(Digit.UploadServices.Filestorage("EWASTE",e,Digit.ULBService.getStateId())).then(function(e){var l,n;if((null==e||null===(l=e.data)||void 0===l||null===(n=l.files)||void 0===n?void 0:n.length)>0){const l=e.data.files[0].fileStoreId;m(e=>{const n=[...e];return n[t]={filestoreId:l,documentuuid:l,documentType:"Photo"+(t+1)},n})}else S(i("CS_FILE_UPLOAD_ERROR"))})},function(){S(i("CS_FILE_UPLOAD_ERROR"))});if(l&&l.then)return l.then(function(){})}}();Promise.resolve(l&&l.then?l.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}(l,t)})(e,t),onDelete:()=>m(e=>{const l=[...e];return l[t]=null,l}),id:"file-upload-"+t,message:E[t]?"1 "+i("CS_ACTION_FILEUPLOADED"):i("CS_ACTION_NO_FILEUPLOADED"),textStyles:{width:"100%"},inputStyles:{width:"280px"},accept:".pdf, .jpeg, .jpg, .png",buttonType:"button",error:!E[t]})))),v&&l.createElement(o.Toast,{label:v,onClose:()=>S(null),error:!0})))},ServiceDoc:e=>{var t;let{t:n,config:i,onSelect:a}=e;const r=Digit.ULBService.getStateId(),s=null!=i&&i.isMutation?["MutationDocuments"]:"Documents",{isLoading:d,data:u={}}=Digit.Hooks.asset.useAssetDocumentsMDMS(r,"ASSET",s);let c=null==u||null===(t=u.ASSET)||void 0===t?void 0:t.Documents;return l.createElement("div",{className:"employee-form-content"},d&&l.createElement(o.Loader,null),Array.isArray(c)&&c.map((e,t)=>{let{code:i,dropdownData:a}=e;return l.createElement(o.Card,{key:t},l.createElement("div",null,l.createElement("h3",{style:{margin:0}},t+1,". ",n(Y(i,".","_")))),a.map((e,t)=>l.createElement("div",{key:t,style:{paddingLeft:"10px",marginBottom:"6px",fontSize:"14px"}},t+1,". ",n(Y(null==e?void 0:e.code,".","_")))))}),l.createElement(o.ActionBar,null,l.createElement(o.SubmitBar,{label:n("COMMON_NEXT"),onSubmit:a})))},AddVendor:e=>{const a=Digit.ULBService.getCurrentTenantId(),{t:r}=i.useTranslation(),d=n.useHistory(),[u,c]=t.useState(1),[E,m]=t.useState(null),[,v]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,S]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,p]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),{mutate:_}=Digit.Hooks.fsm.useVendorCreate(a);t.useEffect(()=>{v(!1),p(),S()},[]);const D={serviceType:{code:"WT",name:"WT",i18nKey:"WT"},tripData:{noOfTrips:1,amountPerTrip:null,amount:null}},[R,g]=t.useState(D),N=function(e,t,n){var i,a;void 0===t&&(t=!1),void 0===n&&(n={});const r="EKYC"===(null===(i=n)||void 0===i||null===(a=i.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(o.DatePicker,s({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(o.DatePicker,s({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(o.DatePicker,s({onChange:e.onChange,date:e.value},t,{max:B((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,R),y=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(o.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(o.FormComposer,{config:N,userType:"employee",onFormValueChange:(e,t)=>{var l,n,o,i;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}))||[],s=(null==R?void 0:R.zoneIds)||[],d=a.join(",")!==s.join(",");((null==t||null===(n=t.serviceType)||void 0===n?void 0:n.code)!==(null==R||null===(o=R.serviceType)||void 0===o?void 0:o.code)||d)&&g(e=>({...e,serviceType:null==t?void 0:t.serviceType})),d&&g(e=>({...e,zoneIds:a})),(null==t?void 0:t.vendorName)&&(null==t?void 0:t.phone)&&(null==t||null===(i=t.serviceType)||void 0===i?void 0:i.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,o,i,r,s,u,c,E,v,S,p,D,R,g;const N=e,T=null==N?void 0:N.propertyAddress,I=null==T?void 0:T.pincode,C=null==T?void 0:T.streetName,A=null==T?void 0:T.houseNo,O=null==T?void 0:T.landmark,b=null==T||null===(t=T.city)||void 0===t?void 0:t.name,f=null==T||null===(l=T.city)||void 0===l?void 0:l.name,h=null==T||null===(n=T.city)||void 0===n?void 0:n.name,V=null==T||null===(o=T.city)||void 0===o?void 0:o.name,L=null==T||null===(i=T.locality)||void 0===i?void 0:i.code,M=null==T||null===(r=T.locality)||void 0===r?void 0:r.name,w=null==T?void 0:T.subLocality,k=null==T||null===(s=T.ward)||void 0===s?void 0:s.code,P=null==T||null===(u=T.ward)||void 0===u?void 0:u.name,F=null==N?void 0:N.vendorName,x=null==N||null===(c=N.plotNo)||void 0===c?void 0:c.trim(),H=null==N||null===(E=N.buildingName)||void 0===E?void 0:E.trim(),U=null==N?void 0:N.emailId,B=null==N?void 0:N.phone,Y="EKYC"===(null==N||null===(v=N.serviceType)||void 0===v?void 0:v.code);let G={tenantId:a,name:F,agencyType:"ULB",paymentPreference:"post-service",address:{tenantId:a,landmark:O,doorNo:A,plotNo:x,street:C,city:b,district:h,region:V,state:f,country:"india",pincode:I,buildingName:H,locality:{code:L||"",name:M||"",label:"Locality",area:w||""},ward:k?{code:k,name:P}:void 0,geoLocation:{latitude:(null==N||null===(S=N.address)||void 0===S?void 0:S.latitude)||28.6139,longitude:(null==N||null===(p=N.address)||void 0===p?void 0:p.longitude)||77.209}},owner:{tenantId:"dl",name:(null==N?void 0:N.ownerName)||F,fatherOrHusbandName:(null==N?void 0:N.fatherOrHusbandName)||F,relationship:(null==N||null===(D=N.relationship)||void 0===D?void 0:D.code)||"OTHER",gender:(null==N||null===(R=N.gender)||void 0===R?void 0:R.code)||"MALE",dob:null!=N&&N.dob?new Date(N.dob).getTime():new Date("1/1/1970").getTime(),emailId:U||"",mobileNumber:B},additionalDetails:{serviceType:Y?"ekyc":null==N||null===(g=N.serviceType)||void 0===g?void 0:g.code},vehicles:[],drivers:[],source:Y?"eKYC Portal":"WhatsApp"};var W,K;Y&&(G={...G,zoneIds:(null==N||null===(W=N.zoneIds)||void 0===W?void 0:W.map(e=>{var t;return null==e||null===(t=e[1])||void 0===t?void 0:t.code}))||[],clusterIds:(null==N||null===(K=N.clusterIds)||void 0===K?void 0:K.map(e=>{var t;return null==e||null===(t=e[1])||void 0===t?void 0:t.code}))||[],contractStartDate:N.contractStartDate?new Date(N.contractStartDate).getTime():null,contractEndDate:N.contractEndDate?new Date(N.contractEndDate).getTime():null});const $={vendor:G};Y&&($.RequestInfo={apiId:"Rainmaker",msgId:"ekyc-vendor-create"}),_($,{onError:e=>{m({key:"error",action:e}),setTimeout(y,5e3)},onSuccess:(e,t)=>{m({key:"success",action:"ADD_VENDOR"}),setTimeout(()=>{y(),d.push("/digit-ui/employee/vendor/search-vendor")},2e3)}})},defaultValues:D,noCard:!0,noBreakLine:!0}),E&&l.createElement(o.Toast,{error:"error"===E.key,label:r("success"===E.key?`ES_FSM_REGISTRY_${E.action}_SUCCESS`:E.action),onClose:y})))},VendorSelectAddress:e=>{var n,i,a;let{t:r,config:s,onSelect:d,userType:u,formData:c}=e;const E=Digit.Hooks.vendor.useTenants();let m=Digit.ULBService.getCurrentTenantId();const{pincode:v}=(null==c?void 0:c.address)||"",S="employee"===u?E.filter(e=>e.code===m):v?E.filter(e=>{var t;return null==e||null===(t=e.pincode)||void 0===t?void 0:t.some(e=>e==v)}):E;let p=null===(n=sessionStorage)||void 0===n?void 0:n.getItem("Digit_FSM_PT");var _;"undefined"!==p&&(p=JSON.parse(null===(_=sessionStorage)||void 0===_?void 0:_.getItem("Digit_FSM_PT")));let D={};p&&(D=S.filter(e=>{var t,l,n;return e.code==(null===(t=p)||void 0===t||null===(l=t.propertyDetails)||void 0===l||null===(n=l.address)||void 0===n?void 0:n.tenantId)}));const[R,g]=t.useState(()=>{var e,t;return(null==c||null===(e=c.address)||void 0===e?void 0:e.city)||(null===(t=D)||void 0===t?void 0:t[0])||null}),{data:N}=Digit.Hooks.useBoundaryLocalities(null==R?void 0:R.code,"revenue",{enabled:!!R},r),{data:y}=Digit.Hooks.useBoundaryLocalities(null==R?void 0:R.code,"admin",{enabled:!!R},r),[T,I]=t.useState(),[C,A]=t.useState(()=>{var e,t,l,n,o,i,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===(o=n.details)||void 0===o||null===(i=o.address)||void 0===i?void 0:i.locality)||(null==c||null===(a=c.address)||void 0===a?void 0:a.locality)}),[O,b]=t.useState(),[f,h]=t.useState(()=>{var e;return null==c||null===(e=c.address)||void 0===e?void 0:e.ward});function V(e){A(null),I(null),h(null),b(null),Digit.SessionStorage.set("fsm.file.address.city",e),g(e)}function L(e){A(e),"employee"===u&&d(s.key,{...c[s.key],locality:e,ward:f})}function M(e){h(e),"employee"===u&&d(s.key,{...c[s.key],ward:e,locality:C})}return t.useEffect(()=>{S&&1===S.length&&g(S[0])},[S]),t.useEffect(()=>{if(R&&N){var e,t,l,n,o,i,a,r;let _=N,D=[];if(null!=c&&null!==(e=c.address)&&void 0!==e&&e.locality)A(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)A(c.cpt.details.address.locality);else if(null!==(o=p)&&void 0!==o&&null!==(i=o.propertyDetails)&&void 0!==i&&null!==(a=i.address)&&void 0!==a&&a.locality){var E,m,v;A(null===(E=p)||void 0===E||null===(m=E.propertyDetails)||void 0===m||null===(v=m.address)||void 0===v?void 0:v.locality)}var S;null!=c&&null!==(r=c.address)&&void 0!==r&&r.pincode&&(D=_.filter(e=>{var t;return null===(t=e.pincode)||void 0===t?void 0:t.find(e=>e==c.address.pincode)}),null!=c&&null!==(S=c.address)&&void 0!==S&&S.locality||A()),"employee"===u&&d(s.key,{...c[s.key],city:R}),I(()=>D.length>0?D:_),1===D.length&&(A(D[0]),"employee"===u&&d(s.key,{...c[s.key],locality:D[0]}))}},[R,null==c||null===(i=c.cpt)||void 0===i||null===(a=i.details)||void 0===a?void 0:a.address,N]),t.useEffect(()=>{var e;R&&y&&(null!=c&&null!==(e=c.address)&&void 0!==e&&e.ward&&h(c.address.ward),b(y))},[R,y]),"employee"===u?l.createElement(l.Fragment,null,l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,r("MYCITY_CODE_LABEL"),s.isMandatory?" * ":null),l.createElement(o.Dropdown,{className:"",isMandatory:!0,selected:1===(null==S?void 0:S.length)?S[0]:R,disable:1===(null==S?void 0:S.length),option:S,select:V,optionKey:"code",t:r})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_WARD"),s.isMandatory?" * ":null),l.createElement(o.Dropdown,{className:"",isMandatory:!0,selected:f,option:O,select:M,optionKey:"name",t:r})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_MOHALLA"),s.isMandatory?" * ":null),l.createElement(o.Dropdown,{className:"",isMandatory:!0,selected:C,option:T,select:L,optionKey:"name",t:r}))):l.createElement(l.Fragment,null,l.createElement(o.FormStep,{config:s,onSelect:function(){d(s.key,{city:R,locality:C,ward:f})},t:r,isDisabled:!C||!f},l.createElement(o.CardLabel,null,r("MYCITY_CODE_LABEL")+" *"),l.createElement(o.RadioOrSelect,{options:S,selectedOption:R,optionKey:"i18nKey",onSelect:V,t:r}),R&&O&&l.createElement(o.CardLabel,null,r("ES_NEW_APPLICATION_LOCATION_WARD")+" *"),R&&O&&l.createElement(o.RadioOrSelect,{isMandatory:s.isMandatory,options:O,selectedOption:f,optionKey:"name",onSelect:M,t:r}),R&&T&&l.createElement(o.CardLabel,null,r("CS_CREATECOMPLAINT_MOHALLA")+" *"),R&&T&&l.createElement(o.RadioOrSelect,{isMandatory:s.isMandatory,options:T,selectedOption:C,optionKey:"name",onSelect:L,t:r})))},SearchApp:e=>{n.useParams();const{t:a}=i.useTranslation(),r=Digit.ULBService.getCurrentTenantId(),[s,d]=t.useState({}),[u,c]=t.useState(null),E={enabled:!!(s&&Object.keys(s).length>0)},{isLoading:m,isSuccess:v,data:{EwasteApplication:S,Count:p}={}}=Digit.Hooks.ew.useEWSearch({tenantId:r,filters:s},E);return l.createElement(l.Fragment,null,l.createElement(G,{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"}):d(n):c({warning:!0,label:"ERR_PROVIDE_MORE_PARAM_WITH_TYPE_STATUS"}):c({warning:!0,label:"ERR_VENDOR_FILL_VALID_FIELDS"})},data:v&&!m?S.length>0?S:{display:"ES_COMMON_NO_DATA"}:"",count:p}),u&&l.createElement(o.Toast,{error:u.error,warning:u.warning,label:a(u.label),isDleteBtn:!0,onClose:()=>{c(null)}}))},SelectServiceType:e=>{let{config:n,onSelect:i,t:a,userType:r,formData:s}=e;const d=Digit.ULBService.getCurrentTenantId(),[u,c]=t.useState(null==s?void 0:s.serviceType),[E,m]=t.useState([]),{data:v,isLoading:S}=Digit.Hooks.useCustomMDMS(d,"tenant",[{name:"citymodule"}],{select:e=>{var t;return null==e||null===(t=e.tenant)||void 0===t?void 0:t.citymodule}});return t.useEffect(()=>{if(v){const e=v.map(e=>({i18nKey:""+e.code,code:""+e.code,value:""+e.name}));if(m(e),!u||"WT"===u.code){const t=e.find(e=>"WT"===e.code);t&&(c(t),"employee"===r&&i(n.key,t))}}},[v]),S?l.createElement(o.Loader,null):"employee"===r?l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,a(n.label)),l.createElement(o.Dropdown,{className:"payment-form-text-input-correction",isMandatory:n.isMandatory,selected:u,option:E,select:e=>{c(e),"employee"===r&&i(n.key,e)},optionKey:"i18nKey",disable:n.disable,t:a})):void 0},SelectVehicleType:e=>{var n;let{t:i,config:a,onSelect:r,formData:s}=e;const d=Digit.ULBService.getStateId(),u=Digit.ULBService.getCurrentTenantId(),{data:c,isLoading:E}=Digit.Hooks.wt.useWTMDMS(d,"Vehicle","VehicleMakeModel"),{data:m,isLoading:v}=Digit.Hooks.useCustomMDMS(u,"tenant",[{name:"citymodule"}],{select:e=>{var t;return null==e||null===(t=e.tenant)||void 0===t?void 0:t.citymodule}}),[S,p]=t.useState({}),[_,D]=t.useState([]),[R,g]=t.useState({}),[N,y]=t.useState([]),[T,I]=t.useState({}),[C,A]=t.useState(""),O=(null==s||null===(n=s.serviceType)||void 0===n?void 0:n.code)||(null==s?void 0:s.serviceType),b=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(b)},[b]),t.useEffect(()=>{if(!c)return;const e=S[O],t=e?c.filter(t=>e.includes(t.code)):c;D(t),g({}),y([]),I({}),A("")},[c,O,S]),t.useEffect(()=>{if(!c||null==R||!R.code)return;const e=c.filter(e=>e.make===R.code);y(e),I({}),A("")},[R,c]),t.useEffect(()=>{null!=T&&T.capacity&&A(T.capacity)},[T]),E||v?l.createElement(o.Loader,null):c&&m?l.createElement(l.Fragment,null,l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_MODEL")),l.createElement(o.Dropdown,{className:"form-field",selected:R,option:_,select:e=>{g(e),r(a.key,{...(null==s?void 0:s[a.key])||{},modal:e,type:""})},optionKey:"name",t:i})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_TYPE")),l.createElement(o.Dropdown,{className:"form-field",selected:T,option:N,select:e=>{I(e),A(e.capacity),r(a.key,{...s[a.key],type:e})},optionKey:"name",t:i})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,i("ES_FSM_REGISTRY_VEHICLE_CAPACITY")),l.createElement(o.TextInput,{className:"",textInputStyle:{width:"100%"},value:C,disable:!0}))):l.createElement("div",null,i("ERROR_FETCHING_DATA"))},BankDetailsComponent:e=>{let{t:n,config:i,onSelect:a,formData:r,...s}=e;const[d,u]=t.useState((null==r?void 0:r.ifscCode)||""),[c,E]=t.useState((null==r?void 0:r.bankName)||""),[m,v]=t.useState((null==r?void 0:r.branchName)||""),[S,p]=t.useState((null==r?void 0:r.accountNumber)||""),[_,D]=t.useState(null);return t.useEffect(()=>{11===d.length&&fetch("https://ifsc.razorpay.com/"+d).then(e=>e.json()).then(e=>{e&&e.BANK&&e.BRANCH?(E(e.BANK),v(e.BRANCH),"function"==typeof a&&a(i.key,{bankName:e.BANK,branchName:e.BRANCH,ifscCode:d,accountNumber:S}),D({error:!1,label:n("VALID_IFSC_CODE")})):D({error:!0,label:n("INVALID_IFSC_CODE")})}).catch(()=>{D({error:!0,label:n("INVALID_IFSC_CODE")})})},[d]),t.useEffect(()=>{"function"==typeof a&&a(i.key,{bankName:c,branchName:m,ifscCode:d,accountNumber:S})},[S,c,m,d]),l.createElement(l.Fragment,null,l.createElement(o.CardLabel,null,n("ES_FSM_REGISTRY_IFSC_CODE")),l.createElement(o.TextInput,{t:n,type:"text",isMandatory:!1,name:"ifscCode",value:d,onChange:e=>{const t=e.target.value.replace(/[^a-zA-Z0-9]/g,"");t.length<=11&&u(t)},style:{width:"100%"},maxLength:11}),l.createElement(o.CardLabel,null,n("ES_FSM_REGISTRY_ACCOUNT_NUMBER")),l.createElement(o.TextInput,{t:n,type:"text",isMandatory:!1,name:"accountNumber",value:S,onChange:e=>p(e.target.value),style:{width:"100%"}}),l.createElement(o.CardLabel,null,n("ES_FSM_REGISTRY_BANK_NAME")),l.createElement(o.TextInput,{t:n,type:"text",isMandatory:!1,name:"bankName",value:c,onChange:e=>E(e.target.value),disabled:11===d.length&&c,style:{width:"100%"}}),l.createElement(o.CardLabel,null,n("ES_FSM_REGISTRY_BRANCH_NAME")),l.createElement(o.TextInput,{t:n,type:"text",isMandatory:!1,name:"branchName",value:m,onChange:e=>v(e.target.value),disabled:11===d.length&&m,style:{width:"100%"}}))},AddDriver:()=>{var e,r;const d=Digit.ULBService.getCurrentTenantId(),{t:u}=i.useTranslation(),c=Digit.ULBService.getStateId(),[E,m]=t.useState(null),v=a.useQueryClient(),S=n.useHistory(),[,p]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,_]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,D]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),R="WT_VENDOR"===Digit.UserService.getType()||Digit.UserService.hasAccess(["WT_VENDOR"]),{mutate:g}=Digit.Hooks.fsm.useDriverCreate(c),{mutate:N}=Digit.Hooks.fsm.useVendorUpdate("dl.djb"),y=null===(e=Digit.UserService.getUser())||void 0===e||null===(r=e.info)||void 0===r?void 0:r.mobileNumber,{data:T}=Digit.Hooks.fsm.useDsoSearch(d,{mobileNumber:y},{enabled:!(!R||!y)});t.useEffect(()=>{p(!1),D(),_()},[]);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(ie,s({onChange:e.onChange,date:e.value},t,{max:(()=>{const e=new Date;return e.setFullYear(e.getFullYear()-18),e.toISOString().split("T")[0]})()}))}},{label:"ES_FSM_REGISTRY_NEW_EMAIL",isMandatory:!1,type:"text",key:"emailId",populators:{name:"emailId",validation:{required:!1,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("FSM_REGISTRY_INVALID_EMAIL"),defaultValue:"",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,A]=t.useState(!1),O=()=>{m(null)};return console.log(R,"iscitizen"),l.createElement(l.Fragment,null,l.createElement(o.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(o.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,o=null==e?void 0:e.license,i=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,s=new Date(""+e.dob).getTime()||new Date("1/1/1970").getTime(),d=null==e||null===(l=e.serviceType)||void 0===l?void 0:l.code;g({driver:{tenantId:"dl.djb",name:n,licenseNumber:o,status:"ACTIVE",owner:{tenantId:c,name:n,fatherOrHusbandName:n,relationship:"OTHER",gender:i,dob:s,emailId:a||"abc@egov.com",mobileNumber:r},additionalDetails:{serviceType:d},vendorDriverStatus:"ACTIVE"}},{onError:(e,t)=>{m({key:"error",action:e}),setTimeout(O,5e3)},onSuccess:(e,t)=>{var l;if(m({key:"success",action:"ADD_DRIVER"}),setTimeout(O,5e3),v.invalidateQueries("FSM_DRIVER_SEARCH"),R&&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]}};N(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(()=>{O(),S.push(`/digit-ui/${n}/vendor/search-vendor?selectedTabs=DRIVER`)},3e3)}})}else{var n,o,i;const e=(null===(n=Digit.UserService.getUser())||void 0===n||null===(o=n.info)||void 0===o||null===(i=o.type)||void 0===i?void 0:i.toLowerCase())||"citizen";v.invalidateQueries("FSM_DRIVER_SEARCH"),setTimeout(()=>{O(),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 o=n.slice(0,18);t.license!==o&&e("license",o)}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)?A(!0):A(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(o.Toast,{error:"error"===E.key,label:u("success"===E.key?`ES_FSM_${E.action}_SUCCESS`:E.action),onClose:O})))},EditVendorDetails:e=>{var r,s,d,u,c,E,m,v,S,p,_;const D=Digit.ULBService.getCurrentTenantId(),{t:R}=i.useTranslation(),g=n.useHistory(),N=a.useQueryClient();let{id:y}=n.useParams();const[T,I]=t.useState(!1),[C,A]=t.useState(null),[O,b]=t.useState(!1),[f,h]=t.useState(null),[V,M]=t.useState([]),[w,k]=t.useState([]),[P,F]=t.useState({}),{data:x,isLoading:H,refetch:U}=Digit.Hooks.fsm.useDsoSearch(D,{ids:y},{staleTime:Infinity}),{data:B,isLoading:Y}=Digit.Hooks.vendor.useEmpvendorCommonSearch({tenantId:D,filters:{vendorId:y}},{enabled:!!y});let G=null==x||null===(r=x[0])||void 0===r||null===(s=r.dsoDetails)||void 0===s?void 0:s.additionalDetails;if("string"==typeof G)try{G=JSON.parse(G)}catch(e){console.error("Error parsing additional details",e)}const W=(null==B||null===(d=B.VendorDetails)||void 0===d||null===(u=d[0])||void 0===u||null===(c=u.vendorAdditionalDetails)||void 0===c?void 0:c.serviceType)||(null===(E=G)||void 0===E?void 0:E.serviceType),K="EKYC"===W||"ekyc"===W,{data:$,refetch:z}=Digit.Hooks.fsm.useVehiclesSearch({tenantId:D,filters:{status:"ACTIVE",sortBy:"registrationNumber",sortOrder:"ASC",vehicleWithNoVendor:!0},config:{enabled:!K}}),{data:q,refetch:j}=Digit.Hooks.fsm.useDriverSearch({tenantId:D,filters:{sortBy:"name",sortOrder:"ASC",status:"ACTIVE",driverWithNoVendor:!0},config:{enabled:!K}}),{data:Q}=Digit.Hooks.fsm.useSupervisorSearch(D,{vendorId:y},{enabled:K}),{data:J}=Digit.Hooks.fsm.useSurveyorSearch(D,{vendorId:y},{enabled:K}),{mutate:ee}=Digit.Hooks.fsm.useVendorUpdate(D);function te(e){I(!1),A(e)}const le=null===(m=Digit.SessionStorage.get("User").info.type)||void 0===m?void 0:m.toLowerCase();console.log(Q,J),t.useEffect(()=>{switch(C){case"DELETE":case"ADD_VEHICLE":case"ADD_DRIVER":return b(!0);case"EDIT":return g.push(`/digit-ui/${le}/fsm/registry/modify-vendor/${y}`);case"HOME":return g.push(`/digit-ui/${le}/fsm/registry?selectedTabs=VENDOR`)}},[C]),t.useEffect(()=>{$&&M((null==$?void 0:$.vehicle)||[])},[$]),t.useEffect(()=>{q&&k((null==q?void 0:q.driver)||[])},[q]);const ne=()=>{h(null)},oe=()=>{A(null),F({}),b(!1)},ie=window.Digit.Utils.browser.isMobile(),ae=l.useMemo(()=>[{Header:"Supervisor Name",accessor:"name"},{Header:"Mobile Number",accessor:"mobileNo"},{Header:"Zone",accessor:"assignedZoneId"},{Header:"Description",accessor:"description"},{Header:"Status",accessor:"status"},{Header:"Email",accessor:"owner.emailId"},{Header:"Gender",accessor:"owner.gender"}],[Q]),re=l.useMemo(()=>[{Header:"Surveyor Name",accessor:"name"},{Header:"Mobile Number",accessor:"mobileNo"},{Header:"Email",accessor:"owner.emailId"},{Header:"Gender",accessor:"owner.gender"},{Header:"Service Type",accessor:"additionalDetails.serviceType"},{Header:"Description",accessor:"description"},{Header:"Status",accessor:"status"}],[J]);if(H)return l.createElement(o.Loader,null);const se=["vendorAdditionalDetailsId","vendorId","tenantId","code","lastModifiedTime","createdTime","lastModifiedBy","createdBy","active","status","vendorType","vendorGroup","narration","documents"];return l.createElement("div",{className:"employee-form-content"},H?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement(o.Card,null,null==x||null===(v=x[0])||void 0===v||null===(S=v.employeeResponse)||void 0===S?void 0:S.map((e,t)=>{var n,i;return K&&t>0?null:l.createElement(l.Fragment,{key:t},t>0&&l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},R(e.title)),l.createElement("div",null,null==e||null===(n=e.values)||void 0===n?void 0:n.map((t,n)=>{var i;if("ES_FSM_REGISTRY_DETAILS_ADDITIONAL_DETAILS"===t.title){var a,r;const e=null==B||null===(a=B.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!se.includes(t)});return l.createElement(l.Fragment,{key:t.title},l.createElement(o.Row,{label:R(t.title),text:"",className:"border-none flex-box"}),Y?l.createElement(o.Loader,null):e?l.createElement(o.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 o=String(t);let i=null!=n&&""!==n?String(n):"N/A";var a,r;return"name"!==t||n&&""!==n||(i=(null==x||null===(a=x[0])||void 0===a||null===(r=a.dsoDetails)||void 0===r?void 0:r.name)||"N/A"),l.createElement(l.Fragment,{key:o},l.createElement("div",{className:"additional-label"},R((e=>{const t=e.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)})(o))),l.createElement("div",{className:"additional-value"},i))})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>g.push(`/digit-ui/${le}/vendor/registry/additionaldetails/info?vendorId=${y}`)},R("Edit Details"))):l.createElement("div",{onClick:()=>g.push(`/digit-ui/${le}/vendor/registry/additionaldetails/vendor-details?vendorId=${y}`),className:"add-details-link hover-button"},R("Add Additional Details")))}return l.createElement(o.Row,{key:R(String(t.title)),label:R(String(t.title)),text:t.value?R(String(t.value)):"N/A",last:n===(null==e||null===(i=e.values)||void 0===i?void 0:i.length)-1,caption:t.caption,className:"border-none flex-box "+(ie?"":"vendor-details-row")})}),null==e||null===(i=e.child)||void 0===i?void 0:i.map((t,n)=>{var i;return l.createElement(o.Card,{className:"card-with-background",key:t.id||n},l.createElement("div",{className:"card-head"},l.createElement("h2",null,R(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)g.push(`/digit-ui/${le}/fsm/registry/modify-driver/${l}`);else{var n,o;let t=null==e||null===(n=e.values)||void 0===n||null===(o=n.find(e=>"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.title))||void 0===o?void 0:o.value;g.push(`/digit-ui/${le}/fsm/registry/modify-vehicle/${t}`)}})(t,e.type,t.id)},l.createElement(o.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 o,i;let e=null==x||null===(o=x[0])||void 0===o?void 0:o.dsoDetails,t=null==e?void 0:e.drivers;t=t.map(e=>(e.id===l&&(e.vendorDriverStatus="INACTIVE"),e)),n={vendor:{...e,owner:{...e.owner,gender:(null===(i=e.owner)||void 0===i?void 0:i.gender)||"OTHERS"},drivers:t}}}else{var a,r,s,d;let t=null==x||null===(a=x[0])||void 0===a?void 0:a.dsoDetails,l=null==t?void 0:t.vehicles,o=null==e||null===(r=e.values)||void 0===r||null===(s=r.find(e=>"ES_FSM_REGISTRY_VEHICLE_NUMBER"===e.title))||void 0===s?void 0:s.value;l=l.map(e=>(e.registrationNumber===o&&(e.vendorVehicleStatus="INACTIVE"),e)),n={vendor:{...t,owner:{...t.owner,gender:(null===(d=t.owner)||void 0===d?void 0:d.gender)||"OTHERS"},vehicles:l}}}ee(n,{onError:(e,t)=>{h({key:"error",action:e}),setTimeout(ne,5e3)},onSuccess:(e,l)=>{h({key:"success",action:"ES_FSM_REGISTRY_DETAILS_TYPE_DRIVER"===t?"DELETE_DRIVER":"DELETE_VEHICLE"}),N.invalidateQueries("DSO_SEARCH"),U(),z(),j(),setTimeout(()=>{ne()},5e3)}})})(t,e.type,t.id)},l.createElement(o.DeleteIcon,{style:{cursor:"pointer"},className:"delete",fill:"#a82227"})))),l.createElement("div",{className:"additional-grid",style:{padding:"8px 16px"}},null==t||null===(i=t.values)||void 0===i?void 0:i.map((e,t)=>l.createElement(l.Fragment,{key:t},l.createElement("div",{className:"additional-label"},R(String(e.title))),l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},e.value?R(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")},R(e.type+"_ADD"))))}),K&&l.createElement(l.Fragment,null,l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},R("ES_VENDOR_SUPERVISOR_DETAILS")),l.createElement("div",null,l.createElement(o.Table,{data:(null==Q?void 0:Q.supervisors)||[],columns:ae,tableTitle:"Supervisors",totalRecords:(null==Q||null===(p=Q.supervisors)||void 0===p?void 0:p.length)||0,manualPagination:!1,pageSizeLimit:10,t:R}),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>g.push(`/digit-ui/${le}/vendor/registry/new-supervisor?vendorId=${y}`)},R("ES_VENDOR_ADD_SUPERVISOR"))),l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},R("ES_VENDOR_SURVEYOR_DETAILS")),l.createElement("div",null,l.createElement(o.Table,{data:(null==J?void 0:J.surveyors)||[],columns:re,tableTitle:"Surveyors",totalRecords:(null==J||null===(_=J.surveyors)||void 0===_?void 0:_.length)||0,manualPagination:!1,pageSizeLimit:10,t:R}),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>g.push(`/digit-ui/${le}/vendor/registry/new-surveyor?vendorId=${y}`)},R("ES_VENDOR_ADD_SURVEYOR"))))),O&&l.createElement(o.Modal,{headerBarMain:l.createElement(Z,{label:R("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(X,{onClick:oe}),actionCancelLabel:R("CS_COMMON_CANCEL"),actionCancelOnSubmit:oe,actionSaveLabel:R("DELETE"===C?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{var e;let t=null==x||null===(e=x[0])||void 0===e?void 0:e.dsoDetails,l={};if("DELETE"===C&&(l={vendor:{...t,status:"INACTIVE"}}),"ADD_VEHICLE"===C){var n;let e=P;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 o;let e=P;e.vendorDriverStatus="ACTIVE",l={vendor:{...t,owner:{...t.owner,gender:(null===(o=t.owner)||void 0===o?void 0:o.gender)||"OTHERS"},drivers:t.drivers?[...t.drivers,e]:[e]}}}ee(l,{onError:(e,t)=>{h({key:"error",action:e}),setTimeout(ne,5e3)},onSuccess:(e,t)=>{h({key:"success",action:"DELETE"===C?"DELETE_VENDOR":C}),N.invalidateQueries("DSO_SEARCH"),U(),z(),j(),setTimeout(()=>{ne(),"DELETE"===C&&g.push(`/digit-ui/${le}/fsm/registry`)},5e3)}}),b(!1),A(null)}},l.createElement(o.Card,{style:{boxShadow:"none"}},"DELETE"===C?l.createElement(L,{t:R,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VEHICLE"===C?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,R("ES_FSM_REGISTRY_SELECT_VEHICLE")),l.createElement(o.Dropdown,{t:R,option:V,value:P,selected:P,select:F,optionKey:"registrationNumber"})):"ADD_DRIVER"===C?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,R("ES_FSM_REGISTRY_SELECT_DRIVER")),l.createElement(o.Dropdown,{t:R,option:w,value:P,selected:P,select:F,optionKey:"name"})):void 0)),f&&l.createElement(o.Toast,{error:"error"===f.key,label:R("success"===f.key?`ES_FSM_REGISTRY_${f.action}_SUCCESS`:f.action),onClose:ne}),l.createElement(o.ActionBar,{style:{zIndex:"19"}},T?l.createElement(o.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE","HOME"],t:R,onSelect:te}):null,l.createElement(o.SubmitBar,{label:R("ES_COMMON_TAKE_ACTION"),onSubmit:()=>I(!T)}))))},AddVehicle:e=>{var r,d;const u=Digit.ULBService.getCurrentTenantId(),c=Digit.ULBService.getStateId(),[E,m]=t.useState(null),v=n.useHistory(),{t:S}=i.useTranslation(),p=a.useQueryClient(),[,_]=Digit.Hooks.useSessionStorage("FSM_MUTATION_HAPPENED",!1),[,,D]=Digit.Hooks.useSessionStorage("FSM_ERROR_DATA",!1),[,,R]=Digit.Hooks.useSessionStorage("FSM_MUTATION_SUCCESS_DATA",!1),g="WT_VENDOR"===Digit.UserService.getType()||Digit.UserService.hasAccess(["WT_VENDOR"]),{mutate:N}=Digit.Hooks.fsm.useVehicleCreate(c),{mutate:y}=Digit.Hooks.fsm.useVendorUpdate("dl.djb"),T=null===(r=Digit.UserService.getUser())||void 0===r||null===(d=r.info)||void 0===d?void 0:d.mobileNumber,{data:I}=Digit.Hooks.fsm.useDsoSearch(u,{mobileNumber:T},{enabled:!(!g||!T)});t.useEffect(()=>{_(!1),R(),D()},[]);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(de,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_VEHICLE_INSURANCE",isMandatory:!1,type:"custom",key:"insurance",populators:{name:"insurance",validation:{required:!0},component:(e,t)=>l.createElement(de,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_VEHICLE_ROAD_TAX",isMandatory:!1,type:"custom",key:"roadTax",populators:{name:"roadTax",validation:{required:!0},component:(e,t)=>l.createElement(de,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_NEW_FITNESS",isMandatory:!1,type:"custom",key:"fitnessValidity",populators:{name:"fitnessValidity",validation:{required:!0},component:(e,t)=>l.createElement(de,s({onChange:e.onChange,date:e.value},t))}},{label:"ES_FSM_REGISTRY_NEW_VEHICLE_OWNER_NAME",isMandatory:!0,type:"text",disable:t,populators:{name:"ownerName",validation:{required:!0,pattern:{value:/^[A-Za-z\s.,/]+$/,message:e("FSM_REGISTRY_INVALID_NAME")}},error:e("FSM_REGISTRY_INVALID_NAME"),defaultValue:""}},{label:"ES_FSM_REGISTRY_NEW_VEHICLE_OWNER_PHONE",isMandatory:!0,type:"mobileNumber",key:"phone",disable:t,populators:{name:"phone",validation:{required:!0,pattern:/^[6-9]\d{9}$/},error:e("FSM_REGISTRY_INVALID_PHONE"),defaultValue:""}},{label:"ES_FSM_REGISTRY_NEW_GENDER",isMandatory:!0,type:"component",route:"select-gender",hideInEmployee:!1,key:"selectGender",component:"SelectGender"},{label:e("ES_FSM_REGISTRY_NEW_DOB"),isMandatory:!0,type:"custom",key:"dob",populators:{name:"dob",validation:{required:!0},component:(e,t)=>l.createElement(de,s({onChange:e.onChange,date:e.value},t,{max:(()=>{const e=new Date;return e.setFullYear(e.getFullYear()-18),e.toISOString().split("T")[0]})()}))}},{label:"ES_FSM_REGISTRY_NEW_EMAIL",isMandatory:!1,type:"text",key:"emailId",populators:{name:"emailId",validation:{required:!1,pattern:/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/},error:e("FSM_REGISTRY_INVALID_EMAIL"),defaultValue:""}}]}]}(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(o.InfoIcon,null),l.createElement("span",{className:"tooltiptext",style:{width:"320px",left:"230%",fontSize:"14px"}},e.populators.validation.title)))});const[A,O]=t.useState(!1),b=()=>{m(null)};return l.createElement(l.Fragment,null,l.createElement(o.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(o.FormComposer,{isDisabled:!A,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,o,i,a,r,s;const d=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===(o=n.modal)||void 0===o?void 0:o.code,S=null==e||null===(i=e.vehicle)||void 0===i||null===(a=i.type)||void 0===a?void 0:a.capacity,_=new Date(""+(null==e?void 0:e.pollutionCert)).getTime(),D=new Date(""+(null==e?void 0:e.insurance)).getTime(),R=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,A=null==e?void 0:e.phone,O=null==e||null===(r=e.serviceType)||void 0===r?void 0:r.code,f=null==e||null===(s=e.selectGender)||void 0===s?void 0:s.code,h=null==e?void 0:e.emailId,V=new Date(""+e.dob).getTime()||new Date("1/1/1970").getTime();N({vehicle:{tenantId:"dl.djb",registrationNumber:d,model:E,type:u,tankCapacity:S,suctionType:"SEWER_SUCTION_MACHINE",pollutionCertiValidTill:_,InsuranceCertValidTill:D,fitnessValidTill:T,roadTaxPaidTill:R,gpsEnabled:!0,source:"Municipal records",owner:{tenantId:c,name:C,fatherOrHusbandName:C,relationship:"OTHER",correspondenceAddress:"",mobileNumber:A,gender:f,dob:V,emailId:h||"abc@egov.com"},additionalDetails:{serviceType:O},vehicleOwner:"ULB"}},{onError:(e,t)=>{var l,n,o,i;const a=(null==e||null===(l=e.response)||void 0===l||null===(n=l.data)||void 0===n||null===(o=n.Errors)||void 0===o||null===(i=o[0])||void 0===i?void 0:i.message)||(null==e?void 0:e.message)||"An error occurred";m({key:"error",action:a}),setTimeout(b,5e3)},onSuccess:(e,t)=>{var l,n,o,i;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===(o=n.Errors)||void 0===o?void 0:o.length)>0){var a,r,s,d,u;const t=(null==e||null===(a=e.data)||void 0===a||null===(r=a.Errors)||void 0===r||null===(s=r[0])||void 0===s?void 0:s.message)||(null==e||null===(d=e.Errors)||void 0===d||null===(u=d[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(b,5e3)}if(m({key:"success",action:"ADD_VEHICLE"}),p.invalidateQueries("FSM_VEICLES_SEARCH"),g&&null!=I&&null!==(i=I[0])&&void 0!==i&&i.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,o;const i=(null==e||null===(t=e.response)||void 0===t||null===(l=t.data)||void 0===l||null===(n=l.Errors)||void 0===n||null===(o=n[0])||void 0===o?void 0:o.message)||(null==e?void 0:e.message)||"An error occurred";m({key:"error",action:i}),setTimeout(b,5e3)},onSuccess:e=>{var t,l,n,o,i,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,s,d,u,c;const t=(null==e||null===(r=e.data)||void 0===r||null===(s=r.Errors)||void 0===s||null===(d=s[0])||void 0===d?void 0:d.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(b,5e3)}m({key:"success",action:"ADD_VEHICLE"}),p.invalidateQueries("DSO_SEARCH");const E=(null===(o=Digit.UserService.getUser())||void 0===o||null===(i=o.info)||void 0===i||null===(a=i.type)||void 0===a?void 0:a.toLowerCase())||"citizen";setTimeout(()=>{b(),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(()=>{b(),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 o=n.match(/^(\d{1,2})/);if(!o)return l+"-"+n;const i=o[1],a=n.slice(i.length),r=a.match(/^([A-Z]*)/),s=r?r[1]:"",d=a.slice(s.length);if(!d)return l+"-"+i+s;if(s.length>=3){const e=s.length<=3?1:2;return l+"-"+i+s.slice(0,e)+"-"+s.slice(e)+"-"+d.slice(0,4)}return l+"-"+i+s+"-"+d.slice(0,4)})(t.registrationNumber);l.length>15&&(l=l.slice(0,15)),l!==t.registrationNumber&&e("registrationNumber",l)}null!=t&&t.registrationNumber&&null!=t&&t.ownerName&&null!=t&&t.phone&&null!=t&&null!==(l=t.vehicle)&&void 0!==l&&l.modal&&null!=t&&null!==(n=t.vehicle)&&void 0!==n&&n.type&&null!=t&&t.selectGender&&null!=t&&t.dob&&new Date(null==t?void 0:t.dob).getTime()<=(new Date).setFullYear((new Date).getFullYear()-18)?O(!0):O(!1)},noBreakLine:!0,mode:"onChange",noCard:!0}),E&&l.createElement(o.Toast,{error:"error"===E.key,label:S("success"===E.key?`ES_FSM_REGISTRY_${E.action}_SUCCESS`:E.action),onClose:b})))},VENDORCreate:e=>{var t,o,r,s;const d=a.useQueryClient(),u=n.useRouteMatch(),{t:c}=i.useTranslation(),{pathname:E,search:m}=n.useLocation(),v=n.useHistory();let S=[];const[p,_,D]=Digit.Hooks.useSessionStorage("VENDOR_Test",{});function R(e,t,l,n,o){if(void 0===o&&(o=!1),"owners"===e){let l=p.owners||[];l[n]=t,_({...p,[e]:[...l]})}else if("units"===e){let e=p.units||[];e=t,_({...p,units:e})}else _({...p,[e]:{...p[e],...t}});((e,t,l,n)=>{let o,i=E.split("/").pop(),a=i.charAt(i.length-1),r=!1;Number(parseInt(i))||"0"===i||"-1"===i?"-1"===i||"-2"===i?(i=E.slice(0,-3),i=i.split("/").pop(),r=!0):(i=E.slice(0,-2),i=i.split("/").pop(),r=!0):r=!1,isNaN(a)||(r=!0);let{nextStep:s={}}=S.find(e=>e.route===(i||"0")),d=v.push;if(e&&(d=v.replace),l&&(s=n),null===s)return console.log("matchhhhh pathhhh",u.path),d(u.path+"/check");o=isNaN(s.split("/").pop())&&r&&"map"!==s?`${u.path}/${s}/${t}`:`${u.path}/${s}`,d(o)})(l,n,o,e)}l.useEffect(()=>{const e=new URLSearchParams(m||window.location.search).get("vendorId");e&&p.vendor_id!==e&&_({...p,vendor_id:e})},[m,window.location.search,p,_]),p&&Object.keys(p).length>0&&window.location.href.includes("/info")&&"true"!==sessionStorage.getItem("docReqScreenByBack")&&(D(),d.invalidateQueries("VENDOR_CREATE"));const g=()=>{},N=()=>{};oe.forEach(e=>{S=S.concat(e.body.filter(e=>!e.hideInCitizen))}),S.indexRoute="info";const y=null===(t=Digit)||void 0===t||null===(o=t.ComponentRegistryService)||void 0===o?void 0:o.getComponent("VENDORCheckPage"),T=null===(r=Digit)||void 0===r||null===(s=r.ComponentRegistryService)||void 0===s?void 0:s.getComponent("NewResponse");return l.createElement(l.Fragment,null,l.createElement(n.Switch,null,S.map((e,t)=>{const{component:o,texts:i,inputs:a,key:r}=e,s="string"==typeof o?Digit.ComponentRegistryService.getComponent(o):o;return l.createElement(n.Route,{path:`${u.path}/${e.route}`,key:t},l.createElement(s,{config:{texts:i,inputs:a,key:r},onSelect:R,onSkip:g,t:c,formData:p,onAdd:N}))}),l.createElement(n.Route,{path:u.path+"/check"},l.createElement(y,{onSubmit:function(){try{return v.push(u.path+"/acknowledgement"),Promise.resolve()}catch(e){return Promise.reject(e)}},value:p})),l.createElement(n.Route,{path:u.path+"/acknowledgement"},l.createElement(T,{data:p,onSuccess:()=>{D(),d.invalidateQueries("VENDOR_CREATE")}})),l.createElement(n.Route,null,l.createElement(n.Redirect,{to:`${u.path}/${S.indexRoute}`}))))},VENDORCheckPage:e=>{var n,a,r,s;let{onSubmit:d,value:u={}}=e;const{t:c}=i.useTranslation(),{vendordet:E,documents:m}=u;console.log("vendordetailssppsss",E),console.log("documents",m);const[v,S]=t.useState(!1);return l.createElement(l.Fragment,null,window.location.href.includes("/employee")?l.createElement(o.VerticalTimeline,{config:[{timeLine:[{actions:c("VENDOR_ADDITIONAL_DETAILS"),currentStep:1}]},{timeLine:[{actions:c("VENDOR_DOCUMENT_DETAILS"),currentStep:2}]},{timeLine:[{actions:c("VENDOR_SUMMARY"),currentStep:3}]}],currentActiveIndex:2,showFinalStep:!1}):null,l.createElement("div",{style:{flex:"1",overflowY:"auto",marginBottom:"20px"}},l.createElement(o.Card,null,l.createElement(o.CardHeader,null,c("VENDOR_CHECK_DETAILS")),l.createElement("div",null,l.createElement("br",null),l.createElement(o.CardSubHeader,null,c("VENDOR_ADDITIONAL_DETAILS")),l.createElement(o.StatusTable,null,l.createElement(l.Fragment,null,l.createElement(o.Row,{label:c("VENDOR_ID"),text:""+c(U(null==E?void 0:E.VendorId)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_BANK_IFSC_CODE"),text:""+c(U(null==E?void 0:E.IFSC)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_BANK_NAME"),text:""+c(U(null==E?void 0:E.Bank)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_BANK_BRANCH"),text:""+c(U(null==E?void 0:E.BankbranchName)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_MICR_NO"),text:""+c(U(null==E?void 0:E.micrNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("BANK_ACCONT_NO"),text:""+c(U(null==E?void 0:E.AccountNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("PAN_NO"),text:""+c(U(null==E?void 0:E.PanNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("GST_NO"),text:""+c(U(null==E?void 0:E.GstNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("GST_REGISTERED_STATE/UT"),text:""+c(U(null==E?void 0:E.GstState)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("REGISTRATION_NO"),text:""+c(U(null==E?void 0:E.RegistrationNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("EPF_NO"),text:""+c(U(null==E?void 0:E.EpfNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("ESI_NO"),text:""+c(U(null==E?void 0:E.EsiNo)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_TYPE"),text:""+c(U(null==E||null===(n=E.VendorType)||void 0===n?void 0:n.code)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_CATEGORY"),text:""+c(U(null==E||null===(a=E.VendorCategory)||void 0===a?void 0:a.code)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}),l.createElement(o.Row,{label:c("VENDOR_STATUS"),text:""+c(U(null==E||null===(r=E.Status)||void 0===r?void 0:r.code)),actionButton:l.createElement(ee,{jumpTo:`/digit-ui/${window.location.pathname.includes("/citizen")?"citizen":"employee"}/vendor/registry/additionaldetails/vendor-details`})}))),l.createElement("br",null),l.createElement(o.CardSubHeader,null,c("VENDOR_DOCUMENTS_DETAILS")),l.createElement(o.StatusTable,null,l.createElement(o.StatusTable,null,l.createElement(o.Row,{label:c("VENDOR_DOCUMENTS"),text:(null==m||null===(s=m.documents)||void 0===s?void 0:s.length)>0?m.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 o=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(o){const e=o.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!")}},c(e.documentType)))):c("CS_NA")}))),l.createElement("br",null),l.createElement(o.CheckBox,{label:c("AST_FINAL_DECLARATION_MESSAGE"),onChange:()=>{S(!v)},styles:{height:"auto"},checked:v})),l.createElement("br",null),l.createElement("div",{className:"formcomposer-section-button"},l.createElement(o.SubmitBar,{label:c("COMMON_BUTTON_SUBMIT"),onSubmit:d,disabled:!v})))))},NewResponse:e=>{let{data:a,onSuccess:r}=e;const{t:s}=i.useTranslation(),d=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,o,i,a,r,s,d,u,c,E,m,v,S,p,_,D,R,g,N,y,T,I;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===(o=e.vendordet)||void 0===o?void 0:o.ContactPerson,vendorMobileNumber:"9876543210",bankAccountNumber:null==e||null===(i=e.vendordet)||void 0===i?void 0:i.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===(s=e.vendordet)||void 0===s?void 0:s.micrNo,epfNo:null==e||null===(d=e.vendordet)||void 0===d?void 0:d.EpfNo,esiNo:null==e||null===(u=e.vendordet)||void 0===u?void 0:u.EsiNo,gstRegisteredState:null==e||null===(c=e.vendordet)||void 0===c?void 0:c.GstState,ifscCode:null==e||null===(E=e.vendordet)||void 0===E?void 0:E.IFSC,panNo:null==e||null===(m=e.vendordet)||void 0===m?void 0:m.PanNo,registrationNo:null==e||null===(v=e.vendordet)||void 0===v?void 0:v.RegistrationNo,status:null==e||null===(S=e.vendordet)||void 0===S||null===(p=S.Status)||void 0===p?void 0:p.code,vendorCategory:null==e||null===(_=e.vendordet)||void 0===_||null===(D=_.VendorCategory)||void 0===D?void 0:D.code,vendorId:null==e?void 0:e.vendor_id,gstTinNo:null==e||null===(R=e.vendordet)||void 0===R?void 0:R.GstNo,serviceType:null==e||null===(g=e.vendordet)||void 0===g||null===(N=g.VendorType)||void 0===N?void 0:N.code,documents:null==e||null===(y=e.documents)||void 0===y?void 0:y.documents,active:null,vendorAdditionalDetailsId:null,vendorGroup:(null==e||null===(T=e.vendordet)||void 0===T?void 0:T.vendorGroup)||"N/A",vendorType:(null==e||null===(I=e.vendordet)||void 0===I?void 0:I.vendorType)||"N/A"}}})(a);console.log("formdata in acknowejkfdlgi ::: ",l),d.mutate(l,{onSuccess:r}),console.log("mutation in acknowejkfdlgi ::: ",d)}catch(e){}},[]),d.isLoading||d.isIdle?l.createElement(o.Loader,null):l.createElement(o.Card,{className:"vehicle-details-card"},l.createElement(ne,{t:s,data:d.data,isSuccess:d.isSuccess,isLoading:d.isIdle||d.isLoading}),l.createElement(o.StatusTable,null,d.isSuccess&&l.createElement(o.Row,{rowContainerStyle:le,last:!0,textStyle:{whiteSpace:"pre",width:"60%"}})),l.createElement(n.Link,{to:"/digit-ui/employee"},l.createElement(o.LinkButton,{label:s("CORE_COMMON_GO_TO_HOME")})))},DriverDetails:()=>{var e,r;const s=Digit.ULBService.getCurrentTenantId(),{t:d}=i.useTranslation(),u=n.useHistory(),c=a.useQueryClient(),{id:E}=n.useParams(),[m,v]=t.useState(!1),[S,p]=t.useState(null),[_,D]=t.useState(!1),[R,g]=t.useState(null),[N,y]=t.useState([]),[T,I]=t.useState({}),{data:C,isLoading:A,refetch:O}=Digit.Hooks.fsm.useDriverDetails(s,{ids:E},{staleTime:Infinity}),{data:b}=Digit.Hooks.fsm.useDsoSearch(s,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{mutate:f}=Digit.Hooks.fsm.useDriverUpdate(s),{mutate:h}=Digit.Hooks.fsm.useVendorUpdate(s);function V(e){p(e),v(!1)}t.useEffect(()=>{if(b){let e=b.map(e=>e.dsoDetails);y(e)}},[b]),t.useEffect(()=>{O()},[]),t.useEffect(()=>{switch(S){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return D(!0);case"EDIT":return u.push("/digit-ui/employee/fsm/registry/modify-driver/"+E);case"HOME":return u.push("/digit-ui/employee/fsm/registry?selectedTabs=DRIVER")}},[S]);const M=()=>{g(null)},w=()=>{p(null),I({}),D(!1)},k=()=>"DELETE"===S||"DELETE_VENDOR"===S?l.createElement(L,{t:d,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===S||"EDIT_VENDOR"===S?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,d("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(o.Dropdown,{t:d,option:N,value:T,selected:T,select:I,optionKey:"name"})):void 0;return A||A?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(o.Card,{style:{position:"relative",backgroundColor:"#fff"}},null==C||null===(e=C[0])||void 0===e||null===(r=e.employeeResponse)||void 0===r?void 0:r.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},d(e.title)),l.createElement(o.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"},d(e.title)),"custom"===(null==e?void 0:e.type)?l.createElement("div",{className:"additional-value",style:{color:"#a82227",display:"flex",gap:"20px",alignItems:"center"}},d(e.value)||"N/A","ES_FSM_REGISTRY_DETAILS_ADD_VENDOR"===e.value&&l.createElement("span",{className:"add-details-link hover-button",onClick:()=>V("ADD_VENDOR"),style:{cursor:"pointer"}},l.createElement(o.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(o.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(o.DeleteIcon,{className:"delete",fill:"#a82227"}))):l.createElement("div",{className:"additional-value"},d(e.value)||"N/A"))))))}))),_&&l.createElement(o.Modal,{headerBarMain:l.createElement(ae,{label:d((()=>{switch(S){case"DELETE":case"DELETE_VENDOR":return"ES_FSM_REGISTRY_DELETE_POPUP_HEADER";case"ADD_VENDOR":case"EDIT_VENDOR":return"ES_FSM_REGISTRY_ADD_VENDOR_POPUP_HEADER"}})())}),headerBarEnd:l.createElement(se,{onClick:w}),actionCancelLabel:d("CS_COMMON_CANCEL"),actionCancelOnSubmit:w,actionSaveLabel:d("DELETE"===S||"DELETE_VENDOR"===S?"ES_EVENT_DELETE":"CS_COMMON_SUBMIT"),actionSaveOnSubmit:()=>{switch(S){case"DELETE":return(()=>{var e;const t={driver:{...null==C||null===(e=C[0])||void 0===e?void 0:e.driverData,status:"INACTIVE"}};f(t,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"DELETE_DRIVER"}),c.invalidateQueries("DSO_SEARCH"),setTimeout(()=>{M(),u.push("/digit-ui/employee/fsm/registry")},5e3)}}),D(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let o={},i=null==C||null===(e=C[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],a=null==i?void 0:i.drivers;a=a.map(e=>(e.id===E&&(e.vendorDriverStatus="INACTIVE"),e)),o={vendor:{...i,owner:{...i.owner,gender:(null===(n=i.owner)||void 0===n?void 0:n.gender)||"OTHERS"},drivers:a}},h(o,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"DELETE_VENDOR"}),c.invalidateQueries("FSM_VENDOR_SEARCH"),O(),setTimeout(M,5e3)}}),D(!1)})();case"ADD_VENDOR":return(()=>{var e,t;let l=T,n=null==C||null===(e=C[0])||void 0===e?void 0:e.driverData;n.vendorDriverStatus="ACTIVE";const o={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},drivers:l.drivers?[...l.drivers,n]:[n]}};h(o,{onError:(e,t)=>{g({key:"error",action:e}),O(),setTimeout(M,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"ADD_VENDOR"}),c.invalidateQueries("DSO_SEARCH"),O(),setTimeout(M,5e3)}}),D(!1),p(null)})();case"EDIT_VENDOR":return(()=>{var e,t;let l=T,n=null==C||null===(e=C[0])||void 0===e?void 0:e.driverData;n.vendorDriverStatus="ACTIVE";const o={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},drivers:l.drivers?[...l.drivers,n]:[n]}};h(o,{onError:(e,t)=>{g({key:"error",action:e}),setTimeout(M,5e3)},onSuccess:(e,t)=>{g({key:"success",action:"EDIT_VENDOR"}),O(),c.invalidateQueries("DSO_SEARCH"),setTimeout(M,5e3)}}),D(!1),p(null)})()}},formId:"modal-action"},"DELETE"===S||"DELETE_VENDOR"===S?k():l.createElement(o.Card,{style:{boxShadow:"none"}},k())),R&&l.createElement(o.Toast,{error:"error"===R.key,label:d("success"===R.key?`ES_FSM_REGISTRY_${R.action}_SUCCESS`:R.action),onClose:M}),l.createElement(o.ActionBar,{style:{zIndex:"19"}},m?l.createElement(o.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:d,onSelect:V}):null,l.createElement(o.SubmitBar,{label:d("ES_COMMON_TAKE_ACTION"),onSubmit:()=>v(!m)})))},VehicleDetails:e=>{var r,s;const d=Digit.ULBService.getCurrentTenantId(),{t:u}=i.useTranslation(),c=n.useHistory(),E=a.useQueryClient();let{id:m}=n.useParams();const[v,S]=t.useState(!1),[p,_]=t.useState(null),[D,R]=t.useState(!1),[g,N]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),[A,O]=t.useState(null),{data:b,isLoading:f,refetch:h}=Digit.Hooks.fsm.useVehicleDetails(d,{registrationNumber:m},{staleTime:Infinity});t.useEffect(()=>{var e,t;!f&&b&&O(null==b||null===(e=b[0])||void 0===e||null===(t=e.vehicleData)||void 0===t?void 0:t.id)},[b,f]);const{data:V}=Digit.Hooks.fsm.useDsoSearch(d,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{});t.useEffect(()=>{if(V){let e=V.map(e=>e.dsoDetails);T(e)}},[V]);const{mutate:M}=Digit.Hooks.fsm.useUpdateVehicle(d),{mutate:w}=Digit.Hooks.fsm.useVendorUpdate(d);function k(e){S(!1),_(e)}t.useEffect(()=>{h()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return R(!0);case"EDIT":return c.push("/digit-ui/employee/fsm/registry/modify-vehicle/"+m);case"HOME":return c.push("/digit-ui/employee/fsm/registry?selectedTabs=VEHICLE")}},[p]);const P=()=>{N(null)},F=()=>{_(null),C({}),R(!1)},x=()=>"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(L,{t:u,title:"ES_FSM_REGISTRY_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(o.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0;return f?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,f?l.createElement(o.Loader,null):l.createElement("div",{className:"employee-form-content"},l.createElement(o.Card,{className:"vehicle-details-card",style:{position:"relative"}},null==b||null===(r=b[0])||void 0===r||null===(s=r.employeeResponse)||void 0===s?void 0:s.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(o.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(o.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(o.EditIcon,{fill:"#a82227"})),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>k("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(o.DeleteIcon,{className:"delete",fill:"#a82227"})))):l.createElement("div",{className:"additional-value",style:"ACTIVE"===e.value?{color:"green"}:{}},u(e.value)||"N/A"))))))})),D&&l.createElement(o.Modal,{headerBarMain:l.createElement(ue,{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(Ee,{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==b||null===(e=b[0])||void 0===e?void 0:e.vehicleData,status:"INACTIVE"}};M(t,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"DELETE_VEHICLE"}),E.invalidateQueries("FSM_VEICLES_SEARCH"),setTimeout(()=>{P(),c.push("/digit-ui/employee/fsm/registry")},5e3)}}),R(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l,n;let o={},i=null==b||null===(e=b[0])||void 0===e||null===(t=e.vendorDetails)||void 0===t||null===(l=t.vendor)||void 0===l?void 0:l[0],a=null==i?void 0:i.vehicles;a=a.map(e=>(e.id===A&&(e.vendorVehicleStatus="INACTIVE"),e)),o={vendor:{...i,owner:{...i.owner,gender:(null===(n=i.owner)||void 0===n?void 0:n.gender)||"OTHERS"},vehicles:a}},w(o,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),h(),setTimeout(P,5e3)}}),R(!1)})();case"ADD_VENDOR":return(()=>{var e,t;let l=I,n=null==b||null===(e=b[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const o={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},vehicles:l.vehicles?[...l.vehicles,n]:[n]}};w(o,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"EDIT_VENDOR"}),h(),E.invalidateQueries("DSO_SEARCH"),setTimeout(P,5e3)}}),R(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e,t;let l=I,n=null==b||null===(e=b[0])||void 0===e?void 0:e.vehicleData;n.vendorVehicleStatus="ACTIVE";const o={vendor:{...l,owner:{...l.owner,gender:(null===(t=l.owner)||void 0===t?void 0:t.gender)||"OTHERS"},vehicles:l.vehicles?[...l.vehicles,n]:[n]}};w(o,{onError:(e,t)=>{N({key:"error",action:e}),setTimeout(P,5e3)},onSuccess:(e,t)=>{N({key:"success",action:"EDIT_VENDOR"}),h(),E.invalidateQueries("DSO_SEARCH"),setTimeout(P,5e3)}}),R(!1),_(null)})()}}},"DELETE"===p||"DELETE_VENDOR"===p?x():l.createElement(o.Card,{style:{boxShadow:"none"}},x())),g&&l.createElement(o.Toast,{error:"error"===g.key,label:u("success"===g.key?`ES_FSM_REGISTRY_${g.action}_SUCCESS`:g.action),onClose:P}),l.createElement(o.ActionBar,{style:{zIndex:"19"}},v?l.createElement(o.Menu,{localeKeyPrefix:"ES_FSM_REGISTRY_ACTION",options:["EDIT","DELETE"],t:u,onSelect:k}):null,l.createElement(o.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)}))))},AddSupervisor:e=>{var r;const{t:s}=i.useTranslation(),u=null===(r=Digit.UserService.getUser())||void 0===r?void 0:r.info,c=Digit.ULBService.getCurrentTenantId(),E=null!=c&&c.includes(".")?c:c+".djb",[m,v]=t.useState(null),S=a.useQueryClient(),[p,_]=t.useState(!1),{mutate:D}=Digit.Hooks.fsm.useSupervisorCreate(E),R=n.useHistory(),g=$(s),N=()=>{v(null)};return l.createElement(l.Fragment,null,l.createElement(o.VerticalTimeline,{config:[{route:"supervisor-details",timeLine:[{actions:s("ES_VENDOR_SUPERVISOR_DETAILS"),currentStep:1}]}],currentActiveIndex:0,showFinalStep:!1}),l.createElement("div",{style:{flex:"1",overflowY:"auto"}},l.createElement(o.FormComposer,{isDisabled:!p,label:s("ES_COMMON_APPLICATION_SUBMIT"),config:g.map(e=>({...e,isCollapsible:!0,isDefaultOpen:!0})),fieldStyle:{marginRight:0},onSubmit:function(e){try{var t,l,n,o;const i=null==u||null===(t=u.roles)||void 0===t?void 0:t.some(e=>"EKYC_VENDOR"===e.code),a=Array.isArray(null==e?void 0:e.zoneIds)?(null==e||null===(l=e.zoneIds)||void 0===l?void 0:l.map(e=>e.code).join(","))||"":null==e?void 0:e.zoneIds,r={RequestInfo:{apiId:"Rainmaker",ver:"1.0",ts:null,action:"_create",msgId:Date.now()+"|en_IN",authToken:(null===(n=Digit.UserService.getUser())||void 0===n?void 0:n.access_token)||(null==u?void 0:u.authToken),...i&&{userInfo:{id:null==u?void 0:u.id,uuid:null==u?void 0:u.uuid,userName:null==u?void 0:u.userName,name:null==u?void 0:u.name,type:null==u?void 0:u.type,tenantId:(null==u?void 0:u.tenantId)||c,roles:null==u?void 0:u.roles}}},supervisor:{tenantId:E,assignedZoneId:a,description:(null==e?void 0:e.description)||"",owner:{tenantId:E,name:null==e?void 0:e.fullName,fatherOrHusbandName:"Static Father",relationship:"FATHER",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}}},s=d(function(){return Promise.resolve(D(r)).then(function(){v({key:"success",action:"ADD_SUPERVISOR"}),S.invalidateQueries("SUPERVISOR_SEARCH"),setTimeout(()=>{N(),R.push("/digit-ui/citizen/vendor/search-vendor")},3e3)})},function(e){v({key:"error",action:(null==e?void 0:e.message)||e}),setTimeout(N,5e3)});return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},defaultValues:{role:{code:"SUPERVISOR",name:"Supervisor"}},onFormValueChange:(e,t)=>{var l;const n=[null==t?void 0:t.fullName,null==t?void 0:t.mobileNumber,null==t?void 0:t.emailId,null==t?void 0:t.gender,null==t?void 0:t.dob,null==t?void 0:t.correspondenceAddress].every(Boolean)&&(null==t||null===(l=t.zoneIds)||void 0===l?void 0:l.length)>0;_(n)},noBreakLine:!0,mode:"onChange",noCard:!0}),m&&l.createElement(o.Toast,{error:"error"===m.key,label:s("success"===m.key?`ES_VENDOR_${m.action}_SUCCESS`:m.action),onClose:N})))},EditSupervisor:z,SupervisorAreaAssignment:e=>{var n,i,a,r;let{config:s,onSelect:d,t:u,formData:c}=e;const E=Digit.ULBService.getCurrentTenantId(),[m,v]=t.useState((null==c||null===(n=c.areaAssignment)||void 0===n?void 0:n.zone)||null),[S,p]=t.useState((null==c||null===(i=c.areaAssignment)||void 0===i?void 0:i.cluster)||null),[_,D]=t.useState((null==c||null===(a=c.areaAssignment)||void 0===a?void 0:a.ward)||null),[R,g]=t.useState((null==c||null===(r=c.areaAssignment)||void 0===r?void 0:r.areas)||[]),[N,y]=t.useState([]),[T,I]=t.useState([]),[C,A]=t.useState([]),[O,b]=t.useState([]),{data:f,isLoading:h}=Digit.Hooks.useCommonMDMS(E,"egov-location",["TenantBoundary"]);t.useEffect(()=>{if(console.log("Boundary Data State:",{boundaryData:f,isLoading:h}),f){var e,t,l,n,o;const i=(null==f||null===(e=f["egov-location"])||void 0===e||null===(t=e.TenantBoundary)||void 0===t?void 0:t[0])||(null==f||null===(l=f.MdmsRes)||void 0===l||null===(n=l["egov-location"])||void 0===n||null===(o=n.TenantBoundary)||void 0===o?void 0:o[0]),a=(null==i?void 0:i.boundary)||(null==i?void 0:i.children)||[];Array.isArray(a)&&a.length>0?y(a):h||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 h||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"}])},[f,h]),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),D(null),g([]))}else I([])},[m]),t.useEffect(()=>{if(S){var e,t;const l=S.children||S.boundary||[];A(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)&&(D(null),g([]))}else A([])},[S]),t.useEffect(()=>{if(_){var e,t;const l=_.children||_.localities||_.boundary||[];b(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)&&g([])}else b([])},[_]);const V=(e,t)=>{const l={...null==c?void 0:c.areaAssignment,[e]:t};"zone"===e?(l.cluster=null,l.ward=null,l.areas=[]):"cluster"===e?(l.ward=null,l.areas=[]):"ward"===e&&(l.areas=[]),d(s.key,l)};return h?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,u("ES_VENDOR_SUPERVISOR_ZONE")+" *"),l.createElement(o.Dropdown,{selected:m,option:N,select:e=>{v(e),V("zone",e)},optionKey:"name",t:u})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,u("ES_VENDOR_SUPERVISOR_CLUSTER")+" *"),l.createElement(o.Dropdown,{selected:S,option:T,select:e=>{p(e),V("cluster",e)},optionKey:"name",t:u,disable:!m})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,u("ES_VENDOR_SUPERVISOR_WARD")+" *"),l.createElement(o.Dropdown,{selected:_,option:C,select:e=>{D(e),V("ward",e)},optionKey:"name",t:u,disable:!S})),l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,u("ES_VENDOR_SUPERVISOR_AREA")+" *"),l.createElement(o.MultiSelectDropdown,{options:O,selected:R,onSelect:e=>{g(e),V("areas",e)},optionsKey:"name",t:u,disable:!_,ServerStyle:{backgroundColor:"#fff"}})))},SurveyorDetails:e=>{var r,s;const d=Digit.ULBService.getCurrentTenantId(),{t:u}=i.useTranslation(),c=n.useHistory(),E=a.useQueryClient(),{id:m}=n.useParams(),[v,S]=t.useState(!1),[p,_]=t.useState(null),[D,R]=t.useState(!1),[g,N]=t.useState(null),[y,T]=t.useState([]),[I,C]=t.useState({}),{data:A}=Digit.Hooks.fsm.useDsoSearch(d,{sortBy:"name",sortOrder:"ASC",status:"ACTIVE"},{}),{data:O,isLoading:b,refetch:f}=Digit.Hooks.fsm.useSurveyorSearch(d,{ids:m},{staleTime:Infinity}),h=l.useMemo(()=>{var e;return null!=O&&null!==(e=O.surveyors)&&void 0!==e&&e.length?O.surveyors.map(e=>{var t,l,n,o;const i=null==A?void 0:A.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==i||null===(t=i.dsoDetails)||void 0===t?void 0:t.name)||e.vendorId||"ES_FSM_REGISTRY_DETAILS_ADD_VENDOR";return{surveyorData:e,vendorDetails:{vendor:i?[i.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===(o=e.owner)||void 0===o?void 0:o.gender},{title:"ES_VENDOR_SURVEYOR_AGENCY_NAME",value:a,type:"custom"}]}]}}):[]},[O,A]),{mutate:V}=Digit.Hooks.fsm.useSurveyorUpdate(d),{mutate:M}=Digit.Hooks.fsm.useVendorUpdate(d);t.useEffect(()=>{if(A){let e=A.map(e=>e.dsoDetails);T(e)}},[A]),t.useEffect(()=>{f()},[]),t.useEffect(()=>{switch(p){case"DELETE":case"ADD_VENDOR":case"EDIT_VENDOR":case"DELETE_VENDOR":return R(!0);case"EDIT":return c.push("/digit-ui/employee/vendor/registry/modify-surveyor/"+m);case"HOME":return c.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SURVEYOR")}},[p]);const w=()=>{N(null)},k=()=>{_(null),C({}),R(!1)};return b?l.createElement(o.Loader,null):l.createElement(l.Fragment,null,l.createElement("div",{className:"employee-form-content"},l.createElement(o.Card,null,null==h||null===(r=h[0])||void 0===r||null===(s=r.employeeResponse)||void 0===s?void 0:s.map((e,t)=>{var n;return l.createElement(l.Fragment,{key:t},t>0&&l.createElement(o.CardSectionHeader,{style:{marginBottom:"16px",marginTop:"32px"}},u(e.title)),l.createElement(o.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(o.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(o.EditIcon,null)),l.createElement("div",{className:"add-details-link hover-button",onClick:()=>_("DELETE_VENDOR"),style:{cursor:"pointer"}},l.createElement(o.DeleteIcon,{fill:"#a82227"})))):l.createElement("div",{className:"additional-value"},u(e.value)||"N/A"))))))}))),D&&l.createElement(o.Modal,{headerBarMain:l.createElement(Q,{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(J,{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==h||null===(e=h[0])||void 0===e?void 0:e.surveyorData,status:"INACTIVE"}};V(t,{onError:e=>{N({key:"error",action:e}),setTimeout(w,5e3)},onSuccess:()=>{N({key:"success",action:"DELETE_SURVEYOR"}),E.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(()=>{w(),c.push("/digit-ui/employee/vendor/search-vendor")},5e3)}}),R(!1)})();case"DELETE_VENDOR":return(()=>{var e,t,l;let n=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],o=(null==n?void 0:n.surveyors)||[];o=o.map(e=>(e.id===m&&(e.vendorSurveyorStatus="INACTIVE"),e));const i={vendor:{...n,surveyors:o}};M(i,{onError:e=>{N({key:"error",action:e}),setTimeout(w,5e3)},onSuccess:()=>{N({key:"success",action:"DELETE_VENDOR"}),E.invalidateQueries("FSM_VENDOR_SEARCH"),f(),setTimeout(w,5e3)}}),R(!1)})();case"ADD_VENDOR":return(()=>{var e;let t=I,l=null==h||null===(e=h[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:{...t,surveyors:t.surveyors?[...t.surveyors,l]:[l]}};M(n,{onError:e=>{N({key:"error",action:e}),f(),setTimeout(w,5e3)},onSuccess:()=>{N({key:"success",action:"ADD_VENDOR"}),E.invalidateQueries("SURVEYOR_SEARCH"),f(),setTimeout(w,5e3)}}),R(!1),_(null)})();case"EDIT_VENDOR":return(()=>{var e;let t=I,l=null==h||null===(e=h[0])||void 0===e?void 0:e.surveyorData;l.vendorSurveyorStatus="ACTIVE";const n={vendor:{...t,surveyors:t.surveyors?[...t.surveyors,l]:[l]}};M(n,{onError:e=>{N({key:"error",action:e}),setTimeout(w,5e3)},onSuccess:()=>{N({key:"success",action:"EDIT_VENDOR"}),f(),E.invalidateQueries("SURVEYOR_SEARCH"),setTimeout(w,5e3)}}),R(!1),_(null)})()}}},l.createElement(o.Card,{style:{boxShadow:"none"}},"DELETE"===p||"DELETE_VENDOR"===p?l.createElement(L,{t:u,title:"ES_VENDOR_SURVEYOR_DELETE_TEXT"}):"ADD_VENDOR"===p||"EDIT_VENDOR"===p?l.createElement(l.Fragment,null,l.createElement(o.CardText,null,u("ES_FSM_REGISTRY_SELECT_VENODOR")),l.createElement(o.Dropdown,{t:u,option:y,value:I,selected:I,select:C,optionKey:"name"})):void 0)),g&&l.createElement(o.Toast,{error:"error"===g.key,label:u("success"===g.key?`ES_VENDOR_${g.action}_SUCCESS`:g.action),onClose:w}),l.createElement(o.ActionBar,{style:{zIndex:"19"}},v?l.createElement(o.Menu,{localeKeyPrefix:"ES_VENDOR_SURVEYOR_ACTION",options:["EDIT","DELETE"],t:u,onSelect:e=>{S(!1),_(e)}}):null,l.createElement(o.SubmitBar,{label:u("ES_COMMON_TAKE_ACTION"),onSubmit:()=>S(!v)})))},EditSurveyor:W,SelectEkycZones:e=>{let{config:n,onSelect:i,t:a,formData:r,isMultiSelect:s=!0}=e;const d=Digit.ULBService.getCurrentTenantId(),[u,c]=t.useState([]),[E,m]=t.useState([]),{data:v,isLoading:S}=Digit.Hooks.useCommonMDMS(d,"egov-location",["TenantBoundary"]);return t.useEffect(()=>{if(u.length)if(s)m(Array.isArray(null==r?void 0:r.zoneIds)?u.filter(e=>r.zoneIds.includes(e.code)):[]);else{const e=u.find(e=>e.code===(null==r?void 0:r.zoneIds));m(e?[e]:[])}},[u,null==r?void 0:r.zoneIds,s]),t.useEffect(()=>{var e,t,l,n,o;const i=(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===(o=n.TenantBoundary)||void 0===o?void 0:o[0]),a=(null==i?void 0:i.boundary)||(null==i?void 0:i.children)||[];if(Array.isArray(null==a?void 0:a.children)&&(null==a?void 0:a.children.length)>0){const e=a.children.flatMap(e=>((null==e?void 0:e.children)||[]).map(e=>({code:e.code,name:e.name}))),t=[...new Map(e.map(e=>[e.code,e])).values()];c(t)}},[v]),S?l.createElement(o.Loader,null):l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,a(n.label)+(n.isMandatory?" *":"")),l.createElement("div",{className:"field",style:{position:"relative",zIndex:10}},l.createElement(o.MultiSelectDropdown,{options:u,selected:E,onSelect:e=>{if(s){const t=Array.isArray(e)?e.map(e=>Array.isArray(e)?e[1]:e).filter(Boolean):[];m(t),i(n.key,t)}else{const t=Array.isArray(e)?Array.isArray(e[0])?e[0][1]:e[0]:e;m(t?[t]:[]),i(n.key,(null==t?void 0:t.code)||"")}},optionsKey:"name",t:a,multiple:s,ServerStyle:{backgroundColor:"#fff"},isMultiSelect:s,showSelectedLabels:!0})))},SelectEkycClusters:e=>{let{config:n,onSelect:i,t:a,formData:r}=e;const s=Digit.ULBService.getCurrentTenantId(),[d,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(s,"egov-location",["TenantBoundary"]);t.useEffect(()=>{var e,t,l,n,o;const i=(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===(o=n.TenantBoundary)||void 0===o?void 0:o[0]),a=(null==i?void 0:i.boundary)||(null==i?void 0:i.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(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,a(n.label)+(n.isMandatory?" *":"")),l.createElement("div",{className:"field",style:{position:"relative",zIndex:9}},l.createElement(o.MultiSelectDropdown,{options:d,selected:c,onSelect:e=>{const t=Array.isArray(e)?e.map(e=>Array.isArray(e)?e[1]:e).filter(Boolean):e;E(t),i(n.key,t)},optionsKey:"name",t:a,ServerStyle:{backgroundColor:"#fff"},disable:S})))},SelectEkycDropdown:e=>{var t,n;let{config:i,onSelect:a,t:r,formData:s}=e;const d=(null==i||null===(t=i.populators)||void 0===t?void 0:t.options)||[],u=(null==i||null===(n=i.populators)||void 0===n?void 0:n.optionsKey)||"name",c=null==s?void 0:s[i.key];return l.createElement(o.LabelFieldPair,null,l.createElement(o.CardLabel,null,r(i.label)),l.createElement("div",{className:"field"},l.createElement(o.Dropdown,{selected:c,option:d,select:e=>{a(i.key,e)},optionKey:u,t:r})))}},ve=e=>{let{userType:o,tenants:i}=e;const{path:a,url:r}=n.useRouteMatch(),s=Digit.StoreData.getCurrentLanguage(),d=Digit.ULBService.getCurrentTenantId();return t.useEffect(()=>{Digit.LocalizationService.getLocale({modules:["rainmaker-vendor"],locale:s,tenantId:"dl"})},[s,d]),Object.entries(me).forEach(e=>{let[t,l]=e;Digit.ComponentRegistryService.setComponent(t,l)}),Digit.SessionStorage.set("VENDOR_TENANTS",i),t.useEffect(()=>{"employee"===o&&Digit.LocalizationService.getLocale({modules:["rainmaker-"+d],locale:s,tenantId:d})},[]),l.createElement("employee"===o?H:q,{path:a,url:r,userType:o})},Se=e=>{const[,,l]=Digit.Hooks.useSessionStorage("VENDOR",{});return t.useEffect(()=>{l()},[]),null};exports.VENDORComponents={VENDORCard:()=>{const{t:e}=i.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 s=[{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"}],d=Digit.UserService.hasAccess(["WT_VENDOR"]),u={Icon:l.createElement(o.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:s.filter(e=>!(null!=e&&e.role)||d),...a?{onDetailsClick:()=>t.push("/digit-ui/citizen/vendor/search-vendor")}:{}};return a?l.createElement("div",{className:"wt-citizen-card-premium"},l.createElement(o.EmployeeModuleCard,u)):l.createElement(o.EmployeeModuleCard,u)},VENDORModule:ve,VENDORLinks:Se},exports.VENDORLinks=Se,exports.VENDORModule=ve;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@djb25/digit-ui-module-vendor",
3
3
  "description": "Vendor Employee",
4
- "version": "1.0.47",
4
+ "version": "1.0.48",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.modern.js",