fix(card): Use correct template endpoints
This commit is contained in:
parent
1657a10dec
commit
5dbe7816cd
@ -48,6 +48,7 @@ func GenerateCard(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
genConfig := &models.CardTemplateOptions{
|
genConfig := &models.CardTemplateOptions{
|
||||||
Cards: cardRequest.Cards,
|
Cards: cardRequest.Cards,
|
||||||
|
CardsSwapped: invertCardArrayItems(cardRequest.Cards),
|
||||||
EventName: "Event name",
|
EventName: "Event name",
|
||||||
CardSubtitle: "Card subtitle",
|
CardSubtitle: "Card subtitle",
|
||||||
BarcodeFormat: "ean13",
|
BarcodeFormat: "ean13",
|
||||||
@ -60,15 +61,24 @@ func GenerateCard(c *fiber.Ctx) error {
|
|||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
c.Set(fiber.HeaderContentType, "text/html")
|
||||||
|
return c.SendString(result)
|
||||||
|
// converter := services.GotenbergConverter{BaseUrl: "http://localhost:3001"}
|
||||||
|
// pdf, err := converter.ToPdf(result, "a4", false)
|
||||||
|
// if err != nil {
|
||||||
|
// return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||||
|
// "error": err.Error(),
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
converter := services.GotenbergConverter{BaseUrl: "http://localhost:3001"}
|
// c.Set(fiber.HeaderContentType, "application/pdf")
|
||||||
pdf, err := converter.ToPdf(result, "a5", true)
|
// return c.Send(pdf)
|
||||||
if err != nil {
|
}
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
|
||||||
"error": err.Error(),
|
func invertCardArrayItems(cards []models.Card) []models.Card {
|
||||||
})
|
inverted := make([]models.Card, 0)
|
||||||
}
|
for i := len(cards) - 1; i >= 0; i-- {
|
||||||
|
inverted = append(inverted, cards[i])
|
||||||
c.Set(fiber.HeaderContentType, "application/pdf")
|
}
|
||||||
return c.Send(pdf)
|
return inverted
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
type CardRequest struct {
|
type CardRequest struct {
|
||||||
Cards []Card `json:"card"`
|
Cards []Card `json:"cards"`
|
||||||
Locale string `json:"locale" enums:"en,de"`
|
Locale string `json:"locale" enums:"en,de"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ type Card struct {
|
|||||||
|
|
||||||
type CardTemplateOptions struct {
|
type CardTemplateOptions struct {
|
||||||
Cards []Card `json:"cards"`
|
Cards []Card `json:"cards"`
|
||||||
|
CardsSwapped []Card `json:"cards_swapped"`
|
||||||
EventName string `json:"event_name"`
|
EventName string `json:"event_name"`
|
||||||
CardSubtitle string `json:"card_subtitle"`
|
CardSubtitle string `json:"card_subtitle"`
|
||||||
BarcodeFormat string `json:"barcode_format"`
|
BarcodeFormat string `json:"barcode_format"`
|
||||||
|
@ -84,7 +84,8 @@ func (t *DefaultTemplater) GenerateBarcode(code int, format string, prefix strin
|
|||||||
|
|
||||||
func (t *DefaultTemplater) StringToTemplate(templateString string) (*template.Template, error) {
|
func (t *DefaultTemplater) StringToTemplate(templateString string) (*template.Template, error) {
|
||||||
return template.New("template").Funcs(template.FuncMap{
|
return template.New("template").Funcs(template.FuncMap{
|
||||||
"barcode": t.GenerateBarcode,
|
"barcode": t.GenerateBarcode,
|
||||||
|
"sponsorLogo": func(id int) string { return "a" },
|
||||||
}).Parse(templateString)
|
}).Parse(templateString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user