Добавлен атрибут картинки для ингредиентов и удален атрибут английского названия

This commit is contained in:
Kayashov.SM
2025-08-25 14:57:06 +04:00
parent 56f81ea54b
commit 6fe2ca6c57
17 changed files with 15 additions and 42 deletions

View File

@@ -111,10 +111,6 @@ export function EditIngredientPage() {
variant="outlined" label={"Название"}
value={ingredient.name}
onChange={(e) => changeIngredientValue("name", e.target.value)}/>
<TextField sx={{mr: 1, mb: 2, minWidth: 330}}
label="Английское название" variant="outlined"
value={ingredient.enName}
onChange={(e) => changeIngredientValue("enName", e.target.value)}/>
</Box>
<Box height={70} mt={1} ml={1}>

View File

@@ -39,6 +39,7 @@ export function UserPopover({anchorEl, onClose, open}) {
} catch (err) {
logger.error('Sign out error', err);
}
// eslint-disable-next-line
}, [checkSession, location]);
return (
@@ -85,7 +86,7 @@ export function UserPopover({anchorEl, onClose, open}) {
}
function userDescriptor(user) {
if(!user) {
if (!user) {
return null;
}
if (!user.name) {

View File

@@ -1,5 +1,5 @@
import Stack from "@mui/material/Stack";
import {isNavItemActive} from "../../lib/isNavItemActive";
import {isNavItemActive} from "./isNavItemActive";
import {navIcons} from "../core/navIcons";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";

View File

@@ -1,7 +1,7 @@
import * as React from 'react';
import {useCallback, useEffect} from 'react';
import {logger} from "../lib/DefaultLogger";
import {tokenUtil} from "../lib/TokenUtil";
import {tokenUtil} from "../lib/clients/TokenUtil";
export const AuthContext = React.createContext(undefined);

View File

@@ -2,7 +2,7 @@ import * as React from "react";
import {createContext, useCallback, useEffect, useState} from "react";
import {logger} from "../lib/DefaultLogger";
import {userClient} from "../lib/clients/UserClient";
import {tokenUtil} from "../lib/TokenUtil";
import {tokenUtil} from "../lib/clients/TokenUtil";
export const UserContext = createContext(undefined);

View File

@@ -1,5 +1,5 @@
import {decodeToken, isExpired} from "react-jwt";
import {requests} from "../requests";
import {requests} from "../../requests";
import axios from "axios";
class TokenUtil {

View File

@@ -1,7 +1,7 @@
import axios from "axios";
import {tokenUtil} from "../TokenUtil";
import {tokenUtil} from "./TokenUtil";
const host = "localhost:8081"; //дебаг вместе с беком
const host = "localhost:8080"; //дебаг вместе с беком
// const host = "192.168.1.100:8091"; //дебаг фронта
// const host = "bar.kayashov.keenetic.pro"; //прод
export const api = () => {

View File

@@ -1,18 +0,0 @@
export const sliceData = (rows, page, elementOnPage) => {
if (!rows || rows.length === 0) {
return [];
}
const maxPage = Math.ceil(rows.length / elementOnPage);
// const start = (page - 1) * elementOnPage;
const start = 0;
console.log(maxPage, start)
let end;
if (page === maxPage) {
end = rows.length;
} else {
end = start + elementOnPage;
}
return rows.slice(start, end);
}

View File

@@ -48,10 +48,5 @@ export const requests = {
type: routes.ingredient + "/type",
crud: routes.ingredient,
},
// receipt: {
// receipts: routes.bar + "receipt?id=",
//
// },
unit: routes.unit + "/units"
}

View File

@@ -32,7 +32,7 @@ public class IngredientResponseDto {
.type(i.getType() != null ? i.getType().getName() : null)
.abv(i.getAbv())
.isHave(i.getIsHave())
.image("https://thecocktaildb.com/images/ingredients/" + i.getEnName() + "-Medium.png")
.image(i.getImage())
.description(i.getDescription())
.build();
}

View File

@@ -16,7 +16,7 @@ public class IngredientSimpleResponseDto {
public static IngredientSimpleResponseDto mapToDto(IngredientEntity ingredient) {
return new IngredientSimpleResponseDto(ingredient.getId(), ingredient.getName(),
"https://thecocktaildb.com/images/ingredients/" + ingredient.getEnName() + "-Medium.png",
ingredient.getImage(),
ingredient.getIsHave());
}
}

View File

@@ -154,7 +154,7 @@ public class CocktailMapper {
private IngredientSimpleResponseDto createIngredientResponseDto(IngredientEntity i) {
return new IngredientSimpleResponseDto(i.getId(),
i.getName(),
"https://thecocktaildb.com/images/ingredients/" + i.getEnName() + "-Medium.png",
i.getImage(),
i.getIsHave());
}

View File

@@ -27,7 +27,7 @@ public class IngredientMapper {
.type(i.getType() != null ? i.getType().getName() : null)
.abv(i.getAbv())
.isHave(i.getIsHave())
.image("https://thecocktaildb.com/images/ingredients/" + i.getEnName() + "-Medium.png")
.image(i.getImage())
.description(i.getDescription())
.build();
}
@@ -40,7 +40,7 @@ public class IngredientMapper {
private IngredientSimpleResponseDto mapIngredientToSimpleDto(IngredientEntity i) {
return new IngredientSimpleResponseDto(i.getId(), i.getName(),
"https://thecocktaildb.com/images/ingredients/" + i.getEnName() + "-Medium.png",
i.getImage(),
i.getIsHave());
}
}

View File

@@ -33,10 +33,10 @@ public class IngredientEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String enName;
private Boolean alcohol;
private Integer abv;
private Boolean isHave;
private String image;
@Column(columnDefinition = "text")
private String description;

View File

@@ -6,6 +6,4 @@ import ru.kayashov.bar.model.entity.IngredientEntity;
import java.util.Optional;
public interface IngredientRepository extends JpaRepository<IngredientEntity, Long> {
Optional<IngredientEntity> findByEnNameIgnoreCase(String name);
}

View File

@@ -93,6 +93,7 @@ public class IngredientService {
IngredientEntity entity;
if (dto.getId() == null) {
entity = new IngredientEntity();
entity.setIsHave(false);
} else {
entity = repository.findById(dto.getId())
.orElse(null);