Files
crater/public/build/assets/ExchangeRateConverter.2eb3213d.js
Mohit Panjwani 3a1f5a417f new build 506
2021-12-10 17:48:34 +05:30

2 lines
2.7 KiB
JavaScript

import{m as D,c as _,t as j}from"./main.f55cd568.js";import{i as p,k as u,D as l,b3 as A,r as d,ap as F,y as o,o as x,s as N,w as m,c as G,Z as z,b as v,z as L,A as C,t as E,x as b}from"./vendor.e9042f2c.js";const O={key:0},U={class:"text-gray-500 sm:text-sm"},q={class:"text-gray-400 text-xs mt-2 font-light"},J={props:{v:{type:Object,default:null},isLoading:{type:Boolean,default:!1},store:{type:Object,default:null},storeProp:{type:String,default:""},isEdit:{type:Boolean,default:!1},customerCurrency:{type:[String,Number],default:null}},setup(r){const e=r,h=D(),B=_(),g=j(),f=p(!1);let a=p(!1);h.fetchCurrencies();const s=u(()=>B.selectedCompanyCurrency),c=u(()=>h.currencies.find(t=>t.id===e.store[e.storeProp].currency_id)),P=u(()=>s.value.id!==e.customerCurrency);l(()=>e.store[e.storeProp].customer,t=>{R(t)},{deep:!0}),l(()=>e.store[e.storeProp].currency_id,t=>{$(t)},{immediate:!0}),l(()=>e.customerCurrency,t=>{t&&e.isEdit&&w()},{immediate:!0});function w(){P.value&&g.checkForActiveProvider(e.customerCurrency).then(t=>{t.data.success&&(f.value=!0)})}function R(t){t?e.store[e.storeProp].currency_id=t.currency.id:e.store[e.storeProp].currency_id=s.value.id}async function $(t){t!==s.value.id?(!e.isEdit&&t&&await y(t),e.store.showExchangeRate=!0):e.store.showExchangeRate=!1}function y(t){a.value=!0,g.getCurrentExchangeRate(t).then(n=>{n.data&&!n.data.error?e.store[e.storeProp].exchange_rate=n.data.exchangeRate[0]:e.store[e.storeProp].exchange_rate="",a.value=!1}).catch(n=>{a.value=!1})}return A(()=>{e.store.showExchangeRate=!1}),(t,n)=>{const k=d("BaseIcon"),S=d("BaseInput"),I=d("BaseInputGroup"),V=F("tooltip");return r.store.showExchangeRate&&o(c)?(x(),N(I,{key:0,"content-loading":o(a)&&!r.isEdit,label:t.$t("settings.exchange_rate.exchange_rate"),error:r.v.exchange_rate.$error&&r.v.exchange_rate.$errors[0].$message,required:""},{labelRight:m(()=>[f.value&&r.isEdit?(x(),G("div",O,[z(v(k,{name:"RefreshIcon",class:L(`h-4 w-4 text-primary-500 cursor-pointer outline-none ${o(a)?" animate-spin transform rotate-180 cursor-not-allowed pointer-events-none ":""}`),onClick:n[0]||(n[0]=i=>y(r.customerCurrency))},null,8,["class"]),[[V,{content:"Fetch Latest Exchange rate"}]])])):C("",!0)]),default:m(()=>[v(S,{modelValue:r.store[r.storeProp].exchange_rate,"onUpdate:modelValue":n[1]||(n[1]=i=>r.store[r.storeProp].exchange_rate=i),"content-loading":o(a)&&!r.isEdit,addon:`1 ${o(c).code} =`,disabled:o(a),onInput:n[2]||(n[2]=i=>r.v.exchange_rate.$touch())},{right:m(()=>[E("span",U,b(o(s).code),1)]),_:1},8,["modelValue","content-loading","addon","disabled"]),E("span",q,b(t.$t("settings.exchange_rate.exchange_help_text",{currency:o(c).code,baseCurrency:o(s).code})),1)]),_:1},8,["content-loading","label","error"])):C("",!0)}}};export{J as _};