This commit is contained in:
MatejGhub
2026-09-13 21:37:20 +02:00
parent ab0e80db18
commit de9a39d1f1
2 changed files with 24 additions and 2 deletions
@@ -162,6 +162,7 @@
</Button>
{/if}
{#if activeTab !== "processed"}
<div class="relative">
<Button
variant="default"
@@ -294,6 +295,7 @@
></button>
{/if}
</div>
{/if}
{#if activeTab === "needs_review" && onMarkAsProcessed}
<Button
+22 -2
View File
@@ -175,6 +175,10 @@
})
);
const canQueueSync = $derived(enabled && hasCredentials && !needsReconnect);
const hasDraftCredentials = $derived(
store_url.trim() !== "" && consumer_key.trim() !== "" && consumer_secret.trim() !== ""
);
const canTestConnection = $derived(canAdmin && (hasCredentials || hasDraftCredentials));
function productSyncResultMessage(snap: StoreSyncSnapshot): string {
const status = snap.status.toLowerCase();
@@ -453,6 +457,19 @@
success = "";
testResult = null;
try {
// Test uses saved credentials — persist draft fields first when present.
if (consumer_key.trim() || consumer_secret.trim() || !hasCredentials) {
const config = await api<WooCommerceConfig>("/api/woocommerce", {
method: "PUT",
body: {
store_url,
consumer_key,
consumer_secret,
is_enabled: enabled
}
});
applyConfig(config);
}
const result = await api<{ status?: string; message?: string }>("/api/woocommerce/test", {
method: "POST"
});
@@ -974,12 +991,15 @@
<Button
type="button"
loading={testing}
disabled={!hasCredentials || !canAdmin}
title={!hasCredentials ? i18n.t("store.saveBeforeTest") : undefined}
disabled={!canTestConnection}
title={!canTestConnection ? i18n.t("store.saveBeforeTest") : undefined}
onclick={onTest}
>
{testing ? i18n.t("store.testing") : i18n.t("store.testConnection")}
</Button>
<Button type="submit" variant="outline" loading={saving} disabled={!canAdmin}>
{saving ? i18n.t("store.saving") : i18n.t("woo.saveConfiguration")}
</Button>
{#if testResult}
{#if testResult.success}
<span class="flex items-center gap-2 text-sm text-green-600">