diff --git a/src/line/flex-templates/basic-cards.ts b/src/line/flex-templates/basic-cards.ts index 8f34afa4ba..de1afdaa8b 100644 --- a/src/line/flex-templates/basic-cards.ts +++ b/src/line/flex-templates/basic-cards.ts @@ -10,6 +10,7 @@ import type { FlexText, ListItem, } from "./types.js"; +import { attachFooterText } from "./common.js"; /** * Create an info card with title, body, and optional footer @@ -76,22 +77,7 @@ export function createInfoCard(title: string, body: string, footer?: string): Fl }; if (footer) { - bubble.footer = { - type: "box", - layout: "vertical", - contents: [ - { - type: "text", - text: footer, - size: "xs", - color: "#AAAAAA", - wrap: true, - align: "center", - } as FlexText, - ], - paddingAll: "lg", - backgroundColor: "#FAFAFA", - }; + attachFooterText(bubble, footer); } return bubble; diff --git a/src/line/flex-templates/common.ts b/src/line/flex-templates/common.ts new file mode 100644 index 0000000000..be39463eea --- /dev/null +++ b/src/line/flex-templates/common.ts @@ -0,0 +1,20 @@ +import type { FlexBox, FlexBubble, FlexText } from "./types.js"; + +export function attachFooterText(bubble: FlexBubble, footer: string) { + bubble.footer = { + type: "box", + layout: "vertical", + contents: [ + { + type: "text", + text: footer, + size: "xs", + color: "#AAAAAA", + wrap: true, + align: "center", + } as FlexText, + ], + paddingAll: "lg", + backgroundColor: "#FAFAFA", + } as FlexBox; +} diff --git a/src/line/flex-templates/schedule-cards.ts b/src/line/flex-templates/schedule-cards.ts index 91c3f440c2..2bf1ab9b4e 100644 --- a/src/line/flex-templates/schedule-cards.ts +++ b/src/line/flex-templates/schedule-cards.ts @@ -1,4 +1,5 @@ import type { Action, FlexBox, FlexBubble, FlexComponent, FlexText } from "./types.js"; +import { attachFooterText } from "./common.js"; /** * Create a receipt/summary card (for orders, transactions, data tables) @@ -135,22 +136,7 @@ export function createReceiptCard(params: { }; if (footer) { - bubble.footer = { - type: "box", - layout: "vertical", - contents: [ - { - type: "text", - text: footer, - size: "xs", - color: "#AAAAAA", - wrap: true, - align: "center", - } as FlexText, - ], - paddingAll: "lg", - backgroundColor: "#FAFAFA", - }; + attachFooterText(bubble, footer); } return bubble; @@ -499,22 +485,7 @@ export function createAgendaCard(params: { }; if (footer) { - bubble.footer = { - type: "box", - layout: "vertical", - contents: [ - { - type: "text", - text: footer, - size: "xs", - color: "#AAAAAA", - align: "center", - wrap: true, - } as FlexText, - ], - paddingAll: "lg", - backgroundColor: "#FAFAFA", - }; + attachFooterText(bubble, footer); } return bubble;