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
return phoneNumber ? `"${state.whatsApp?.contact.phoneNumber}"` : null
}
case 'Now':
if (isEmpty(options.timeZone)) return 'new Date().toISOString()'
return toISOWithTz(new Date(), options.timeZone)
case 'Now': {
const timeZone = parseVariables(
state.typebotsQueue[0].typebot.variables
)(options.timeZone)
if (isEmpty(timeZone)) return 'new Date().toISOString()'
return toISOWithTz(new Date(), timeZone)
}
case 'Today':
return 'new Date().toISOString()'
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 toISOWithTz(new Date(Date.now() + 86400000), options.timeZone)
return toISOWithTz(new Date(Date.now() + 86400000), timeZone)
}
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 toISOWithTz(new Date(Date.now() - 86400000), options.timeZone)
return toISOWithTz(new Date(Date.now() - 86400000), timeZone)
}
case 'Random ID': {
return `"${createId()}"`