Skip to content

Commit 9a67439

Browse files
committed
fix(extension): paste-code connect path for unpacked/dev (no ID needed)
The copy-paste connect fallback showed a code on the web page but the popup had nowhere to paste it. Add a code input to the connect screen that stores the token directly — works without a published extension ID.
1 parent db64628 commit 9a67439

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

extension/src/add-ui.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,26 @@ async function getToken(): Promise<string | null> {
1717
export async function renderAddUI({ root, product, onConnectNeeded }: RenderOpts) {
1818
const token = await getToken();
1919
if (!token) {
20-
root.innerHTML = `<div class="sl-pad"><p>Connect the extension to your shoplit account first.</p>
21-
<button id="sl-connect" class="sl-btn">Connect to shoplit</button></div>`;
20+
// Two ways to connect: (1) "Open connect page" attempts an automatic
21+
// handoff (needs the published extension ID); (2) paste the code shown on
22+
// that page — works for unpacked/dev with no ID coordination.
23+
root.innerHTML = `<div class="sl-pad">
24+
<p>Connect the extension to your shoplit account.</p>
25+
<button id="sl-connect" class="sl-btn">Open connect page</button>
26+
<p class="sl-msg">Then paste the connection code shown there:</p>
27+
<input id="sl-code" class="sl-input" placeholder="Paste connection code" />
28+
<button id="sl-save-code" class="sl-btn">Connect</button>
29+
<p id="sl-msg" class="sl-msg"></p>
30+
</div>`;
2231
root.querySelector<HTMLButtonElement>("#sl-connect")!.onclick = onConnectNeeded;
32+
root.querySelector<HTMLButtonElement>("#sl-save-code")!.onclick = () => {
33+
const code = root.querySelector<HTMLInputElement>("#sl-code")!.value.trim();
34+
if (!code) return;
35+
chrome.storage.local.set({ token: code }, () => {
36+
// Re-render now that we have a token.
37+
renderAddUI({ root, product, onConnectNeeded });
38+
});
39+
};
2340
return;
2441
}
2542
if (!product) {

0 commit comments

Comments
 (0)