2
0

🐛 (setVariable) Fix timeZone variable parsing

This commit is contained in:
Baptiste Arnaud
2024-02-16 10:13:56 +01:00
parent 3e0d3e7724
commit 519f3aa4f9

View File

@ -87,20 +87,31 @@ const getExpressionToEvaluate =
const phoneNumber = state.whatsApp?.contact.phoneNumber const phoneNumber = state.whatsApp?.contact.phoneNumber
return phoneNumber ? `"${state.whatsApp?.contact.phoneNumber}"` : null return phoneNumber ? `"${state.whatsApp?.contact.phoneNumber}"` : null
} }
case 'Now': case 'Now': {
if (isEmpty(options.timeZone)) return 'new Date().toISOString()' const timeZone = parseVariables(
return toISOWithTz(new Date(), options.timeZone) state.typebotsQueue[0].typebot.variables
)(options.timeZone)
if (isEmpty(timeZone)) return 'new Date().toISOString()'
return toISOWithTz(new Date(), timeZone)
}
case 'Today': case 'Today':
return 'new Date().toISOString()' return 'new Date().toISOString()'
case 'Tomorrow': { case 'Tomorrow': {
if (isEmpty(options.timeZone)) const timeZone = parseVariables(
state.typebotsQueue[0].typebot.variables
)(options.timeZone)
if (isEmpty(timeZone))
return 'new Date(Date.now() + 86400000).toISOString()' return 'new Date(Date.now() + 86400000).toISOString()'
return toISOWithTz(new Date(Date.now() + 86400000), options.timeZone) return toISOWithTz(new Date(Date.now() + 86400000), timeZone)
} }
case 'Yesterday': { case 'Yesterday': {
if (isEmpty(options.timeZone)) const timeZone = parseVariables(
state.typebotsQueue[0].typebot.variables
)(options.timeZone)
if (isEmpty(timeZone))
return 'new Date(Date.now() - 86400000).toISOString()' return 'new Date(Date.now() - 86400000).toISOString()'
return toISOWithTz(new Date(Date.now() - 86400000), options.timeZone) return toISOWithTz(new Date(Date.now() - 86400000), timeZone)
} }
case 'Random ID': { case 'Random ID': {
return `"${createId()}"` return `"${createId()}"`