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> </Button>
{/if} {/if}
{#if activeTab !== "processed"}
<div class="relative"> <div class="relative">
<Button <Button
variant="default" variant="default"
@@ -294,6 +295,7 @@
></button> ></button>
{/if} {/if}
</div> </div>
{/if}
{#if activeTab === "needs_review" && onMarkAsProcessed} {#if activeTab === "needs_review" && onMarkAsProcessed}
<Button <Button
+22 -2
View File
@@ -175,6 +175,10 @@
}) })
); );
const canQueueSync = $derived(enabled && hasCredentials && !needsReconnect); 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 { function productSyncResultMessage(snap: StoreSyncSnapshot): string {
const status = snap.status.toLowerCase(); const status = snap.status.toLowerCase();
@@ -453,6 +457,19 @@
success = ""; success = "";
testResult = null; testResult = null;
try { 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", { const result = await api<{ status?: string; message?: string }>("/api/woocommerce/test", {
method: "POST" method: "POST"
}); });
@@ -974,12 +991,15 @@
<Button <Button
type="button" type="button"
loading={testing} loading={testing}
disabled={!hasCredentials || !canAdmin} disabled={!canTestConnection}
title={!hasCredentials ? i18n.t("store.saveBeforeTest") : undefined} title={!canTestConnection ? i18n.t("store.saveBeforeTest") : undefined}
onclick={onTest} onclick={onTest}
> >
{testing ? i18n.t("store.testing") : i18n.t("store.testConnection")} {testing ? i18n.t("store.testing") : i18n.t("store.testConnection")}
</Button> </Button>
<Button type="submit" variant="outline" loading={saving} disabled={!canAdmin}>
{saving ? i18n.t("store.saving") : i18n.t("woo.saveConfiguration")}
</Button>
{#if testResult} {#if testResult}
{#if testResult.success} {#if testResult.success}
<span class="flex items-center gap-2 text-sm text-green-600"> <span class="flex items-center gap-2 text-sm text-green-600">