page.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package e19_stripeui_key_info
  2. import (
  3. "fmt"
  4. "time"
  5. . "github.com/qor5/ui/vuetify"
  6. vx "github.com/qor5/ui/vuetifyx"
  7. "github.com/qor5/web"
  8. "github.com/sunfmin/reflectutils"
  9. h "github.com/theplant/htmlgo"
  10. )
  11. type Event struct {
  12. Title string
  13. CreatedAt time.Time
  14. }
  15. func KeyInfoDemo(ctx *web.EventContext) (pr web.PageResponse, err error) {
  16. data := []*Event{
  17. {
  18. "<span><strong>¥5,000</strong> was refunded from a <strong>¥236,170</strong> payment</span>",
  19. time.Now(),
  20. },
  21. {
  22. "<span><strong>¥207,626</strong> was refunded from a <strong>¥236,170</strong> payment</span>",
  23. time.Now(),
  24. },
  25. {
  26. "<span><strong>¥7,848</strong> was refunded from a <strong>¥236,170</strong> payment</span>",
  27. time.Now(),
  28. },
  29. {
  30. "<span><strong>¥5,000</strong> was refunded from a <strong>¥236,170</strong> payment</span>",
  31. time.Now(),
  32. },
  33. {
  34. "<span><strong>¥207,626</strong> was refunded from a <strong>¥236,170</strong> payment</span>",
  35. time.Now(),
  36. },
  37. {
  38. "<span><strong>¥7,848</strong> was refunded from a <strong>¥236,170</strong> payment</span>",
  39. time.Now(),
  40. },
  41. }
  42. dt := vx.DataTable(data).WithoutHeader(true).LoadMoreAt(3, "Show More")
  43. dt.Column("Title").CellComponentFunc(func(obj interface{}, fieldName string, ctx *web.EventContext) h.HTMLComponent {
  44. return h.Td(h.RawHTML(fmt.Sprint(reflectutils.MustGet(obj, fieldName))))
  45. })
  46. dt.Column("CreatedAt").CellComponentFunc(func(obj interface{}, fieldName string, ctx *web.EventContext) h.HTMLComponent {
  47. t := reflectutils.MustGet(obj, fieldName).(time.Time)
  48. return h.Td(h.Text(t.Format("01/02/06, 15:04:05 PM"))).Class("text-right")
  49. })
  50. logsDt := vx.DataTable(data).
  51. WithoutHeader(true).
  52. LoadMoreAt(3, "Show More").
  53. LoadMoreURL("/e20_vuetify_expansion_panels").
  54. RowExpandFunc(func(obj interface{}, ctx *web.EventContext) h.HTMLComponent {
  55. return h.Div().Text(h.JSONString(obj)).Class("pa-5")
  56. })
  57. logsDt.Column("Title").CellComponentFunc(func(obj interface{}, fieldName string, ctx *web.EventContext) h.HTMLComponent {
  58. return h.Td(h.RawHTML(fmt.Sprint(reflectutils.MustGet(obj, fieldName))))
  59. })
  60. logsDt.Column("CreatedAt").CellComponentFunc(func(obj interface{}, fieldName string, ctx *web.EventContext) h.HTMLComponent {
  61. t := reflectutils.MustGet(obj, fieldName).(time.Time)
  62. return h.Td(h.Text(t.Format("01/02/06, 15:04:05 PM"))).Class("text-right")
  63. })
  64. pr.Body = VApp(
  65. VMain(
  66. vx.Card(
  67. vx.KeyInfo(
  68. vx.KeyField(h.Text(time.Now().Format("Jan _2, 15:04 PM"))).Label("Date"),
  69. vx.KeyField(h.A().Href("https://google.com").Text("customer0077N52")).Label("Customer"),
  70. vx.KeyField(h.Text("•••• 4242")).Label("Payment method").Icon(VIcon("credit_card")),
  71. vx.KeyField(h.Text("Normal")).Label("Risk evaluation").Icon(VChip(h.Text("43")).Small(true)),
  72. ),
  73. ).SystemBar(
  74. VIcon("link"),
  75. h.Text("Hello"),
  76. VSpacer(),
  77. h.Text("ch_1EJtQMAqkzzGorqLtIjCEPU5"),
  78. ).Header(
  79. h.Text("$100.00USD"),
  80. VChip(h.Text("Refunded"), VIcon("reply").Small(true)).Small(true),
  81. ).Actions(
  82. VBtn("Edit").Depressed(true),
  83. ).Class("mb-4"),
  84. vx.Card(vx.DetailInfo(
  85. vx.DetailColumn(
  86. vx.DetailField(vx.OptionalText("cus_EnUK8WcwQkuKQP")).Label("ID"),
  87. vx.DetailField(vx.OptionalText(time.Now().Format("2006/01/02 15:04"))).Label("Created"),
  88. vx.DetailField(vx.OptionalText("hello@example.com")).Label("Email"),
  89. vx.DetailField(vx.OptionalText("customer0077N52")).Label("Description"),
  90. vx.DetailField(vx.OptionalText("B0E69DBD")).Label("Invoice prefix"),
  91. vx.DetailField(vx.OptionalText("").ZeroLabel("No VAT number")).Label("VAT number"),
  92. vx.DetailField(vx.OptionalText("Normal")).Label("Risk evaluation").Icon(VChip(h.Text("43")).Small(true)),
  93. ).Header("ACCOUNT INFORMATION"),
  94. vx.DetailColumn(
  95. vx.DetailField(vx.OptionalText("").ZeroLabel("No address")).Label("Address"),
  96. vx.DetailField(vx.OptionalText("").ZeroLabel("No phone number")).Label("Phone number"),
  97. ).Header("BILLING INFORMATION"),
  98. )).HeaderTitle("Details").
  99. Actions(VBtn("Update details").Depressed(true)).
  100. Class("mb-4"),
  101. vx.Card(dt).HeaderTitle("Events").Class("mb-4"),
  102. vx.Card(logsDt).HeaderTitle("Logs").Class("mb-4"),
  103. ),
  104. )
  105. return
  106. }