Compare commits
1 Commits
docs/packa
...
feat/roast
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c891cebe6 |
@@ -26,6 +26,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
{
|
{
|
||||||
Name: "Espresso",
|
Name: "Espresso",
|
||||||
RoastType: "Dark Roast",
|
RoastType: "Dark Roast",
|
||||||
|
RoastLevel: 5,
|
||||||
Ounces: 2,
|
Ounces: 2,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 1800, // $18.00
|
Price: 1800, // $18.00
|
||||||
@@ -35,6 +36,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
{
|
{
|
||||||
Name: "Americano",
|
Name: "Americano",
|
||||||
RoastType: "Medium Roast",
|
RoastType: "Medium Roast",
|
||||||
|
RoastLevel: 3,
|
||||||
Ounces: 8,
|
Ounces: 8,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 2200, // $22.00
|
Price: 2200, // $22.00
|
||||||
@@ -44,6 +46,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
{
|
{
|
||||||
Name: "Cappuccino",
|
Name: "Cappuccino",
|
||||||
RoastType: "Medium Roast",
|
RoastType: "Medium Roast",
|
||||||
|
RoastLevel: 3,
|
||||||
Ounces: 6,
|
Ounces: 6,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 2200, // $22.00
|
Price: 2200, // $22.00
|
||||||
@@ -53,6 +56,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
{
|
{
|
||||||
Name: "Latte",
|
Name: "Latte",
|
||||||
RoastType: "Medium Roast",
|
RoastType: "Medium Roast",
|
||||||
|
RoastLevel: 2,
|
||||||
Ounces: 12,
|
Ounces: 12,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 2500, // $25.00
|
Price: 2500, // $25.00
|
||||||
@@ -62,6 +66,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
{
|
{
|
||||||
Name: "Mocha",
|
Name: "Mocha",
|
||||||
RoastType: "Dark Roast",
|
RoastType: "Dark Roast",
|
||||||
|
RoastLevel: 4,
|
||||||
Ounces: 12,
|
Ounces: 12,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 3000, // $30.00
|
Price: 3000, // $30.00
|
||||||
@@ -71,6 +76,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
{
|
{
|
||||||
Name: "Macchiato",
|
Name: "Macchiato",
|
||||||
RoastType: "Dark Roast",
|
RoastType: "Dark Roast",
|
||||||
|
RoastLevel: 4,
|
||||||
Ounces: 3,
|
Ounces: 3,
|
||||||
BeanType: "Robusta Blend",
|
BeanType: "Robusta Blend",
|
||||||
Price: 1800, // $18.00
|
Price: 1800, // $18.00
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ type Coffee struct {
|
|||||||
ID uint `gorm:"primaryKey" json:"id"`
|
ID uint `gorm:"primaryKey" json:"id"`
|
||||||
Name string `gorm:"size:255;not null" json:"name"`
|
Name string `gorm:"size:255;not null" json:"name"`
|
||||||
RoastType string `gorm:"size:100" json:"roast_type"`
|
RoastType string `gorm:"size:100" json:"roast_type"`
|
||||||
|
RoastLevel int `json:"roast_level"` // 1-5 roast-intensity
|
||||||
Ounces int `json:"ounces"`
|
Ounces int `json:"ounces"`
|
||||||
BeanType string `gorm:"size:100" json:"bean_type"`
|
BeanType string `gorm:"size:100" json:"bean_type"`
|
||||||
Price int `gorm:"not null" json:"price"`
|
Price int `gorm:"not null" json:"price"`
|
||||||
|
|||||||
@@ -837,6 +837,7 @@ func NewModel(username string) Model {
|
|||||||
{
|
{
|
||||||
Name: "Espresso",
|
Name: "Espresso",
|
||||||
RoastType: "Dark Roast",
|
RoastType: "Dark Roast",
|
||||||
|
RoastLevel: 5,
|
||||||
Ounces: 2,
|
Ounces: 2,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 350, // $3.50
|
Price: 350, // $3.50
|
||||||
@@ -846,6 +847,7 @@ func NewModel(username string) Model {
|
|||||||
{
|
{
|
||||||
Name: "Latte",
|
Name: "Latte",
|
||||||
RoastType: "Medium Roast",
|
RoastType: "Medium Roast",
|
||||||
|
RoastLevel: 2,
|
||||||
Ounces: 12,
|
Ounces: 12,
|
||||||
BeanType: "Arabica Blend",
|
BeanType: "Arabica Blend",
|
||||||
Price: 500, // $5.00
|
Price: 500, // $5.00
|
||||||
@@ -855,6 +857,7 @@ func NewModel(username string) Model {
|
|||||||
{
|
{
|
||||||
Name: "Cappuccino",
|
Name: "Cappuccino",
|
||||||
RoastType: "Medium Roast",
|
RoastType: "Medium Roast",
|
||||||
|
RoastLevel: 3,
|
||||||
Ounces: 8,
|
Ounces: 8,
|
||||||
BeanType: "Italian Blend",
|
BeanType: "Italian Blend",
|
||||||
Price: 450, // $4.50
|
Price: 450, // $4.50
|
||||||
@@ -864,6 +867,7 @@ func NewModel(username string) Model {
|
|||||||
{
|
{
|
||||||
Name: "Americano",
|
Name: "Americano",
|
||||||
RoastType: "Dark Roast",
|
RoastType: "Dark Roast",
|
||||||
|
RoastLevel: 4,
|
||||||
Ounces: 16,
|
Ounces: 16,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 400, // $4.00
|
Price: 400, // $4.00
|
||||||
@@ -873,6 +877,7 @@ func NewModel(username string) Model {
|
|||||||
{
|
{
|
||||||
Name: "Mocha",
|
Name: "Mocha",
|
||||||
RoastType: "Medium Roast",
|
RoastType: "Medium Roast",
|
||||||
|
RoastLevel: 3,
|
||||||
Ounces: 16,
|
Ounces: 16,
|
||||||
BeanType: "Colombian",
|
BeanType: "Colombian",
|
||||||
Price: 550, // $5.50
|
Price: 550, // $5.50
|
||||||
@@ -882,6 +887,7 @@ func NewModel(username string) Model {
|
|||||||
{
|
{
|
||||||
Name: "Macchiato",
|
Name: "Macchiato",
|
||||||
RoastType: "Dark Roast",
|
RoastType: "Dark Roast",
|
||||||
|
RoastLevel: 4,
|
||||||
Ounces: 3,
|
Ounces: 3,
|
||||||
BeanType: "Robusta Blend",
|
BeanType: "Robusta Blend",
|
||||||
Price: 425, // $4.25
|
Price: 425, // $4.25
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ func (m Model) shopLayout() (contentW, menuW, detailW, wideW int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// roastLevel maps a roast type to a 1-5 intensity for the roast meter.
|
// roastLevel maps a roast type to a 1-5 intensity for the roast meter.
|
||||||
|
// It is the fallback for products stored before the roast_level column existed.
|
||||||
func roastLevel(roastType string) int {
|
func roastLevel(roastType string) int {
|
||||||
rt := strings.ToLower(roastType)
|
rt := strings.ToLower(roastType)
|
||||||
switch {
|
switch {
|
||||||
@@ -105,7 +106,11 @@ func (m Model) shopDetailContent(w int) string {
|
|||||||
pDim.Render(fmt.Sprintf("%dOZ", coffee.Ounces)) + sep +
|
pDim.Render(fmt.Sprintf("%dOZ", coffee.Ounces)) + sep +
|
||||||
pDim.Render(strings.ToUpper(coffee.BeanType))
|
pDim.Render(strings.ToUpper(coffee.BeanType))
|
||||||
|
|
||||||
strength := pDim.Render("roast ") + roastMeter(roastLevel(coffee.RoastType))
|
level := coffee.RoastLevel
|
||||||
|
if level < 1 || level > 5 {
|
||||||
|
level = roastLevel(coffee.RoastType)
|
||||||
|
}
|
||||||
|
strength := pDim.Render("roast ") + roastMeter(level)
|
||||||
|
|
||||||
price := lipgloss.NewStyle().Foreground(lipgloss.Color(coffee.Color)).Bold(true).
|
price := lipgloss.NewStyle().Foreground(lipgloss.Color(coffee.Color)).Bold(true).
|
||||||
Render(fmt.Sprintf("$%d.%02d", coffee.Price/100, coffee.Price%100)) +
|
Render(fmt.Sprintf("$%d.%02d", coffee.Price/100, coffee.Price%100)) +
|
||||||
|
|||||||
Reference in New Issue
Block a user