From 018e85f43343f308dceb57be869184096964ce77 Mon Sep 17 00:00:00 2001 From: Kieran Huggins Date: Thu, 12 Sep 2024 20:58:37 -0700 Subject: [PATCH] update block builders to account for null values --- functions/request-invitation.mjs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/request-invitation.mjs b/functions/request-invitation.mjs index 856e106..ea456d1 100644 --- a/functions/request-invitation.mjs +++ b/functions/request-invitation.mjs @@ -61,12 +61,12 @@ const slack_payload = ({name, email, company, bio, github, website, avatar, crea // "created_at": "2008-03-19T21:02:08Z", // "iat": 1724362049 // } - const header = (text='(undefined)') => { return { type: "header", text: { type: "plain_text", text } } } - const para = (text='undefined') => { return { type: "section", text: { type: "mrkdwn", text } } } + const header = (text) => { return { type: 'header', text: { type: 'plain_text', text: text || 'undefined' } } } + const para = (text) => { return { type: 'section', text: { type: 'mrkdwn', text: text || 'undefined' } } } const section = (obj={}) => { return { type: 'section', fields: Object.entries(obj).map( ([key, val]) => field(key, val) ) } } - const field = (name, value='undefined') => { return { type: 'mrkdwn', text: `*${name}*\n${value}` } } - const bio_with_avatar = (text='undefined', image_url='https://www.gravatar.com/avatar/?d=identicon') => { return { type: 'section', text: { type: "mrkdwn", text }, accessory: { type: "image", image_url, alt_text: 'Github Avatar' } } } - const divider = () => { return { type: "divider" } } + const field = (name, value) => { return { type: 'mrkdwn', text: `*${name || 'undefined'}*\n${value || 'undefined'}` } } + const bio_with_avatar = (text, image_url) => { return { type: 'section', text: { type: 'mrkdwn', text: text || 'undefined' }, accessory: { type: 'image', image_url: image_url || 'https://www.gravatar.com/avatar/?d=identicon', alt_text: 'Github Avatar' } } } + const divider = () => { return { type: 'divider' } } return { channel: process.env.SLACK_CHANNEL,