add AddReceipt screen mock

This commit is contained in:
Stanislaw-Golebiewski 2019-12-26 00:24:00 +01:00
parent f57f2887d6
commit 086a8e5f38
16 changed files with 331 additions and 73 deletions

View File

@ -11090,6 +11090,14 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.12.0.tgz",
"integrity": "sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q=="
},
"react-minimal-pie-chart": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/react-minimal-pie-chart/-/react-minimal-pie-chart-6.0.1.tgz",
"integrity": "sha512-AlnZn2TjgX7Rm9E4SlV4iZphJVx8r3cojhm/VAzxuJMOevizCAxbSKhBlYjmmRtCNAWBX6JlALaPkOpEaPBFMQ==",
"requires": {
"prop-types": "^15.5.7"
}
},
"react-popper": {
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-1.3.7.tgz",

View File

@ -10,6 +10,7 @@
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-html5-camera-photo": "^1.5.4",
"react-minimal-pie-chart": "^6.0.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.3.0",
"semantic-ui-react": "^0.88.2"

View File

@ -1,21 +1,14 @@
import React from "react";
import {
BrowserRouter as Router,
Switch,
Route,
Link,
useRouteMatch,
useParams
} from "react-router-dom";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import { Home, Login, AddReceipt, Statistics, Receipts } from "./screens";
import SimpleReactFileUpload from "./react-file-upload.js";
// import SimpleReactFileUpload from "./react-file-upload.js";
function App() {
return (
<Router>
<Switch>
<Route path="/add_receipt">
<Route path="/home/add_receipt">
<AddReceipt />
</Route>
<Route path="/home/statistics">
@ -24,9 +17,6 @@ function App() {
<Route path="/home/receipts">
<Receipts />
</Route>
<Route path="/debug">
<SimpleReactFileUpload />
</Route>
<Route path="/home">
<Home />
</Route>

View File

@ -1,7 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
<g fill="#61DAFB">
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
<circle cx="420.9" cy="296.5" r="45.7"/>
<path d="M520.5 78.1z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,3 +1,27 @@
.add_receipt {
background-color: orange;
.site-wrapper {
height: 100%;
}
.add_receipt-container {
height: 85%;
}
.nav-menu {
/* height: 10%; */
}
.products-list-container {
background-color: rgba(0, 0, 0, 0.4);
/* opacity: 0.2; */
height: 80%;
width: 100%;
overflow: scroll;
}
.add-product-btn {
margin-bottom: 2rem !important;
/* margin-right: 1rem !important; */
}
.sum-container {
}

View File

@ -1,21 +0,0 @@
import React from "react";
import { Button } from "semantic-ui-react";
import Summary from "./subscreens/Summary/Summary";
import TakePhoto from "./subscreens/TakePhoto/TakePhoto";
import "./AddReceipt.css";
function handleTakePhoto(dataUri) {
console.log(dataUri);
}
function AddReceipt() {
return (
<div className="add_recepit">
<h2>Dodaj Paragon</h2>
<TakePhoto />
</div>
);
}
export default AddReceipt;

View File

@ -0,0 +1,121 @@
import React, { useState } from "react";
import { Button, Container, Icon, Menu } from "semantic-ui-react";
import { useHistory } from "react-router-dom";
import { ProductTile, ModalConfirm } from "./components";
import "./AddReceipt.css";
const INIT_STATE = [];
function AddReceipt() {
const [products, setProducts] = useState(INIT_STATE);
const [confirmModalOpen, setConfirmModalOpen] = useState(false);
const history = useHistory();
const addItem = item => {
setProducts([...products, item]);
};
const removeItem = index => {
const new_products = [...products];
new_products.splice(index, 1);
setProducts([...new_products]);
};
const openConfirmModal = () => {
setConfirmModalOpen(true);
};
const closeConfirmModal = () => {
setConfirmModalOpen(false);
};
const handleConfirm = () => {
history.push("/home");
};
return (
<div className="site-wrapper">
<Menu icon className="nav-menu">
<Menu.Item onClick={() => history.push("/home")}>
<Icon name="arrow left" />
</Menu.Item>
</Menu>
<div className="add_receipt-container">
<Container className="products-list-container">
{products.map((product, index) => (
<ProductTile
text="keh"
key={index}
number={index + 1}
name={product.name}
price={product.price}
onRemove={() => {
console.log(index, "lol");
removeItem(index);
}}
/>
))}
</Container>
<Container textAlign="right">
Razem:{" "}
{products.length > 0 ? sum_products_prices(products).toFixed(2) : "-"}
</Container>
<Button
fluid
icon
color="green"
onClick={() => {
addItem(get_random_product());
}}
className="add-product-btn"
>
<Icon name="plus" />
Dodaj produkt
</Button>
{products.length > 0 && (
<Button
fluid
icon
color="olive"
onClick={openConfirmModal}
className="add-product-btn"
>
<Icon name="upload" />
Dodaj paragon
</Button>
)}
</div>
<ModalConfirm
open={confirmModalOpen}
onClose={closeConfirmModal}
onConfirm={handleConfirm}
/>
</div>
);
}
function get_random_product() {
const products = [
"Ser",
"Ogórek",
"Papier toaletowy",
"Awokado",
"Chleb",
"Woda",
"Szampon"
];
let tmp = Math.random() * Math.floor(Math.random() * Math.floor(10));
return {
name: products[Math.floor(Math.random() * products.length)],
price: tmp
};
}
function sum_products_prices(products) {
let sum = 0;
products.forEach(prod => (sum += prod.price));
return sum;
}
export default AddReceipt;

View File

@ -0,0 +1,6 @@
.product_tile-container {
height: 5rem;
width: 100%;
margin-top: 1rem;
background-color: lightgray;
}

View File

@ -0,0 +1,26 @@
import React from "react";
import { Button, Modal } from "semantic-ui-react";
import "./ModalConfirm.css";
const ModalConfirm = props => (
<Modal size="mini" open={props.open} onClose={props.onClose}>
<Modal.Content>
<p>Zakończyć edycję nowego paragonu i dodać go do bazy?</p>
</Modal.Content>
<Modal.Actions>
<Button
positive
icon="checkmark"
labelPosition="right"
content="Tak"
onClick={props.onConfirm}
/>
<Button negative onClick={props.onClose}>
Nie
</Button>
</Modal.Actions>
</Modal>
);
export default ModalConfirm;

View File

@ -0,0 +1,50 @@
.product_tile-container {
display: flex;
justify-content: space-around;
align-items: center;
height: 5rem;
width: 100%;
margin-top: 1rem;
background-color: rgba(200, 200, 80, 0.5);
}
.tile-number {
margin-left: 1rem;
text-align: center;
vertical-align: middle;
background-color: white;
height: 1.5rem;
width: 1.5rem;
border-radius: 50%;
}
.tile-name {
margin-left: 1rem;
flex-grow: 20;
}
.tile-price {
flex-grow: 1;
text-align: center;
vertical-align: middle;
width: 4rem;
height: 1.5rem;
background-color: #00bb00;
border-radius: 15%;
margin-right: 1rem;
}
.headerDivider {
border-left: 1px solid #38546d;
border-right: 1px solid #16222c;
height: 80px;
position: absolute;
right: 249px;
top: 10px;
}
.icon-delete {
position: absolute;
top: 0;
right: 0;
}

View File

@ -0,0 +1,35 @@
import React, { useState } from "react";
import { Icon } from "semantic-ui-react";
import "./ProductTile.css";
function ProductTile(props) {
const [clicked, setClicked] = useState(false);
return (
<div
className="product_tile-container"
onClick={() => {
setClicked(!clicked);
}}
>
<div className="tile-number">
<span className="tile-number-text">{props.number}</span>
</div>
<div className="tile-name">{props.name}</div>
<div className="tile-price"> {props.price.toFixed(2)} </div>
{clicked && (
<Icon
name="trash alternate"
size="large"
color="red"
onClick={props.onRemove}
/>
)}
</div>
);
}
export default ProductTile;

View File

@ -0,0 +1,4 @@
import ProductTile from "./ProductTile/ProductTile";
import ModalConfirm from "./ModalConfirm/ModalConfirm";
export { ProductTile, ModalConfirm };

View File

@ -1,5 +1,5 @@
import React from "react";
import { Button, Container, Grid, Icon } from "semantic-ui-react";
import { Button, Container, Icon } from "semantic-ui-react";
import { useHistory } from "react-router-dom";
import "./Home.css";
@ -33,7 +33,7 @@ function Home() {
icon
size="massive"
className="home-button-wrapper"
onClick={() => history.push("/home/statistics")}
onClick={() => history.push("/home/add_receipt")}
>
<Icon name="add circle" />
Dodaj paragon

View File

@ -3,8 +3,6 @@ import {
Button,
Form,
Grid,
Header,
Message,
Segment,
Container,
Image

View File

@ -1,17 +1,5 @@
import React, { useState } from "react";
import {
Container,
Header,
Icon,
Image,
Menu,
Segment,
Sidebar,
Pagination,
Accordion,
Table,
Label
} from "semantic-ui-react";
import { Container, Icon, Menu, Accordion, Table } from "semantic-ui-react";
import { useHistory } from "react-router-dom";
import "./Receipts.css";
@ -40,7 +28,7 @@ function Receipts() {
>
Zakup #1
</Accordion.Title>
<Accordion.Content active={active == 0}>
<Accordion.Content active={active === 0}>
<Table celled unstackable>
<Table.Header>
<Table.Row>
@ -70,7 +58,7 @@ function Receipts() {
>
Zakup #2
</Accordion.Title>
<Accordion.Content active={active == 1}>
<Accordion.Content active={active === 1}>
<Table celled unstackable>
<Table.Header>
<Table.Row>

View File

@ -1,14 +1,7 @@
import React, { Component, useState } from "react";
import {
Container,
Header,
Icon,
Image,
Menu,
Segment,
Sidebar
} from "semantic-ui-react";
import React, { useState } from "react";
import { Container, Icon, Menu, Sidebar } from "semantic-ui-react";
import { useHistory } from "react-router-dom";
import PieChart from "react-minimal-pie-chart";
import "./Statistics.css";
@ -44,7 +37,49 @@ function Statistics() {
<Icon name="sidebar" />
</Menu.Item>
</Menu>
<Container></Container>
<Container>
<PieChart
animate={true}
animationDuration={500}
animationEasing="ease-out"
cx={50}
cy={50}
data={[
{
color: "#E38627",
title: "One",
value: 10
},
{
color: "#C13C37",
title: "Two",
value: 15
},
{
color: "#6A2135",
title: "Three",
value: 20
}
]}
label
labelPosition={50}
labelStyle={{
fill: "#121212",
fontFamily: "sans-serif",
fontSize: "5px"
}}
lengthAngle={360}
lineWidth={100}
onClick={undefined}
onMouseOut={undefined}
onMouseOver={undefined}
paddingAngle={0}
radius={50}
rounded={false}
startAngle={0}
viewBoxSize={[100, 100]}
/>
</Container>
</Sidebar.Pusher>
</Sidebar.Pushable>
);