1 Commits
Author SHA1 Message Date
kennyboy55 0f90972bcb 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
2026-08-11 11:56:17 +02:00
+2 -6
View File
@@ -17,7 +17,6 @@ function toDate(value: Date | string | null | undefined): Date | null {
}
function DrinkCard(arg:Arguments) {
var trimmedDescription = arg.drink.description.length > 120 ? arg.drink.description.substring(0, 120) + "..." : arg.drink.description;
var link = "/inventory/";
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 latestTimestamp = drinkAddedAt && (!latestActivity || drinkAddedAt.getTime() > latestActivity.getTime())
? drinkAddedAt
: latestActivity;
const isNewlyAdded = latestTimestamp ? (Date.now() - latestTimestamp.getTime()) <= 30 * 24 * 60 * 60 * 1000 : false;
const isNewlyAdded = drinkAddedAt ? (Date.now() - drinkAddedAt.getTime()) <= 30 * 24 * 60 * 60 * 1000 : false;
const isRecentlyRestocked = latestActivity ? (Date.now() - latestActivity.getTime()) <= 14 * 24 * 60 * 60 * 1000 : false;
return (
@@ -76,7 +72,7 @@ function DrinkCard(arg:Arguments) {
className='position-absolute top-0 start-0 m-2 text-wrap'
style={{ zIndex: 2 }}
>
{isNewlyAdded && isRecentlyRestocked ? "New · Restocked" : isNewlyAdded ? "New" : "Recently added"}
{isNewlyAdded && isRecentlyRestocked ? "New · Restocked" : isNewlyAdded ? "New" : "Restocked"}
</Badge>
) : null }
<Card.Img