mirror of
https://framagit.org/enfance-libre/statistiques
synced 2025-03-12 13:55:02 +00:00
24 lines
759 B
TypeScript
24 lines
759 B
TypeScript
import { Client } from "@notionhq/client";
|
|
import {
|
|
StatGroupDesc,
|
|
StatsType,
|
|
} from "../../../statistiques/v2/desc/StatsDesc";
|
|
import { createStatGroupChildrenListItemBlock } from "./createStatGroupListItemBlock";
|
|
import { updatePageContent } from "./updatePageContent";
|
|
import { createParagraphBlock } from "../blocks/createParagraphBlock";
|
|
|
|
export async function publishStatsToPage<D extends StatGroupDesc>(
|
|
notionClient: Client,
|
|
statsPageId: string,
|
|
pageHeader: string,
|
|
descriptor: D,
|
|
stats: StatsType<D>
|
|
) {
|
|
const statsBlocks = createStatGroupChildrenListItemBlock(descriptor, stats);
|
|
|
|
const textBlock = createParagraphBlock(pageHeader);
|
|
await updatePageContent(notionClient, statsPageId, [
|
|
textBlock,
|
|
...statsBlocks,
|
|
]);
|
|
}
|