From 65213126e1690b9a234b7ebeb6a29bca1eec9786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Arod?= Date: Wed, 16 Oct 2024 14:09:30 +0200 Subject: [PATCH] feat: utilise un toggle pour les stats multi --- .../publish/v2/createMultiValueStatListItemBlock.ts | 10 ++++++++-- src/notion/publish/v2/createStatGroupListItemBlock.ts | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/notion/publish/v2/createMultiValueStatListItemBlock.ts b/src/notion/publish/v2/createMultiValueStatListItemBlock.ts index 4029131..32eacb7 100644 --- a/src/notion/publish/v2/createMultiValueStatListItemBlock.ts +++ b/src/notion/publish/v2/createMultiValueStatListItemBlock.ts @@ -1,15 +1,21 @@ +import { BlockObjectRequest } from "@notionhq/client/build/src/api-endpoints"; import { ValueFormatOptions } from "../../../format/ValueFormatOptions"; import { MultiValueStatDesc } from "../../../statistiques/v2/desc/StatsDesc"; import { BulletedListItemBlockObjectRequest } from "../blocks/BulletedListItemBlockObjectRequest"; import { BulletedListItemChildren } from "../blocks/BulletedListItemChildren"; import { createSingleValueStatListItemBlock } from "./createSingleValueStatListItemBlock"; +export type ToggleBlockObjectRequest = Extract< + BlockObjectRequest, + { toggle: object } +>; + export function createMultiValueStatListItemBlock( descriptor: MultiValueStatDesc, statValue: Record -): BulletedListItemBlockObjectRequest { +): ToggleBlockObjectRequest { return { - bulleted_list_item: { + toggle: { rich_text: [ { text: { diff --git a/src/notion/publish/v2/createStatGroupListItemBlock.ts b/src/notion/publish/v2/createStatGroupListItemBlock.ts index ac3a390..89a6322 100644 --- a/src/notion/publish/v2/createStatGroupListItemBlock.ts +++ b/src/notion/publish/v2/createStatGroupListItemBlock.ts @@ -10,6 +10,7 @@ import { BulletedListItemBlockObjectRequest } from "../blocks/BulletedListItemBl import { BulletedListItemChildren } from "../blocks/BulletedListItemChildren"; import { createMultiValueStatListItemBlock } from "./createMultiValueStatListItemBlock"; import { ValueFormatOptions } from "../../../format/ValueFormatOptions"; +import { BlockObjectRequest } from "@notionhq/client/build/src/api-endpoints"; export function createStatGroupListItemBlock( descriptor: D, @@ -35,7 +36,7 @@ export function createStatGroupListItemBlock( export function createStatGroupChildrenListItemBlock( descriptor: D, stats: StatsType -): BulletedListItemBlockObjectRequest[] { +): BlockObjectRequest[] { return Object.keys(descriptor.stats).map((statName) => { const childStatDesc = descriptor.stats[statName]; const childStatValue = stats[statName];