diff --git a/app/page.tsx b/app/page.tsx index bce225c..a5595a3 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -175,7 +175,10 @@ export default function Home() { - + f.sale_active === true)} + maxSalePercentage={Math.max(...filaments.filter(f => f.sale_active).map(f => f.sale_percentage || 0), 0)} + /> ({ days: 0, hours: 0, minutes: 0, seconds: 0 }); const [mounted, setMounted] = useState(false); @@ -58,15 +63,21 @@ export function SaleCountdown() { return
; // Placeholder to prevent hydration mismatch } + // Only show countdown if there are active sales + if (!hasActiveSale) return null; + const isActive = timeLeft.days > 0 || timeLeft.hours > 0 || timeLeft.minutes > 0 || timeLeft.seconds > 0; if (!isActive) return null; return ( -
-
-

🔥 AKCIJA SE ZAVRŠAVA!

-

Popust od 5% važi još:

+
+
+
+

AKCIJA SE ZAVRŠAVA!

+

+ Popust od {maxSalePercentage}% važi još: +

@@ -89,10 +100,6 @@ export function SaleCountdown() {
sek
- -

- Poruči sada i uštedi na Bambu Lab filamentima! -

); diff --git a/src/components/SaleManager.tsx b/src/components/SaleManager.tsx index e02fdbc..a06d38b 100644 --- a/src/components/SaleManager.tsx +++ b/src/components/SaleManager.tsx @@ -14,13 +14,17 @@ export function SaleManager({ filaments, selectedFilaments, onSaleUpdate }: Sale const [saleStartDate, setSaleStartDate] = useState(''); const [saleEndDate, setSaleEndDate] = useState(''); const [enableSale, setEnableSale] = useState(true); - const [applyToAll, setApplyToAll] = useState(false); const [loading, setLoading] = useState(false); const handleSaleUpdate = async () => { + if (selectedFilaments.size === 0) { + alert('Molimo izaberite filamente za primenu popusta'); + return; + } + setLoading(true); try { - const filamentIds = applyToAll ? undefined : Array.from(selectedFilaments); + const filamentIds = Array.from(selectedFilaments); try { await filamentService.updateBulkSale({ @@ -45,7 +49,6 @@ export function SaleManager({ filaments, selectedFilaments, onSaleUpdate }: Sale setSaleStartDate(''); setSaleEndDate(''); setEnableSale(true); - setApplyToAll(false); } catch (error) { console.error('Error updating sale:', error); alert('Greška pri ažuriranju popusta'); @@ -79,23 +82,9 @@ export function SaleManager({ filaments, selectedFilaments, onSaleUpdate }: Sale
- - - {!applyToAll && ( -

- Izabrano: {selectedFilaments.size} filament{selectedFilaments.size === 1 ? '' : 'a'} -

- )} +

+ Izabrano: {selectedFilaments.size} filament{selectedFilaments.size === 1 ? '' : 'a'} +

@@ -166,7 +155,7 @@ export function SaleManager({ filaments, selectedFilaments, onSaleUpdate }: Sale diff --git a/src/styles/index.css b/src/styles/index.css index 0809d07..40af6cb 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -28,4 +28,18 @@ .no-transitions * { transition: none !important; } +} + +/* Shimmer animation for sale banner */ +@keyframes shimmer { + 0% { + transform: translateX(-100%); + } + 100% { + transform: translateX(200%); + } +} + +.animate-shimmer { + animation: shimmer 3s ease-in-out infinite; } \ No newline at end of file