Hook up syncing with postgres

This commit is contained in:
Dominic Ferrando
2026-07-03 12:54:50 -04:00
parent 934c523bf9
commit fc9cd6f1ae
9 changed files with 261 additions and 216 deletions
@@ -7,13 +7,16 @@
const synchronizer = $state({
isRunning: false,
printfulProductIds: [] as number[],
syncingPrintfulProductIds: [] as number[],
poll: async function () {
const res = await api.products.sync.get();
if (res.data) {
synchronizer.isRunning = res.data.isRunning;
synchronizer.printfulProductIds =
res.data.state.printfulProductIds;
if (res.error) {
synchronizer.isRunning = false;
synchronizer.syncingPrintfulProductIds = [];
} else {
synchronizer.isRunning = true;
synchronizer.syncingPrintfulProductIds =
res.data.syncingPrintfulProductIds;
}
},
startPolling: () => {
@@ -93,7 +96,7 @@
>
<td>
{#await isProductSynced(printfulProduct) then isSynced}
{#if synchronizer.printfulProductIds.includes(printfulProduct.id)}
{#if synchronizer.syncingPrintfulProductIds.includes(printfulProduct.id)}
<div class="badge badge-warning">
Syncing...
</div>