From f8ba2175aa97e8c1e1616eed1bedeb35382ba135 Mon Sep 17 00:00:00 2001 From: Egor Savkin Date: Mon, 5 Aug 2024 10:26:56 +0800 Subject: [PATCH] Add AFWS item to the shop and update bundle Signed-off-by: Egor Savkin # Conflicts: # static/js/shop.bundle.js --- static/images/shop/graphic-03_AFWS.svg | 1 + static/js/shop/json_porter.js | 3 ++- static/js/shop/options/validation.js | 7 +++---- static/js/shop_data.js | 25 +++++++++++++++++++++++-- 4 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 static/images/shop/graphic-03_AFWS.svg diff --git a/static/images/shop/graphic-03_AFWS.svg b/static/images/shop/graphic-03_AFWS.svg new file mode 100644 index 0000000..b7dc2b2 --- /dev/null +++ b/static/images/shop/graphic-03_AFWS.svg @@ -0,0 +1 @@ + diff --git a/static/js/shop/json_porter.js b/static/js/shop/json_porter.js index 139b1d2..8da0b7b 100644 --- a/static/js/shop/json_porter.js +++ b/static/js/shop/json_porter.js @@ -65,12 +65,13 @@ export function CratesToJSON(crates) { const crateOptions = useShopStore.getState().crate_options; const orderOptions = useShopStore.getState().order_options; const orderOptionsData = useShopStore.getState().order_options_data; + const crateParams = useShopStore.getState().crateParams; return JSON.stringify({ // additional fields can go here crates: Array.from(crates.map((crate, _i) => ({ items: Array.from(crate.items.map((card, _) => ({ pn: card.name_number, - options: (card.options_data && card.options) ? FilterOptions(card.options, card.options_data) : null + options: (card.options_data && card[crateParams(crate.crate_mode).options]) ? FilterOptions(card[crateParams(crate.crate_mode).options], card.options_data) : null }))), type: crate.crate_mode, options: FilterOptions(crateOptions, crate.options_data) diff --git a/static/js/shop/options/validation.js b/static/js/shop/options/validation.js index 9fd1ab3..28d3f13 100644 --- a/static/js/shop/options/validation.js +++ b/static/js/shop/options/validation.js @@ -27,10 +27,9 @@ const hostname = (params) => { } const labels = text.split('.'); for (const label of labels) { - if (label.length < 1 || label.length > maxLabelLength) { - return false; - } - if (!labelRegex.test(label)) { + if (label.length < 1 + || label.length > maxLabelLength + || !labelRegex.test(label)) { return false; } } diff --git a/static/js/shop_data.js b/static/js/shop_data.js index 6130e06..acec056 100644 --- a/static/js/shop_data.js +++ b/static/js/shop_data.js @@ -18,7 +18,7 @@ const shop_data = { }, no_crate: { id: 'no_crate', - name: 'Spare cards', + name: 'Spare items', price: 0, hp: -1, warnings_disabled: true, @@ -1456,6 +1456,26 @@ const shop_data = { hp: 8, }, }, + 'afws': { + id: 'afws', + name: 'Subscription', + name_number: 'AFWS', + name_codename: '', + price: 800, + image: '/images/shop/graphic-03_AFWS.svg', + specs: [ + "Artiq Firmware Service for one variant for one year.", + "Includes support at helpdesk.", + "Included with purchase of any Carrier with no additional cost.", + ], + crateless: true, + crateless_options: [ + {type: "Line", args: {title: "Variant name", outvar: "variant_name", fallback: "", + tip: "Variant name can be found on the sticker on top of the crate. If you don't have one, leave the preferred name here."}}, + ], + size: 'big', + warnings: [], + }, }, columns: { @@ -1513,6 +1533,7 @@ const shop_data = { 'koster', 'eem_pwr_mod', 'kirdy', + 'afws', ]} ], }, @@ -1527,7 +1548,7 @@ const shop_data = { }, { id: "spare", - name: "Spare cards", + name: "Spare items", crate_mode: "no_crate", items: [], warnings: [],