From 9567290f0d8967c729edc425461e33babf6f5cdc Mon Sep 17 00:00:00 2001 From: Lheorvine Date: Mon, 26 May 2025 17:36:01 +0200 Subject: [PATCH] polish #1 --- migrations/20250525163531_cena.sql | 3 +++ src/main.rs | 8 +++++--- static/css/styles.css | 31 +++++++++++++----------------- static/index.html | 2 +- static/js/main.js | 27 ++++++++------------------ 5 files changed, 30 insertions(+), 41 deletions(-) create mode 100644 migrations/20250525163531_cena.sql diff --git a/migrations/20250525163531_cena.sql b/migrations/20250525163531_cena.sql new file mode 100644 index 0000000..6578bea --- /dev/null +++ b/migrations/20250525163531_cena.sql @@ -0,0 +1,3 @@ +ALTER TABLE ksiazki +ALTER COLUMN cena TYPE DECIMAL(10,2), +ALTER COLUMN cena SET NOT NULL; diff --git a/src/main.rs b/src/main.rs index 3224d22..f3ce665 100644 --- a/src/main.rs +++ b/src/main.rs @@ -182,7 +182,8 @@ async fn get_ksiazki( cena, COALESCE('/images/' || obraz_url, '/images/placeholder.jpg') as obraz_url, COALESCE(opis, 'Brak opisu') as opis - FROM ksiazki"; + FROM ksiazki + ORDER BY tytul"; let sort_clause = match sort_by { "price_asc" => " ORDER BY cena ASC", @@ -294,7 +295,8 @@ async fn get_cart( COALESCE('/images/' || NULLIF(b.obraz_url, ''), '/images/placeholder.jpg') as "obraz_url!" FROM koszyk k JOIN ksiazki b ON k.book_id = b.id - WHERE k.user_id = $1"#, + WHERE k.user_id = $1 + ORDER BY b.tytul"#, user_id ) .fetch_all(pool.get_ref()) @@ -359,7 +361,7 @@ async fn get_order_history( JOIN pozycje_zamowienia pz ON z.id = pz.zamowienie_id JOIN ksiazki k ON pz.book_id = k.id WHERE z.user_id = $1 - ORDER BY z.data_zamowienia DESC + ORDER BY z.id DESC, k.tytul ASC "#, user_id ) diff --git a/static/css/styles.css b/static/css/styles.css index f6269e3..a60c94b 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -76,28 +76,23 @@ footer { } .book-card { - aspect-ratio: 5/8; - position: relative; - transition: transform 0.3s; -} - -.book-cover img { - width: 100%; height: 100%; - object-fit: cover; - border-radius: 5px; -} - -.book-cover { - height: 100%; - width: 100%; - border-radius: 2px; - overflow: hidden; + display: flex; + flex-direction: column; + background: #1a1a1a; + border: 1px solid #343434; + transition: transform 0.3s ease; } .book-card:hover { - transform: scale(1.05); - z-index: 1; + transform: translateY(-5px); +} + +.book-cover { + width: 100%; + height: 300px; + object-fit: contain; + padding: 15px; } .book-overlay { diff --git a/static/index.html b/static/index.html index 23e1853..b53a2fd 100644 --- a/static/index.html +++ b/static/index.html @@ -50,7 +50,7 @@

NOWOŚCI

-
+
diff --git a/static/js/main.js b/static/js/main.js index 6ec00b9..cbf6113 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -128,25 +128,14 @@ function renderBooks(books) { } container.innerHTML = books.map(book => ` -
-
- -
- ${book.tytul} -
-
${book.tytul}
-
-
-
-
-
${book.tytul}
-

${book.autor}

-

${book.cena} PLN

- -
+ `).join('');