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.
2 lines
5.8 KiB
2 lines
5.8 KiB
2 weeks ago
|
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.d
|