diff --git a/internal/domains/accounts/mocks.go b/internal/domains/accounts/mocks.go index f5421c9..0add306 100644 --- a/internal/domains/accounts/mocks.go +++ b/internal/domains/accounts/mocks.go @@ -322,7 +322,6 @@ func (db *Store) CreateMockListing(ctx context.Context, listing MockListing) (Mo return listing, nil } -// UpdateMockListing updates a mock listing, but not it's count func (db *Store) UpdateMockListing(ctx context.Context, listing MockListing) error { _, listingTableName, err := getMockShopAndListingsTableNames(listing.Platform) if err != nil { @@ -338,7 +337,8 @@ func (db *Store) UpdateMockListing(ctx context.Context, listing MockListing) err SET sku = @sku, name = @name, - description = @description + description = @description, + "count" = @count WHERE account_id = @account_id AND shop_id = @shop_id @@ -353,6 +353,7 @@ func (db *Store) UpdateMockListing(ctx context.Context, listing MockListing) err "sku": listing.SKU, "name": listing.Name, "description": listing.Description, + "count": listing.Count, }, ) if err != nil { @@ -365,6 +366,7 @@ func (db *Store) UpdateMockListing(ctx context.Context, listing MockListing) err return nil } +// TODO: will have to be updated once we start creating mock sync groups func (db *Store) DeleteMockListing(ctx context.Context, ids AccountShopListingIDs) error { _, listingTableName, err := getMockShopAndListingsTableNames(ids.Platform) if err != nil { diff --git a/internal/server/api/accounts/router.go b/internal/server/api/accounts/router.go index 05d5402..d019d0a 100644 --- a/internal/server/api/accounts/router.go +++ b/internal/server/api/accounts/router.go @@ -279,6 +279,7 @@ func (s *accountSubrouter) addMockListing(c *gin.Context) (response.Response, er name string sku string description string + count int ) err := param.Path("platform", param.Platform(&platform)). @@ -286,6 +287,7 @@ func (s *accountSubrouter) addMockListing(c *gin.Context) (response.Response, er Form("name", param.Text(&name)). Form("sku", param.Text(&sku)). Form("description", param.Text(&description)). + Form("count", param.Int(&count)). Unmarshal(c) if err != nil { return nil, err @@ -300,6 +302,7 @@ func (s *accountSubrouter) addMockListing(c *gin.Context) (response.Response, er Name: name, SKU: sku, Description: description, + Count: int64(count), }, ) if err != nil { @@ -320,6 +323,7 @@ func (s *accountSubrouter) updateMockListing(c *gin.Context) (response.Response, name string sku string description string + count int ) err := param.Path("platform", param.Platform(&platform)). @@ -328,6 +332,7 @@ func (s *accountSubrouter) updateMockListing(c *gin.Context) (response.Response, Form("name", param.Text(&name)). Form("sku", param.Text(&sku)). Form("description", param.Text(&description)). + Form("count", param.Int(&count)). Unmarshal(c) if err != nil { return nil, err @@ -342,6 +347,7 @@ func (s *accountSubrouter) updateMockListing(c *gin.Context) (response.Response, Name: name, SKU: sku, Description: description, + Count: int64(count), }, ) if err != nil { diff --git a/templates/pages/accounts/{acctID.int64}/platforms/{platform}/shops/mocks/{shopID}/index.html.tmpl b/templates/pages/accounts/{acctID.int64}/platforms/{platform}/shops/mocks/{shopID}/index.html.tmpl index 4de97a6..63e1075 100644 --- a/templates/pages/accounts/{acctID.int64}/platforms/{platform}/shops/mocks/{shopID}/index.html.tmpl +++ b/templates/pages/accounts/{acctID.int64}/platforms/{platform}/shops/mocks/{shopID}/index.html.tmpl @@ -35,14 +35,16 @@ listingID, name, sku, - description + description, + count ) send hide to #new-listing-form send show( listingID: listingID, name: name, sku: sku, - description: description + description: description, + count: count ) to #edit-listing-form on startEditingNewListing @@ -72,6 +74,7 @@ set the value of the first in me to '' set the value of the first in me to '' set the value of the first in me to '' + set the value of the first in me to '0' on show remove .hidden from me remove @disabled from @@ -87,7 +90,6 @@ type="text" name="name" required - minlength="5" placeholder="What's in a name..." class="bg-accent p-[0.25em] rounded-sm" /> @@ -107,10 +109,20 @@ type="text" name="description" required - minlength="10" placeholder="Anything will do..." class="bg-accent p-[0.25em] rounded-sm" /> + + {{ component "button" "Text" "Save" "Class" "self-center p-[1em] col-span-2" @@ -141,11 +153,13 @@ set the value of the first in me to '' set the value of the first in me to '' set the value of the first in me to '' + set the value of the first in me to '' on show( listingID, name, sku, - description + description, + count ) set :listingID to listingID remove .hidden from me @@ -155,6 +169,7 @@ set the value of the first in me to name set the value of the first in me to sku set the value of the first in me to description + set the value of the first in me to count set the innerHTML of the
in me to ('Editing: ' + name) " > @@ -168,7 +183,6 @@ type="text" name="name" required - minlength="5" placeholder="What's in a name..." class="bg-accent p-[0.25em] rounded-sm" /> @@ -188,10 +202,20 @@ type="text" name="description" required - minlength="10" placeholder="Anything will do..." class="bg-accent p-[0.25em] rounded-sm" /> + + in the closest