This commit is contained in:
Ruidy 2024-11-15 17:35:33 +01:00
parent 650139d9a1
commit cd10b91e75
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
4 changed files with 76 additions and 68 deletions

View file

@ -1,15 +1,17 @@
package view
templ ReportSection(report *ReportViewModel) {
<div class="grid">
<h2>Your report </h2>
<div>
<a class="outline" role="button" href={ report.PdfUrl } target="_blank">Create PDF</a>
<a href="https://web.whatsapp.com/" target="_blank" rel="noreferrer noopener"><img src="/static/icons/whatsapp.png" width="20px" style="width: 2rem; margin: 0 1rem"/></a>
<div class="flex justify-between items-center mb-4 bg-base-200 p-4 rounded-lg">
<h2 class="text-2xl font-bold">Your report</h2>
<div class="flex items-center gap-2">
<a class="btn btn-primary" href={ report.PdfUrl } target="_blank">Create PDF</a>
<a class="btn btn-ghost" href="https://web.whatsapp.com/" target="_blank" rel="noreferrer noopener">
<img src="/static/icons/whatsapp.png" class="w-8 h-8" alt="Share on WhatsApp"/>
</a>
</div>
</div>
<div class="overflow-auto">
<table class="striped">
<table class="table table-zebra w-full">
<thead>
<tr>
<th scope="col">ID</th>

View file

@ -29,7 +29,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"grid\"><h2>Your report </h2><div><a class=\"outline\" role=\"button\" href=\"")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex justify-between items-center mb-4 bg-base-200 p-4 rounded-lg\"><h2 class=\"text-2xl font-bold\">Your report</h2><div class=\"flex items-center gap-2\"><a class=\"btn btn-primary\" href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -38,7 +38,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" target=\"_blank\">Create PDF</a> <a href=\"https://web.whatsapp.com/\" target=\"_blank\" rel=\"noreferrer noopener\"><img src=\"/static/icons/whatsapp.png\" width=\"20px\" style=\"width: 2rem; margin: 0 1rem\"></a></div></div><div class=\"overflow-auto\"><table class=\"striped\"><thead><tr><th scope=\"col\">ID</th><th scope=\"col\">Name</th><th scope=\"col\">From</th><th scope=\"col\">To</th><th scope=\"col\">Revenue (€)</th><th scope=\"col\">Platform</th><th scope=\"col\">Platform Fees (€)</th><th scope=\"col\">Fees (€)</th><th scope=\"col\">Profit (€)</th></tr></thead> <tbody>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" target=\"_blank\">Create PDF</a> <a class=\"btn btn-ghost\" href=\"https://web.whatsapp.com/\" target=\"_blank\" rel=\"noreferrer noopener\"><img src=\"/static/icons/whatsapp.png\" class=\"w-8 h-8\" alt=\"Share on WhatsApp\"></a></div></div><div class=\"overflow-auto\"><table class=\"table table-zebra w-full\"><thead><tr><th scope=\"col\">ID</th><th scope=\"col\">Name</th><th scope=\"col\">From</th><th scope=\"col\">To</th><th scope=\"col\">Revenue (€)</th><th scope=\"col\">Platform</th><th scope=\"col\">Platform Fees (€)</th><th scope=\"col\">Fees (€)</th><th scope=\"col\">Profit (€)</th></tr></thead> <tbody>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -59,7 +59,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(row.Id)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 31, Col: 16}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 33, Col: 16}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
@ -72,7 +72,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(row.CustomerName)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 34, Col: 28}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 36, Col: 28}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
@ -85,7 +85,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(row.From)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 35, Col: 20}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 37, Col: 20}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
@ -98,7 +98,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(row.To)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 36, Col: 18}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 38, Col: 18}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
@ -111,7 +111,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(row.Total)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 37, Col: 21}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 39, Col: 21}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
@ -124,7 +124,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(row.Platform)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 38, Col: 24}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 40, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
@ -137,7 +137,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(row.PlatformFees)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 39, Col: 28}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 41, Col: 28}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
if templ_7745c5c3_Err != nil {
@ -150,7 +150,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var11 string
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(row.Fee)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 40, Col: 19}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 42, Col: 19}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
if templ_7745c5c3_Err != nil {
@ -163,7 +163,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(row.Profit)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 41, Col: 22}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 43, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil {
@ -181,7 +181,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(report.Total)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 51, Col: 23}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 53, Col: 23}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil {
@ -194,7 +194,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(report.PlatformFees)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 53, Col: 30}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 55, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
if templ_7745c5c3_Err != nil {
@ -207,7 +207,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(report.Fee)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 54, Col: 21}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 56, Col: 21}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
if templ_7745c5c3_Err != nil {
@ -220,7 +220,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var16 string
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(report.Profit)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 55, Col: 24}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 57, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
if templ_7745c5c3_Err != nil {
@ -233,7 +233,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var17 string
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(report.CardTotal)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 62, Col: 27}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 64, Col: 27}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil {
@ -246,7 +246,7 @@ func ReportSection(report *ReportViewModel) templ.Component {
var templ_7745c5c3_Var18 string
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(report.BookingFees)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 64, Col: 29}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/report_section.templ`, Line: 66, Col: 29}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
if templ_7745c5c3_Err != nil {

View file

@ -7,49 +7,55 @@ import (
templ Reports(months []string, m int, year string) {
@layout.BaseLayout() {
<section>
<hgroup>
<h1>Reports</h1>
<h2>Generate monthly and yearly statements</h2>
<section class="container">
<hgroup class="text-center mb-4">
<h1 class="text-2xl font-bold">Reports</h1>
<h2 class="text-gray-600">Generate monthly and yearly statements</h2>
</hgroup>
</section>
<section>
<form hx-get="/reports/do" hx-target="#report">
<fieldset>
<legend>Period</legend>
<label for="month">
<input type="radio" id="month" name="period" value="month" checked/>
Monthly
</label>
<label for="year">
<input type="radio" id="year" name="period" value="year"/>
Yearly
</label>
<label for="year">
Year
<input type="number" id="year" name="year" value={ year }/>
</label>
<label for="month">
Month
<select name="month" id="month" autofocus>
for i, month := range months {
<option
value={ strconv.Itoa(i + 1) }
if i+1 == m {
selected
}
>
{ month }
</option>
}
</select>
</label>
<section class="container mx-auto max-w-2xl">
<form hx-get="/reports/do" hx-target="#report" class="bg-base-200 p-6 rounded-lg shadow-md">
<fieldset class="space-y-4">
<legend class="text-lg font-semibold mb-4">Period</legend>
<div class="flex gap-6 mb-4">
<label for="month" class="flex items-center space-x-2 cursor-pointer">
<input type="radio" id="month" name="period" value="month" checked class="radio radio-primary"/>
<span>Monthly</span>
</label>
<label for="year" class="flex items-center space-x-2 cursor-pointer">
<input type="radio" id="year" name="period" value="year" class="radio radio-primary"/>
<span>Yearly</span>
</label>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<label for="year" class="block">
<span class="block text-sm font-medium mb-1">Year</span>
<input type="number" id="year" name="year" value={ year } class="input input-primary w-full"/>
</label>
<label for="month" class="block">
<span class="block text-sm font-medium mb-1">Month</span>
<select name="month" id="month" autofocus class="select select-primary w-full">
for i, month := range months {
<option
value={ strconv.Itoa(i + 1) }
if i+1 == m {
selected
}
>
{ month }
</option>
}
</select>
</label>
</div>
</fieldset>
<button>
Submit
</button>
<div class="mt-6 flex justify-end">
<button class="btn btn-primary">
Generate Report
</button>
</div>
</form>
</section>
<section id="report"></section>
<section id="report" class="container mx-auto max-w-2xl mt-8"></section>
}
}

View file

@ -46,20 +46,20 @@ func Reports(months []string, m int, year string) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<section><hgroup><h1>Reports</h1><h2>Generate monthly and yearly statements</h2></hgroup></section><section><form hx-get=\"/reports/do\" hx-target=\"#report\"><fieldset><legend>Period</legend> <label for=\"month\"><input type=\"radio\" id=\"month\" name=\"period\" value=\"month\" checked> Monthly</label> <label for=\"year\"><input type=\"radio\" id=\"year\" name=\"period\" value=\"year\"> Yearly</label> <label for=\"year\">Year <input type=\"number\" id=\"year\" name=\"year\" value=\"")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<section class=\"container\"><hgroup class=\"text-center mb-4\"><h1 class=\"text-2xl font-bold\">Reports</h1><h2 class=\"text-gray-600\">Generate monthly and yearly statements</h2></hgroup></section><section class=\"container mx-auto max-w-2xl\"><form hx-get=\"/reports/do\" hx-target=\"#report\" class=\"bg-base-200 p-6 rounded-lg shadow-md\"><fieldset class=\"space-y-4\"><legend class=\"text-lg font-semibold mb-4\">Period</legend><div class=\"flex gap-6 mb-4\"><label for=\"month\" class=\"flex items-center space-x-2 cursor-pointer\"><input type=\"radio\" id=\"month\" name=\"period\" value=\"month\" checked class=\"radio radio-primary\"> <span>Monthly</span></label> <label for=\"year\" class=\"flex items-center space-x-2 cursor-pointer\"><input type=\"radio\" id=\"year\" name=\"period\" value=\"year\" class=\"radio radio-primary\"> <span>Yearly</span></label></div><div class=\"grid grid-cols-1 md:grid-cols-2 gap-4\"><label for=\"year\" class=\"block\"><span class=\"block text-sm font-medium mb-1\">Year</span> <input type=\"number\" id=\"year\" name=\"year\" value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(year)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 30, Col: 61}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 33, Col: 62}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></label> <label for=\"month\">Month <select name=\"month\" id=\"month\" autofocus>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"input input-primary w-full\"></label> <label for=\"month\" class=\"block\"><span class=\"block text-sm font-medium mb-1\">Month</span> <select name=\"month\" id=\"month\" autofocus class=\"select select-primary w-full\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -71,7 +71,7 @@ func Reports(months []string, m int, year string) templ.Component {
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(i + 1))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 37, Col: 36}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 40, Col: 37}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
@ -94,7 +94,7 @@ func Reports(months []string, m int, year string) templ.Component {
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(month)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 42, Col: 16}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/view/reports.templ`, Line: 45, Col: 17}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
@ -105,7 +105,7 @@ func Reports(months []string, m int, year string) templ.Component {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</select></label></fieldset><button>Submit</button></form></section><section id=\"report\"></section>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</select></label></div></fieldset><div class=\"mt-6 flex justify-end\"><button class=\"btn btn-primary\">Generate Report</button></div></form></section><section id=\"report\" class=\"container mx-auto max-w-2xl mt-8\"></section>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}