json import export project | UI cleaner | binding geometry to each other

This commit is contained in:
taDuc
2026-05-08 23:26:27 +07:00
parent ce4bc4f2a5
commit c945a56a33
18 changed files with 1362 additions and 380 deletions
+20
View File
@@ -28,3 +28,23 @@ export async function fetchWikiById(id: string): Promise<Wiki> {
return requestJson<Wiki>(`${API_ENDPOINTS.wikis}/${encodeURIComponent(wikiId)}`);
}
export async function checkWikiSlugExists(slug: string): Promise<boolean> {
const value = String(slug || "").trim();
if (!value.length) return false;
const params = new URLSearchParams({ slug: value });
const url = `${API_ENDPOINTS.wikis}/slug/exists?${params.toString()}`;
const payload = await requestJson<unknown>(url);
if (typeof payload === "boolean") return payload;
if (payload && typeof payload === "object") {
const anyPayload = payload as any;
if (typeof anyPayload.exists === "boolean") return anyPayload.exists;
if (typeof anyPayload.exists === "number") return anyPayload.exists !== 0;
if (typeof anyPayload.is_exists === "boolean") return anyPayload.is_exists;
if (typeof anyPayload.is_exists === "number") return anyPayload.is_exists !== 0;
}
// Be conservative: unknown payload shape, treat as "exists" to prevent creating conflicting slugs.
return true;
}