stubbed simulations page content: refund

This commit is contained in:
2026-08-19 23:19:16 -06:00
parent fdc8aaea6a
commit 53bbf85fe1
2 changed files with 119 additions and 2 deletions
+27
View File
@@ -81,6 +81,7 @@ func Routes(
simulations := r.Group("/:acctID/simulations") simulations := r.Group("/:acctID/simulations")
simulations.POST("/sale", response.Handler(as.postNewSale)) simulations.POST("/sale", response.Handler(as.postNewSale))
simulations.POST("/refund", response.Handler(as.postNewRefund))
} }
// POST / // POST /
@@ -765,6 +766,32 @@ func (s *accountSubrouter) postNewSale(c *gin.Context) (response.Response, error
return response.StatusCreated(), nil return response.StatusCreated(), nil
} }
// POST /:acctID/simulations/refund
func (s *accountSubrouter) postNewRefund(c *gin.Context) (response.Response, error) {
acctID := auth.GetIdentity(c).Account.AccountID
var (
shopID string
listingID string
count int
)
if err := param.Form("shop-id", param.Text(&shopID)).
Form("listing-id", param.Text(&listingID)).
Form("count", param.Int(&count)).
Unmarshal(c); err != nil {
return nil, err
}
s.log.Debugf("refund posted:")
s.log.Debugf(" account: %d", acctID)
s.log.Debugf(" shop: %s", shopID)
s.log.Debugf(" listing: %s", listingID)
s.log.Debugf(" count: %d", count)
return response.StatusCreated(), nil
}
func lowerSnakeCase(s accounts.Platform) string { func lowerSnakeCase(s accounts.Platform) string {
return strings.ToLower(strings.Join(strings.Split(string(s), " "), "_")) return strings.ToLower(strings.Join(strings.Split(string(s), " "), "_"))
} }
@@ -3,6 +3,7 @@
</h1> </h1>
{{/* SALES */}}
{{- define "sale-accordion-header" }} {{- define "sale-accordion-header" }}
<h2 class="inline-block"> <h2 class="inline-block">
Simulate Sale Simulate Sale
@@ -72,7 +73,7 @@
<div> <div>
{{ component "button" {{ component "button"
"Text" "Simulate Sale" "Text" "Submit"
"Background" true "Background" true
"Class" "m-0" "Class" "m-0"
}} }}
@@ -81,7 +82,7 @@
{{ end }} {{ end }}
{{ component "accordion" {{ component "accordion"
"Name" "sale" "Name" "simulate"
"Open" true "Open" true
"Class" ` "Class" `
mx-[1em] mx-[1em]
@@ -90,3 +91,92 @@
"#accordion-header" "sale-accordion-header" "#accordion-header" "sale-accordion-header"
"#accordion-body" "sale-accordion-body" "#accordion-body" "sale-accordion-body"
}} }}
{{/* REFUNDS */}}
{{- define "refund-accordion-header" }}
<h2 class="inline-block">
Simulate Refund
</h2>
{{ end }}
{{- define "refund-accordion-body" }}
{{ $acctID := .Identity.Account.AccountID }}
<form
class="flex flex-col items-center gap-[0.75em]"
hx-post="/api/accounts/{{$acctID}}/simulations/refund"
hx-swap="none"
>
<select
name="shop-id"
class="bg-background"
required
>
<option value="shop-1">
Shop 1
</option>
<option value="shop-2">
Shop 2
</option>
<option value="shop-3">
Shop 3
</option>
<option value="shop-4">
Shop 4
</option>
<option value="shop-5">
Shop 5
</option>
</select>
<select
name="listing-id"
class="bg-background"
required
>
<option value="listing-1">
Listing 1
</option>
<option value="listing-2">
Listing 2
</option>
<option value="listing-3">
Listing 3
</option>
<option value="listing-4">
Listing 4
</option>
<option value="listing-5">
Listing 5
</option>
</select>
<input
class="p-[0.5em] border-medium border-border rounded-lg bg-background"
type="number"
min="1"
max="1000000000"
name="count"
value="0"
required
/>
<div>
{{ component "button"
"Text" "Submit"
"Background" true
"Class" "m-0"
}}
</div>
</form>
{{ end }}
{{ component "accordion"
"Name" "simulate"
"Class" `
mx-[1em]
mb-[1em]
`
"#accordion-header" "refund-accordion-header"
"#accordion-body" "refund-accordion-body"
}}