stubbed simulations page content: set inventory

This commit is contained in:
2026-08-20 00:35:05 -06:00
parent 1330d6efe2
commit ef7bd051fe
2 changed files with 120 additions and 0 deletions
+27
View File
@@ -82,6 +82,7 @@ func Routes(
simulations := r.Group("/:acctID/simulations")
simulations.POST("/sale", response.Handler(as.postNewSale))
simulations.POST("/refund", response.Handler(as.postNewRefund))
simulations.PUT("/shops/:shopID/listings/:listingID/count", response.Handler(as.setListingCount))
}
// POST /
@@ -792,6 +793,32 @@ func (s *accountSubrouter) postNewRefund(c *gin.Context) (response.Response, err
return response.StatusCreated(), nil
}
// PUT /:acctID/simulations/shops/:shopID/listings/:listingID/count
func (s *accountSubrouter) setListingCount(c *gin.Context) (response.Response, error) {
acctID := auth.GetIdentity(c).Account.AccountID
var (
shopID string
listingID string
count int
)
if err := param.Path("shopID", param.Text(&shopID)).
Path("listingID", param.Text(&listingID)).
Form("count", param.Int(&count)).
Unmarshal(c); err != nil {
return nil, err
}
s.log.Debugf("listing inventory set:")
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.StatusOK(), nil
}
func lowerSnakeCase(s accounts.Platform) string {
return strings.ToLower(strings.Join(strings.Split(string(s), " "), "_"))
}
@@ -180,3 +180,96 @@
"#accordion-header" "refund-accordion-header"
"#accordion-body" "refund-accordion-body"
}}
{{/* SET INVENTORY */}}
{{- define "set-inventory-accordion-header" }}
<h2 class="inline-block">
Simulate Set Inventory
</h2>
{{ end }}
{{- define "set-inventory-accordion-body" }}
{{ $acctID := .Identity.Account.AccountID }}
<form
class="flex flex-col items-center gap-[0.75em]"
hx-put="/api/accounts/{{$acctID}}/simulations/shops/{shopID}/listings/{listingID}/count"
hx-vals='js:{
shopID: event.target.children.namedItem("shop-id").value,
listingID: event.target.children.namedItem("listing-id").value
}'
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" "set-inventory-accordion-header"
"#accordion-body" "set-inventory-accordion-body"
}}