Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions src/Socket/business.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@

node.push(
...simpleFields
.filter(key => args[key])
.filter(key => args[key] !== undefined && args[key] !== null)
.map(key => ({
tag: key,
attrs: {},
content: args[key] as string
}))
)

if (args.websites) {
if (args.websites !== undefined) {
node.push(
...args.websites.map(website => ({
tag: 'website',
Expand All @@ -41,30 +41,33 @@
)
}

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({

Check failure on line 45 in src/Socket/business.ts

View workflow job for this annotation

GitHub Actions / check-lint

Replace `····` with `↹`
tag: 'business_hours',

Check failure on line 46 in src/Socket/business.ts

View workflow job for this annotation

GitHub Actions / check-lint

Replace `········` with `↹↹`
attrs: { timezone: args.hours.timezone },

Check failure on line 47 in src/Socket/business.ts

View workflow job for this annotation

GitHub Actions / check-lint

Replace `········` with `↹↹`
content: args.hours.days.map(dayConfig => {

Check failure on line 48 in src/Socket/business.ts

View workflow job for this annotation

GitHub Actions / check-lint

Replace `········` with `↹↹`
const base = {

Check failure on line 49 in src/Socket/business.ts

View workflow job for this annotation

GitHub Actions / check-lint

Replace `············` with `↹↹↹`
tag: 'business_hours_config',

Check failure on line 50 in src/Socket/business.ts

View workflow job for this annotation

GitHub Actions / check-lint

Replace `················` with `↹↹↹↹`
attrs: {

Check failure on line 51 in src/Socket/business.ts

View workflow job for this annotation

GitHub Actions / check-lint

Replace `················attrs:·{·` with `↹↹↹↹attrs:·{`
day_of_week: dayConfig.day,

Check failure on line 52 in src/Socket/business.ts

View workflow job for this annotation

GitHub Actions / check-lint

Replace `····················day_of_week:·dayConfig.day,·` with `↹↹↹↹↹day_of_week:·dayConfig.day,`
mode: dayConfig.mode

Check failure on line 53 in src/Socket/business.ts

View workflow job for this annotation

GitHub Actions / check-lint

Replace `····················mode:·dayConfig.mode·` with `↹↹↹↹↹mode:·dayConfig.mode`
}

Check failure on line 54 in src/Socket/business.ts

View workflow job for this annotation

GitHub Actions / check-lint

Replace `················` with `↹↹↹↹`
} 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({
Expand Down
Loading