1import{a as j}from"./chunk-PWHNHOFW.js";import{a as $}from"./chunk-VMBIBL2I.js";import{C as G,c as B,f as W,g as E,h as F,j as T,l as N,p as V,q as R}from"./chunk-6PVRY6BZ.js";import{a as u}from"./chunk-OAKXDUFU.js";import{c as D}from"./chunk-PG5BH2CI.js";import{c as k}from"./chunk-UPS6RJ6F.js";import"./chunk-DDBO23QJ.js";import"./chunk-YY6WN6JJ.js";import"./chunk-4L5G6IH5.js";import"./chunk-VNI7HO5L.js";import{i as y,k as x,u as S,v as I}from"./chunk-DCZ4TRWP.js";import{Ic as l,Jb as C,Jc as s,Kc as P,Lb as _,Mb as b,Nb as d,Ob as n,Pb as a,Qb as g,Za as t,ac as f,da as p,oa as w,ob as M,qc as i,rc as m,sc as h,ub as O}from"./chunk-VKGFTMIO.js";import{g as H}from"./chunk-WWX6BADO.js";var v=H(j());function K(r,c){r&1&&(n(0,"tr")(1,"td",16)(2,"div",17),g(3,"i",18),a(),n(4,"p"),i(5),l(6,"translate"),a()()()),r&2&&(t(5),m(s(6,1,"walletPage.table.emptyState")))}function U(r,c){if(r&1&&(n(0,"tr")(1,"td"),i(2),l(3,"currency"),a(),n(4,"td")(5,"p",19),i(6),a()(),n(7,"td"),i(8),a()()),r&2){let e=c.$implicit;t(2),m(P(3,4,e.amount,"Ksh ")),t(3),d("ngClass",e.amountStatus=="credited"?"bg-success-subtle text-success-emphasis":"bg-danger-subtle text-danger-emphasis"),t(),h(" ",e.amountStatus," "),t(2),m(e.comments)}}function q(r,c){if(r&1&&_(0,U,9,7,"tr",null,C),r&2){let e=c.$implicit;b(e.data)}}var z=class r{walletBalance="0";service=p(D);backendService=p($);destroyRef=p(w);transactions=[];voucherForm=new F({voucher:new T("")});constructor(){}ngOnInit(){this.getWalletData(),this.getWalletHistory()}transferMoney(){}
1applyVoucher(){if(this.voucherForm.invalid){this.voucherForm.markAllAsTouched();return}let c=this.voucherForm.value.voucher;this.backendService.redeemVoucher(c).pipe(u(this.destroyRef)).subscribe({next:e=>{e.isSuccess?v.default.fire({icon:"success",title:"Voucher Redeemed",text:`Voucher ${e.message.code} has been redeemed successfully to amount ${e.message.currencyCode} ${e.message.amount}`,timer:3e3,width:"350px",customClass:{popup:"tiny-swal",icon:"tiny-icon"}}):e.isSuccess==!1&&v.default.fire({icon:"error",title:"Voucher Not Redeemed",text:e.message.message,timer:3e3,width:"350px",customClass:{popup:"tiny-swal"}})}}),this.getWalletData()}getWalletData(){let e=this.service.getConfig("userData").userId;this.backendService.getUserWalletData(e).pipe(u(this.destroyRef)).subscribe({next:o=>{o.data&&(this.walletBalance=o.data[0].amount)}})}getWalletHistory(){let e=this.service.getConfig("userData").userId;this.backendService.getWalletHistoryData(e).pipe(u(this.destroyRef)).subscribe({next:o=>{this.transactions=o.data},error:o=>{console.error("Error fetching wallet history:",o)}})}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=M({type:r,selectors:[["app-view-user-profile-wallet"]],decls:42,vars:27,consts:[[1,"wallet-container"],[1,"wallet-header"],[1,"wallet-icon"],[1,"bi","bi-wallet2-fill"],[1,"wallet-balance"],[1,"wallet-actions"],[1,"row","g-4"],[1,"col-12"],[1,"form-group"],[1,"form",3,"ngSubmit","formGroup"],["for","voucher",1,"form-label"],["formControlName","voucher","id","voucher","type","text",1,"form-control",3,"placeholder"],[1,"btn","btn-primary","rounded-pill",3,"click"],[1,"data-table-container"],[1,"table"],[4,"ngIf"],["colspan","3",1,"text-center","empty-state"],[1,"empty-icon"],[1,"bi","bi-bank"],[1,"p-1","rounded","fw-semibold","d-flex","flex-column","justify-content-center","align-items-center",3,"ngClass"]],template:function(e,o){e&1&&(n(0,"div",0)(1,"div",1)(2,"div",2),g(3,"i",3),a(),n(4,"div",4)(5,"h2"),i(6),l(7,"currency"),a(),n(8,"p"),i(9),l(10,"translate"),a()(),n(11,"div",5)(12,"div",6)(13,"div",7)(14,"div",8)(15,"form",9),f("ngSubmit",function(){return o.applyVoucher()}),n(16,"label",10),i(17),l(18,"translate"),a(),g(19,"input",11),l(20,"translate"),a()()(),n(21,"div",7)(22,"button",12),f("click",function(){return o.applyVoucher()}),i(23),l(24,"translate"),a()()()()(),n(25,"div",13)(26,"table",14)(27,"thead")(28,"tr")(29,"th"),i(30),l(31,"translate"),a(),n(32,"th"),i(33),l(34,"translate"),a(),n(35,"th"),i(36),l(37,"translate"),a()()(),n(38,"tbody"),O(39,K,7,3,"tr",15),_(40,q,2,0,null,null,C),a()()()()),e&2&&(t(6),m(P(7,10,o.walletBalance,"Ksh")),t(3),m(s(10,13,"walletPage.balance.title")),t(6),d("formGroup",o.voucherForm),t(2),m(s(18,15,"walletPage.voucher.label")),t(2),d("placeholder",s(20,17,"walletPage.voucher.placeholder")),t(4),h(" ",s(24,19,"walletPage.voucher.button")," "),t(7),m(s(31,21,"walletPage.table.headers.amount")),t(3),m(s(34,23,"walletPage.table.headers.status")),t(3),m(s(37,25,"walletPage.table.headers.comment")),t(3),d("ngIf",o.transactions.length===0),t(),b(o.transactions))},dependencies:[I,y,x,G,N,B,W,E,V,R,S,k],styles:[".wallet-container[_ngcontent-%COMP%] .wallet-header[_ngcontent-%COMP%]{display:flex;align-items:center;border-radius:6px;border:1px solid var(--border-color);margin-bottom:1.5rem;padding:1rem}.wallet-container[_ngcontent-%COMP%] .wallet-header[_ngcontent-%COMP%] .wallet-icon[_ngcontent-%COMP%]{font-size:2.5rem;color:var(--secondary-color);margin-right:1.5rem}.wallet-container[_ngcontent-%COMP%] .wallet-header[_ngcontent-%COMP%] .wallet-icon[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{color:var(--primary-color)}.wallet-container[_ngcontent-%COMP%] .wallet-header[_ngcontent-%COMP%] .wallet-balance[_ngcontent-%COMP%]{flex-grow:1}.wallet-container[_ngcontent-%COMP%] .wallet-header[_ngcontent-%COMP%] .wallet-balance[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{font-size:1.75rem;font-weight:600;margin-bottom:.25rem}.wallet-container[_ngcontent-%COMP%] .wallet-header[_ngcontent-%COMP%] .wallet-balance[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin-bottom:0;color:var(--text-muted)}.wallet-container[_ngcontent-%COMP%] .wallet-header[_ngcontent-%COMP%] .wallet-actions[_ngcontent-%COMP%] .btn-danger[_ngcontent-%COMP%]{padding:.5rem 1.5rem}.wallet-container[_ngcontent-%COMP%] .data-table-container[_ngcontent-%COMP%]{background-color:var(--surface-color);border-radius:6px;box-shadow:0 2px 6px #00000014;overflow:hidden}.wallet-container[_ngcontent-%COMP%] .data-table-container[_ngcontent-%COMP%] table[_ngcontent-%COMP%]{margin-bottom:0}.wallet-container[_ngcontent-%COMP%] .data-table-container[_ngcontent-%COMP%] table[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]{background-color:var(--primary-color-100)}.wallet-container[_ngcontent-%COMP%] .data-table-container[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{background:var(--primary-color-500);color:#fff;font-weight:500;padding:.75rem 1rem}.wallet-container[_ngcontent-%COMP%] .data-table-container[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:.5rem;vertical-align:middle}.wallet-container[_ngcontent-%COMP%] .data-table-container[_ngcontent-%COMP%] table[_ngcontent-%COMP%] .empty-state[_ngcontent-%COMP%]{padding:3rem 1rem;text-align:center}.wallet-container[_ngcontent-%COMP%] .data-table-container[_ngcontent-%COMP%] table[_ngcontent-%COMP%] .empty-state[_ngcontent-%COMP%] .empty-icon[_ngcontent-%COMP%]{font-size:3rem;margin-bottom:1rem;color:var(--text-muted)}.wallet-container[_ngcontent-%COMP%] .data-table-container[_ngcontent-%COMP%] table[_ngcontent-%COMP%] .empty-state[_ngcontent-%COMP%] .empty-icon[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{color:var(--text-muted)}.wallet-container[_ngcontent-%COMP%] .data-table-container[_ngcontent-%COMP%] table[_ngcontent-%COMP%] .empty-state[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{font-size:1.1rem;color:var(--text-muted);margin-bottom:0}@media (max-width: 768px){.wallet-container[_ngcontent-%COMP%] .wallet-header[_ngcontent-%COMP%]{flex-direction:column;text-align:center}.wallet-container[_ngcontent-%COMP%] .wallet-header[_ngcontent-%COMP%] .wallet-icon[_ngcontent-%COMP%]{margin-right:0;margin-bottom:1rem}.wallet-container[_ngcontent-%COMP%] .wallet-header[_ngcontent-%COMP%] .wallet-balance[_ngcontent-%COMP%]{margin-bottom:1.5rem}}.btn-primary[_ngcontent-%COMP%]{background-image:linear-gradient(to right,var(--primary-color-400),var(--primary-color-500),var(--primary-color-600),var(--primary-color-600));color:#fff;border:none}"]})};export{z as WalletComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.