From 720cc688d6987a0c36a8057a1c90f9f250d7c749 Mon Sep 17 00:00:00 2001 From: Ibrahim Pelumi Lasisi <113442282+ibrahimpelumi6142@users.noreply.github.com> Date: Thu, 8 Jan 2026 19:56:13 +0000 Subject: [PATCH] fix: avoid variable shadowing and preserve empty business profile fields (#2183) * Update business.ts * chore: fix lint issues --- src/Socket/business.ts | 55 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/Socket/business.ts b/src/Socket/business.ts index cd00b7bd..27c3007f 100644 --- a/src/Socket/business.ts +++ b/src/Socket/business.ts @@ -23,7 +23,7 @@ export const makeBusinessSocket = (config: SocketConfig) => { node.push( ...simpleFields - .filter(key => args[key]) + .filter(key => args[key] !== undefined && args[key] !== null) .map(key => ({ tag: key, attrs: {}, @@ -31,7 +31,7 @@ export const makeBusinessSocket = (config: SocketConfig) => { })) ) - if (args.websites) { + if (args.websites !== undefined) { node.push( ...args.websites.map(website => ({ tag: 'website', @@ -41,30 +41,33 @@ export const makeBusinessSocket = (config: SocketConfig) => { ) } - if (args.hours) { - node.push({ - tag: 'business_hours', - attrs: { timezone: args.hours.timezone }, - content: args.hours.days.map(config => { - const base = { - tag: 'business_hours_config', - attrs: { day_of_week: config.day, mode: config.mode } - } - - if (config.mode === 'specific_hours') { - return { - ...base, - attrs: { - ...base.attrs, - open_time: config.openTimeInMinutes, - close_time: config.closeTimeInMinutes - } - } - } - - return base - }) - }) + if (args.hours !== undefined) { + node.push({ + tag: 'business_hours', + attrs: { timezone: args.hours.timezone }, + content: args.hours.days.map(dayConfig => { + const base = { + tag: 'business_hours_config', + attrs: { + day_of_week: dayConfig.day, + mode: dayConfig.mode + } + } as const + + if (dayConfig.mode === 'specific_hours') { + return { + ...base, + attrs: { + ...base.attrs, + open_time: dayConfig.openTimeInMinutes, + close_time: dayConfig.closeTimeInMinutes + } + } + } + + return base + }) + }) } const result = await query({