fix: avoid variable shadowing and preserve empty business profile fields (#2183)

* Update business.ts

* chore: fix lint issues
This commit is contained in:
Ibrahim Pelumi Lasisi
2026-01-08 19:56:13 +00:00
committed by GitHub
parent 81d9c12e86
commit 720cc688d6
+29 -26
View File
@@ -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({