Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/common/api/indexer/sync.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { INDEXER_API_ENDPOINT_URL } from "@/common/_config";

// Use same logic as hooks.ts - staging/production should hit dev.potlock.io
// because that's where the sync endpoints are deployed
const SYNC_API_BASE_URL =
process.env.NEXT_PUBLIC_ENV === "test" ? INDEXER_API_ENDPOINT_URL : "https://dev.potlock.io";

export const syncApi = {
/**
* Sync a campaign after creation or update
* @param campaignId - The on-chain campaign ID
*/
async campaign(campaignId: number | string): Promise<{ success: boolean; message?: string }> {
try {
const response = await fetch(
`${INDEXER_API_ENDPOINT_URL}/api/v1/campaigns/${campaignId}/sync`,
{ method: "POST" },
);
const response = await fetch(`${SYNC_API_BASE_URL}/api/v1/campaigns/${campaignId}/sync`, {
method: "POST",
});

if (!response.ok) {
const error = await response.json().catch(() => ({}));
Expand Down Expand Up @@ -40,7 +44,7 @@ export const syncApi = {
): Promise<{ success: boolean; message?: string }> {
try {
const response = await fetch(
`${INDEXER_API_ENDPOINT_URL}/api/v1/campaigns/${campaignId}/donations/sync`,
`${SYNC_API_BASE_URL}/api/v1/campaigns/${campaignId}/donations/sync`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
Expand Down
Loading