Search Apps Documentation Source Content File Folder Download Copy Actions Download

view_proposals_page.gno

1.18 Kb · 37 lines
 1package basedao
 2
 3import (
 4	"gno.land/p/moul/md"
 5	"gno.land/p/nt/ufmt/v0"
 6	"gno.land/p/samcrew/daokit"
 7)
 8
 9func (d *DAOPrivate) ProposalsPageView(path string) string {
10	return d.ProposalsHeaderView() +
11		d.ProposalsView(path)
12}
13
14func (d *DAOPrivate) ProposalsHeaderView() string {
15	pkgPath := d.Realm.PkgPath()
16	linkPath := getLinkPath(pkgPath)
17	name := d.GetProfileString(d.Realm.Address(), "DisplayName", "DAO")
18	s := ""
19	s += ufmt.Sprintf("# %s - Proposals\n\n", name)
20	s += md.Link("> Go to the Proposal history 📜", ufmt.Sprintf("%s:%s", linkPath, PROPOSAL_HISTORY_PATH)) + "\n\n"
21	s += md.Link("Add a new proposal 🗳️", ufmt.Sprintf("%s$help", linkPath)) + "\n\n"
22	s += ufmt.Sprintf("\n--------------------------------\n")
23	return s
24}
25
26func (d *DAOPrivate) ProposalsView(path string) string {
27	activeProposals := d.Core.Proposals.GetProposals(
28		func(p daokit.Proposal) bool {
29			return p.Status == daokit.ProposalStatusOpen || p.Status == daokit.ProposalStatusPassed
30		},
31	)
32	s := ""
33	s += ufmt.Sprintf("## Active Proposals 🗳️ (%d)\n\n", activeProposals.Tree.Size())
34	s += d.RenderProposalsTable(path, activeProposals)
35	s += ufmt.Sprintf("\n--------------------------------\n")
36	return s
37}