refactor(docs): remove legacy documentation pages and admin manual assets
Some checks failed
lotteryadmin CI / build (push) Has been cancelled
Some checks failed
lotteryadmin CI / build (push) Has been cancelled
Deleted all admin and integration documentation pages from /docs routes, including admin manual PNG assets. Removed DocCode, DocFigure, DocsSidebar, and DocsShell components along with their associated navigation configurations. Eliminated "Related Docs" menu item from admin toolbar. Cleaned up unused documentation layout files and redirect pages across admin-manual, integration-guide, and docs sections.
This commit is contained in:
@@ -146,7 +146,6 @@ export function AgentLineDetailPanel({
|
||||
{
|
||||
key: "downline",
|
||||
label: t("lineUi.tabDownline", { defaultValue: "直属下级" }),
|
||||
count: childAgents.length,
|
||||
visible: canViewDownlineTab,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -48,12 +48,6 @@ const HUB_CARDS: HubCard[] = [
|
||||
descKey: "hub.integrationDesc",
|
||||
requiredAny: PRD_INTEGRATION_ACCESS_ANY,
|
||||
},
|
||||
{
|
||||
href: "/docs/integration",
|
||||
titleKey: "hub.integrationGuideTitle",
|
||||
descKey: "hub.integrationGuideDesc",
|
||||
requiredAny: PRD_INTEGRATION_ACCESS_ANY,
|
||||
},
|
||||
];
|
||||
|
||||
export function ConfigHubScreen() {
|
||||
|
||||
@@ -1,428 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
|
||||
import {
|
||||
DocFigure,
|
||||
DocList,
|
||||
DocNote,
|
||||
DocOrderedList,
|
||||
DocPage,
|
||||
DocPageHeader,
|
||||
DocParagraph,
|
||||
DocSection,
|
||||
DocTable,
|
||||
} from "@/components/docs/doc-ui";
|
||||
import { ADMIN_MANUAL_IMAGES } from "@/lib/admin-manual-images";
|
||||
import { useAdminDoc } from "@/modules/docs/admin/use-admin-doc";
|
||||
|
||||
export function AdminOverviewDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("overview");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocFigure src={ADMIN_MANUAL_IMAGES.cover} alt={p("figureAlt")} />
|
||||
<DocNote>{p("loginNote")}</DocNote>
|
||||
<DocSection title={p("scope")}>
|
||||
<DocList items={list("scopeItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("menuMap")}>
|
||||
<DocParagraph>{p("menuMapNote")}</DocParagraph>
|
||||
<DocTable compact headers={header("menu")} rows={rows("menuMapRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("modes")}>
|
||||
<DocTable compact headers={header("module")} rows={rows("modeRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("readingOrder")}>
|
||||
<DocOrderedList items={list("readingItems")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminRolesDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("roles");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("matrix")}>
|
||||
<DocTable compact headers={header("role")} rows={rows("matrixRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("accountModel")}>
|
||||
<DocList items={list("accountItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("accountSetup")}>
|
||||
<DocOrderedList items={list("accountSetupSteps")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminSiteSetupDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("siteSetup");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocFigure src={ADMIN_MANUAL_IMAGES.integrationSite} alt={p("figureAlt")} />
|
||||
<DocSection title={p("path")}>
|
||||
<DocOrderedList items={list("pathItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("fields")}>
|
||||
<DocTable compact headers={header("field")} rows={rows("fieldRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("caution")}>
|
||||
<DocList items={list("cautionItems")} />
|
||||
</DocSection>
|
||||
<DocNote>
|
||||
{p("apiLinkNote")}{" "}
|
||||
<Link
|
||||
href="/docs/integration/preparation"
|
||||
className="font-medium text-slate-900 underline decoration-slate-300 underline-offset-2 hover:decoration-slate-500"
|
||||
>
|
||||
{p("apiLinkLabel")}
|
||||
</Link>
|
||||
</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminDrawsDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("draws");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("lifecycle")}>
|
||||
<DocFigure src={ADMIN_MANUAL_IMAGES.drawLifecycle} alt={p("figureAlt")} />
|
||||
<DocTable compact headers={header("status")} rows={rows("statusRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("workflow")}>
|
||||
<DocOrderedList items={list("workflowItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("publishWalkthrough")}>
|
||||
<DocOrderedList items={list("publishSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("reopenWalkthrough")}>
|
||||
<DocOrderedList items={list("reopenSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("rules")}>
|
||||
<DocList items={list("rulesItems")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
<DocParagraph>
|
||||
{p("manualReviewLinkNote")}{" "}
|
||||
<Link
|
||||
href="/docs/admin/manual-review"
|
||||
className="font-medium text-slate-900 underline decoration-slate-300 underline-offset-2 hover:decoration-slate-500"
|
||||
>
|
||||
{p("manualReviewLinkLabel")}
|
||||
</Link>
|
||||
</DocParagraph>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminSettlementCenterDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("settlementCenter");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocFigure src={ADMIN_MANUAL_IMAGES.settlementDual} alt={p("figureAlt")} />
|
||||
<DocSection title={p("entry")}>
|
||||
<DocList items={list("entryItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("periodFlow")}>
|
||||
<DocOrderedList items={list("periodItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("openWalkthrough")}>
|
||||
<DocOrderedList items={list("openSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("closeWalkthrough")}>
|
||||
<DocOrderedList items={list("closeSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("paymentWalkthrough")}>
|
||||
<DocOrderedList items={list("paymentSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("detailTabs")}>
|
||||
<DocList items={list("detailTabItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("billStatusSection")}>
|
||||
<DocTable compact headers={header("billStatusTable")} rows={rows("billStatusRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("operations")}>
|
||||
<DocList items={list("operationItems")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
<DocParagraph>
|
||||
{p("fundOpsLinkNote")}{" "}
|
||||
<Link
|
||||
href="/docs/admin/fund-operations"
|
||||
className="font-medium text-slate-900 underline decoration-slate-300 underline-offset-2 hover:decoration-slate-500"
|
||||
>
|
||||
{p("fundOpsLinkLabel")}
|
||||
</Link>
|
||||
</DocParagraph>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminAgentsDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("agents");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocFigure src={ADMIN_MANUAL_IMAGES.agentTree} alt={p("figureAlt")} />
|
||||
<DocSection title={p("structure")}>
|
||||
<DocOrderedList items={list("structureItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("provisionWalkthrough")}>
|
||||
<DocOrderedList items={list("provisionSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("dailyWalkthrough")}>
|
||||
<DocOrderedList items={list("dailySteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("profile")}>
|
||||
<DocTable compact headers={header("field")} rows={rows("profileRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("siteAdmin")}>
|
||||
<DocList items={list("siteAdminItems")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminPlayersDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("players");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("list")}>
|
||||
<DocList items={list("listItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("createWalkthrough")}>
|
||||
<DocOrderedList items={list("createSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("freezeWalkthrough")}>
|
||||
<DocOrderedList items={list("freezeSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("modes")}>
|
||||
<DocFigure src={ADMIN_MANUAL_IMAGES.walletVsCredit} alt={p("figureAlt")} />
|
||||
<DocTable compact headers={header("module")} rows={rows("modeRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("detail")}>
|
||||
<DocList items={list("detailItems")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminTicketsDocScreen(): React.ReactElement {
|
||||
const { p, list } = useAdminDoc("tickets");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("entry")}>
|
||||
<DocList items={list("entryItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("filter")}>
|
||||
<DocList items={list("filterItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("detail")}>
|
||||
<DocList items={list("detailItems")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminWalletDocScreen(): React.ReactElement {
|
||||
const { p, list } = useAdminDoc("wallet");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("walletSection")}>
|
||||
<DocList items={list("walletItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("transferSection")}>
|
||||
<DocList items={list("transferItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("reconcileSection")}>
|
||||
<DocOrderedList items={list("reconcileSteps")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
<DocParagraph>
|
||||
{p("fundOpsLinkNote")}{" "}
|
||||
<Link
|
||||
href="/docs/admin/fund-operations"
|
||||
className="font-medium text-slate-900 underline decoration-slate-300 underline-offset-2 hover:decoration-slate-500"
|
||||
>
|
||||
{p("fundOpsLinkLabel")}
|
||||
</Link>
|
||||
</DocParagraph>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminConfigDocScreen(): React.ReactElement {
|
||||
const { p, list } = useAdminDoc("config");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("plays")}>
|
||||
<DocList items={list("playsItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("odds")}>
|
||||
<DocList items={list("oddsItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("riskCap")}>
|
||||
<DocList items={list("riskCapItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("risk")}>
|
||||
<DocList items={list("riskItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("jackpot")}>
|
||||
<DocList items={list("jackpotItems")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminFundOperationsDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("fundOperations");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("twoSystems")}>
|
||||
<DocFigure src={ADMIN_MANUAL_IMAGES.settlementDual} alt={p("figureAlt")} />
|
||||
<DocList items={list("twoSystemsItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("creditModel")}>
|
||||
<DocList items={list("creditModelItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("creditLifecycle")}>
|
||||
<DocOrderedList items={list("creditLifecycleSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("creditLedger")}>
|
||||
<DocTable compact headers={header("ledger")} rows={rows("creditLedgerRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("creditBill")}>
|
||||
<DocList items={list("creditBillItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("creditAdjust")}>
|
||||
<DocOrderedList items={list("creditAdjustSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("walletLifecycle")}>
|
||||
<DocOrderedList items={list("walletLifecycleSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("walletTxn")}>
|
||||
<DocTable compact headers={header("walletTxn")} rows={rows("walletTxnRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("walletReconcile")}>
|
||||
<DocTable compact headers={header("reconcile")} rows={rows("walletReconcileRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("compare")}>
|
||||
<DocTable compact headers={header("compare")} rows={rows("compareRows")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminManualReviewDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("manualReview");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocFigure src={ADMIN_MANUAL_IMAGES.reviewPayout} alt={p("figureAlt")} />
|
||||
<DocSection title={p("distinction")}>
|
||||
<DocList items={list("distinctionItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("drawReview")}>
|
||||
<DocList items={list("drawReviewItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("drawPublishSteps")}>
|
||||
<DocOrderedList items={list("drawPublishStepItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("cooldown")}>
|
||||
<DocList items={list("cooldownItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("settlementBatch")}>
|
||||
<DocList items={list("settlementBatchItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("batchStatusSection")}>
|
||||
<DocTable compact headers={header("batchStatus")} rows={rows("batchStatusRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("batchWalkthrough")}>
|
||||
<DocOrderedList items={list("batchWalkthroughSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("settings")}>
|
||||
<DocTable compact headers={header("setting")} rows={rows("settingRows")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("settingsNote")}</DocNote>
|
||||
<DocNote>{p("rejectNote")}</DocNote>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminReportsDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("reports");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("entry")}>
|
||||
<DocList items={list("entryItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("types")}>
|
||||
<DocTable compact headers={header("report")} rows={rows("reportRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("export")}>
|
||||
<DocList items={list("exportItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("scope")}>
|
||||
<DocList items={list("scopeItems")} />
|
||||
</DocSection>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminFaqDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useAdminDoc("faq");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection>
|
||||
<DocTable compact headers={header("faq")} rows={rows("faqRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("integration")}>
|
||||
<DocList items={list("integrationItems")} />
|
||||
<DocParagraph>
|
||||
<Link
|
||||
href="/docs/integration"
|
||||
className="font-medium text-slate-900 underline decoration-slate-300 underline-offset-2 hover:decoration-slate-500"
|
||||
>
|
||||
{p("integrationLinkLabel")}
|
||||
</Link>
|
||||
</DocParagraph>
|
||||
</DocSection>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export type AdminDocPageKey =
|
||||
| "overview"
|
||||
| "roles"
|
||||
| "siteSetup"
|
||||
| "draws"
|
||||
| "settlementCenter"
|
||||
| "agents"
|
||||
| "players"
|
||||
| "tickets"
|
||||
| "wallet"
|
||||
| "config"
|
||||
| "fundOperations"
|
||||
| "manualReview"
|
||||
| "reports"
|
||||
| "faq";
|
||||
|
||||
const ADMIN_DOCS_NS = "adminDocs";
|
||||
|
||||
function asStringArray(value: unknown): string[] {
|
||||
return Array.isArray(value) ? value.filter((item): item is string => typeof item === "string") : [];
|
||||
}
|
||||
|
||||
function asStringMatrix(value: unknown): string[][] {
|
||||
return Array.isArray(value)
|
||||
? value.filter((row): row is string[] => Array.isArray(row) && row.every((cell) => typeof cell === "string"))
|
||||
: [];
|
||||
}
|
||||
|
||||
export function useAdminDoc(page: AdminDocPageKey) {
|
||||
const { t } = useTranslation(ADMIN_DOCS_NS);
|
||||
|
||||
return {
|
||||
t,
|
||||
p: (key: string) => t(`pages.${page}.${key}`, { ns: ADMIN_DOCS_NS }),
|
||||
rows: (key: string) =>
|
||||
asStringMatrix(t(`pages.${page}.${key}`, { returnObjects: true, ns: ADMIN_DOCS_NS })),
|
||||
list: (key: string) =>
|
||||
asStringArray(t(`pages.${page}.${key}`, { returnObjects: true, ns: ADMIN_DOCS_NS })),
|
||||
header: (key: string) =>
|
||||
asStringArray(t(`headers.${key}`, { returnObjects: true, ns: ADMIN_DOCS_NS })),
|
||||
};
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
/** @deprecated 单页长文档已拆分为 /docs/integration/* 多页;保留导出避免旧引用报错 */
|
||||
export function IntegrationGuideScreen(): never {
|
||||
redirect("/docs/integration");
|
||||
}
|
||||
@@ -1,373 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
DocCode,
|
||||
DocEndpoint,
|
||||
DocPage,
|
||||
DocPageHeader,
|
||||
DocParagraph,
|
||||
DocSection,
|
||||
DocTable,
|
||||
DocList,
|
||||
DocOrderedList,
|
||||
DocNote,
|
||||
} from "@/components/docs/doc-ui";
|
||||
|
||||
const CURL_PLAYER_ME = `curl -sS "https://{lottery_api}/api/v1/player/me" \\
|
||||
-H "Authorization: Bearer {JWT}" \\
|
||||
-H "Accept: application/json"`;
|
||||
|
||||
const CURL_WALLET_BALANCE = `curl -sS "https://{wallet_host}/wallet/balance?site_code=demo&site_player_id=100001¤cy_code=NPR" \\
|
||||
-H "Authorization: Bearer {wallet_api_key}"`;
|
||||
|
||||
const CURL_WALLET_DEBIT = `curl -sS -X POST "https://{wallet_host}/wallet/debit-for-lottery" \\
|
||||
-H "Authorization: Bearer {wallet_api_key}" \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-d '{
|
||||
"site_code": "demo",
|
||||
"site_player_id": "100001",
|
||||
"player_id": 42,
|
||||
"currency_code": "NPR",
|
||||
"amount_minor": 100,
|
||||
"idempotent_key": "accept-debit-001"
|
||||
}'`;
|
||||
|
||||
const IFRAME_EXAMPLE = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>主站集成</title></head>
|
||||
<body>
|
||||
<iframe id="lotteryFrame" src="https://lottery.example.com/"></iframe>
|
||||
<script>
|
||||
const LOTTERY_ORIGIN = "https://lottery.example.com";
|
||||
|
||||
window.addEventListener("message", (event) => {
|
||||
if (event.origin !== LOTTERY_ORIGIN) return;
|
||||
const { data } = event;
|
||||
switch (data.type) {
|
||||
case "LOTTERY_READY":
|
||||
fetchNewToken().then(token => {
|
||||
sendToIframe("MAIN_INIT_TOKEN", { token });
|
||||
});
|
||||
break;
|
||||
case "LOTTERY_TOKEN_NEEDED":
|
||||
case "LOTTERY_TOKEN_REFRESH_REQUEST":
|
||||
fetchNewToken().then(token => {
|
||||
sendToIframe("MAIN_REFRESH_TOKEN", { token });
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
function sendToIframe(type, payload) {
|
||||
const iframe = document.getElementById("lotteryFrame");
|
||||
iframe.contentWindow.postMessage(
|
||||
{ type, payload, timestamp: Date.now(), source: "main-site" },
|
||||
LOTTERY_ORIGIN
|
||||
);
|
||||
}
|
||||
|
||||
async function fetchNewToken() {
|
||||
const res = await fetch("/api/auth/lottery-token", {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
});
|
||||
const data = await res.json();
|
||||
return data.token;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
const JWT_SIGN_TS = `const header = base64url(JSON.stringify({ alg: "HS256", typ: "JWT" }));
|
||||
const payload = base64url(JSON.stringify({
|
||||
site_code: "demo",
|
||||
site_player_id: "100001",
|
||||
iat: Math.floor(Date.now() / 1000),
|
||||
exp: Math.floor(Date.now() / 1000) + 300,
|
||||
}));
|
||||
const sig = hmacSha256Base64url(\`\${header}.\${payload}\`, SSO_JWT_SECRET);
|
||||
const token = \`\${header}.\${payload}.\${sig}\`;`;
|
||||
|
||||
export function ApiReferenceDocScreen(): React.ReactElement {
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader
|
||||
title="API 对接参考"
|
||||
description="面向主站开发/集成工程师的技术文档:SSO、iframe、钱包网关、错误码与上线清单。"
|
||||
/>
|
||||
|
||||
<DocSection title="1. 接入总览">
|
||||
<DocTable
|
||||
compact
|
||||
headers={["组件", "职责", "实现方"]}
|
||||
rows={[
|
||||
["主站", "签发 JWT;实现钱包网关(余额查询 / 扣款 / 加款)", "客户"],
|
||||
["彩票 API", "验签、玩法、划转、下注、结算、开奖", "我方"],
|
||||
["彩票前端", "H5 / iframe 承载,玩家交互界面", "我方"],
|
||||
]}
|
||||
/>
|
||||
<DocNote>
|
||||
金额一律使用最小货币单位整数(minor),如 2000 = 20.00。编码 UTF-8 JSON。
|
||||
</DocNote>
|
||||
<DocOrderedList
|
||||
items={[
|
||||
"主站登录 → 服务端签发 JWT",
|
||||
"进入彩票(URL 跳转或 iframe 嵌入)",
|
||||
"转入:主站扣款 + 彩票加款",
|
||||
"下注 / 派奖(彩票内余额)",
|
||||
"转出:彩票扣款 + 主站加款",
|
||||
]}
|
||||
/>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="2. 快速开始">
|
||||
<DocParagraph>最小验证步骤:</DocParagraph>
|
||||
<DocCode language="bash">{CURL_PLAYER_ME}</DocCode>
|
||||
<DocCode language="bash">{CURL_WALLET_BALANCE}</DocCode>
|
||||
<DocCode language="bash">{CURL_WALLET_DEBIT}</DocCode>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="3. 接入配置">
|
||||
<DocOrderedList
|
||||
items={[
|
||||
"超管登录后台 → 平台管理 → 接入配置 → 新建站点",
|
||||
"填写站点编码(site_code)、名称、默认币种、wallet_api_url、lottery_h5_base_url、iframe_allowed_origins",
|
||||
"创建成功后立即保存一次性展示的 sso_jwt_secret 和 wallet_api_key",
|
||||
"将密钥写入主站 .env;执行「连通性测试」",
|
||||
]}
|
||||
/>
|
||||
<DocTable
|
||||
compact
|
||||
headers={["项", "后台字段", "主站 .env", "说明"]}
|
||||
rows={[
|
||||
["站点编码", "code", "MAIN_SITE_CODE", "JWT 与玩家建档标识;双方须一致"],
|
||||
["SSO 密钥", "sso_jwt_secret", "MAIN_SITE_SSO_JWT_SECRET", "主站签发;彩票验签"],
|
||||
["钱包鉴权", "wallet_api_key", "MAIN_SITE_WALLET_API_KEY", "彩票回调主站时 Bearer 携带;主站校验"],
|
||||
["钱包根地址", "wallet_api_url", "—", "客户 HTTPS 根地址;彩票拼接 /wallet/* 路径"],
|
||||
["彩票入口", "lottery_h5_base_url", "NEXT_PUBLIC_LOTTERY_IFRAME_URL", "跳转或 iframe 目标"],
|
||||
["iframe 白名单", "iframe_allowed_origins", "NEXT_PUBLIC_LOTTERY_ORIGIN", "主站 origin;彩票允许嵌入"],
|
||||
]}
|
||||
/>
|
||||
<DocNote>
|
||||
测试与生产环境的 site_code、密钥、域名须完全隔离。生产环境 wallet_api_url 仅允许 HTTPS 公网地址,拒绝 localhost / 私网 IP。
|
||||
</DocNote>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="4. 单点登录(SSO)">
|
||||
<DocParagraph>采用 HS256 JWT。主站签发,彩票验签。</DocParagraph>
|
||||
<DocTable
|
||||
compact
|
||||
headers={["字段", "类型", "必填", "说明"]}
|
||||
rows={[
|
||||
["site_code", "string", "是", "接入站点编码"],
|
||||
["site_player_id", "string", "是", "主站用户 ID,稳定唯一"],
|
||||
["iat", "number", "是", "签发时间(Unix 秒)"],
|
||||
["exp", "number", "是", "过期时间(Unix 秒);建议 ≤ 300 秒"],
|
||||
]}
|
||||
/>
|
||||
<DocCode language="typescript">{JWT_SIGN_TS}</DocCode>
|
||||
|
||||
<DocSection title="入场方式">
|
||||
<DocParagraph>方式 A — URL 跳转:</DocParagraph>
|
||||
<DocCode>{`https://{lottery_h5_base_url}/?token={JWT}`}</DocCode>
|
||||
<DocParagraph>方式 B — iframe 嵌入:</DocParagraph>
|
||||
<DocCode>{`<iframe id="lotteryFrame" src="https://lottery.example.com/"></iframe>`}</DocCode>
|
||||
<DocNote>
|
||||
首次有效 JWT 调用 GET /api/v1/player/me 时自动建档。username / nickname 由彩票生成,不从主站同步。
|
||||
</DocNote>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="入场接口">
|
||||
<DocEndpoint method="GET" path="/api/v1/player/me" />
|
||||
<DocCode language="http">{`GET /api/v1/player/me
|
||||
Authorization: Bearer {JWT}
|
||||
Accept-Language: zh`}</DocCode>
|
||||
<DocNote>
|
||||
彩票不提供「登录换票」接口。主站登录后自行签发 JWT,玩家 API 统一用 Authorization: Bearer 携带。
|
||||
</DocNote>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="SSO 错误码">
|
||||
<DocTable
|
||||
compact
|
||||
headers={["错误码", "说明"]}
|
||||
rows={[
|
||||
["8001", "缺少 Authorization 头"],
|
||||
["8002", "JWT 无效或已过期"],
|
||||
["8003", "玩家未建档"],
|
||||
["8004", "SSO 密钥未配置"],
|
||||
["8005", "账号已冻结(站点不存在/停用或玩家冻结)"],
|
||||
]}
|
||||
/>
|
||||
</DocSection>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="5. iframe 协议">
|
||||
<DocOrderedList
|
||||
items={[
|
||||
"主站页面嵌入 <iframe src=\"{lottery_h5_base_url}\">",
|
||||
"彩票 H5 加载白名单后发送 LOTTERY_READY",
|
||||
"主站监听 message,校验 origin 后发送 MAIN_INIT_TOKEN",
|
||||
"彩票 H5 保存 token,调用 /api/v1/player/me 入场",
|
||||
"Token 将过期时:彩票发 LOTTERY_TOKEN_NEEDED → 主站续签后发 MAIN_REFRESH_TOKEN",
|
||||
]}
|
||||
/>
|
||||
<DocNote>
|
||||
postMessage 第二参数须为具体 origin(如 https://www.partner.com),禁止使用 *。
|
||||
收到 MAIN_INIT_TOKEN 后彩票子页不再发送 LOTTERY_READY,避免重复下发 token。
|
||||
</DocNote>
|
||||
|
||||
<DocSection title="彩票 → 主站">
|
||||
<DocTable
|
||||
compact
|
||||
headers={["方向", "消息类型", "说明"]}
|
||||
rows={[
|
||||
["→ 主站", "LOTTERY_READY", "子页就绪,请求下发 token"],
|
||||
["→ 主站", "LOTTERY_TOKEN_NEEDED", "token 失效,请求续签"],
|
||||
["→ 主站", "LOTTERY_TOKEN_REFRESH_REQUEST", "主动请求刷新 token"],
|
||||
["→ 主站", "LOTTERY_HEARTBEAT", "心跳(可忽略)"],
|
||||
["→ 主站", "LOTTERY_TOKEN_REFRESHED", "续签成功通知"],
|
||||
]}
|
||||
/>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="主站 → 彩票">
|
||||
<DocTable
|
||||
compact
|
||||
headers={["方向", "消息类型", "载荷", "说明"]}
|
||||
rows={[
|
||||
["→ 彩票", "MAIN_INIT_TOKEN", "{ token }", "首次下发 JWT"],
|
||||
["→ 彩票", "MAIN_REFRESH_TOKEN", "{ token }", "续签 JWT"],
|
||||
["→ 彩票", "MAIN_REQUEST_STATUS", "—", "请求子页状态"],
|
||||
["→ 彩票", "MAIN_NAVIGATE", "{ path }", "导航到指定路径"],
|
||||
]}
|
||||
/>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="完整示例">
|
||||
<DocCode>{IFRAME_EXAMPLE}</DocCode>
|
||||
</DocSection>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="6. 钱包网关">
|
||||
<DocParagraph>
|
||||
由客户实现。彩票服务端调用。鉴权:Authorization: Bearer {"{wallet_api_key}"}。
|
||||
</DocParagraph>
|
||||
|
||||
<DocSection title="查询余额">
|
||||
<DocEndpoint method="GET" path="/wallet/balance" />
|
||||
<DocTable
|
||||
compact
|
||||
headers={["参数", "类型", "说明"]}
|
||||
rows={[
|
||||
["site_code", "string", "站点编码"],
|
||||
["site_player_id", "string", "主站用户 ID"],
|
||||
["currency_code", "string", "币种代码"],
|
||||
]}
|
||||
/>
|
||||
<DocCode>{`{
|
||||
"success": true,
|
||||
"data": { "main_balance": 500000, "currency_code": "NPR" }
|
||||
}`}</DocCode>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="扣款(转入时调用)">
|
||||
<DocEndpoint method="POST" path="/wallet/debit-for-lottery" />
|
||||
<DocTable
|
||||
compact
|
||||
headers={["字段", "类型", "说明"]}
|
||||
rows={[
|
||||
["site_code", "string", "站点编码"],
|
||||
["site_player_id", "string", "主站用户 ID"],
|
||||
["player_id", "number", "彩票玩家 ID(参考)"],
|
||||
["currency_code", "string", "币种"],
|
||||
["amount_minor", "integer", "minor 正整数"],
|
||||
["idempotent_key", "string", "幂等键"],
|
||||
]}
|
||||
/>
|
||||
<DocCode>{`{
|
||||
"success": true,
|
||||
"external_ref_no": "MW-001",
|
||||
"data": { "main_balance": 498000, "currency_code": "NPR" }
|
||||
}`}</DocCode>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="加款(转出时调用)">
|
||||
<DocEndpoint method="POST" path="/wallet/credit-from-lottery" />
|
||||
<DocParagraph>请求体与扣款相同。用于转出或失败回滚加款。</DocParagraph>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="HTTP 契约">
|
||||
<DocTable
|
||||
compact
|
||||
headers={["场景", "HTTP 状态码", "响应体"]}
|
||||
rows={[
|
||||
["扣款/加款成功", "200", "success: true;含 external_ref_no 与 data.main_balance"],
|
||||
["余额查询成功", "200", "success: true;data.main_balance + currency_code"],
|
||||
["参数非法", "422", "success: false;message: invalid request"],
|
||||
["鉴权失败", "401", "success: false;message: unauthorized"],
|
||||
["业务拒绝", "409", "success: false;message 说明原因(如余额不足)"],
|
||||
["幂等重放", "200", "与首次成功/拒绝响应完全一致"],
|
||||
]}
|
||||
/>
|
||||
</DocSection>
|
||||
|
||||
<DocNote>
|
||||
idempotent_key:相同键 + 相同操作须返回首次 JSON(HTTP 200),禁止重复记账;同键不同操作/金额 → success: false。
|
||||
</DocNote>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="7. 错误码汇总">
|
||||
<DocSection title="SSO 鉴权">
|
||||
<DocTable
|
||||
compact
|
||||
headers={["错误码", "说明"]}
|
||||
rows={[
|
||||
["8001", "缺少 Authorization 头"],
|
||||
["8002", "JWT 无效或已过期"],
|
||||
["8003", "玩家未建档"],
|
||||
["8004", "SSO 密钥未配置"],
|
||||
["8005", "账号已冻结"],
|
||||
]}
|
||||
/>
|
||||
</DocSection>
|
||||
<DocSection title="彩票钱包 / 划转">
|
||||
<DocTable
|
||||
compact
|
||||
headers={["错误码", "说明"]}
|
||||
rows={[
|
||||
["1001", "彩票余额不足(转出时)"],
|
||||
["1009", "主站钱包处理失败"],
|
||||
["1010", "幂等键冲突(同键不同金额)"],
|
||||
["2003", "请先转入后再下注"],
|
||||
]}
|
||||
/>
|
||||
</DocSection>
|
||||
<DocSection title="客户钱包网关 HTTP">
|
||||
<DocTable
|
||||
compact
|
||||
headers={["HTTP", "message", "原因"]}
|
||||
rows={[
|
||||
["401", "unauthorized", "API Key 错误"],
|
||||
["422", "invalid request", "字段或金额非法"],
|
||||
["409", "—", "业务拒绝(如余额不足)"],
|
||||
]}
|
||||
/>
|
||||
</DocSection>
|
||||
</DocSection>
|
||||
|
||||
<DocSection title="8. 上线清单">
|
||||
<DocList
|
||||
items={[
|
||||
"测试与生产:site_code、密钥、域名完全隔离",
|
||||
"JWT 仅服务端签发,有效期 ≤ 5 分钟",
|
||||
"钱包接口走 HTTPS,超时建议 ≤ 10 秒",
|
||||
"idempotent_key 幂等处理已正确实现",
|
||||
"iframe 模式:已配置 iframe_allowed_origins",
|
||||
"全链路联调通过:转入 → 下注 → 派奖 → 转出",
|
||||
]}
|
||||
/>
|
||||
</DocSection>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
/** 文档默认环境地址(当前 Tanumo 部署;客户独立环境以商务交付为准) */
|
||||
export const DOC_ENV = {
|
||||
lotteryH5Origin: "https://front.tanumo.com",
|
||||
lotteryH5Wallet: "https://front.tanumo.com/wallet",
|
||||
lotteryApiBase: "https://lotterylaravel.tanumo.com",
|
||||
adminBase: "https://lotteryadmin.tanumo.com",
|
||||
integrationDocs: "https://lotteryadmin.tanumo.com/docs/integration",
|
||||
integrationSitesAdmin: "https://lotteryadmin.tanumo.com/admin/config/integration-sites",
|
||||
} as const;
|
||||
|
||||
/** 代码示例(语言无关,三语共用) */
|
||||
export const SSO_JWT_PAYLOAD_EXAMPLE = `{
|
||||
"site_code": "demo",
|
||||
"site_player_id": "100001",
|
||||
"iat": 1718000000,
|
||||
"exp": 1718000300
|
||||
}`;
|
||||
|
||||
export const SSO_JWT_SIGN_EXAMPLE = `import jwt from "jsonwebtoken";
|
||||
|
||||
const token = jwt.sign(
|
||||
{
|
||||
site_code: "demo",
|
||||
site_player_id: "100001",
|
||||
},
|
||||
process.env.MAIN_SITE_SSO_JWT_SECRET!,
|
||||
{
|
||||
algorithm: "HS256",
|
||||
expiresIn: 300,
|
||||
},
|
||||
);`;
|
||||
|
||||
export const SSO_ENTRY_URL = `${DOC_ENV.lotteryH5Origin}/?token={JWT}`;
|
||||
|
||||
export const SSO_POSTMESSAGE = `iframe.contentWindow.postMessage(
|
||||
{ type: "MAIN_INIT_TOKEN", token: jwt, source: "main-site" },
|
||||
"${DOC_ENV.lotteryH5Origin}"
|
||||
);`;
|
||||
|
||||
export const PLAYER_ME_REQUEST = `GET ${DOC_ENV.lotteryApiBase}/api/v1/player/me
|
||||
Authorization: Bearer {JWT}
|
||||
Accept-Language: zh`;
|
||||
|
||||
export const PLAYER_ME_SUCCESS = `{
|
||||
"code": 0,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"id": 42,
|
||||
"site_code": "demo",
|
||||
"site_player_id": "100001",
|
||||
"auth_source": "main_site_sso",
|
||||
"funding_mode": "wallet",
|
||||
"username": null,
|
||||
"nickname": null,
|
||||
"default_currency": "NPR",
|
||||
"status": 0,
|
||||
"locale": "zh",
|
||||
"last_login_at": "2026-06-14T10:00:00+00:00",
|
||||
"created_at": "2026-06-14T10:00:00+00:00"
|
||||
}
|
||||
}`;
|
||||
|
||||
export const IFRAME_CHILD_READY = `{
|
||||
"type": "LOTTERY_READY",
|
||||
"payload": { "url": "${DOC_ENV.lotteryH5Origin}/", "userAgent": "..." },
|
||||
"timestamp": 1718000000000,
|
||||
"source": "lottery-iframe"
|
||||
}`;
|
||||
|
||||
export const IFRAME_PARENT_INIT = `{
|
||||
"type": "MAIN_INIT_TOKEN",
|
||||
"token": "eyJhbGciOiJIUzI1NiIs...",
|
||||
"timestamp": 1718000000000,
|
||||
"source": "main-site"
|
||||
}`;
|
||||
|
||||
export const IFRAME_INTEGRATION_EXAMPLE = `<iframe id="lotteryFrame" src="${DOC_ENV.lotteryH5Origin}/"></iframe>
|
||||
<script>
|
||||
const LOTTERY_ORIGIN = "${DOC_ENV.lotteryH5Origin}";
|
||||
|
||||
window.addEventListener("message", (event) => {
|
||||
if (event.origin !== LOTTERY_ORIGIN) return;
|
||||
const { type } = event.data ?? {};
|
||||
if (type === "LOTTERY_READY" || type === "LOTTERY_TOKEN_NEEDED" || type === "LOTTERY_TOKEN_REFRESH_REQUEST") {
|
||||
issueLotteryJwt().then((token) => sendToken(type === "LOTTERY_READY" ? "MAIN_INIT_TOKEN" : "MAIN_REFRESH_TOKEN", token));
|
||||
}
|
||||
});
|
||||
|
||||
function sendToken(type, token) {
|
||||
document.getElementById("lotteryFrame").contentWindow.postMessage(
|
||||
{ type, token, timestamp: Date.now(), source: "main-site" },
|
||||
LOTTERY_ORIGIN,
|
||||
);
|
||||
}
|
||||
|
||||
async function issueLotteryJwt() {
|
||||
const res = await fetch("/api/your-server/sign-lottery-jwt", { method: "POST", credentials: "include" });
|
||||
const { token } = await res.json();
|
||||
return token;
|
||||
}
|
||||
</script>`;
|
||||
|
||||
export const ACCEPTANCE_PLAYER_ME = `curl -sS "${DOC_ENV.lotteryApiBase}/api/v1/player/me" \\
|
||||
-H "Authorization: Bearer {JWT}" \\
|
||||
-H "Accept: application/json"`;
|
||||
|
||||
export const ACCEPTANCE_WALLET_DEBIT = `curl -sS -X POST "https://{wallet_host}/wallet/debit-for-lottery" \\
|
||||
-H "Authorization: Bearer {wallet_api_key}" \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-d '{
|
||||
"site_code": "demo",
|
||||
"site_player_id": "100001",
|
||||
"player_id": 42,
|
||||
"currency_code": "NPR",
|
||||
"amount_minor": 100,
|
||||
"idempotent_key": "accept-debit-001"
|
||||
}'`;
|
||||
|
||||
export const PLAYER_AUTH_ERROR = `HTTP/1.1 401 Unauthorized
|
||||
|
||||
{
|
||||
"code": 8002,
|
||||
"msg": "Token 无效或已过期",
|
||||
"data": null
|
||||
}`;
|
||||
|
||||
export const WALLET_BALANCE_RESPONSE = `{
|
||||
"success": true,
|
||||
"data": { "main_balance": 500000, "currency_code": "NPR" }
|
||||
}`;
|
||||
|
||||
export const WALLET_DEBIT_REQUEST = `POST /wallet/debit-for-lottery
|
||||
Authorization: Bearer {wallet_api_key}
|
||||
|
||||
{
|
||||
"site_code": "demo",
|
||||
"site_player_id": "100001",
|
||||
"player_id": 42,
|
||||
"currency_code": "NPR",
|
||||
"amount_minor": 2000,
|
||||
"idempotent_key": "TI-20260610-abc"
|
||||
}`;
|
||||
|
||||
export const WALLET_SUCCESS = `{
|
||||
"success": true,
|
||||
"external_ref_no": "MW-001",
|
||||
"data": { "main_balance": 498000, "currency_code": "NPR" }
|
||||
}`;
|
||||
|
||||
export const WALLET_FAIL = `{
|
||||
"success": false,
|
||||
"message": "main balance insufficient",
|
||||
"data": { "main_balance": 500, "currency_code": "NPR" }
|
||||
}`;
|
||||
|
||||
export const WALLET_CREDIT_REQUEST = `POST /wallet/credit-from-lottery
|
||||
Authorization: Bearer {wallet_api_key}
|
||||
|
||||
{
|
||||
"site_code": "demo",
|
||||
"site_player_id": "100001",
|
||||
"player_id": 42,
|
||||
"currency_code": "NPR",
|
||||
"amount_minor": 2000,
|
||||
"idempotent_key": "TO-20260610-abc"
|
||||
}`;
|
||||
|
||||
export const TRANSFER_IN = `POST /api/v1/wallet/transfer-in
|
||||
Authorization: Bearer {player_jwt}
|
||||
|
||||
{ "amount": 2000, "currency": "NPR", "idempotent_key": "ti-001" }`;
|
||||
|
||||
export const TRANSFER_OUT = `POST /api/v1/wallet/transfer-out
|
||||
Authorization: Bearer {player_jwt}
|
||||
|
||||
{ "amount": 1000, "currency": "NPR", "idempotent_key": "to-001" }`;
|
||||
|
||||
export const TRANSFER_SUCCESS = `{
|
||||
"code": 0,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"transfer_no": "TI20260614001",
|
||||
"direction": "in",
|
||||
"currency_code": "NPR",
|
||||
"amount": 2000,
|
||||
"status": "success",
|
||||
"external_ref_no": "debit-for-lottery-1718360000-a1b2c3",
|
||||
"balance": 2000,
|
||||
"log_id": "WX_20260614_0001",
|
||||
"lottery_balance_after": 2000,
|
||||
"lottery_available_after": 2000,
|
||||
"finished_at": "2026-06-14T10:00:00+00:00"
|
||||
}
|
||||
}`;
|
||||
@@ -1,359 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
DocCode,
|
||||
DocEndpoint,
|
||||
DocList,
|
||||
DocNote,
|
||||
DocOrderedList,
|
||||
DocPage,
|
||||
DocPageHeader,
|
||||
DocSection,
|
||||
DocTable,
|
||||
} from "@/components/docs/doc-ui";
|
||||
import {
|
||||
SSO_ENTRY_URL,
|
||||
SSO_JWT_PAYLOAD_EXAMPLE,
|
||||
SSO_JWT_SIGN_EXAMPLE,
|
||||
SSO_POSTMESSAGE,
|
||||
ACCEPTANCE_PLAYER_ME,
|
||||
ACCEPTANCE_WALLET_DEBIT,
|
||||
IFRAME_CHILD_READY,
|
||||
IFRAME_INTEGRATION_EXAMPLE,
|
||||
IFRAME_PARENT_INIT,
|
||||
PLAYER_AUTH_ERROR,
|
||||
PLAYER_ME_REQUEST,
|
||||
PLAYER_ME_SUCCESS,
|
||||
TRANSFER_IN,
|
||||
TRANSFER_OUT,
|
||||
TRANSFER_SUCCESS,
|
||||
WALLET_BALANCE_RESPONSE,
|
||||
WALLET_CREDIT_REQUEST,
|
||||
WALLET_DEBIT_REQUEST,
|
||||
WALLET_FAIL,
|
||||
WALLET_SUCCESS,
|
||||
} from "@/modules/docs/integration/integration-doc-data";
|
||||
import { useIntegrationDoc } from "@/modules/docs/integration/use-integration-doc";
|
||||
|
||||
export function OverviewDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useIntegrationDoc("overview");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("roles")}>
|
||||
<DocTable compact headers={header("component")} rows={rows("matrix")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("flow")}>
|
||||
<DocOrderedList items={list("flowItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("e2eSequence")}>
|
||||
<DocTable compact headers={header("sequence")} rows={rows("e2eRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("conventions")}>
|
||||
<DocTable compact headers={header("convention")} rows={rows("conventionRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("readingOrder")}>
|
||||
<DocList items={list("readingItems")} />
|
||||
</DocSection>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function DeliveryDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useIntegrationDoc("delivery");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("handoffScope")}>
|
||||
<DocTable compact headers={header("handoffTable")} rows={rows("handoffRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("weProvide")}>
|
||||
<DocTable compact headers={header("param")} rows={rows("provideRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("youProvide")}>
|
||||
<DocTable compact headers={header("param")} rows={rows("submitRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("environment")}>
|
||||
<DocTable compact headers={header("env")} rows={rows("environmentRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("process")}>
|
||||
<DocOrderedList items={list("processSteps")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function QuickstartDocScreen(): React.ReactElement {
|
||||
const { p, list } = useIntegrationDoc("quickstart");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("prereq")}>
|
||||
<DocList items={list("prereqItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("steps")}>
|
||||
<DocOrderedList items={list("stepItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("acceptance")}>
|
||||
<DocOrderedList items={list("acceptanceItems")} />
|
||||
<DocCode language="bash">{ACCEPTANCE_PLAYER_ME}</DocCode>
|
||||
<DocCode language="bash">{ACCEPTANCE_WALLET_DEBIT}</DocCode>
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function FundamentalsDocScreen(): React.ReactElement {
|
||||
const { p, rows, header } = useIntegrationDoc("fundamentals");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} />
|
||||
<DocSection title={p("balances")}>
|
||||
<DocTable compact headers={header("balance")} rows={rows("balanceRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("calls")}>
|
||||
<DocTable compact headers={header("call")} rows={rows("callRows")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function SetupDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useIntegrationDoc("setup");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("weProvide")}>
|
||||
<DocTable compact headers={header("param")} rows={rows("receiveRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("youProvide")}>
|
||||
<DocTable compact headers={header("param")} rows={rows("provideRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("defaultPaths")}>
|
||||
<DocTable compact headers={header("methodPath")} rows={rows("pathRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("envMapping")}>
|
||||
<DocTable compact headers={header("envMap")} rows={rows("envMappingRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("adminSop")}>
|
||||
<DocOrderedList items={list("adminSopSteps")} />
|
||||
<DocTable compact headers={header("adminField")} rows={rows("adminFieldRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("network")}>
|
||||
<DocList items={list("networkItems")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function SsoDocScreen(): React.ReactElement {
|
||||
const { p, rows, header } = useIntegrationDoc("sso");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("claims")}>
|
||||
<DocTable compact headers={header("claim")} rows={rows("claimRows")} />
|
||||
<DocCode>{SSO_JWT_PAYLOAD_EXAMPLE}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("sign")}>
|
||||
<DocCode language="typescript">{SSO_JWT_SIGN_EXAMPLE}</DocCode>
|
||||
</DocSection>
|
||||
<DocNote>{p("noExchangeNote")}</DocNote>
|
||||
<DocSection title={p("entryA")}>
|
||||
<DocCode>{SSO_ENTRY_URL}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("entryB")}>
|
||||
<DocTable compact headers={header("message")} rows={rows("messageRows")} />
|
||||
<DocCode language="typescript">{SSO_POSTMESSAGE}</DocCode>
|
||||
<DocNote>{p("iframeNote")}</DocNote>
|
||||
</DocSection>
|
||||
<DocSection title={p("entryApi")}>
|
||||
<DocEndpoint method="GET" path="/api/v1/player/me" />
|
||||
<DocNote>{p("entryApiNote")}</DocNote>
|
||||
<DocCode language="http">{PLAYER_ME_REQUEST}</DocCode>
|
||||
<DocCode>{PLAYER_ME_SUCCESS}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("publicApis")}>
|
||||
<DocTable compact headers={header("methodPath")} rows={rows("publicApiRows")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("h5ScopeNote")}</DocNote>
|
||||
<DocNote>{p("refreshNote")}</DocNote>
|
||||
<DocSection title={p("authResponse")}>
|
||||
<DocCode language="http">{PLAYER_AUTH_ERROR}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("errors")}>
|
||||
<DocTable compact headers={header("code")} rows={rows("errorRows")} />
|
||||
</DocSection>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function IframeDocScreen(): React.ReactElement {
|
||||
const { p, rows, list, header } = useIntegrationDoc("iframe");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("sequence")}>
|
||||
<DocOrderedList items={list("sequenceSteps")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("envelopeSection")}>
|
||||
<DocTable compact headers={header("envelopeTable")} rows={rows("envelopeRows")} />
|
||||
<DocNote>{p("envelopeNote")}</DocNote>
|
||||
</DocSection>
|
||||
<DocSection title={p("childMessages")}>
|
||||
<DocTable compact headers={header("message")} rows={rows("childMessageRows")} />
|
||||
<DocCode>{IFRAME_CHILD_READY}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("parentMessages")}>
|
||||
<DocTable compact headers={header("message")} rows={rows("parentMessageRows")} />
|
||||
<DocCode>{IFRAME_PARENT_INIT}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("example")}>
|
||||
<DocCode language="html">{IFRAME_INTEGRATION_EXAMPLE}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("targetOrigin")}>
|
||||
<DocNote>{p("targetOriginNote")}</DocNote>
|
||||
</DocSection>
|
||||
<DocNote>{p("timingNote")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function WalletDocScreen(): React.ReactElement {
|
||||
const { p, rows, header } = useIntegrationDoc("wallet");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("balance")}>
|
||||
<DocEndpoint method="GET" path="/wallet/balance" />
|
||||
<DocTable compact headers={header("query")} rows={rows("queryRows")} />
|
||||
<DocCode>{WALLET_BALANCE_RESPONSE}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("debit")}>
|
||||
<DocEndpoint method="POST" path="/wallet/debit-for-lottery" />
|
||||
<DocTable compact headers={header("field")} rows={rows("fieldRows")} />
|
||||
<DocCode language="http">{WALLET_DEBIT_REQUEST}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("credit")}>
|
||||
<DocEndpoint method="POST" path="/wallet/credit-from-lottery" />
|
||||
<DocCode language="http">{WALLET_CREDIT_REQUEST}</DocCode>
|
||||
<DocNote>{p("creditNote")}</DocNote>
|
||||
</DocSection>
|
||||
<DocSection title={p("httpContract")}>
|
||||
<DocTable compact headers={header("contract")} rows={rows("httpContractRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("response")}>
|
||||
<div className="grid gap-3 lg:grid-cols-2">
|
||||
<DocCode>{WALLET_SUCCESS}</DocCode>
|
||||
<DocCode>{WALLET_FAIL}</DocCode>
|
||||
</div>
|
||||
</DocSection>
|
||||
<DocSection title={p("httpErrors")}>
|
||||
<DocTable compact headers={header("http")} rows={rows("httpErrorRows")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("idempotentNote")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function TransferDocScreen(): React.ReactElement {
|
||||
const { p, rows, header } = useIntegrationDoc("transfer");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocNote>{p("outOfScopeNote")}</DocNote>
|
||||
<DocSection title={p("requestFields")}>
|
||||
<DocTable compact headers={header("field")} rows={rows("requestFieldRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("transferIn")}>
|
||||
<DocEndpoint method="POST" path="/api/v1/wallet/transfer-in" />
|
||||
<DocNote>{p("inNote")}</DocNote>
|
||||
<DocCode language="http">{TRANSFER_IN}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("transferOut")}>
|
||||
<DocEndpoint method="POST" path="/api/v1/wallet/transfer-out" />
|
||||
<DocNote>{p("outNote")}</DocNote>
|
||||
<DocCode language="http">{TRANSFER_OUT}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("transferResponse")}>
|
||||
<DocNote>{p("responseNote")}</DocNote>
|
||||
<DocCode>{TRANSFER_SUCCESS}</DocCode>
|
||||
</DocSection>
|
||||
<DocSection title={p("errors")}>
|
||||
<DocTable compact headers={header("code")} rows={rows("errorRows")} />
|
||||
</DocSection>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function ErrorsDocScreen(): React.ReactElement {
|
||||
const { p, rows, header } = useIntegrationDoc("errors");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} />
|
||||
<DocSection title={p("sso")}>
|
||||
<DocTable compact headers={header("code")} rows={rows("ssoRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("lotteryWallet")}>
|
||||
<DocTable compact headers={header("code")} rows={rows("lotteryRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("gateway")}>
|
||||
<DocTable compact headers={header("http")} rows={rows("gatewayRows")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("idempotentNote")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function GoLiveDocScreen(): React.ReactElement {
|
||||
const { p, list } = useIntegrationDoc("golive");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("deliveryChecklist")}>
|
||||
<DocList items={list("deliveryItems")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("checklist")}>
|
||||
<DocList items={list("items")} />
|
||||
</DocSection>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
|
||||
export function TroubleshootingDocScreen(): React.ReactElement {
|
||||
const { p, rows, header } = useIntegrationDoc("troubleshooting");
|
||||
|
||||
return (
|
||||
<DocPage>
|
||||
<DocPageHeader title={p("title")} description={p("description")} />
|
||||
<DocSection title={p("faq")}>
|
||||
<DocTable compact headers={header("faq")} rows={rows("faqRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("jwt")}>
|
||||
<DocTable compact headers={header("faq")} rows={rows("jwtRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("iframe")}>
|
||||
<DocTable compact headers={header("faq")} rows={rows("iframeRows")} />
|
||||
</DocSection>
|
||||
<DocSection title={p("wallet")}>
|
||||
<DocTable compact headers={header("faq")} rows={rows("walletRows")} />
|
||||
</DocSection>
|
||||
<DocNote>{p("note")}</DocNote>
|
||||
</DocPage>
|
||||
);
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
type DocPageKey =
|
||||
| "overview"
|
||||
| "delivery"
|
||||
| "quickstart"
|
||||
| "fundamentals"
|
||||
| "setup"
|
||||
| "sso"
|
||||
| "iframe"
|
||||
| "wallet"
|
||||
| "transfer"
|
||||
| "errors"
|
||||
| "troubleshooting"
|
||||
| "golive";
|
||||
|
||||
const INTEGRATION_DOCS_NS = "integrationDocs";
|
||||
|
||||
function asStringArray(value: unknown): string[] {
|
||||
return Array.isArray(value) ? value.filter((item): item is string => typeof item === "string") : [];
|
||||
}
|
||||
|
||||
function asStringMatrix(value: unknown): string[][] {
|
||||
return Array.isArray(value)
|
||||
? value.filter((row): row is string[] => Array.isArray(row) && row.every((cell) => typeof cell === "string"))
|
||||
: [];
|
||||
}
|
||||
|
||||
export function useIntegrationDoc(page: DocPageKey) {
|
||||
const { t } = useTranslation(INTEGRATION_DOCS_NS);
|
||||
|
||||
return {
|
||||
t,
|
||||
p: (key: string) => t(`pages.${page}.${key}`, { ns: INTEGRATION_DOCS_NS }),
|
||||
rows: (key: string) =>
|
||||
asStringMatrix(t(`pages.${page}.${key}`, { returnObjects: true, ns: INTEGRATION_DOCS_NS })),
|
||||
list: (key: string) =>
|
||||
asStringArray(t(`pages.${page}.${key}`, { returnObjects: true, ns: INTEGRATION_DOCS_NS })),
|
||||
header: (key: string) =>
|
||||
asStringArray(t(`headers.${key}`, { returnObjects: true, ns: INTEGRATION_DOCS_NS })),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user