product

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

Index

Constants

View Source
const DefaultPageSize = 20

DefaultPageSize is used when no valid per_page query param is supplied.

Variables

View Source
var PageSizes = []int{20, 50, 100}

PageSizes are the selectable "items per page" options for the products list.

Functions

func Form

func Form(
	data layout.AppLayoutData,
	p *model.Product,
	recipe *dto.RecipeDTO,
	cogs int64,
	cogsAvailable bool,
	errMsg string,
	categorySuggestions []string,
	productCategories []model.Category,
	branchOptions []model.Branch,
	productBranches []model.Branch,
	enableRecipes bool,
	lockedType *model.ProductType,
) templ.Component

func Index

func Index(props IndexProps) templ.Component

func Recipe

func Recipe(
	data layout.AppLayoutData,
	product model.Product,
	recipe dto.RecipeDTO,
	ingredients []model.Product,
) templ.Component

Types

type IndexProps

type IndexProps struct {
	Data           layout.AppLayoutData
	Products       []model.Product
	ActiveType     string
	ActiveCategory string
	ActiveBranch   uuid.UUID
	// EnableRecipes gates the Recipe tab — off means this company doesn't
	// use recipes, so it never appears. Ingredients never appear here
	// regardless (they have their own dedicated page).
	EnableRecipes bool
	// TypeLocked, when true, renders this page as the dedicated Ingredients
	// list: hides the type tab row entirely, points all links
	// (new/edit/delete/pagination) at /ingredients instead of /products, and
	// swaps the Price column for Cost (LPPByProduct) since ingredients have
	// no selling price.
	TypeLocked bool
	// LPPByProduct holds each listed product's current and previous
	// procurement cost, used by the Cost column and its trend indicator on
	// the Ingredients list. A product with no key present has no
	// procurement recorded yet. Only populated when TypeLocked.
	LPPByProduct map[uuid.UUID]LPPInfo
	// Categories lists the company's categories, used as the filter
	// dropdown's options.
	Categories []model.Category
	// Branches lists the company's branches, used as the branch filter
	// dropdown's options. Rendered only when there's more than one — a
	// single-branch company has nothing meaningful to filter.
	Branches   []model.Branch
	Search     string
	Page       int
	PerPage    int
	TotalItems int
	// Created, when non-empty, is the name of a product just created —
	// triggers a success toast confirming the save.
	Created string
}

IndexProps holds the data needed to render the products list page.

type LPPInfo added in v0.5.1

type LPPInfo struct {
	Current int64
	// Previous is nil if there's no earlier procurement to compare against.
	Previous *int64
}

LPPInfo holds a product's current and previous last-procurement price, used by the Ingredients list's Cost column and trend indicator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL