1import{b as e,u as l,r as t,j as s}from"./index-dqSqdwqf.js";import{R as i}from"./index-CNRxWrpi.js";import{B as a}from"./primary-DE0ooBNy.js";import{I as n,r}from"./flightUtil-D9zZK87K.js";import{T as o}from"./textInput-4bly1edJ.js";import{E as d}from"./ExternalsManager-WN7sWvzG.js";import{i as c,A as m}from"./Utils-Bdf22AqU.js";import{S as u}from"./react-select.esm-DxxZFVLT.js";import{C as h}from"./Container-TfFh-ejU.js";import{T as p}from"./Table-QOuNnPZ5.js";import{O as v,T as j}from"./OverlayTrigger-eyBhLZad.js";import{M as g}from"./Modal-LFIeP2RU.js";import{F as x}from"./Form-3YEd6Jj4.js";import"./index-X4KCfggp.js";import"./calendar-icon-a6hKn8ZX.js";import"./baseInput-DUEg5WxM.js";import"./objectSpread2-CDzZogqW.js";import"./defineProperty-DiB_izgz.js";import"./unsupportedIterableToArray-AuDun9xq.js";import"./slicedToArray-BvV6eCYh.js";import"./toConsumableArray-DHMPlY1A.js";import"./classCallCheck-7i8NRbhX.js";import"./createSuper-Ch9CM58t.js";import"./assertThisInitialized-PUtynf78.js";import"./floating-ui.dom-B8bHMvy1.js";import"./index-AEDesM2K.js";import"./index-BaqZIR9i.js";import"./ThemeProvider-BZVkeKTo.js";import"./ImperativeTransition-Ya2amIiW.js";import"./NoopTransition-Cw7pTn7K.js";import"./Transition-CSjsbdUF.js";import"./TransitionGroupContext-hmoDmHEJ.js";import"./warning-CzffBXUz.js";import"./hook-CIetSo2v.js";import"./createPopper-WKo9Skj4.js";import"./DataKey-DLQkwkS3.js";import"./divWithClassName-H9Tq6PLF.js";import"./ElementChildren-CS_YMqPo.js";const f=()=>{e();const{pushHistory:f}=l(),[b,N]=t.useState(null),[F,y]=t.useState(null),[T,S]=t.useState(""),[C,w]=t.useState(),[k,I]=t.useState("TOKEN"),[U,P]=t.useState(""),[A,E]=t.useState(""),[O,M]=t.useState(""),[V,K]=t.useState(""),[R,L]=t.useState(!1),[q,W]=t.useState([]),[z,D]=t.useState(!0),[G,H]=t.useState(""),[_,B]=t.useState(1),[Z,$]=t.useState(0),[J,Q]=t.useState(!1),[X,Y]=t.useState(""),[ee,le]=t.useState(null),te=t.useCallback(async()=>{var e,l;Q(!0);let t={page:_}
1,s=await(null==(e=d)?void 0:e.API.post("/getvendors",t));"success"===(null==s?void 0:s.type)?(W(null==s?void 0:s.data[0].Docs),$(null==(l=null==s?void 0:s.data[0])?void 0:l.totalCount),Q(!1)):(window.alert(`Status Code: ${null==s?void 0:s.status}\nMessage: ${null==s?void 0:s.message}`),Q(!1))},[_]);t.useEffect(()=>{te()},[_,te]),t.useEffect(()=>{c()||f("/")},[]);const se=async e=>{var l;let{data:t}=await(null==(l=d)?void 0:l.API.post("/createvendor",e));t.error?alert(t.message):te()},ie=async e=>{var l;await(null==(l=d)?void 0:l.API.post("/updatevendor",e)),te()},ae=e=>s.jsx(j,{id:"button-tooltip",...e,children:"Copy URL"});return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"Flight-mainContainer",children:s.jsxs(h,{fluid:"xl",className:"Flight-container-xl",children:[s.jsx(m,{}),s.jsxs("div",{children:[s.jsxs("div",{className:"d-flex justify-content-between align-items-center mb-2",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"Flight-font14 Flight-font-bold mb-sm-1 mb-0 Flight-ln",children:"Vendor Management"}),s.jsx("p",{className:"Flight-font12 Flight-font-semibold mb-0 d-sm-block d-none",children:" "})]}),s.jsx("div",{children:s.jsx(a,{name:"createModal",className:"Flight-btn-purple Flight-btn btn rounded-pill Flight-font14 Flight-font-semibold rounded py-1 px-4","data-toggle":"modal",onClick:e=>{var l;y(null==(l=null==e?void 0:e.target)?void 0:l.name),S(""),w("flight"),K(""),M(""),K("")},children:"Create Vendor"})})]}),s.jsxs("div",{className:"modalDiv",children:[s.jsx("div",{className:"TableContainer Flight-vm-table Flight-vm-table2 Flight-font13 rounded position-relative",children:s.jsxs(p,{responsive:!0,className:"mb-0",children:[s.jsx("thead",{striped:"true",children:s.jsxs("tr",{children:[s.jsx("th",{children:"Vendor Name"}),s.jsx("th",{children:"Service Type"}),s.jsx("th",{children:"Authentication"}),s.jsx("th",{children:"User Name"}),s.jsx("th",{children:"Password / Token"}),s.jsx("th",{children:"URL"}),s.jsx("th",{className:"text-center",children:"Action"})]})}),s.jsx("tbody",{children:J?s.jsx("tr",{className:"pl-2 Flight-font14",children:s.jsx("td",{colSpan:7,children:s.jsx("div",{className:"Flight-loaderGIF",children:s.jsx(n,{src:r("flight-loader.gif"),className:"img-fluid",alt:"loader"})})})}):(null==q?void 0:q.length)>0?null==q?void 0:q.map((e,l)=>{var t,i,a,o,d;return s.jsxs("tr",{children:[s.jsx("td",{children:null==e?void 0:e.name}),s.jsx("td",{children:"flight"===(null==e?void 0:e.vendorType)?"Flight":"flightstatus"===(null==e?void 0:e.vendorType)?"Flight Status":"webcheckin"===(null==e?void 0:e.vendorType)?"Web Checkin":null}),s.jsx("td",{children:null==(t=null==e?void 0:e.credentials)?void 0:t.type}),s.jsx("td",{children:(null==(i=null==e?void 0:e.credentials)?void 0:i.username)?null==(a=null==e?void 0:e.credentials)?void 0:a.username:"-"}),s.jsx("td",{children:s.jsx("input",{className:"border-0",style:{outline:"none"},type:"password",value:(null==(o=null==e?void 0:e.credentials)?void 0:o.password)||(null==(d=null==e?void 0:e.credentials)?void 0:d.token),readOnly:!0})}),s.jsx("td",{children:null==e?void 0:e.apiUrl}),s.jsx("td",{className:"text-center",children:s.jsxs("div",{className:"d-flex align-items-center justify-content-center",children:[s.jsx(v,{placement:"top",delay:{show:250,hide:400},overlay:ae,children:s.jsx(n,{className:"Flight-cursor-pointer me-2",alt:"url",style:{width:"18px"},src:r("copy-url-icon.svg"),name:"copy",onClick:()=>{navigator.clipboard.writeText(null==e?void 0:e.apiUrl)}})}),s.jsx(n,{id:null==e?void 0:e.sourceId,name:"editModal",className:"Flight-cursor-pointer","data-toggle":"modal",onClick:l=>((e,l)=>{var t,s,i,a,n,r,o,d;H(null==l?void 0:l._id),D("TOKEN"===(null==(t=null==l?void 0:l.credentials)?void 0:t.type)),N(null==(s=null==e?void 0:e.target)?void 0:s.name),S(null==l?void 0:l.name),w(null==l?void 0:l.vendorType),P(null==(i=null==l?void 0:l.credentials)?void 0:i.token),I(null==(a=null==l?void 0:l.credentials)?void 0:a.type),y(null),M("TOKEN"===(null==(n=null==l?void 0:l.credentials)?void 0:n.type)?"":null==(r=null==l?void 0:l.credentials)?void 0:r.password),E("TOKEN"===(null==(o=null==l?void 0:l.credentials)?void 0:o.type)?"":null==(d=null==l?void 0:l.credentials)?void 0:d.username),K(null==l?void 0:l.apiUrl)})(l,e),alt:"edit",src:r("edit-vendor-icon.svg")})]})})]},"vndlist"+l)}):s.jsx("tr",{className:"pl-2 Flight-font14",children:s.jsx("td",{colSpan:7,children:"No Record Found!"})})})]})}),Z>9?s.jsx("div",{className:"p-3 Flight-pagination",children:s.jsx(i,{current:_,total:Math.ceil(Z/10),onPageChange:e=>{B(e)}})}):null]})]})]})}),s.jsxs(g,{className:"Flight-modal",size:"md",show:F||b,onHide:()=>{S(""),w("flight"),P(""),y(null),N(null),M(""),E(""),K(""),L(!1)},children:[s.jsx(g.Header,{closeButton:!0,children:s.jsxs(g.Title,{className:"Flight-font16",children:[F?"Create Vendor":"Edit Vendor"," "]})}),s.jsxs(g.Body,{children:[s.jsxs("div",{className:"mb-2",children:[s.jsx("label",{className:"form-label Flight-font14 mb-1 Flight-font-medium",children:"Name"}),s.jsx(o,{className:"form-control form-home Flight-form-control",placeholder:"Name*",required:!0,value:T.trimStart(),onChange:e=>S(e.currentTarget.value)})]}),s.jsx("div",{className:"mb-2 tl-bsc-select",children:s.jsxs(x.Group,{controlId:"exampleForm.SelectCustom",children:[s.jsx(x.Label,{className:"Flight-font14 mb-1 Flight-font-medium",children:"Vendor Type"}),s.jsx(u,{placeholder:"Select Vendor Type",name:"vendorType",options:[{value:"flight",label:"Flight"},{value:"flightstatus",label:"Flight Status"},{value:"webcheckin",label:"Web Checkin"}],className:"basic-multi-select basic-single",classNamePrefix:"select",value:ee,onChange:e=>{le(e),w(e?e.value:null)}})]})}),s.jsx("div",{className:"mb-2 tl-bsc-select",children:s.jsxs(x.Group,{controlId:"exampleForm.SelectCustom",children:[s.jsx(x.Label,{className:"Flight-font14 mb-1 Flight-font-medium",children:"Type"}),s.jsx(u,{placeholder:"Select Type",name:"colors",options:[{value:"TOKEN",label:"Token"},{value:"PASSWORD",label:"Password"}],className:"basic-multi-select basic-single",classNamePrefix:"select",value:k,onChange:e=>{console.log(e);let l=null==e?void 0:e.value;D("TOKEN"===l),I(e)}})]})}),z?s.jsxs("div",{className:"mb-2",children:[s.jsxs("label",{className:"form-label Flight-font14 mb-1 Flight-font-medium",children:[" ","Token"," "]}),s.jsx(o,{className:"form-control form-home Flight-form-control",placeholder:"Token*",required:!0,value:U.trimStart(),onChange:e=>{var l;return P(null==(l=null==e?void 0:e.target)?void 0:l.value)}})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-2",children:[s.jsxs("label",{className:"form-label Flight-font14 mb-1 Flight-font-medium",children:[" ","Username"," "]}),s.jsx(o,{className:"form-control form-home Flight-form-control",placeholder:"Username*",required:!0,value:A,onChange:e=>{var l;return E(null==(l=null==e?void 0:e.target)?void 0:l.value)}})]}),s.jsxs("div",{className:"mb-2",children:[s.jsxs("label",{className:"form-label Flight-font14 mb-1 Flight-font-medium",children:[" ","Password"," "]}),s.jsx(o,{className:"form-control form-home Flight-form-control",placeholder:"Password*",required:!0,value:O,onChange:e=>{var l;return M(null==(l=null==e?void 0:e.target)?void 0:l.value)}})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"form-label Flight-font14 mb-1 Flight-font-medium",children:["URL"," "]}),s.jsx(o,{className:"form-control form-home Flight-form-control",placeholder:"API URL*",required:!0,value:V.trimStart(),onChange:e=>{const l=e.target.value;if(K(l),""===l)Y("");else{/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_.+~#?&//=]*)/g.test(l)?Y(""):Y("Invalid URL")}}}),X&&s.jsx("p",{className:"error-message text-danger",children:X})]})]}),s.jsxs(g.Footer,{className:"border-top-0 pt-0",children:[R&&s.jsxs("p",{className:"error-message text-danger",children:[s.jsx("strong",{children:"Please!"})," fill all required fields."]}),s.jsx(a,{name:"cancelModal",className:"btn Flight-btn rounded-pill Flight-font-semibold Flight-font13 btn-secondary",onClick:()=>{y(null),N(null),L("")},children:"Cancel"}),s.jsx(a,{name:"createModal",onClick:F?()=>{if(z){if(!U||!V||!T||!k||X)return void L(!0);L(!1),y(null),se({name:T,vendorType:C,apiUrl:V,credentials:{type:k,token:U}})}else{if(!(T&&k&&A&&O&&V))return void L(!0);L(!1),y(null),se({name:T,vendorType:C,apiUrl:V,credentials:{type:k,password:O,username:A}})}S(""),I("TOKEN"),P(""),K("")}:()=>
1{if(z){if(!(T&&U&&V&&k))return void L(!0);L(!1),y(null),ie({vendorId:G,name:T,vendorType:C,apiUrl:V,credentials:{type:k,token:U}})}else{if(!(T&&k&&A&&O&&V))return void L(!0);L(!1),y(null),ie({vendorId:G,name:T,vendorType:C,apiUrl:V,credentials:{type:k,password:O,username:A}})}N(null)},className:"Flight-btn-purple rounded-pill Flight-btn btn Flight-font13 Flight-font-semibold",children:"Save"})]})]})]})};export{f as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.