~_~
This commit is contained in:
parent
09dd2f7ae2
commit
ac0427a16e
@ -35,10 +35,10 @@ public class OrderController {
|
|||||||
return new OrderDto(orderService.addProduct(id, productId));
|
return new OrderDto(orderService.addProduct(id, productId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/{id}")
|
@PatchMapping("/removeProduct/{id}/")
|
||||||
public Orders updateOrder(@PathVariable Long id,
|
public OrderDto removeProduct(@PathVariable Long id,
|
||||||
@RequestParam() Long supplierId) {
|
@RequestParam() Long productId){
|
||||||
return orderService.updateOrder(id, supplierId);
|
return new OrderDto(orderService.removeProduct(id, productId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
@ -14,7 +14,7 @@ public class OrderDto {
|
|||||||
private Supplier supplier;
|
private Supplier supplier;
|
||||||
private List<Product> products;
|
private List<Product> products;
|
||||||
|
|
||||||
public OrderDto(Orders order){
|
public OrderDto(_Order order){
|
||||||
this.id = order.getId();
|
this.id = order.getId();
|
||||||
this.dateOfOrder = order.getDateOfOrder();
|
this.dateOfOrder = order.getDateOfOrder();
|
||||||
this.supplier = order.getSupplier();
|
this.supplier = order.getSupplier();
|
||||||
|
@ -2,5 +2,5 @@ package com.example.demo.supply.Order;
|
|||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface OrderRepository extends JpaRepository<Orders, Long> {
|
public interface OrderRepository extends JpaRepository<_Order, Long> {
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
package com.example.demo.supply.Order;
|
package com.example.demo.supply.Order;
|
||||||
|
|
||||||
import com.example.demo.supply.Product.Product;
|
|
||||||
import com.example.demo.supply.Product.ProductRepository;
|
|
||||||
import com.example.demo.supply.Product.ProductService;
|
import com.example.demo.supply.Product.ProductService;
|
||||||
import com.example.demo.supply.Supplier.Supplier;
|
|
||||||
import com.example.demo.supply.Supplier.SupplierService;
|
import com.example.demo.supply.Supplier.SupplierService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -30,8 +26,8 @@ public class OrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Orders addOrder(Long supplierId){
|
public _Order addOrder(Long supplierId){
|
||||||
final Orders order = new Orders(new Date(System.currentTimeMillis()));
|
final _Order order = new _Order(new Date(System.currentTimeMillis()));
|
||||||
order.setSupplier(supplierService.findSupplier(supplierId));
|
order.setSupplier(supplierService.findSupplier(supplierId));
|
||||||
return orderRepository.save(order);
|
return orderRepository.save(order);
|
||||||
}
|
}
|
||||||
@ -44,40 +40,33 @@ public class OrderService {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Orders addProduct(Long id, Long productId) {
|
public _Order addProduct(Long id, Long productId) {
|
||||||
final Orders currentOrder = findOrder(id);
|
final _Order currentOrder = findOrder(id);
|
||||||
currentOrder.addProduct(productService.findProduct(productId));
|
currentOrder.addProduct(productService.findProduct(productId));
|
||||||
return orderRepository.save(currentOrder);
|
return orderRepository.save(currentOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Orders deleteProduct(Long id, Long productId) {
|
public _Order removeProduct(Long id, Long productId) {
|
||||||
final Orders currentOrder = findOrder(id);
|
final _Order currentOrder = findOrder(id);
|
||||||
currentOrder.addProduct(productService.findProduct(productId));
|
currentOrder.addProduct(productService.findProduct(productId));
|
||||||
return orderRepository.save(currentOrder);
|
return orderRepository.save(currentOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Orders findOrder(Long id) {
|
public _Order findOrder(Long id) {
|
||||||
final Optional<Orders> order = orderRepository.findById(id);
|
final Optional<_Order> order = orderRepository.findById(id);
|
||||||
return order.orElseThrow(() -> new OrderNotFoundException(id));
|
return order.orElseThrow(() -> new OrderNotFoundException(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<Orders> findAllOrders() {
|
public List<_Order> findAllOrders() {
|
||||||
return orderRepository.findAll();
|
return orderRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Orders updateOrder(Long id, Long supplierId) {
|
public _Order deleteOrder(Long id) {
|
||||||
final Orders currentOrder = findOrder(id);
|
final _Order currentOrder = findOrder(id);
|
||||||
currentOrder.setSupplier(supplierService.findSupplier(supplierId));
|
|
||||||
return orderRepository.save(currentOrder);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Orders deleteOrder(Long id) {
|
|
||||||
final Orders currentOrder = findOrder(id);
|
|
||||||
orderRepository.delete(currentOrder);
|
orderRepository.delete(currentOrder);
|
||||||
return currentOrder;
|
return currentOrder;
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,12 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Orders {
|
public class _Order {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column
|
@Column(nullable = false)
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
private Date dateOfOrder;
|
private Date dateOfOrder;
|
||||||
|
|
||||||
@ -36,12 +36,12 @@ public class Orders {
|
|||||||
public Long getId(){
|
public Long getId(){
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
public Orders(Date dateOfOrder) {
|
public _Order(Date dateOfOrder) {
|
||||||
this.dateOfOrder = dateOfOrder;
|
this.dateOfOrder = dateOfOrder;
|
||||||
products = new ArrayList<>();
|
products = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Orders() {
|
public _Order() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getDateOfOrder() {
|
public Date getDateOfOrder() {
|
||||||
@ -81,7 +81,7 @@ public class Orders {
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Orders order = (Orders) o;
|
_Order order = (_Order) o;
|
||||||
if(!Objects.equals(id, order.id)) return false;
|
if(!Objects.equals(id, order.id)) return false;
|
||||||
|
|
||||||
if(!Objects.equals(dateOfOrder.toString(), order.dateOfOrder.toString())) return false;
|
if(!Objects.equals(dateOfOrder.toString(), order.dateOfOrder.toString())) return false;
|
@ -1,8 +1,7 @@
|
|||||||
package com.example.demo.supply.Product;
|
package com.example.demo.supply.Product;
|
||||||
|
|
||||||
import com.example.demo.supply.Order.Orders;
|
import com.example.demo.supply.Order._Order;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -21,7 +20,7 @@ public class Product {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private double cost;
|
private double cost;
|
||||||
@ManyToMany(fetch = FetchType.EAGER, mappedBy = "products")
|
@ManyToMany(fetch = FetchType.EAGER, mappedBy = "products")
|
||||||
private List<Orders> orders;
|
private List<_Order> orders;
|
||||||
|
|
||||||
public Product(){}
|
public Product(){}
|
||||||
|
|
||||||
@ -47,11 +46,11 @@ public class Product {
|
|||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Orders> getOrders() {
|
public List<_Order> getOrders() {
|
||||||
return orders;
|
return orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrders(List<Orders> orders) {
|
public void setOrders(List<_Order> orders) {
|
||||||
this.orders = orders;
|
this.orders = orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.example.demo.supply.Product;
|
package com.example.demo.supply.Product;
|
||||||
|
|
||||||
import com.example.demo.supply.Order.Orders;
|
import com.example.demo.supply.Order._Order;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ public class ProductDto {
|
|||||||
private long id;
|
private long id;
|
||||||
private String name;
|
private String name;
|
||||||
private double cost;
|
private double cost;
|
||||||
private List<Orders> orders;
|
private List<_Order> orders;
|
||||||
|
|
||||||
public ProductDto(Product product) {
|
public ProductDto(Product product) {
|
||||||
this.id = product.getId();
|
this.id = product.getId();
|
||||||
@ -26,7 +26,7 @@ public class ProductDto {
|
|||||||
public double getCost() {
|
public double getCost() {
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
public List<Orders> getOrders() {
|
public List<_Order> getOrders() {
|
||||||
return orders;
|
return orders;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.example.demo.supply.Supplier;
|
package com.example.demo.supply.Supplier;
|
||||||
|
|
||||||
import com.example.demo.supply.Order.Orders;
|
import com.example.demo.supply.Order._Order;
|
||||||
|
import com.example.demo.supply.Product.Product;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ public class Supplier {
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "supplier", cascade = CascadeType.REMOVE)
|
@OneToMany(fetch = FetchType.EAGER, mappedBy = "supplier", cascade = CascadeType.REMOVE)
|
||||||
private List<Orders> orders;
|
private List<_Order> orders;
|
||||||
|
|
||||||
public Supplier(){}
|
public Supplier(){}
|
||||||
|
|
||||||
@ -48,11 +49,11 @@ public class Supplier {
|
|||||||
this.license = license;
|
this.license = license;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Orders> getOrders() {
|
public List<_Order> getOrders() {
|
||||||
return orders;
|
return orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrders(List<Orders> orders) {
|
public void setOrders(List<_Order> orders) {
|
||||||
this.orders = orders;
|
this.orders = orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.example.demo.supply.Supplier;
|
package com.example.demo.supply.Supplier;
|
||||||
|
|
||||||
import com.example.demo.supply.Order.Orders;
|
import com.example.demo.supply.Order._Order;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ public class SupplierDto {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
private int license;
|
private int license;
|
||||||
private List<Orders> orders;
|
private List<_Order> orders;
|
||||||
|
|
||||||
public SupplierDto(Supplier supplier){
|
public SupplierDto(Supplier supplier){
|
||||||
this.id = supplier.getId();
|
this.id = supplier.getId();
|
||||||
@ -24,7 +24,7 @@ public class SupplierDto {
|
|||||||
public int getLicense() {
|
public int getLicense() {
|
||||||
return license;
|
return license;
|
||||||
}
|
}
|
||||||
public List<Orders> getOrders() {
|
public List<_Order> getOrders() {
|
||||||
return orders;
|
return orders;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,7 @@
|
|||||||
package com.example.demo;
|
package com.example.demo;
|
||||||
|
|
||||||
import com.example.demo.supply.Order.Orders;
|
|
||||||
import com.example.demo.supply.Product.Product;
|
|
||||||
import com.example.demo.supply.Product.ProductService;
|
|
||||||
import com.example.demo.supply.Supplier.Supplier;
|
|
||||||
import com.example.demo.supply.Order.OrderService;
|
|
||||||
import com.example.demo.supply.Supplier.SupplierService;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class Tests {
|
public class Tests {
|
||||||
}
|
}
|
@ -1,7 +1,8 @@
|
|||||||
import { BrowserRouter, Route, Routes} from "react-router-dom";
|
import { BrowserRouter, Route, Routes} from "react-router-dom";
|
||||||
import CatalogProducts from "./Pages/CatalogProducts";
|
import CatalogProducts from "./Pages/CatalogProducts";
|
||||||
import CatalogSuppliers from "./Pages/CatalogSuppliers";
|
import CatalogSuppliers from "./Pages/CatalogSuppliers";
|
||||||
import OrderPage from "./Pages/OrderPage";
|
import OrderPage from "./Pages/OrdersPage";
|
||||||
|
import CreateOrderPage from "./Pages/CreateOrderPage";
|
||||||
import Header from "./general/Header";
|
import Header from "./general/Header";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
@ -14,6 +15,7 @@ function App() {
|
|||||||
<Route path="/products" Component={CatalogProducts} />
|
<Route path="/products" Component={CatalogProducts} />
|
||||||
<Route path="/suppliers" Component={CatalogSuppliers} />
|
<Route path="/suppliers" Component={CatalogSuppliers} />
|
||||||
<Route path="/orders" Component={OrderPage} />
|
<Route path="/orders" Component={OrderPage} />
|
||||||
|
<Route path="/createOrder" Component={CreateOrderPage} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
|
131
front/src/Pages/CreateOrderPage.jsx
Normal file
131
front/src/Pages/CreateOrderPage.jsx
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
import { React, useState, useEffect } from "react";
|
||||||
|
import Supplier from "../models/Supplier";
|
||||||
|
import DataService from "../DataService";
|
||||||
|
import Order from "../models/Order";
|
||||||
|
import Product from "../models/Product";
|
||||||
|
import Table from "../general/Table";
|
||||||
|
import Modal from "../general/Modal";
|
||||||
|
|
||||||
|
export default function CreateOrderPage(props){
|
||||||
|
const url = 'order/'
|
||||||
|
const supplierUrl = 'supplier/'
|
||||||
|
const productUrl = 'product/'
|
||||||
|
|
||||||
|
const headers = [
|
||||||
|
{ name: 'name', label: 'Продукт' },
|
||||||
|
{ name: 'cost', label: 'Цена' }
|
||||||
|
];
|
||||||
|
|
||||||
|
const transformer = (data) => new Order(data)
|
||||||
|
const transformerSupplier = (data) => new Supplier(data)
|
||||||
|
const transformerProduct = (data) => new Product(data)
|
||||||
|
|
||||||
|
const [suppliers, setSuppliers] = useState([])
|
||||||
|
const [products, setProducts] = useState([])
|
||||||
|
|
||||||
|
const [productsOrder, setProductsOrder] = useState([])
|
||||||
|
|
||||||
|
const [modalHeader, setModalHeader] = useState('')
|
||||||
|
const [modalConfirm, setModalConfirm] = useState('')
|
||||||
|
const [modalVisible, setModalVisible] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadItems()
|
||||||
|
//eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const loadItems = () => {
|
||||||
|
// DataService.getOrders(url).then(data => {
|
||||||
|
// console.log(data)
|
||||||
|
// setOrders([])
|
||||||
|
// data.map(order => {
|
||||||
|
// setOrders(prevState => [...prevState, new Order(order)])
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
|
||||||
|
DataService.readAll(supplierUrl, transformerSupplier).then(data => setSuppliers(data))
|
||||||
|
DataService.readAll(productUrl, transformerProduct).then(data => setProducts(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveItems = () => {
|
||||||
|
console.log("saveItems")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleFormChange = (event) => {
|
||||||
|
//console.log([event.target.id].event.target.value)
|
||||||
|
// console.log(currOrder)
|
||||||
|
// setData({ ...data, [event.target.id]: event.target.value })
|
||||||
|
// console.log(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
const addProduct = () => {
|
||||||
|
setModalHeader('Добавление продукта');
|
||||||
|
setModalConfirm('Добавить');
|
||||||
|
setModalVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideModal = () => setModalVisible(false)
|
||||||
|
const modalDone = () => saveItems()
|
||||||
|
const ds = () => console.log("")
|
||||||
|
|
||||||
|
return(
|
||||||
|
<div className="container">
|
||||||
|
<div className="row">
|
||||||
|
<h1 className="display-6">Создание заказа</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row gx-5">
|
||||||
|
<div className="btn-group" role="group" aria-label="Basic mixed styles example">
|
||||||
|
<button type="button" className="btn btn-success">Создать</button>
|
||||||
|
<button type="button" className="btn btn-danger">Отмена</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br></br>
|
||||||
|
<div className="mb-3">
|
||||||
|
<p className="h4" htmlFor="supplierId">Поставщик</p>
|
||||||
|
<select id="supplierId" className="form-select " required
|
||||||
|
onChange={handleFormChange}>
|
||||||
|
<option disabled value="">Укажите поставщика</option>
|
||||||
|
{
|
||||||
|
suppliers.map(supplier =>
|
||||||
|
<option key={supplier.id} value={supplier.id}>{supplier.name}</option>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<p className="h4">Продукты</p>
|
||||||
|
<div className="btn-group" role="group" aria-label="Basic mixed styles example">
|
||||||
|
<button type="button" className="btn btn-success" onClick={addProduct}>Добавить продукт</button>
|
||||||
|
<button type="button" className="btn btn-danger">Удалить продукт</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Table
|
||||||
|
headers={headers}
|
||||||
|
items={productsOrder}
|
||||||
|
selectable={true}
|
||||||
|
onClick={ds}
|
||||||
|
onDblClick={ds}/>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
header={modalHeader}
|
||||||
|
confirm={modalConfirm}
|
||||||
|
visible={modalVisible}
|
||||||
|
onHide={hideModal}
|
||||||
|
onDone={modalDone}>
|
||||||
|
<div className="mb-3">
|
||||||
|
<p className="h4" htmlFor="product">Продукт</p>
|
||||||
|
<select id="product" className="form-select " required
|
||||||
|
onChange={handleFormChange}>
|
||||||
|
<option disabled value="">Укажите продукт</option>
|
||||||
|
{
|
||||||
|
products.map(product =>
|
||||||
|
<option key={product.id} value={product.id}>{product.name}</option>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
import { Link } from 'react-router-dom';
|
||||||
import { React, useState, useEffect } from "react";
|
import { React, useState, useEffect } from "react";
|
||||||
import Table from "../general/Table";
|
import Table from "../general/Table";
|
||||||
import ToolBar from "../general/ToolBar";
|
import ToolBar from "../general/ToolBar";
|
||||||
@ -92,9 +93,9 @@ export default function OrderPage(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleFormChange = (event) => {
|
const handleFormChange = (event) => {
|
||||||
console.log(currOrder)
|
// console.log(currOrder)
|
||||||
setData({ ...data, [event.target.id]: event.target.value })
|
// setData({ ...data, [event.target.id]: event.target.value })
|
||||||
console.log(data)
|
// console.log(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -129,7 +130,7 @@ export default function OrderPage(){
|
|||||||
visible={modalVisible}
|
visible={modalVisible}
|
||||||
onHide={hideModal}
|
onHide={hideModal}
|
||||||
onDone={modalDone}>
|
onDone={modalDone}>
|
||||||
<div className="mb-3">
|
{/* <div className="mb-3">
|
||||||
<label htmlFor="supplierId" className="form-label">Поставщик</label>
|
<label htmlFor="supplierId" className="form-label">Поставщик</label>
|
||||||
<select id="supplierId" className="form-select" required
|
<select id="supplierId" className="form-select" required
|
||||||
value={currOrder.supplierId} onChange={handleFormChange}>
|
value={currOrder.supplierId} onChange={handleFormChange}>
|
||||||
@ -140,9 +141,9 @@ export default function OrderPage(){
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div> */}
|
||||||
|
|
||||||
<div className="mb-3">
|
{/* <div className="mb-3">
|
||||||
<label htmlFor="product" className="form-label">Поставщик</label>
|
<label htmlFor="product" className="form-label">Поставщик</label>
|
||||||
<select id="product" className="form-select" required
|
<select id="product" className="form-select" required
|
||||||
onChange={handleFormChange}>
|
onChange={handleFormChange}>
|
||||||
@ -153,7 +154,7 @@ export default function OrderPage(){
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div> */}
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
@ -162,7 +163,7 @@ export default function OrderPage(){
|
|||||||
visible={addProdVisible}
|
visible={addProdVisible}
|
||||||
onHide={hideModal}
|
onHide={hideModal}
|
||||||
onDone={modalDone}>
|
onDone={modalDone}>
|
||||||
<div className="mb-3">
|
{/* <div className="mb-3">
|
||||||
<label htmlFor="product" className="form-label">Поставщик</label>
|
<label htmlFor="product" className="form-label">Поставщик</label>
|
||||||
<select id="product" className="form-select" required
|
<select id="product" className="form-select" required
|
||||||
value={products} onChange={handleFormChange}>
|
value={products} onChange={handleFormChange}>
|
||||||
@ -173,7 +174,7 @@ export default function OrderPage(){
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div> */}
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
20
front/src/general/CastomSelect.jsx
Normal file
20
front/src/general/CastomSelect.jsx
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
export default function CastomSelect(props){
|
||||||
|
|
||||||
|
const handleFormChange = () => console.log("efhekjf")
|
||||||
|
|
||||||
|
return(
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="castomSelect" className="form-label">{props.header}</label>
|
||||||
|
<select id="castomSelect" className="form-select" required
|
||||||
|
value="" onChange={handleFormChange}>
|
||||||
|
<option disabled value="">{props.description}</option>
|
||||||
|
{
|
||||||
|
props.items.map(item =>
|
||||||
|
<option key={item.id} value={item.id}>{item.name}</option>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
@ -16,7 +16,6 @@ export default function Header() {
|
|||||||
<Link className="nav-link" to="/products">
|
<Link className="nav-link" to="/products">
|
||||||
Продукты
|
Продукты
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<li className="nav-item">
|
<li className="nav-item">
|
||||||
<Link className="nav-link" to="/suppliers">
|
<Link className="nav-link" to="/suppliers">
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { Link } from 'react-router-dom';
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import styles from './Toolbar.module.css';
|
import styles from './Toolbar.module.css';
|
||||||
|
|
||||||
@ -12,24 +13,23 @@ function ToolBar(props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="btn-group mt-2" role="group">
|
<div className="btn-group mt-2" role="group">
|
||||||
<button type="button" className={`btn btn-success ${styles.btn}`} onClick={add}>
|
<button type="button" className={`btn btn-success ${styles.btn}`} onClick={add}
|
||||||
|
style={{ display: props.addsVisible ? 'none' : 'block' }}>
|
||||||
Добавить
|
Добавить
|
||||||
</button>
|
</button>
|
||||||
<button type="button" className={`btn btn-warning ${styles.btn}`} onClick={edit} >
|
<Link to="/createOrder">
|
||||||
|
<button type="button" className={`btn btn-success ${styles.btn}`} onClick={add}
|
||||||
|
style={{ display: props.addsVisible ? 'block' : 'none' }}>
|
||||||
|
Добавить
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
|
<button type="button" className={`btn btn-warning ${styles.btn}`} onClick={edit}
|
||||||
|
style={{ display: props.addsVisible ? 'none' : 'block' }}>
|
||||||
Изменить
|
Изменить
|
||||||
</button >
|
</button >
|
||||||
<button type="button" className={`btn btn-danger ${styles.btn}`} onClick={remove}>
|
<button type="button" className={`btn btn-danger ${styles.btn}`} onClick={remove}>
|
||||||
Удалить
|
Удалить
|
||||||
</button >
|
</button >
|
||||||
|
|
||||||
<button type="button" className={`btn btn-success ${styles.btn}`} onClick={addProduct}
|
|
||||||
style={{ display: props.addsVisible ? 'block' : 'none' }}>
|
|
||||||
Добавить продукт
|
|
||||||
</button>
|
|
||||||
<button type="button" className={`btn btn-danger ${styles.btn}`} onClick={removeProduct}
|
|
||||||
style={{ display: props.addsVisible ? 'block' : 'none' }}>
|
|
||||||
Удалить продукт
|
|
||||||
</button >
|
|
||||||
</div >
|
</div >
|
||||||
|
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user