import{u as y,c as u,b as t,t as l,a as i,g as e,i as p,w as f,d as _,l as h,o as c,P as v}from"./app-CYVHboi-.js";import{_ as V}from"./SecondaryButton-CHQvCfls.js";import{_ as k}from"./LoadingButton-CH88QwYm.js";import{_ as C}from"./CheckBox-FJj299Iw.js";import{_ as b}from"./Input-VvJHlcSh.js";import{_ as P}from"./Textarea-D40HahXW.js";import"./browser-BwNzv7vE.js";import"./InputError-u5FIXCwc.js";import"./Keyboard-VWzCpVN-.js";import"./composable-DK3kcOvi.js";import"./InputLabel-dHPaqRUC.js";const S={class:"border-b border-gray-200 px-6 py-4 dark:border-gray-700"},U={class:"sm:flex sm:items-baseline sm:justify-between"},A={class:"sm:w-0 sm:flex-1"},N={class:"text-focus text-base font-semibold"},x={class:"text-mute mt-1 truncate text-sm"},B={class:"grid grid-cols-6 gap-6 p-6"},T={class:"col-span-full"},j={class:"col-span-full"},D={key:0,class:"col-span-full"},E={class:"mb-2 font-bold"},F={key:0,class:"mt-6"},G={class:"mt-1 text-sm font-bold"},M={class:"flex flex-row justify-end rounded-b-lg bg-gray-100 px-6 py-4 text-end dark:bg-gray-950"},X={__name:"Topup",props:["current"],emits:["close","done"],setup(a,{emit:g}){const d=a,m=g,o=y({amount:null,description:null,award_points:null,use_award_points:!1,gift_card_id:d.current.id}),$=()=>{o.reset(),m("close")};function w(){console.log("gift_cards.topup",d.current),o.post(v("gift_cards.topup",d.current.id),{onSuccess:()=>{o.reset(),m("done"),m("close")}})}return(s,r)=>(c(),u("form",{onSubmit:h(w,["prevent"])},[t("div",S,[t("div",U,[t("div",A,[t("h1",N,l(s.$t("Topup Gift Card")),1),t("p",x,l(s.$t("Please fill the form below to {action} {record}.",{record:s.$t("gift card"),action:s.$t("add balance to")})),1)])])]),t("div",B,[t("div",T,[i(e(b),{id:"amount",type:"number",label:s.$t("Amount"),modelValue:e(o).amount,"onUpdate:modelValue":r[0]||(r[0]=n=>e(o).amount=n),error:e(o).errors.amount},null,8,["label","modelValue","error"])]),t("div",j,[i(e(P),{label:s.$t("Description"),modelValue:e(o).description,"onUpdate:modelValue":r[1]||(r[1]=n=>e(o).description=n),error:s.$page.props.errors.description},null,8,["label","modelValue","error"])]),s.$page.props.settings.loyalty?.customer?.spent&&s.$page.props.settings.loyalty?.customer?.points&&a.current?.customer&&a.current.customer.points>0?(c(),u("div",D,[t("p",E,l(a.current?.customer.company||a.current?.customer.name),1),i(e(C),{label:s.$t("Use Award Points"),checked:e(o).use_award_points,"onUpdate:checked":r[2]||(r[2]=n=>e(o).use_award_points=n),error:s.$page.props.errors.use_award_points},null,8,["label","checked","error"]),e(o).use_award_points?(c(),u("div",F,[i(e(b),{min:1,type:"number",id:"award_points",label:s.$t("Award Points"),modelValue:e(o).award_points,"onUpdate:modelValue":r[3]||(r[3]=n=>e(o).award_points=n),max:a.current?.customer.points,error:e(o).errors.award_points},null,8,["label","modelValue","max","error"]),t("div",G,l(s.$t("Available Points"))+": "+l(a.current?.customer.points),1)])):p("",!0)])):p("",!0)]),t("div",M,[i(e(V),{onClick:$},{default:f(()=>[_(l(s.$t("Cancel")),1)]),_:1}),i(e(k),{class:"ms-3",loading:e(o).processing},{default:f(()=>[_(l(s.$t("Save")),1)]),_:1},8,["loading"])])],32))}};export{X as default};
