event <- input$event_P2
add_calendar <- TRUE
if(is.null(input$substance_date_P2)) {
show_toast(title = "Missing dates", text = "", type = "error",
position = "center", width = "50%")
add_calendar <- FALSE
}
if(event == "") {
show_toast(title = "Missing event name", text = "", type = "error",
position = "center", width = "50%")
add_calendar <- FALSE
}
if(add_calendar) {
for (day in as.character(input$substance_date_P2)) {
timevis_data_cal(
timevis_data_cal() |>
add_row(
tibble(
id = randomID(),
calendarId = 3,
period = "Post-LMP",
what = "Event",
event = event,
substance = NA,
frequency = NA,
title = event,
body = "",
recurrenceRule = NA,
start = as.Date(day),
end = as.Date(day),
category = "allday",
location = NA,
bgColor = NA,
color = NA,
borderColor = NA
)
)
)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.