mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-03-25 09:25:51 +00:00
link sku
This commit is contained in:
parent
3dc0b8d835
commit
f09416aae9
1 changed files with 16 additions and 1 deletions
|
|
@ -1222,6 +1222,9 @@ export async function renderSkuLinker($app) {
|
|||
let pinnedL = null;
|
||||
let pinnedR = null;
|
||||
|
||||
// ✅ change: if page was opened with #/link/?left=... (or sku=...), reload after LINK completes
|
||||
let shouldReloadAfterLink = false;
|
||||
|
||||
function renderCard(it, pinned) {
|
||||
const storeCount = it.stores.size || 0;
|
||||
const plus = storeCount > 1 ? ` +${storeCount - 1}` : "";
|
||||
|
|
@ -1550,7 +1553,12 @@ export async function renderSkuLinker($app) {
|
|||
const qi = h.indexOf("?");
|
||||
if (qi !== -1) {
|
||||
const qs = new URLSearchParams(h.slice(qi + 1));
|
||||
const leftSku = String(qs.get("left") || qs.get("sku") || "").trim();
|
||||
const leftSkuRaw = qs.get("left") || qs.get("sku");
|
||||
const leftSku = String(leftSkuRaw || "").trim();
|
||||
|
||||
// ✅ change: remember that the query param was set (even if SKU not found)
|
||||
if (leftSku) shouldReloadAfterLink = true;
|
||||
|
||||
if (leftSku && !pinnedL) {
|
||||
const it = findAggForPreselectSku(leftSku);
|
||||
if (it) pinnedL = it;
|
||||
|
|
@ -1659,6 +1667,10 @@ export async function renderSkuLinker($app) {
|
|||
pinnedL = null;
|
||||
pinnedR = null;
|
||||
updateAll();
|
||||
|
||||
// ✅ change: reload after LINK completes when query param was used
|
||||
if (shouldReloadAfterLink) location.reload();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1686,6 +1698,9 @@ export async function renderSkuLinker($app) {
|
|||
pinnedL = null;
|
||||
pinnedR = null;
|
||||
updateAll();
|
||||
|
||||
// ✅ change: reload after LINK completes when query param was used
|
||||
if (shouldReloadAfterLink) location.reload();
|
||||
} catch (e) {
|
||||
$status.textContent = `Write failed: ${String(e && e.message ? e.message : e)}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue