You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
5.8 KiB
1 lines
5.8 KiB
var I=Object.defineProperty;var D=(t,e,r)=>e in t?I(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var s=(t,e,r)=>D(t,typeof e!="symbol"?e+"":e,r);import{aa as x,C as O,V as U,f as $,_ as N,g,x as b,h as y,j as a,m as v,s as C,t as j,i as m,l as w,w as S,k as E}from"./index-BLqts8WY.js";import{l as k,aL as T}from"./index-MyY_xqVN.js";var V=Object.defineProperty,M=Object.getOwnPropertyDescriptor,h=(t,e,r,i)=>{for(var o=i>1?void 0:i?M(e,r):e,d=t.length-1,l;d>=0;d--)(l=t[d])&&(o=(i?l(e,r,o):l(o))||o);return i&&o&&V(e,r,o),o};let c=class extends U{constructor(){super(...arguments);s(this,"$notify");s(this,"projectId");s(this,"projectName");s(this,"activeDid","");s(this,"apiServer","");s(this,"amountInput","0");s(this,"amountUnitCode","HUR");s(this,"description","");s(this,"expirationDateInput","");s(this,"recipientDid","");s(this,"recipientName","");s(this,"visible",!1);s(this,"libsUtil",k)}async open(r,i){try{this.recipientDid=r,this.recipientName=i;const o=await $();this.apiServer=o.apiServer||"",this.activeDid=o.activeDid||""}catch(o){console.error("Error retrieving settings from database:",o),this.$notify({group:"alert",type:"danger",title:"Error",text:o.message||"There was an error retrieving your settings."},-1)}this.visible=!0}close(){this.visible=!1}changeUnitCode(){const r=Object.keys(this.libsUtil.UNIT_SHORT),i=r.indexOf(this.amountUnitCode);this.amountUnitCode=r[(i+1)%r.length]}increment(){this.amountInput=`${(parseFloat(this.amountInput)||0)+1}`}decrement(){this.amountInput=`${Math.max(0,(parseFloat(this.amountInput)||1)-1)}`}cancel(){this.close(),this.eraseValues()}eraseValues(){this.description="",this.amountInput="0",this.amountUnitCode="HUR"}async confirm(){this.close(),this.$notify({group:"alert",type:"toast",text:"Recording the offer...",title:""},1e3),this.recordOffer(this.description,parseFloat(this.amountInput),this.amountUnitCode,this.expirationDateInput).then(()=>{this.description="",this.amountInput="0"})}async recordOffer(r,i,o="HUR",d){var l,u,n;if(!this.activeDid){this.$notify({group:"alert",type:"danger",title:"Error",text:"You must select an identity before you can record an offer."},7e3);return}if(!r&&!i){this.$notify({group:"alert",type:"danger",title:"Error",text:`You must enter a description or some number of ${this.libsUtil.UNIT_LONG[o]}.`},-1);return}try{const p=await T(this.axios,this.apiServer,this.activeDid,r,i,o,"",d,this.recipientDid,this.projectId);if(p.type==="error"||this.isOfferCreationError(p.response)){const f=this.getOfferCreationErrorMessage(p);console.error("Error with offer creation result:",p),this.$notify({group:"alert",type:"danger",title:"Error",text:f||"There was an error creating the offer."},-1)}else this.$notify({group:"alert",type:"success",title:"Success",text:"That offer was recorded."},5e3)}catch(p){console.error("Error with offer recordation caught:",p);const f=p.userMessage||((n=(u=(l=p.response)==null?void 0:l.data)==null?void 0:u.error)==null?void 0:n.message)||"There was an error recording the offer.";this.$notify({group:"alert",type:"danger",title:"Error",text:f},-1)}}isOfferCreationError(r){var i;return r.status!==201||((i=r.data)==null?void 0:i.error)}getOfferCreationErrorMessage(r){var i,o,d,l,u;return((i=r.error)==null?void 0:i.userMessage)||((o=r.error)==null?void 0:o.error)||((u=(l=(d=r.response)==null?void 0:d.data)==null?void 0:l.error)==null?void 0:u.message)}};h([x],c.prototype,"projectId",2);h([x],c.prototype,"projectName",2);c=h([O],c);const H={key:0,class:"dialog-overlay"},R={class:"dialog"},A={class:"flex flex-row mt-2"},F={class:"mt-4 flex justify-center"},P={class:"grid grid-cols-1 sm:grid-cols-2 gap-2"};function B(t,e,r,i,o,d){const l=g("fa"),u=g("router-link");return t.visible?(b(),y("div",H,[a("div",R,[e[8]||(e[8]=a("h1",{class:"text-xl font-bold text-center mb-4"},"Offer Help",-1)),v(a("input",{type:"text","data-testId":"inputDescription",class:"block w-full rounded border border-slate-400 mb-2 px-3 py-2",placeholder:"Description of what is offered","onUpdate:modelValue":e[0]||(e[0]=n=>t.description=n)},null,512),[[C,t.description]]),a("div",A,[a("span",{class:"rounded-l border border-r-0 border-slate-400 bg-slate-200 w-1/3 text-center text-blue-500 px-2 py-2",onClick:e[1]||(e[1]=n=>t.changeUnitCode())},j(t.libsUtil.UNIT_SHORT[t.amountUnitCode]),1),t.amountInput!=="0"?(b(),y("div",{key:0,class:"border border-r-0 border-slate-400 bg-slate-200 px-4 py-2",onClick:e[2]||(e[2]=n=>t.decrement())},[m(l,{icon:"chevron-left"})])):w("",!0),v(a("input",{"data-testId":"inputOfferAmount",type:"number",class:"w-full border border-r-0 border-slate-400 px-2 py-2 text-center","onUpdate:modelValue":e[3]||(e[3]=n=>t.amountInput=n)},null,512),[[C,t.amountInput]]),a("div",{class:"rounded-r border border-slate-400 bg-slate-200 px-4 py-2",onClick:e[4]||(e[4]=n=>t.increment())},[m(l,{icon:"chevron-right"})])]),a("div",F,[a("span",null,[m(u,{to:{name:"offer-details",query:{amountInput:t.amountInput,description:t.description,offererDid:t.activeDid,projectId:t.projectId,projectName:t.projectName,recipientDid:t.recipientDid,recipientName:t.recipientName,unitCode:t.amountUnitCode}},class:"text-blue-500"},{default:S(()=>e[7]||(e[7]=[E(" Conditions & more options... ")])),_:1},8,["to"])])]),e[9]||(e[9]=a("p",{class:"text-center mt-6 mb-2 italic"}," Sign & Send to publish to the world ",-1)),a("div",P,[a("button",{class:"block w-full text-center text-lg font-bold uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md",onClick:e[5]||(e[5]=(...n)=>t.confirm&&t.confirm(...n))}," Sign & Send "),a("button",{class:"block w-full text-center text-md uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-2 rounded-md",onClick:e[6]||(e[6]=(...n)=>t.cancel&&t.cancel(...n))}," Cancel ")])])])):w("",!0)}const z=N(c,[["render",B]]);export{z as O};
|
|
|