Skip to content

Commit

Permalink
add fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
o6ez9na committed Nov 29, 2024
1 parent 8066114 commit f596fb7
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 14 deletions.
Binary file removed frontend/public/tenor.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion frontend/src/components/api/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from "axios";

const Instance = axios.create({
baseURL: "http://127.0.0.1:8000/api/v1",
timeout: 5000,
timeout: 15000,
headers: {
"Content-Type": "application/json",
},
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/auth/logout/Logout.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import React from "react";
import { useNavigate } from "react-router-dom";
import Instance from "../../api/instance";
import {useBasket} from "../../basket-context/BasketContext";
export default function Logout() {
const navigate = useNavigate();
const {clearBasket} = useBasket();

const handleLogout = async () => {
try {
await Instance.post("/logout/");

localStorage.removeItem("accessToken");
localStorage.removeItem("refreshToken");

clearBasket();
navigate("/");
} catch (error) {
console.error("Ошибка при выходе:", error);
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/basket-context/BasketContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ export const BasketProvider = ({ children }) => {

const totalItems = basketItems.length;

const clearBasket = () => {
setBasketItems([]);
};

return (
<BasketContext.Provider
value={{
totalItems,
basketItems,
addToBasket,
removeFromBasket,
clearBasket
}}
>
{children}
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/components/main-page/Basket/Order/Order.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@ export default function Order({
removeFromBasket,
quantity,
date,
removeOneFromBasket,
item,
addToBasket,
}) {
const declension = getDeclension(quantity, "товар", "товара", "товаров");
const declension = getDeclension(quantity, "грядка", "грядок", "грядок");
const [comment, setComment] = useState("");
const [selectedPlant, setSelectedPlant] = useState(null); // Состояние для выбранного растения

// Логируем выбранное растение при его изменении
useEffect(() => {
if (selectedPlant) {
console.log("Выбранное растение:", selectedPlant);
Expand Down Expand Up @@ -73,6 +69,7 @@ export default function Order({
<div>Дата заказа: {date}</div>
<div className="order-change-volume">
Итог:{" "}
?
{" "}
{declension}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
display: flex;
flex-wrap: wrap; /* Разрешает перенос строк */
gap: 7px;
justify-content: center;
/*margin: 5px;*/
}

.plant-search-area{
width: 98%;
width: 100%;
height: 50px;
background-color: #0f3a42;
margin: 0 0 5px 0;
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/components/main-page/Basket/Order/order.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
.order-order {
padding: 20px;
border-radius: 20px;
width: auto;
width: 20vw;
height: auto;
background-color: lightblue;
display: flex;
Expand Down Expand Up @@ -63,12 +63,13 @@
}

.order-image {
width: 180px;
height: 180px;
width: 190px;
height: 190px;
padding: 10px;
}

.order-image-align{
width: 180px;
width: auto;
height: auto;
display: flex;
justify-content: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export default function SearchBlock({onSelectItem}) {
const [data, setData] = useState([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);

useEffect(() => {

setLoading(true);
Instance.get("/field/?format=json").then((response) => {
setData(response.data);
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/components/main-page/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,11 @@ html {
flex-direction: row;
}

.order-input{
height: 14vh !important;
}
.order-info {
width: 45vw !important;
width: auto !important;
height: 50vh !important;
display: flex;
flex-direction: column;
Expand All @@ -496,6 +499,9 @@ html {
gap: 20px;
}

.oreder-description {
width: 40vw !important;
}
.order-image {
width: 20vw !important;
height: auto !important;
Expand All @@ -509,6 +515,8 @@ html {
}

.order {
display: flex;
flex-direction: column;
padding: 2vw !important;
}

Expand Down

0 comments on commit f596fb7

Please sign in to comment.