PageSourceSearch

https://lender.sparkil.org/assets/projects-aMuvfwTW.js

js sparkil.org collected 2026-09-26 07:53:19 UTC 2,676 bytes, 1 lines download raw bytes

1import{Z as g}from"./main-QFd2JyzA.js";import{f as n,h as i,u as f}from"./payments-DXXwx96o.js";import{u as d}from"./useFunctions-Dbtk2qdY.js";const p=250,l={fetchProjects(e){const t=!e||e=="all"?"":`&categories=${e}`;return n(i.get(`/projects?limit=${p}&populate=loans${t}`,{params:{}}),!1)},fetchProject(e){return n(i.get(`/projects/${e}/?`,{params:{}}))},fetchProjectSupporters(e){return n(i.get(`/projects/${e}/supporters/?`,{params:{}}))},lendProject(e,t){return n(i.post(`/projects/${e}/lend`,t,{params:{removeLang:!0}}),!1)},pledgeProject(e){return n(i.post("/hooks/pledge",e,{params:{removeLang:!0}}),!1)}},j={fetchCategories(){return n(i.get("/categories?",{params:{}}))}},S=g("projects",{state:()=>({projects:null,categories:null,flatCategories:null,filteredProjects:[],selectedCategory:"",currentProject:null,currentProjectSupporters:null,loading:!1}),actions:{async refetch(){this.loading=!1,this.selectedCategory="all"},async fetchProjects(e="all"){this.loading=!0,this.projects=null;const{onSuccess:t,onError:r}=l.fetchProjects(e);r(()=>{this.loading=!1}),t(o=>{const{getDaysLeft:s}=d();this.projects=o.data.reduce((a,c)=>c.summary.total_goal_complete!==100&&s(c.ends_on)!=0?[c,...a]:[...a,c],[]),this.loading=!1})},fetchCategories(){this.loading=!0;const{onSuccess:e,onError:t}=j.fetchCategories();t(()=>{this.loading=!1}),e(r=>{this.categories=r.data,this.setFlatCategories(),this.loading=!1})},selectCategory(e){this.selectedCategory=e.name,this.fetchProjects(e.slug)},findCategoryBySlug(e){var r;let t=null;return(r=this.categories)==null||r.forEach(o=>{const s=o.children.find(a=>a.slug==e);s&&(t=s)}),t},fetchProject(e){this.loading=!0;const{onSuccess:t,onError:r}=l.fetchProject(e);return r(()=>{this.loading=!1}),new Promise(o=>{t(s=>{this.currentProject=s.data,this.loading=!1,o(s.data)})})},fetchProjectSupporters(e){this.loading=!0;const{onSuccess:t,onError:r}=l.fetchProjectSupporters(e);return new Promise(o=>{r(()=>{this.loading=!1}),t(s=>{this.currentProjectSupporters=s.data,this.loading=!1,o(s.data)})})},setFlatCategories(){this.flatCategories=[],this.categories&&this.categories.forEach(e=>{var t;this.flatCategories=(t=this.flatCategories||[])==null?void 0:t.concat(...e.children)})},lendProject(e,t){this.loading=!0;const{onSuccess:r,onError:o}=l.lendProject(e,t);return new Promise((s,a)=>{o(c=>{this.loading=!1,a(c)}),r(c=>{this.loading=!1;const h=f();t.payments.filter(u=>u.type==="wallet").forEach(u=>{h.updateBalance(u.amount,u.wallet)}),s(c)})})},pledgeProject(e){this.loading=!0;const{onSuccess:t,onError:r}=l.pledgeProject(e);return new Promise((o,s)=>{r(a=>{this.loading=!1,s(a)}),t(a=>{this.loading=!1,o(a)})})}}});export{S as u};

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.