6.8.3: Последний объём из истории в плейсхолдере
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m20s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m20s
This commit is contained in:
@@ -17742,6 +17742,7 @@ type ShoppingItem struct {
|
|||||||
Completed int `json:"completed"`
|
Completed int `json:"completed"`
|
||||||
LastCompletedAt *string `json:"last_completed_at,omitempty"`
|
LastCompletedAt *string `json:"last_completed_at,omitempty"`
|
||||||
CreatedAt string `json:"created_at"`
|
CreatedAt string `json:"created_at"`
|
||||||
|
LastVolume *float64 `json:"last_volume,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShoppingItemRequest struct {
|
type ShoppingItemRequest struct {
|
||||||
@@ -18722,6 +18723,18 @@ func (a *App) getShoppingItemHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
item.CreatedAt = createdAt.Format(time.RFC3339)
|
item.CreatedAt = createdAt.Format(time.RFC3339)
|
||||||
|
|
||||||
|
// Получаем последний купленный объём из истории
|
||||||
|
var lastVolume sql.NullFloat64
|
||||||
|
a.DB.QueryRow(`
|
||||||
|
SELECT volume FROM shopping_item_history
|
||||||
|
WHERE item_id = $1
|
||||||
|
ORDER BY completed_at DESC
|
||||||
|
LIMIT 1
|
||||||
|
`, itemID).Scan(&lastVolume)
|
||||||
|
if lastVolume.Valid {
|
||||||
|
item.LastVolume = &lastVolume.Float64
|
||||||
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(item)
|
json.NewEncoder(w).Encode(item)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "play-life-web",
|
"name": "play-life-web",
|
||||||
"version": "6.8.2",
|
"version": "6.8.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ function ShoppingItemDetail({ itemId, onClose, onRefresh, onItemCompleted, onNav
|
|||||||
throw new Error('Неверное значение объёма')
|
throw new Error('Неверное значение объёма')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
payload.volume = item.volume_base
|
payload.volume = item.last_volume ?? item.volume_base
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await authFetch(`/api/shopping/items/${itemId}/complete`, {
|
const response = await authFetch(`/api/shopping/items/${itemId}/complete`, {
|
||||||
@@ -189,7 +189,7 @@ function ShoppingItemDetail({ itemId, onClose, onRefresh, onItemCompleted, onNav
|
|||||||
step="any"
|
step="any"
|
||||||
value={volumeValue}
|
value={volumeValue}
|
||||||
onChange={(e) => setVolumeValue(e.target.value)}
|
onChange={(e) => setVolumeValue(e.target.value)}
|
||||||
placeholder={item.volume_base?.toString() || '1'}
|
placeholder={(item.last_volume ?? item.volume_base)?.toString() || '1'}
|
||||||
className="progression-input"
|
className="progression-input"
|
||||||
/>
|
/>
|
||||||
<div className="progression-controls-capsule">
|
<div className="progression-controls-capsule">
|
||||||
|
|||||||
Reference in New Issue
Block a user