mock sync group editing: made tables columns more consistent; initialize database rows upon editing

This commit is contained in:
2026-02-20 23:04:18 -07:00
parent 5ec4fe67b0
commit 4352062227
9 changed files with 479 additions and 232 deletions
@@ -0,0 +1,21 @@
BEGIN;
DROP TABLE mock.shop_amazon_sync_group_editing_listings;
DROP TABLE mock.shop_big_cartel_sync_group_editing_listings;
DROP TABLE mock.shop_ebay_sync_group_editing_listings;
DROP TABLE mock.shop_ecwid_sync_group_editing_listings;
DROP TABLE mock.shop_etsy_sync_group_editing_listings;
DROP TABLE mock.shop_shopify_sync_group_editing_listings;
DROP TABLE mock.shop_square_online_sync_group_editing_listings;
DROP TABLE mock.shop_squarespace_sync_group_editing_listings;
DROP TABLE mock.shop_tiktok_sync_group_editing_listings;
DROP TABLE mock.shop_walmart_marketplace_sync_group_editing_listings;
DROP TABLE mock.shop_wix_sync_group_editing_listings;
DROP TABLE mock.shop_woo_commerce_sync_group_editing_listings;
DROP TABLE mock.shop_zoho_sync_group_editing_listings;
DROP TABLE mock.sync_group_editing_listing_order_indexes;
DROP TABLE mock.sync_group_editing;
COMMIT;
@@ -0,0 +1,187 @@
BEGIN;
CREATE TABLE mock.sync_group_editing (
account_id INTEGER PRIMARY KEY REFERENCES mock.accounts ON DELETE CASCADE,
sync_group_id INTEGER NOT NULL REFERENCES mock.sync_groups ON DELETE CASCADE,
UNIQUE (account_id, sync_group_id),
UNIQUE (sync_group_id)
);
CREATE TABLE mock.sync_group_editing_listing_order_indexes (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL CHECK (order_index >= 0),
PRIMARY KEY (account_id, order_index)
);
CREATE TABLE mock.shop_amazon_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_amazon ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_big_cartel_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_big_cartel ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_ebay_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_ebay ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_ecwid_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_ecwid ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_etsy_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_etsy ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_shopify_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_shopify ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_square_online_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_square_online ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_squarespace_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_squarespace ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_tiktok_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_tiktok ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_walmart_marketplace_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_walmart_marketplace ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_wix_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_wix ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_woo_commerce_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_woo_commerce ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
CREATE TABLE mock.shop_zoho_sync_group_editing_listings (
account_id INTEGER NOT NULL REFERENCES mock.sync_group_editing ON DELETE CASCADE,
order_index INTEGER NOT NULL,
shop_id TEXT NOT NULL,
listing_id TEXT,
PRIMARY KEY (account_id, order_index),
UNIQUE (account_id, shop_id),
FOREIGN KEY (account_id, shop_id) REFERENCES mock.shop_zoho ON DELETE CASCADE,
FOREIGN KEY (account_id, order_index) REFERENCES mock.sync_group_editing_listing_order_indexes ON DELETE CASCADE
);
GRANT ALL ON SCHEMA mock TO PUBLIC;
COMMIT;
+103 -16
View File
@@ -39,6 +39,7 @@ type (
Listing struct { Listing struct {
AccountShopListingIDs AccountShopListingIDs
ShopName string
SKU string SKU string
Name string Name string
Description string Description string
@@ -362,17 +363,23 @@ func (db *Store) GetMockListingsForShop(ctx context.Context, acctID int64, platf
fmt.Sprintf( fmt.Sprintf(
` `
SELECT SELECT
listing_id, sh.name as shop_name,
sku, li.listing_id,
name, li.sku,
description, li.name,
"count" li.description,
li."count"
FROM FROM
%s %s as sh
JOIN
%s as li
USING
(account_id, shop_id)
WHERE WHERE
account_id = @account_id account_id = @account_id
AND shop_id = @shop_id AND shop_id = @shop_id
`, `,
in.shopTable,
in.listingsTable, in.listingsTable,
), ),
pgx.NamedArgs{ pgx.NamedArgs{
@@ -385,6 +392,7 @@ func (db *Store) GetMockListingsForShop(ctx context.Context, acctID int64, platf
} }
vs, err := pgx.CollectRows(rows, pgx.RowToStructByNameLax[struct { vs, err := pgx.CollectRows(rows, pgx.RowToStructByNameLax[struct {
Shop_name string
Listing_id string Listing_id string
SKU string SKU string
Name string Name string
@@ -401,6 +409,7 @@ func (db *Store) GetMockListingsForShop(ctx context.Context, acctID int64, platf
AccountShopListingIDs: NewAccountIDs(acctID). AccountShopListingIDs: NewAccountIDs(acctID).
ShopID(in.platform, shopID). ShopID(in.platform, shopID).
ListingID(v.Listing_id), ListingID(v.Listing_id),
ShopName: v.Shop_name,
SKU: v.SKU, SKU: v.SKU,
Name: v.Name, Name: v.Name,
Description: v.Description, Description: v.Description,
@@ -422,17 +431,23 @@ func (db *Store) GetMockListing(ctx context.Context, acctID int64, platform Plat
fmt.Sprintf( fmt.Sprintf(
` `
SELECT SELECT
name, sh.name as shop_name,
count, li.name,
sku, li.count,
description li.sku,
li.description
FROM FROM
%s %s AS sh
JOIN
%s AS li
USING
(account_id, shop_id)
WHERE WHERE
account_id = @account_id account_id = @account_id
AND shop_id = @shop_id AND shop_id = @shop_id
AND listing_id = @listing_id AND listing_id = @listing_id
`, `,
in.shopTable,
in.listingsTable, in.listingsTable,
), ),
pgx.NamedArgs{ pgx.NamedArgs{
@@ -446,6 +461,7 @@ func (db *Store) GetMockListing(ctx context.Context, acctID int64, platform Plat
} }
v, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByNameLax[struct { v, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByNameLax[struct {
Shop_name string
Name string Name string
Count int64 Count int64
Sku string Sku string
@@ -469,6 +485,7 @@ func (db *Store) GetMockListing(ctx context.Context, acctID int64, platform Plat
}, },
ListingID: listingID, ListingID: listingID,
}, },
ShopName: v.Shop_name,
SKU: v.Sku, SKU: v.Sku,
Name: v.Name, Name: v.Name,
Description: v.Name, Description: v.Name,
@@ -502,7 +519,13 @@ func (db *Store) DeleteMockSyncGroup(ctx context.Context, acctID, syncGroupID in
} }
func (db *Store) StartEditingMockSyncGroup(ctx context.Context, acctID, syncGroupID int64) (prevSyncGroupID int64, prevSyncGroupExists bool, err error) { func (db *Store) StartEditingMockSyncGroup(ctx context.Context, acctID, syncGroupID int64) (prevSyncGroupID int64, prevSyncGroupExists bool, err error) {
rows, err := db.db.Query( tx, err := db.db.Begin(ctx)
if err != nil {
return 0, false, fmt.Errorf("failed to begin transaction: %w", err)
}
defer tx.Rollback(ctx)
rows, err := tx.Query(
ctx, ctx,
` `
WITH deleted_row AS ( WITH deleted_row AS (
@@ -551,13 +574,77 @@ func (db *Store) StartEditingMockSyncGroup(ctx context.Context, acctID, syncGrou
} }
v, err := pgx.CollectExactlyOneRow(rows, pgx.RowTo[pgtype.Int8]) v, err := pgx.CollectExactlyOneRow(rows, pgx.RowTo[pgtype.Int8])
if err != nil { if err != nil && !errors.Is(err, pgx.ErrNoRows) {
if errors.Is(err, pgx.ErrNoRows) {
return 0, false, nil
}
return 0, false, fmt.Errorf("failed to scan rows: %w", err) return 0, false, fmt.Errorf("failed to scan rows: %w", err)
} }
// insert the mock sync group listings into the draft table
for _, in := range getAllMockShopSchemaInfos() {
_, err := tx.Exec(
ctx,
fmt.Sprintf(
`
WITH existing_listings AS (
SELECT
shop_id,
listing_id,
order_index
FROM
%s
WHERE
account_id = @account_id
AND sync_group_id = @sync_group_id
), inserted_order_indexes AS (
INSERT INTO
mock.sync_group_editing_listing_order_indexes (
account_id,
order_index
)
SELECT
@account_id,
order_index
FROM
existing_listings
RETURNING
order_index
)
INSERT INTO
%s (
account_id,
shop_id,
listing_id,
order_index
)
SELECT
@account_id,
shop_id,
listing_id,
order_index
FROM
existing_listings
JOIN
inserted_order_indexes
USING
(order_index)
`,
in.syncGroupListingsTable,
in.syncGroupEditingListingTable,
),
pgx.NamedArgs{
"account_id": acctID,
"sync_group_id": syncGroupID,
},
)
if err != nil {
return 0, false, fmt.Errorf("failed to insert into editing listings table: %w", err)
}
}
if err := tx.Commit(ctx); err != nil {
return 0, false, fmt.Errorf("failed to commit transaction: %w", err)
}
return v.Int64, v.Valid, nil return v.Int64, v.Valid, nil
} }
+12
View File
@@ -108,6 +108,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "1", ListingID: "1",
}, },
ShopName: "Etsy 1",
SKU: "sku 1", SKU: "sku 1",
Name: "name 1", Name: "name 1",
Description: "description 1", Description: "description 1",
@@ -124,6 +125,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "2", ListingID: "2",
}, },
ShopName: "Etsy 1",
SKU: "sku 2", SKU: "sku 2",
Name: "name 2", Name: "name 2",
Description: "description 2", Description: "description 2",
@@ -140,6 +142,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "3", ListingID: "3",
}, },
ShopName: "Etsy 1",
SKU: "sku 3", SKU: "sku 3",
Name: "name 3", Name: "name 3",
Description: "description 3", Description: "description 3",
@@ -156,6 +159,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "4", ListingID: "4",
}, },
ShopName: "Etsy 1",
SKU: "sku 4", SKU: "sku 4",
Name: "name 4", Name: "name 4",
Description: "description 4", Description: "description 4",
@@ -172,6 +176,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "5", ListingID: "5",
}, },
ShopName: "Etsy 1",
SKU: "sku 5", SKU: "sku 5",
Name: "name 5", Name: "name 5",
Description: "description 5", Description: "description 5",
@@ -188,6 +193,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "6", ListingID: "6",
}, },
ShopName: "Etsy 1",
SKU: "sku 6", SKU: "sku 6",
Name: "name 6", Name: "name 6",
Description: "description 6", Description: "description 6",
@@ -204,6 +210,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "7", ListingID: "7",
}, },
ShopName: "Etsy 2",
SKU: "sku 7", SKU: "sku 7",
Name: "name 7", Name: "name 7",
Description: "description 7", Description: "description 7",
@@ -220,6 +227,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "8", ListingID: "8",
}, },
ShopName: "Etsy 2",
SKU: "sku 8", SKU: "sku 8",
Name: "name 8", Name: "name 8",
Description: "description 8", Description: "description 8",
@@ -236,6 +244,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "9", ListingID: "9",
}, },
ShopName: "Etsy 2",
SKU: "sku 9", SKU: "sku 9",
Name: "name 9", Name: "name 9",
Description: "description 9", Description: "description 9",
@@ -252,6 +261,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "10", ListingID: "10",
}, },
ShopName: "Etsy 2",
SKU: "sku 10", SKU: "sku 10",
Name: "name 10", Name: "name 10",
Description: "description 10", Description: "description 10",
@@ -268,6 +278,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "11", ListingID: "11",
}, },
ShopName: "Etsy 2",
SKU: "sku 11", SKU: "sku 11",
Name: "name 11", Name: "name 11",
Description: "description 11", Description: "description 11",
@@ -284,6 +295,7 @@ func getDevListings(acctID int64) []Listing {
}, },
ListingID: "12", ListingID: "12",
}, },
ShopName: "Etsy 2",
SKU: "sku 12", SKU: "sku 12",
Name: "name 12", Name: "name 12",
Description: "description 12", Description: "description 12",
+14
View File
@@ -528,6 +528,7 @@ type mockShopSchemaInfo struct {
listingsTable string listingsTable string
syncGroupListingsTable string syncGroupListingsTable string
syncGroupListingDraftsTable string syncGroupListingDraftsTable string
syncGroupEditingListingTable string
} }
func getMockShopSchemaInfo(platform Platform) (mockShopSchemaInfo, bool) { func getMockShopSchemaInfo(platform Platform) (mockShopSchemaInfo, bool) {
@@ -548,6 +549,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_amazon_listings", listingsTable: "mock.shop_amazon_listings",
syncGroupListingsTable: "mock.shop_amazon_sync_group_listings", syncGroupListingsTable: "mock.shop_amazon_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_amazon_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_amazon_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_amazon_sync_group_editing_listings",
}, },
{ {
platform: BigCartel, platform: BigCartel,
@@ -555,6 +557,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_big_cartel_listings", listingsTable: "mock.shop_big_cartel_listings",
syncGroupListingsTable: "mock.shop_big_cartel_sync_group_listings", syncGroupListingsTable: "mock.shop_big_cartel_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_big_cartel_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_big_cartel_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_big_cartel_sync_group_editing_listings",
}, },
{ {
platform: Ebay, platform: Ebay,
@@ -562,6 +565,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_ebay_listings", listingsTable: "mock.shop_ebay_listings",
syncGroupListingsTable: "mock.shop_ebay_sync_group_listings", syncGroupListingsTable: "mock.shop_ebay_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_ebay_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_ebay_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_ebay_sync_group_editing_listings",
}, },
{ {
platform: Ecwid, platform: Ecwid,
@@ -569,6 +573,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_ecwid_listings", listingsTable: "mock.shop_ecwid_listings",
syncGroupListingsTable: "mock.shop_ecwid_sync_group_listings", syncGroupListingsTable: "mock.shop_ecwid_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_ecwid_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_ecwid_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_ecwid_sync_group_editing_listings",
}, },
{ {
platform: Etsy, platform: Etsy,
@@ -576,6 +581,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_etsy_listings", listingsTable: "mock.shop_etsy_listings",
syncGroupListingsTable: "mock.shop_etsy_sync_group_listings", syncGroupListingsTable: "mock.shop_etsy_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_etsy_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_etsy_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_etsy_sync_group_editing_listings",
}, },
{ {
platform: Shopify, platform: Shopify,
@@ -583,6 +589,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_shopify_listings", listingsTable: "mock.shop_shopify_listings",
syncGroupListingsTable: "mock.shop_shopify_sync_group_listings", syncGroupListingsTable: "mock.shop_shopify_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_shopify_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_shopify_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_shopify_sync_group_editing_listings",
}, },
{ {
platform: SquareOnline, platform: SquareOnline,
@@ -590,6 +597,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_square_online_listings", listingsTable: "mock.shop_square_online_listings",
syncGroupListingsTable: "mock.shop_square_online_sync_group_listings", syncGroupListingsTable: "mock.shop_square_online_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_square_online_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_square_online_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_square_online_sync_group_editing_listings",
}, },
{ {
platform: Squarespace, platform: Squarespace,
@@ -597,6 +605,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_squarespace_listings", listingsTable: "mock.shop_squarespace_listings",
syncGroupListingsTable: "mock.shop_squarespace_sync_group_listings", syncGroupListingsTable: "mock.shop_squarespace_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_squarespace_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_squarespace_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_squarespace_sync_group_editing_listings",
}, },
{ {
platform: Tiktok, platform: Tiktok,
@@ -604,6 +613,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_tiktok_listings", listingsTable: "mock.shop_tiktok_listings",
syncGroupListingsTable: "mock.shop_tiktok_sync_group_listings", syncGroupListingsTable: "mock.shop_tiktok_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_tiktok_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_tiktok_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_tiktok_sync_group_editing_listings",
}, },
{ {
platform: WalmartMarketplace, platform: WalmartMarketplace,
@@ -611,6 +621,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_walmart_marketplace_listings", listingsTable: "mock.shop_walmart_marketplace_listings",
syncGroupListingsTable: "mock.shop_walmart_marketplace_sync_group_listings", syncGroupListingsTable: "mock.shop_walmart_marketplace_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_walmart_marketplace_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_walmart_marketplace_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_walmart_marketplace_sync_group_editing_listings",
}, },
{ {
platform: Wix, platform: Wix,
@@ -618,6 +629,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_wix_listings", listingsTable: "mock.shop_wix_listings",
syncGroupListingsTable: "mock.shop_wix_sync_group_listings", syncGroupListingsTable: "mock.shop_wix_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_wix_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_wix_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_wix_sync_group_editing_listings",
}, },
{ {
platform: WooCommerce, platform: WooCommerce,
@@ -625,6 +637,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_woo_commerce_listings", listingsTable: "mock.shop_woo_commerce_listings",
syncGroupListingsTable: "mock.shop_woo_commerce_sync_group_listings", syncGroupListingsTable: "mock.shop_woo_commerce_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_woo_commerce_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_woo_commerce_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_woo_commerce_sync_group_editing_listings",
}, },
{ {
platform: Zoho, platform: Zoho,
@@ -632,6 +645,7 @@ func getAllMockShopSchemaInfos() []mockShopSchemaInfo {
listingsTable: "mock.shop_zoho_listings", listingsTable: "mock.shop_zoho_listings",
syncGroupListingsTable: "mock.shop_zoho_sync_group_listings", syncGroupListingsTable: "mock.shop_zoho_sync_group_listings",
syncGroupListingDraftsTable: "mock.shop_zoho_sync_group_listing_drafts", syncGroupListingDraftsTable: "mock.shop_zoho_sync_group_listing_drafts",
syncGroupEditingListingTable: "mock.shop_zoho_sync_group_editing_listings",
}, },
} }
} }
+27 -139
View File
@@ -220,79 +220,10 @@
} }
} }
} }
.grid-table-\[minmax\(20vw\,80vw\)_1fr_1fr_1fr_1fr_1fr\] { .grid-table-\[1fr_1fr_1fr_1fr_1fr_1fr_1fr\] {
&:is(table) { &:is(table) {
display: grid; display: grid;
grid-template-columns: minmax(20vw,80vw) 1fr 1fr 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
& > :is(thead, tbody, tfoot) {
grid-column-start: 1;
grid-column-end: -1;
display: grid;
grid-template-columns: subgrid;
& > tr {
grid-column-start: 1;
grid-column-end: -1;
display: grid;
grid-template-columns: subgrid;
& > th, & > td {
grid-column: span 1;
align-content: center;
text-align: center;
}
}
}
}
}
.grid-table-\[minmax\(20vw\,max-content\)_1fr_1fr_1fr_1fr_1fr\] {
&:is(table) {
display: grid;
grid-template-columns: minmax(20vw,max-content) 1fr 1fr 1fr 1fr 1fr;
& > :is(thead, tbody, tfoot) {
grid-column-start: 1;
grid-column-end: -1;
display: grid;
grid-template-columns: subgrid;
& > tr {
grid-column-start: 1;
grid-column-end: -1;
display: grid;
grid-template-columns: subgrid;
& > th, & > td {
grid-column: span 1;
align-content: center;
text-align: center;
}
}
}
}
}
.grid-table-\[minmax\(auto\,80vw\)_1fr_1fr_1fr_1fr_1fr\] {
&:is(table) {
display: grid;
grid-template-columns: minmax(auto,80vw) 1fr 1fr 1fr 1fr 1fr;
& > :is(thead, tbody, tfoot) {
grid-column-start: 1;
grid-column-end: -1;
display: grid;
grid-template-columns: subgrid;
& > tr {
grid-column-start: 1;
grid-column-end: -1;
display: grid;
grid-template-columns: subgrid;
& > th, & > td {
grid-column: span 1;
align-content: center;
text-align: center;
}
}
}
}
}
.grid-table-\[minmax\(min-content\,80vw\)_1fr_1fr_1fr_1fr_1fr\] {
&:is(table) {
display: grid;
grid-template-columns: minmax(min-content,80vw) 1fr 1fr 1fr 1fr 1fr;
& > :is(thead, tbody, tfoot) { & > :is(thead, tbody, tfoot) {
grid-column-start: 1; grid-column-start: 1;
grid-column-end: -1; grid-column-end: -1;
@@ -363,15 +294,9 @@
.my-\[0\.5em\] { .my-\[0\.5em\] {
margin-block: 0.5em; margin-block: 0.5em;
} }
.my-\[1em\] {
margin-block: 1em;
}
.my-\[1rem\] { .my-\[1rem\] {
margin-block: 1rem; margin-block: 1rem;
} }
.mt-\[0\.5em\] {
margin-top: 0.5em;
}
.mt-\[0\.25em\] { .mt-\[0\.25em\] {
margin-top: 0.25em; margin-top: 0.25em;
} }
@@ -384,18 +309,9 @@
.mt-\[3em\] { .mt-\[3em\] {
margin-top: 3em; margin-top: 3em;
} }
.mb-\[-0\.5em\] {
margin-bottom: -0.5em;
}
.mb-\[-1em\] {
margin-bottom: -1em;
}
.mb-\[0\.5em\] { .mb-\[0\.5em\] {
margin-bottom: 0.5em; margin-bottom: 0.5em;
} }
.mb-\[0\] {
margin-bottom: 0;
}
.mb-\[1\.25rem\] { .mb-\[1\.25rem\] {
margin-bottom: 1.25rem; margin-bottom: 1.25rem;
} }
@@ -453,9 +369,6 @@
.w-full { .w-full {
width: 100%; width: 100%;
} }
.max-w-\[10px\] {
max-width: 10px;
}
.max-w-\[50\%\] { .max-w-\[50\%\] {
max-width: 50%; max-width: 50%;
} }
@@ -471,9 +384,6 @@
.flex-shrink { .flex-shrink {
flex-shrink: 1; flex-shrink: 1;
} }
.flex-grow {
flex-grow: 1;
}
.flex-grow-\[1\] { .flex-grow-\[1\] {
flex-grow: 1; flex-grow: 1;
} }
@@ -489,12 +399,6 @@
.basis-full { .basis-full {
flex-basis: 100%; flex-basis: 100%;
} }
.border-collapse {
border-collapse: collapse;
}
.transform {
transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
}
.animate-pulse { .animate-pulse {
animation: var(--animate-pulse); animation: var(--animate-pulse);
} }
@@ -616,12 +520,6 @@
.bg-card { .bg-card {
background-color: var(--card); background-color: var(--card);
} }
.bg-foreground {
background-color: var(--foreground);
}
.bg-primary {
background-color: var(--primary);
}
.p-\[0\.5em\] { .p-\[0\.5em\] {
padding: 0.5em; padding: 0.5em;
} }
@@ -661,9 +559,6 @@
.font-display { .font-display {
font-family: var(--display-family); font-family: var(--display-family);
} }
.font-text {
font-family: var(--text-family);
}
.text-lg { .text-lg {
font-size: var(--text-lg); font-size: var(--text-lg);
line-height: var(--tw-leading, var(--text-lg--line-height)); line-height: var(--tw-leading, var(--text-lg--line-height));
@@ -687,9 +582,6 @@
.text-nowrap { .text-nowrap {
text-wrap: nowrap; text-wrap: nowrap;
} }
.text-wrap {
text-wrap: wrap;
}
.capitalize { .capitalize {
text-transform: capitalize; text-transform: capitalize;
} }
@@ -699,10 +591,6 @@
.underline { .underline {
text-decoration-line: underline; text-decoration-line: underline;
} }
.outline {
outline-style: var(--tw-outline-style);
outline-width: 1px;
}
.outline-1 { .outline-1 {
outline-style: var(--tw-outline-style); outline-style: var(--tw-outline-style);
outline-width: 1px; outline-width: 1px;
@@ -1277,26 +1165,6 @@
} }
} }
} }
@property --tw-rotate-x {
syntax: "*";
inherits: false;
}
@property --tw-rotate-y {
syntax: "*";
inherits: false;
}
@property --tw-rotate-z {
syntax: "*";
inherits: false;
}
@property --tw-skew-x {
syntax: "*";
inherits: false;
}
@property --tw-skew-y {
syntax: "*";
inherits: false;
}
@property --tw-border-style { @property --tw-border-style {
syntax: "*"; syntax: "*";
inherits: false; inherits: false;
@@ -1379,6 +1247,26 @@
inherits: false; inherits: false;
initial-value: 1; initial-value: 1;
} }
@property --tw-rotate-x {
syntax: "*";
inherits: false;
}
@property --tw-rotate-y {
syntax: "*";
inherits: false;
}
@property --tw-rotate-z {
syntax: "*";
inherits: false;
}
@property --tw-skew-x {
syntax: "*";
inherits: false;
}
@property --tw-skew-y {
syntax: "*";
inherits: false;
}
@property --tw-content { @property --tw-content {
syntax: "*"; syntax: "*";
initial-value: ""; initial-value: "";
@@ -1396,11 +1284,6 @@
@layer properties { @layer properties {
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) { @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
*, ::before, ::after, ::backdrop { *, ::before, ::after, ::backdrop {
--tw-rotate-x: initial;
--tw-rotate-y: initial;
--tw-rotate-z: initial;
--tw-skew-x: initial;
--tw-skew-y: initial;
--tw-border-style: solid; --tw-border-style: solid;
--tw-font-weight: initial; --tw-font-weight: initial;
--tw-outline-style: solid; --tw-outline-style: solid;
@@ -1420,6 +1303,11 @@
--tw-scale-x: 1; --tw-scale-x: 1;
--tw-scale-y: 1; --tw-scale-y: 1;
--tw-scale-z: 1; --tw-scale-z: 1;
--tw-rotate-x: initial;
--tw-rotate-y: initial;
--tw-rotate-z: initial;
--tw-skew-x: initial;
--tw-skew-y: initial;
--tw-content: ""; --tw-content: "";
--tw-leading: initial; --tw-leading: initial;
} }
@@ -2,7 +2,10 @@
{{- $acctID := .PathParams.acctID }} {{- $acctID := .PathParams.acctID }}
{{- $orderIndex := .PathParams.orderIndex }} {{- $orderIndex := .PathParams.orderIndex }}
{{- $entry := .Accounts.GetMockSyncGroupListingDraft $acctID $orderIndex }} {{- $entry := .Entry }}
{{- if not $entry }}
{{- $entry = .Accounts.GetMockSyncGroupListingDraft $acctID $orderIndex }}
{{- end }}
{{- $selectedShopPlatform := $entry.Platform }} {{- $selectedShopPlatform := $entry.Platform }}
{{- $selectedShopID := $entry.ShopID }} {{- $selectedShopID := $entry.ShopID }}
{{- $selectedListingID := $entry.ListingID }} {{- $selectedListingID := $entry.ListingID }}
@@ -31,7 +34,7 @@
call setFilledOut(false) call setFilledOut(false)
" "
> >
<td> <td class="text-nowrap">
{{/* TODO: filter out shops that are already selected */}} {{/* TODO: filter out shops that are already selected */}}
{{- $shops := .Accounts.GetMockShops $acctID -}} {{- $shops := .Accounts.GetMockShops $acctID -}}
<select <select
@@ -80,7 +83,7 @@
{{- if $entry.Platform }}{{ $entry.Platform }}{{ else }}-{{ end }} {{- if $entry.Platform }}{{ $entry.Platform }}{{ else }}-{{ end }}
</td> </td>
<td> <td class="text-nowrap">
{{- $selectedListing := "" }} {{- $selectedListing := "" }}
{{- if $selectedShopID }} {{- if $selectedShopID }}
{{- $shopListings := .Accounts.GetMockListingsForShop $acctID $selectedShopPlatform $selectedShopID }} {{- $shopListings := .Accounts.GetMockListingsForShop $acctID $selectedShopPlatform $selectedShopID }}
@@ -125,7 +128,7 @@
{{- end }} {{- end }}
</td> </td>
<td data-id="sku"> <td data-id="sku" class="text-nowrap">
{{if $selectedListing}}{{$selectedListing.SKU}}{{else}}-{{end}} {{if $selectedListing}}{{$selectedListing.SKU}}{{else}}-{{end}}
</td> </td>
@@ -133,6 +136,10 @@
{{if $selectedListing}}{{$selectedListing.Description}}{{else}}-{{end}} {{if $selectedListing}}{{$selectedListing.Description}}{{else}}-{{end}}
</td> </td>
<td data-id="count">
{{if $selectedListing}}{{$selectedListing.Count}}{{else}}-{{end}}
</td>
<td data-id="remove"> <td data-id="remove">
{{ component "button" {{ component "button"
"HXDelete" (printf "/api/accounts/%d/inventory/sync-groups/mock/draft/listings/%d" $acctID $orderIndex) "HXDelete" (printf "/api/accounts/%d/inventory/sync-groups/mock/draft/listings/%d" $acctID $orderIndex)
@@ -10,7 +10,7 @@
class=" class="
max-w-full overflow-x-auto max-w-full overflow-x-auto
grid-table-[1fr_1fr_1fr_1fr_1fr_1fr] grid-table-[1fr_1fr_1fr_1fr_1fr_1fr_1fr]
max-h-[50vh] max-h-[50vh]
" "
hx-get="{{ printf "/ui/accounts/%d/inventory/sync-groups/mock/draft/table" $acctID }}" hx-get="{{ printf "/ui/accounts/%d/inventory/sync-groups/mock/draft/table" $acctID }}"
@@ -35,6 +35,9 @@
<th> <th>
Description Description
</th> </th>
<th>
Count
</th>
<th> <th>
</th> </th>
@@ -67,6 +70,7 @@
{{- range $listing := $listings }} {{- range $listing := $listings }}
{{- component (printf "accounts/%d/inventory/sync-groups/mock/draft/listings/%d" $acctID $listing.OrderIndex) {{- component (printf "accounts/%d/inventory/sync-groups/mock/draft/listings/%d" $acctID $listing.OrderIndex)
"Listings" $listings "Listings" $listings
"Entry" $listing
}} }}
{{- end }} {{- end }}
</tbody> </tbody>
@@ -88,6 +92,9 @@
<th> <th>
Description Description
</th> </th>
<th>
Count
</th>
<th> <th>
</th> </th>
@@ -45,6 +45,12 @@
<table id="sync-group-data-{{$syncGroupID}}"> <table id="sync-group-data-{{$syncGroupID}}">
<thead> <thead>
<tr> <tr>
<th>
Shop
</th>
<th>
Platform
</th>
<th> <th>
Name Name
</th> </th>
@@ -64,13 +70,19 @@
{{- range $listing := .Group.Listings }} {{- range $listing := .Group.Listings }}
<tr> <tr>
{{- $val := $dot.Accounts.GetMockListing $acctID $listing.Platform $listing.ShopID $listing.ListingID }} {{- $val := $dot.Accounts.GetMockListing $acctID $listing.Platform $listing.ShopID $listing.ListingID }}
<td class="text-nowrap">
{{ $val.ShopName }}
</td>
<td> <td>
{{ $val.Platform }}
</td>
<td class="text-nowrap">
{{ $val.Name }} {{ $val.Name }}
</td> </td>
<td> <td class="text-nowrap">
{{ $val.SKU }} {{ $val.SKU }}
</td> </td>
<td> <td class="text-nowrap">
{{ $val.Description }} {{ $val.Description }}
</td> </td>
<td> <td>
@@ -109,6 +121,12 @@
<table id="sync-group-{{$syncGroupID}}-form"> <table id="sync-group-{{$syncGroupID}}-form">
<thead> <thead>
<tr> <tr>
<th>
Shop
</th>
<th>
Platform
</th>
<th> <th>
Name Name
</th> </th>
@@ -128,6 +146,12 @@
{{- range $listing := .Group.Listings }} {{- range $listing := .Group.Listings }}
<tr> <tr>
{{- $val := $dot.Accounts.GetMockListing $acctID $listing.Platform $listing.ShopID $listing.ListingID }} {{- $val := $dot.Accounts.GetMockListing $acctID $listing.Platform $listing.ShopID $listing.ListingID }}
<td>
{{ $val.ShopName }}
</td>
<td>
{{ $val.Platform }}
</td>
<td> <td>
{{ $val.Name }} {{ $val.Name }}
</td> </td>