feat: utilise un toggle pour les stats multi
parent
ab251909d0
commit
65213126e1
|
@ -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<string, number>
|
||||
): BulletedListItemBlockObjectRequest {
|
||||
): ToggleBlockObjectRequest {
|
||||
return {
|
||||
bulleted_list_item: {
|
||||
toggle: {
|
||||
rich_text: [
|
||||
{
|
||||
text: {
|
||||
|
|
|
@ -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<D extends StatGroupDesc>(
|
||||
descriptor: D,
|
||||
|
@ -35,7 +36,7 @@ export function createStatGroupListItemBlock<D extends StatGroupDesc>(
|
|||
export function createStatGroupChildrenListItemBlock<D extends StatGroupDesc>(
|
||||
descriptor: D,
|
||||
stats: StatsType<D>
|
||||
): BulletedListItemBlockObjectRequest[] {
|
||||
): BlockObjectRequest[] {
|
||||
return Object.keys(descriptor.stats).map((statName) => {
|
||||
const childStatDesc = descriptor.stats[statName];
|
||||
const childStatValue = stats[statName];
|
||||
|
|
Loading…
Reference in New Issue