"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[297],{297:function(e,t,s){s.r(t),s.d(t,{default:function(){return CardDeleteView}});var n=s(85893);let TrashIcon=e=>(0,n.jsx)("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})});var l=s(60802),r=s(5233),a=s(93967),d=s.n(a),confirmation=e=>{let{onCancel:t,onDelete:s,icon:a,title:c="text-delete",description:u="text-card-delete-confirm",cancelBtnText:i="text-cancel",deleteBtnText:o="text-delete",cancelBtnClassName:m,deleteBtnClassName:f,cancelBtnLoading:x,deleteBtnLoading:h}=e,{t:C}=(0,r.$G)("common");return(0,n.jsx)("div",{className:"flex h-full min-h-screen w-screen flex-col justify-center bg-light p-7 text-left dark:bg-dark-250 xs:h-auto xs:min-h-0 sm:w-96 md:rounded-xl",children:(0,n.jsx)("div",{className:"h-full w-full text-center",children:(0,n.jsxs)("div",{className:"flex h-full flex-col justify-between",children:[(0,n.jsx)("span",{className:"m-auto mt-4 text-brand",children:a||(0,n.jsx)(TrashIcon,{className:"h-14 w-14"})}),(0,n.jsx)("p",{className:"mt-4 mb-1 text-xl font-bold text-black dark:text-light",children:C(c)}),(0,n.jsx)("p",{className:"mb-1 px-6 py-2 leading-relaxed",children:C(u)}),(0,n.jsxs)("div",{className:"mt-7 flex w-full items-center justify-between space-x-4 rtl:space-x-reverse",children:[(0,n.jsx)("div",{className:"w-1/2",children:(0,n.jsx)(l.Z,{onClick:t,isLoading:x,disabled:x,className:d()("w-full",m),children:C(i)})}),(0,n.jsx)("div",{className:"w-1/2",children:(0,n.jsx)(l.Z,{onClick:s,isLoading:h,disabled:h,className:d()("w-full rounded bg-red-600 py-2 px-4 text-center text-base font-semibold text-light shadow-md transition duration-200 ease-in hover:bg-red-700 focus:bg-red-700 focus:outline-none",f),children:C(o)})})]})]})})})},c=s(45009),u=s(65700);function CardDeleteView(){let{data:{card_id:e}}=(0,c.X9)(),{closeModal:t}=(0,c.SO)(),{deleteCard:s,isLoading:l}=(0,u.Li)();return(0,n.jsx)(confirmation,{onCancel:t,onDelete:function(){e&&s({id:e})},deleteBtnLoading:l})}},65700:function(e,t,s){s.d(t,{Kj:function(){return useCards},Li:function(){return useDeleteCard},VR:function(){return useDefaultPaymentMethod},ie:function(){return useAddCards}});var n=s(88767),l=s(77649),r=s(28319),a=s(86501),d=s(45009),c=s(5233),u=s(99930);function useCards(e,t){let{isAuthorized:s}=(0,u.P)(),{data:a,isLoading:d,error:c}=(0,n.useQuery)([l.P.CARDS,e],()=>r.Z.cards.all(e),{enabled:s,...t});return{cards:null!=a?a:[],isLoading:d,error:c}}let useDeleteCard=()=>{let e=(0,n.useQueryClient)(),{t}=(0,c.$G)(),{closeModal:s}=(0,d.SO)(),{mutate:u,isLoading:i,error:o}=(0,n.useMutation)(r.Z.cards.remove,{onSuccess:()=>{s(),a.ZP.success(t("common:text-card-successfully-deleted"))},onSettled:()=>{e.invalidateQueries(l.P.CARDS)}});return{deleteCard:u,isLoading:i,error:o}};function useAddCards(e){let{t}=(0,c.$G)(),{closeModal:s}=(0,d.SO)(),u=(0,n.useQueryClient)(),{mutate:i,isLoading:o,error:m}=(0,n.useMutation)(r.Z.cards.addPaymentMethod,{onSuccess:()=>{s(),a.ZP.success(t("common:text-card-successfully-add"),{id:"success"})},onError:e=>{let{response:{data:s}}=null!=e?e:{};a.ZP.error(t(null==s?void 0:s.message),{id:"error"})},onSettled:()=>{u.invalidateQueries(l.P.CARDS)}});return{addNewCard:i,isLoading:o,error:m}}function useDefaultPaymentMethod(){let{t:e}=(0,c.$G)(),t=(0,n.useQueryClient)(),{mutate:s,isLoading:d,error:u}=(0,n.useMutation)(r.Z.cards.makeDefaultPaymentMethod,{onSuccess:()=>{a.ZP.success(e("common:text-set-default-card-message"))},onSettled:()=>{t.invalidateQueries(l.P.CARDS)}});return{createDefaultPaymentMethod:s,isLoading:d,error:u}}}}]);