const { createEmbed, page } = require("#utils/embed"); const { acknowledge } = require("#utils/interactions"); const DynamicCardStack = require("../../../labscore/cardstack/DynamicCardStack"); module.exports = { label: "text", name: "test", metadata: { description: 'test.', description_short: 'test', examples: ['test'], category: 'dev', usage: 'test' }, onBefore: context => context.user.isClientOwner, onCancel: ()=>{}, run: async (context, args) => { await acknowledge(context); try{ // This will create a new dynamic card stack new DynamicCardStack(context, { cards: [ createEmbed("default", context, { description: "page 1"}), createEmbed("default", context, { description: "page 2. this has a conditional button."}) ].map((p, index)=>page(p, {}, { key: `t_${index}` })), interactive: { conditional_button: { // Button Label label: "Conditional", // Next to pagination or new row inline: false, visible: (page) => { console.log(page.getAllState()); console.log(page.getState("t_1")); return (page.getState("key") === "t_1") }, resolvePage: (page) => { return [ createEmbed("default", context, { description: "this is a conditional sub page"}) ].map((p)=>page(p)); } }, dynamic_button: { // Button Label label: (page) => { return page.getState("key"); }, // Next to pagination or new row inline: false, visible: true, // Renders the loading state card renderLoadingState: (page) => { return createEmbed("default", context, { description: "-# Subpage Loading :)", }) }, resolvePage: (page) => { return [ createEmbed("default", context, { description: "this is a conditional sub page"}) ].map((p)=>page(p)); } } } }) }catch(e){ console.log(e) } } };