Fix bug with new/restock labels
Build dev docker image / build (push) Successful in 40s
Build dev docker image / build (push) Successful in 36s
Build dev docker image / release (push) Successful in 2s

This commit is contained in:
2026-08-11 11:56:17 +02:00
parent 36881293ed
commit 0f90972bcb
+2 -6
View File
@@ -17,7 +17,6 @@ function toDate(value: Date | string | null | undefined): Date | null {
} }
function DrinkCard(arg:Arguments) { function DrinkCard(arg:Arguments) {
var trimmedDescription = arg.drink.description.length > 120 ? arg.drink.description.substring(0, 120) + "..." : arg.drink.description;
var link = "/inventory/"; var link = "/inventory/";
switch (arg.drink.type) { switch (arg.drink.type) {
@@ -61,10 +60,7 @@ function DrinkCard(arg:Arguments) {
} }
const drinkAddedAt = toDate((arg.drink as { addedAt?: Date | string | null }).addedAt ?? null); const drinkAddedAt = toDate((arg.drink as { addedAt?: Date | string | null }).addedAt ?? null);
const latestTimestamp = drinkAddedAt && (!latestActivity || drinkAddedAt.getTime() > latestActivity.getTime()) const isNewlyAdded = drinkAddedAt ? (Date.now() - drinkAddedAt.getTime()) <= 30 * 24 * 60 * 60 * 1000 : false;
? drinkAddedAt
: latestActivity;
const isNewlyAdded = latestTimestamp ? (Date.now() - latestTimestamp.getTime()) <= 30 * 24 * 60 * 60 * 1000 : false;
const isRecentlyRestocked = latestActivity ? (Date.now() - latestActivity.getTime()) <= 14 * 24 * 60 * 60 * 1000 : false; const isRecentlyRestocked = latestActivity ? (Date.now() - latestActivity.getTime()) <= 14 * 24 * 60 * 60 * 1000 : false;
return ( return (
@@ -76,7 +72,7 @@ function DrinkCard(arg:Arguments) {
className='position-absolute top-0 start-0 m-2 text-wrap' className='position-absolute top-0 start-0 m-2 text-wrap'
style={{ zIndex: 2 }} style={{ zIndex: 2 }}
> >
{isNewlyAdded && isRecentlyRestocked ? "New · Restocked" : isNewlyAdded ? "New" : "Recently added"} {isNewlyAdded && isRecentlyRestocked ? "New · Restocked" : isNewlyAdded ? "New" : "Restocked"}
</Badge> </Badge>
) : null } ) : null }
<Card.Img <Card.Img