Jade/Stripe.go
2024-05-24 09:48:33 +02:00

61 lines
1.8 KiB
Go

package main
import (
"github.com/flosch/pongo2"
"github.com/gofiber/fiber/v2"
)
func PricingTableHandler(c *fiber.Ctx) error {
return c.SendString(generatePricingTableChatHTML())
}
func generatePricingTableChatHTML() string {
stripeTable := `
<stripe-pricing-table pricing-table-id="prctbl_1PJAxDP2nW0okNQyY0Q3mbg4"
publishable-key="pk_live_51OxXuWP2nW0okNQyme1qdwbL535jbMmM1uIUi6U5zcvEUUwKraktmpCzudXNdPSTxlHpw2FbCtxpwbyFFcasQ7aj000tJJGpWW">
</stripe-pricing-table>`
closeBtn := `
<div class="is-flex is-justify-content-flex-end">
<a class="button is-small is-danger is-outlined" hx-get="/loadChat" hx-target="#chat-container" hx-swap="outerHTML"
hx-trigger="click">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</a>
</div>`
htmlString := "<div class='columns is-centered' id='chat-container'><div class='column is-12-mobile is-8-tablet is-6-desktop' id='chat-messages'>"
NextMessages := []TemplateMessage{}
nextMsg := TemplateMessage{
Icon: "icons/bouvai2.png", // Assuming Icon is a field you want to include from Message
Content: "<br>" + stripeTable + closeBtn,
Hidden: false, // Assuming Hidden is a field you want to include from Message
Id: "0",
Name: "JADE",
}
NextMessages = append(NextMessages, nextMsg)
botOut, err := botTmpl.Execute(pongo2.Context{"Messages": NextMessages, "ConversationAreaId": 0, "NotClickable": true, "notFlex": true})
if err != nil {
panic(err)
}
htmlString += botOut
htmlString += "<div style='height: 10px;'></div>"
htmlString += "</div></div>"
// Render the HTML template with the messages
return htmlString
}
func IsCurrentUserSubscribed() bool {
// TODO Ask Stripe if user is subscribed
return true
}
func IsCurrentUserLimiteReached() bool {
// TODO Ask Stripe if user is subscribed
return true
}