File size: 21,060 Bytes
76126cd
aafec2f
76126cd
 
 
0c0f648
1029596
0c0f648
76126cd
aafec2f
 
 
 
0864583
 
 
aafec2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fc8ce0a
0c0f648
76126cd
 
 
1029596
26e06c3
 
 
85e967b
26e06c3
 
1029596
323071f
76126cd
aafec2f
76126cd
 
 
fc8ce0a
aafec2f
26e06c3
aafec2f
26e06c3
 
aafec2f
26e06c3
 
aafec2f
 
26e06c3
 
aafec2f
 
 
 
 
 
 
 
 
76126cd
 
aafec2f
76126cd
 
 
aafec2f
0c0f648
 
 
aafec2f
 
0c0f648
aafec2f
0c0f648
 
 
aafec2f
0c0f648
 
aafec2f
0c0f648
aafec2f
 
 
0c0f648
 
aafec2f
0c0f648
aafec2f
 
 
 
 
 
0c0f648
 
 
 
aafec2f
85e967b
aafec2f
 
26e06c3
aafec2f
0c0f648
26e06c3
0c0f648
aafec2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0c0f648
 
 
aafec2f
0c0f648
 
aafec2f
85e967b
aafec2f
 
0c0f648
aafec2f
 
0c0f648
 
 
 
 
aafec2f
0c0f648
aafec2f
 
0c0f648
aafec2f
0c0f648
 
aafec2f
26e06c3
37f141e
0c0f648
aafec2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37f141e
0c0f648
 
 
 
aafec2f
0c0f648
aafec2f
0c0f648
aafec2f
0c0f648
aafec2f
 
 
 
 
 
 
 
 
 
 
0c0f648
aafec2f
0c0f648
aafec2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37f141e
0c0f648
 
aafec2f
26e06c3
aafec2f
 
 
 
 
26e06c3
 
aafec2f
26e06c3
aafec2f
b1314ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26e06c3
0c0f648
76126cd
 
aafec2f
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
library(shiny)
library(shinyMobile)
library(shinyalert)
library(shinyWidgets)
library(glue)
library(dplyr)
library(dbplyr)
library(stringr)

word_wrap <- function(x){
  str_split(x, ",") |> 
    unlist() |> 
    str_trim("both") |> 
    sapply(FUN = function(k){
      if_else(is.na(k), "-", k)
    }) |> 
    sapply(FUN = function(z){
      if_else(nchar(z) > 90,
              paste(substring(z, 1, 30), substring(z, 31, 60), substring(z, 61, 90), substring(z, 91), sep = "<br>"),
              if_else(nchar(z) > 60, paste(substring(z, 1, 30), substring(z, 31, 60), substring(z, 61), sep = "<br>"),
                      if_else(nchar(z) > 30, paste(substring(z, 1, 30), substring(z, 31), sep = "<br>"),
                              z)))
    }) |> 
    str_c(collapse = ",<br>") |> 
    HTML()
}

ui <- f7Page(
  options = list(theme = "ios", dark = FALSE, skeletonOnLoad = TRUE), 
  allowPWA = TRUE, 
  f7TabLayout(
    navbar = f7Navbar(title = "SIMPASI"), 
    f7Tabs(animated = T, 
           id = "tabs", 
           f7Tab(tabName = "input_menu", title = "Input Menu", active = TRUE, icon = f7Icon("book"), 
                 # Content 
                 f7Card(
                   h4(span(f7Icon("calendar"), "Tanggal"), style="margin:0px 0px 10px 0px;"),
                   f7DatePicker("tgl", NULL), 
                   hr()
                   ), 
                 f7Card(
                   h4(span(f7Icon("tray"), "Karbohidrat"), style="margin:0px 0px 10px 0px;"),
                   f7TextArea("karbo", NULL, resize = TRUE), 
                   hr()
                 ), 
                 f7Card(
                   h4(span(f7Icon("poultry_leg"), "Protein Hewani"), style="margin:0px 0px 10px 0px;"),
                   f7TextArea("protein_hewani", NULL, resize = TRUE), 
                   hr()
                 ), 
                 f7Card(
                   h4(span(f7Icon("tree"), "Protein Nabati"), style="margin:0px 0px 10px 0px;"),
                   f7TextArea("protein_nabati", NULL, resize = TRUE), 
                   hr()
                 ), 
                 f7Card(
                   h4(span(f7Icon("leaf_arrow_circlepath"), "Buah/Sayur"), style="margin:0px 0px 10px 0px;"),
                   f7TextArea("buah_sayur", NULL, resize = TRUE), 
                   hr()
                 ), 
                 f7Card(
                   h4(span(f7Icon("drop"), "Lemak Tambahan"), style="margin:0px 0px 10px 0px;"),
                   f7TextArea("lemak_tambahan", NULL, resize = TRUE), 
                   hr()
                 ), 
                 f7Card(
                   h4(span(f7Icon("circle_grid_hex"), "Camilan"), style="margin:0px 0px 10px 0px;"),
                   f7TextArea("camilan", NULL, resize = TRUE), 
                   hr()
                 ), 
                 f7Card(
                   h4(span(f7Icon("bandage"), "Gejala Alergi"), style="margin:0px 0px 10px 0px;"),
                   f7TextArea("gejala", NULL, resize = TRUE), 
                   hr()
                 ), 
                 f7Card(
                   h4(span(f7Icon("calendar_today"), "Tanggal Terjadi Gejala"), style="margin:0px 0px 10px 0px;"),
                   f7DatePicker("tgl_gejala", NULL),
                   hr()
                 ),
                 
                 f7Card(
                   f7Button("save", "Simpan", size = "large"), 
                   br(), 
                   p("Copyright (C) 2024 aephidayatuloh", style = "text-align: center")
                 )
                 ), 
           f7Tab(tabName = "cari", title = "Cari Catatan", icon = f7Icon("doc_text_search"),
                 # Content 
                 f7Card(
                   f7Select("komponen", "Cari berdasarkan:", width = "100%", 
                                         choices = list("Tanggal" = "tanggal", 
                                                        "Karbohidrat" = "karbo", 
                                                        "Protein Hewani" = "protein_hewani", 
                                                        "Protein Nabati" = "protein_nabati", 
                                                        "Buah/Sayur" = "buah_sayur", 
                                                        "Lemak Tambahan" = "lemak_tambahan", 
                                                        "Camilan" = "camilan", 
                                                        "Gejala Alergi" = "gejala"))
                   ), 
                     conditionalPanel("input.komponen == 'tanggal'", 
                                      f7Card(
                                        h4(span(f7Icon("calendar"), "Tanggal MPASI"), style="margin:0px 0px 10px 0px;"), 
                                        f7DatePicker("cari_date", NULL, value = Sys.Date()), 
                                        hr()
                                        ), 
                                      f7Card(
                                        f7Segment(container = "row", 
                                                  f7Button("prev", "< Prev", size = "large"), 
                                                  f7Button("nex", "Next >", size = "large")
                                                  )
                                        ), 
                                      f7Card(uiOutput("out_cari_tgl"))
                                      
                     ), 
                     conditionalPanel("input.komponen != 'tanggal'", 
                                      f7Card(
                                        p("Kata Kunci", style="text-align:center;"),
                                        f7Text("keyword", NULL, value = ""), 
                                        hr(style="margin:5px 0px;")
                                        ), 
                                      uiOutput("out_cari_komponen")
                                      
                     )
                   
                 
           ), 
           f7Tab(tabName = "update_gejala", title = "Update Gejala", icon = f7Icon("bubble_left_bubble_right"), 
                 # Content
                 f7Card(
                   h4(span(f7Icon("calendar_today"), "Tanggal Terjadi Gejala"), style="margin:0px 0px 10px 0px;"),
                   f7DatePicker("edit_tgl_gejala", NULL),
                   hr()
                   ), 
                 f7Card(
                   h4(span(f7Icon("bandage"), "Gejala Alergi"), style="margin:0px 0px 10px 0px;"),
                   f7TextArea("edit_gejala", NULL, resize = TRUE), 
                   hr()
                 ), 
                 f7Card(
                   h4(span(f7Icon("bandage"), "Tanggal Pemberian MPASI"), style="margin:0px 0px 10px 0px;"),
                   f7DatePicker("edit_tanggal", NULL), 
                   hr()
                 ), 
                 f7Card(
                   f7Button("edit_update", "Update", size = "large")
                 )
                 )
    )
  )
)

server <- function(input, output, session){
  menu_tbl <- reactive({
    # source("dbconnect.R")
    # menu <- pg_con |>
    pg_con |>
      tbl("menu")
    # dbDisconnect(pg_con)
    # return(menu)
  })

  observeEvent(input$save, {
    shinyalert(text = "Yakin ingin menyimpan?", type = "info", showCancelButton = TRUE,
               callbackR = function(x){
                 if(x  != FALSE){
                   shinyalert(text = "Menyimpan data ...", type = "info", showConfirmButton = FALSE, closeOnEsc = FALSE, closeOnClickOutside = FALSE)
                   tgl_gejala <- if_else(input$gejala %in% c(NA, NULL, "", "-"), NA , as.Date(input$tgl_gejala))

                   # source("dbconnect.R")
                   # query <- glue("INSERT INTO public.menu (id_parent, id_anak, tanggal, karbo, protein_hewani, protein_nabati, buah_sayur, lemak_tambahan, camilan, gejala, tgl_gejala, created_date)
                   #                   VALUES (1, 2, '{input$tgl}', '{input$karbo}', '{input$protein_hewani}', '{input$protein_nabati}', '{input$buah_sayur}', '{input$lemak_tambahan}', '{input$camilan}', '{input$gejala}', {tgl_gejala}, '{Sys.time()}')")
                   menu_data <- tribble(
                     ~id_parent, ~id_anak, ~tanggal, ~karbo, ~protein_hewani, ~protein_nabati, ~buah_sayur, ~lemak_tambahan, ~camilan, ~gejala, ~tgl_gejala, ~created_date,
                     1, 2, input$tgl, input$karbo, input$protein_hewani, input$protein_nabati, input$buah_sayur, input$lemak_tambahan, input$camilan, input$gejala, tgl_gejala, Sys.time()
                   )

                   pg_con |>
                     dbAppendTable(name = "menu", value = menu_data)
                   # dbDisconnect(pg_con)
                   updateF7DatePicker(session = session, "tgl", NULL, value = Sys.Date())
                   updateF7TextArea(session = session, "karbo", NULL, value = "")
                   updateF7TextArea(session = session, "protein_hewani", NULL, value = "")
                   updateF7TextArea(session = session, "protein_nabati", NULL, value = "")
                   updateF7TextArea(session = session, "buah_sayur", NULL, value = "")
                   updateF7TextArea(session = session, "lemak_tambahan", NULL, value = "")
                   updateF7TextArea(session = session, "camilan", NULL, value = "")
                   updateF7TextArea(session = session, "gejala", NULL, value = "")
                   updateF7DatePicker(session = session, "tgl_gejala", NULL, value = Sys.Date())
                   # closeAlert()
                   shinyalert(text = "Data berhasil disimpan.", type = "success", immediate = TRUE)

                 }
               })
  })

  observeEvent(input$prev, {
    date_val <- reactiveValues()
    date_val$curr_dt <- input$cari_date
    updateF7DatePicker("cari_date", NULL, value = date_val$curr_dt - 1, session = session)
  }
  )

  observeEvent(input$nex, {
    date_val <- reactiveValues()
    date_val$curr_dt <- input$cari_date
    updateF7DatePicker("cari_date", NULL, value = date_val$curr_dt + 1, session = session)
  }
  )

  observeEvent(input$prev_history, {
    date_val_history <- reactiveValues()
    date_val_history$curr_dt_history <- as.Date(input$history_date)
    updateF7DatePicker(inputId = "history_date", NULL, value = date_val_history$curr_dt_history - 1, session = session)
  }
  )

  observeEvent(input$nex_history, {
    message("Next sampai sini bisa")
    date_val_history <- reactiveValues()
    message("Next sampai reactivevalues() bisa")
    date_val_history$curr_dt_history <- as.Date(input$history_date)
    message("Next sampai update reactiveValues bisa")
    updateF7DatePicker(inputId = "history_date", NULL, value = date_val_history$curr_dt_history + 1, session = session)
  }
  )
  
  output$out_cari_tgl <- renderUI({
    cari_menu <- menu_tbl() |>
      collect() |>
      mutate(across(karbo:gejala, ~if_else(.x == "", "-", .x))) |>
      filter(tanggal == input$cari_date) |>
      mutate(tgl_gejala = tgl_gejala |> as.Date() |> format("%d %b %Y"))

    if(nrow(cari_menu) == 0){
      p("Tidak ada catatan", style="text-align: center;")
    } else {
      f7List(
        f7ListItem(media = f7Icon("calendar"), 
                   header = "Tanggal", 
                   h5(format(input$cari_date, "%d %b %Y"), style="margin: 5px 0px;")
                   ), 
        f7ListItem(media = f7Icon("tray"), 
                   header = "Karbohidrat", 
                   h5(word_wrap(cari_menu$karbo), style="margin: 5px 0px;")
        ), 
        f7ListItem(media = f7Icon("poultry_leg"), 
                   header = "Protein Hewani", 
                   h5(word_wrap(cari_menu$protein_hewani), style="margin: 5px 0px;")
        ), 
        f7ListItem(media = f7Icon("tree"), 
                   header = "Protein Nabati", 
                   h5(word_wrap(cari_menu$protein_nabati), style="margin: 5px 0px;")
        ), 
        f7ListItem(media = f7Icon("leaf_arrow_circlepath"), 
                   header = "Buah/Sayur", 
                   h5(word_wrap(cari_menu$buah_sayur), style="margin: 5px 0px;")
        ), 
        f7ListItem(media = f7Icon("drop"), 
                   header = "Lemak Tambahan", 
                   h5(word_wrap(cari_menu$lemak_tambahan), style="margin: 5px 0px;")
        ), 
        f7ListItem(media = f7Icon("circle_grid_hex"), 
                   header = "Camilan", 
                   h5(word_wrap(cari_menu$camilan), style="margin: 5px 0px;")
        ), 
        f7ListItem(media = f7Icon("bandage"), 
                   header = "Gejala Alergi", 
                   h5(word_wrap(cari_menu$gejala), style="margin: 5px 0px;color: red;")
        ), 
        f7ListItem(media = f7Icon("calendar_today"), 
                   header = "Tanggal Terjadi Gejala", 
                   h5(ifelse(is.na(cari_menu$tgl_gejala), "-", cari_menu$tgl_gejala), style="margin: 5px 0px;color: red;")
        )
      )
    }
  })

  cari_history <- reactive({
    if(input$keyword != ""){
      menu_tbl() |>
        collect() |>
        mutate(across(karbo:gejala, ~if_else(.x == "", "-", .x))) |>
        mutate(tgl_gejala = tgl_gejala |> as.Date() |> format("%d %b %Y")) |>
        mutate(kolom := tolower(!!sym(input$komponen))) |> #slice(1)
        filter(str_detect(kolom, tolower(input$keyword))) |> 
        arrange(tanggal)
    } else {
      x <- data.frame(x = 0)
      return(x)
    }
  })

  history <- reactive({
    cari_history() |>
      slice(input$index_history_komponen)
  })

  output$out_history <- renderUI({
    if(ncol(cari_history()) == 1 | input$keyword == "" | nrow(history()) == 0){
      wellPanel(style="background-color:transparent;",
                p("Tidak ada catatan", style="text-align: center;")
      )
    } else if(ncol(cari_history()) >= 1){
      f7Card(
        f7List(
          
          f7ListItem(media = f7Icon("calendar"), 
                     header = "Tanggal", 
                     h5(format(as.Date(history()$tanggal), "%d %b %Y"), style="margin: 5px 0px;")
          ), 
          f7ListItem(media = f7Icon("tray"), 
                     header = "Karbohidrat", 
                     h5(word_wrap(history()$karbo), 
                        style="margin: 5px 0px;max-width: 300px;overflow-wrap: inherit;word-wrap: inherit;hyphens: auto;")
          ), 
          f7ListItem(media = f7Icon("poultry_leg"), 
                     header = "Protein Hewani", 
                     h5(word_wrap(history()$protein_hewani), 
                        style="margin: 5px 0px;max-width: 300px;overflow-wrap: inherit;word-wrap: inherit;hyphens: auto;")
          ), 
          f7ListItem(media = f7Icon("tree"), 
                     header = "Protein Nabati", 
                     h5(word_wrap(history()$protein_nabati), style="margin: 5px 0px;max-width: 300px;")
          ), 
          f7ListItem(media = f7Icon("leaf_arrow_circlepath"), 
                     header = "Buah/Sayur", 
                     h5(word_wrap(history()$buah_sayur), style="margin: 5px 0px;")
          ), 
          f7ListItem(media = f7Icon("drop"), 
                     header = "Lemak Tambahan", 
                     h5(word_wrap(history()$lemak_tambahan), style="margin: 5px 0px;")
          ), 
          f7ListItem(media = f7Icon("circle_grid_hex"), 
                     header = "Camilan", 
                     h5(word_wrap(history()$camilan), style="margin: 5px 0px;")
          ), 
          f7ListItem(media = f7Icon("bandage"), 
                     header = "Gejala Alergi", 
                     h5(word_wrap(history()$gejala), style="margin: 5px 0px;color: red;")
          ), 
          f7ListItem(media = f7Icon("calendar_today"), 
                     header = "Tanggal Terjadi Gejala", 
                     h5(ifelse(is.na(history()$tgl_gejala), "-", history()$tgl_gejala), style="margin: 5px 0px;color: red;")
          )
        )
      )
    }
  })
  output$out_cari_komponen <- renderUI({

    if(ncol(cari_history()) == 1 | input$keyword == "" | nrow(cari_history()) == 0){
      f7Card(p("Tidak ada catatan", style="text-align: center;"))
    } else if(nrow(cari_history()) > 1){
      n_history_komponen <- nrow(cari_history())
      tagList(
        # f7DatePicker("history_date", NULL, 
        #                    value = min(cari_history()$tanggal)),
        div(style="margin-left: 120px;width:150%;", 
            f7Stepper("index_history_komponen", label = NULL, value = 1, min = 1, max = n_history_komponen, step = 1, 
                  raised = TRUE, rounded = TRUE, size = "small", fill = TRUE, color = "blue", wraps = TRUE)
            ), 
        # f7Segment(container = "segment", 
        #     f7Button("prev_history", "< Prev"),
        #     f7Button("nex_history", "Next >")
        # ),
        uiOutput("out_history")
      )

    } else {
      f7Card(
        f7List(
          f7ListItem(media = f7Icon("calendar"), 
                     header = "Tanggal", 
                     h5(format(as.Date(cari_history()$tanggal), "%d %b %Y"), style="margin: 5px 0px;")
          ), 
          f7ListItem(media = f7Icon("tray"), 
                     header = "Karbohidrat", 
                     h5(word_wrap(cari_history()$karbo), 
                        style="margin: 5px 0px;max-width: 300px;overflow-wrap: inherit;word-wrap: inherit;hyphens: auto;")
          ), 
          f7ListItem(media = f7Icon("poultry_leg"), 
                     header = "Protein Hewani", 
                     h5(word_wrap(cari_history()$protein_hewani), 
                        style="margin: 5px 0px;max-width: 300px;overflow-wrap: inherit;word-wrap: inherit;hyphens: auto;")
          ), 
          f7ListItem(media = f7Icon("tree"), 
                     header = "Protein Nabati", 
                     h5(word_wrap(cari_history()$protein_nabati), style="margin: 5px 0px;max-width: 300px;")
          ), 
          f7ListItem(media = f7Icon("leaf_arrow_circlepath"), 
                     header = "Buah/Sayur", 
                     h5(word_wrap(cari_history()$buah_sayur), style="margin: 5px 0px;")
          ), 
          f7ListItem(media = f7Icon("drop"), 
                     header = "Lemak Tambahan", 
                     h5(word_wrap(cari_history()$lemak_tambahan), style="margin: 5px 0px;")
          ), 
          f7ListItem(media = f7Icon("circle_grid_hex"), 
                     header = "Camilan", 
                     h5(word_wrap(cari_history()$camilan), style="margin: 5px 0px;")
          ), 
          f7ListItem(media = f7Icon("bandage"), 
                     header = "Gejala Alergi", 
                     h5(word_wrap(cari_history()$gejala), style="margin: 5px 0px;color: red;")
          ), 
          f7ListItem(media = f7Icon("calendar_today"), 
                     header = "Tanggal Terjadi Gejala", 
                     h5(ifelse(is.na(cari_history()$tgl_gejala), "-", cari_history()$tgl_gejala), style="margin: 5px 0px;color: red;")
          )
        )
      )
    }

  })

  observeEvent(input$edit_update, {
    shinyalert(type = "info",
               text = "Anda yakin ingin memperbarui data?",
               showCancelButton = TRUE, showConfirmButton = TRUE,
               callbackR = function(x){
                 if(x != FALSE){
                   shinyalert(type = "info", text = "Sedang diproses...", immediate = TRUE,
                              showConfirmButton = FALSE, closeOnEsc = FALSE, closeOnClickOutside = FALSE)

                   if(menu_tbl() |> 
                      collect() |> 
                      filter(tanggal == input$edit_tanggal) |> 
                      nrow() < 1){
                     shinyalert(type = "warning", text = "Tidak ada data untuk tanggal MPASI tersebut", immediate = TRUE,
                                showCancelButton = FALSE, showConfirmButton = TRUE, 
                                closeOnEsc = FALSE, closeOnClickOutside = FALSE)
                   } else {
                     qr <- glue("UPDATE public.menu SET gejala = '{input$edit_gejala}', tgl_gejala = '{input$edit_tgl_gejala}' WHERE tanggal = '{input$edit_tanggal}'")
                     r <- dbSendQuery(pg_con, qr)
                     dbClearResult(r)
                     
                     updateF7DatePicker("edit_tgl_gejala", NULL, value = Sys.Date(), session = session)
                     updateF7TextArea("edit_gejala", NULL, value = "", session = session)
                     updateF7DatePicker("edit_tanggal", NULL, value = Sys.Date(), session = session)
                     
                     shinyalert(type = "success", text = "Data berhasil diperbarui", immediate = TRUE,
                                showCancelButton = FALSE, showConfirmButton = TRUE, 
                                closeOnEsc = FALSE, closeOnClickOutside = FALSE)
                     }
                   }
               })
  })
}

shinyApp(ui, server, 
         onStart = function(){
           source("dbconnect.R")
           onStop(function(){
             dbDisconnect(pg_con)
             })
           }
         )