%PDF- %PDF-
Direktori : /home/opti/public_html/startup-life/assets/ |
Current File : /home/opti/public_html/startup-life/assets/SingleSoldService-3dd0d98b.js |
import{u as M,j as a,C as U,Q as u,e as K,F as Y,r as z}from"./index-5492fbe1.js";import{D as X}from"./dashboard-page-layout-2cec2413.js";import{u as Z}from"./get-all-accounts.api-23fb4193.js";import{C as p}from"./index-2c4b8b3c.js";import{M as ee}from"./Modal-01a2ce69.js";import{P as ae}from"./Paper-26f2abc8.js";import{B as te}from"./Box-263f925f.js";import{B as C}from"./Button-e32596e7.js";import{D as se}from"./dashboard-footer-navigation-f658b457.js";import{u as ne}from"./index-9f8785a2.js";import{u as oe}from"./update-stream-user.api-f76bb8dc.js";import{u as re}from"./get-all-startuplife-users.api-644aad92.js";import{u as ie}from"./post-notification.api-d7cee9b0.js";import{h as le}from"./moment-a9aaa855.js";import{u as ce}from"./useQuery-0abbcf43.js";import"./motion-4a110d9b.js";import"./useTheme-0dfa0cbc.js";import"./useForkRef-ff55d5c8.js";import"./TransitionGroupContext-29effe25.js";import"./setPrototypeOf-0bb37fbe.js";import"./useSlotProps-b42d44e4.js";import"./ButtonBase-0400401d.js";import"./assertThisInitialized-081f9914.js";import"./joinClasses-adfcc520.js";import"./isNativeReflectConstruct-061ae640.js";const de=({open:d,handleClose:x,job_poster:h})=>{const l=M();console.log(h);const{data:s,isLoading:n,isError:r}=Z();return console.log(s),a.jsx(ee,{open:d,onClose:x,"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",children:a.jsxs(ae,{className:"ModalBody w-[400px] mx-auto p-[20px] mt-[200px]",children:[a.jsx("div",{className:"cancel cursor-pointer text-[1.7rem] text-right mb-[10px]",onClick:()=>x(!1),children:"x"}),a.jsx(p,{appear:n,children:a.jsx(U,{})}),a.jsx(p,{appear:r,children:"ERR: INTERNET_CONNECTION_REFUSED"}),a.jsx(p,{appear:!n&&!r&&s,children:a.jsxs(te,{className:"bodyContain flex flex-col gap-[20px]",children:[a.jsx(C,{type:"button",className:"!bg-[#A8CF45]",variant:"contained",fullWidth:!0,onClick:()=>{const y=s.filter(N=>N.user_email===h.email);if(y.length===0){u.error("This user has not created a wallet yet. You can chat him up to negotiate");return}l(`/financials/transfer?status=wallet-to-wallet-transfer&recipient-wallet-email=${y[0].user_email}&recipient-wallet-id=${y[0].userId}`)},sx:{bgColor:""},children:"Wallet To Wallet Transfer"}),a.jsx(C,{type:"button",className:"!bg-[#A8CF45]",variant:"contained",fullWidth:!0,sx:{bgColor:"bg-[#A8CF45]"},children:"Bank Transfer"}),a.jsx(C,{type:"button",className:"!bg-[#A8CF45]",variant:"contained",fullWidth:!0,sx:{bgColor:"bg-[#A8CF45]"},children:"Card Transfer"})]})})]})})},me=({id:d})=>ce({queryFn:async()=>{var l;try{const n=(await K.get(`/service/get-single/${d}`)).data;return console.log(n),n}catch(s){return(l=s.response)==null?void 0:l.data}},queryKey:["GET_SINGLE_SERVICES",d],enabled:!!d}),De=()=>{var S,T,I,A;const d=Y(),[x,h]=z.useState(!1),l=M(),{client:s,decoded:n}=ne(),{data:r}=re(),{mutateAsync:y}=oe(),{data:N,isLoading:_,isError:k}=me({id:d.id}),e=N==null?void 0:N.data;console.log(e);const{mutateAsync:L}=ie(),g=JSON.parse(localStorage.getItem("user")),W=[{title:"Service require",info:e==null?void 0:e.kind},{title:"Time Needed",info:a.jsx("p",{className:"bg-[#EBECFE] text-[#27AE60] !py-1 text-sm !px-4 w-fit rounded-full",children:le(e==null?void 0:e.availability).add(1,"days").calendar()})},{title:"Vendor's Name",info:((S=e==null?void 0:e.account)==null?void 0:S.firstName)+" "+((T=e==null?void 0:e.account)==null?void 0:T.lastName)},{title:"Location",info:e==null?void 0:e.location},{title:"Description",info:e==null?void 0:e.description}],G=async o=>{var m;try{console.log(o);const t=(m=r==null?void 0:r.data)==null?void 0:m.filter(w=>w.email===o)[0];console.log(t);const b=t.id.toString();y({userId:b}).then(async w=>{var B,F,v,$,q,O;const Q={type:"messaging",members:{$in:[n.user_id]}},V=[{last_message_at:-1}],R=await s.queryChannels(Q,V,{watch:!0,state:!0,limit:30});console.log(b),console.log(n.user_id),console.log(R);const f=R.filter(c=>c.id.includes(n.user_id)&&c.id.includes(b)&&c.id.includes("chat_with_profile_user"));if(console.log(f),f.length>0){u.success("you will be redirected to the previous chat channel established with this user");const D=await(await s.channel("messaging",(F=(B=f[0])==null?void 0:B.data)==null?void 0:F.id,{name:(v=f==null?void 0:f.data)==null?void 0:v.name,private:!0})).watch();console.log(D),l(`/startup-messaging-channel/${D.channel.id}`);return}const j=await s.channel("messaging","chat_with_profile_user_"+b+"_"+n.user_id,{name:t.email,Image:"",members:[n.user_id],private:!0}),i=await j.watch(),H=await s.channel("messaging",($=i==null?void 0:i.channel)==null?void 0:$.id,{name:(q=i==null?void 0:i.channel)==null?void 0:q.name});let E=[];for(const c in w.users)E=[...E,w.users[parseInt(c)].id];const J=await H.addMembers([...E]);console.log(J),console.log("Channel created successfully:",i),L({message:`${g==null?void 0:g.email} sent you message regarding the job you posted.`,email:[t==null?void 0:t.email],to:[b],fullName:[`${t==null?void 0:t.firstName} ${t==null?void 0:t.lastName}`],channelId:(O=j==null?void 0:j.data)==null?void 0:O.id}).then(()=>{u.success("private channel created successfully."),u.success("Note: that channel will not be recreated if channel name already exist."),l(`/startup-messaging-channel/${i.channel.id}`)}).catch(c=>{console.log(c),u.error("error while creating channel")}),u.success("private channel created successfully."),u.success("Note: that channel will not be recreated if channel name already exist."),l(`/startup-messaging-channel/${i.channel.id}`)})}catch(t){console.error("Error creating channel:",t)}},P=((I=e==null?void 0:e.account)==null?void 0:I.email)!==(g==null?void 0:g.email);return a.jsxs(X,{children:[a.jsxs("section",{className:"px-5",children:[a.jsx("div",{className:"flex justify-between",children:a.jsx("header",{className:"text-[#537473] font-bold !mb-5",children:"Offer service"})}),a.jsx(p,{appear:_,children:a.jsx(U,{})}),a.jsx(p,{appear:k,children:"ERROR: INTERNET_CONNECTION_REFUSED"}),a.jsxs(p,{appear:!_&&!!e,children:[a.jsx("div",{className:"grid grid-cols-3 !gap-5 !mt-5 place-items-start",children:W.map((o,m)=>a.jsxs("div",{className:"bg-white space-y-3 rounded-xl max-w-[326px] w-full !p-5",children:[a.jsx("h4",{className:"text-[#828282]",children:o.title}),a.jsx("p",{className:"font-semibold",children:o.info})]},m))}),a.jsx(p,{appear:!!P,children:a.jsx(se,{backBtnText:"Negotiate",continueEventHandler:()=>h(!0),cancelEventHandler:()=>{var o;return G((o=e==null?void 0:e.account)==null?void 0:o.email)},continueBtnText:"Buy"})})]})]}),a.jsx(de,{open:x,job_poster:(A=r==null?void 0:r.data)==null?void 0:A.filter(o=>{var m;return o.email===((m=e==null?void 0:e.account)==null?void 0:m.email)})[0],handleClose:h})]})};export{De as default};