bug fixes + new calendar picker

This commit is contained in:
Stanislaw-Golebiewski 2020-01-26 21:40:16 +01:00
parent 5a6ddce8ad
commit 4afd46579f
5 changed files with 100 additions and 38 deletions

View File

@ -4312,6 +4312,27 @@
}
}
},
"date-fns": {
"version": "1.30.1",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.30.1.tgz",
"integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw=="
},
"dayzed": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/dayzed/-/dayzed-3.1.0.tgz",
"integrity": "sha512-Mwb/T78ppKDIoXsNgSLfIYfIO7ylal+vKp8VVMzK6rQq4VJSE7AdrGFN2EQDmve037J9TKZo06mX+QuuKQ2raA==",
"requires": {
"@babel/runtime": "^7.6.2",
"date-fns": "^2.0.0"
},
"dependencies": {
"date-fns": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.9.0.tgz",
"integrity": "sha512-khbFLu/MlzLjEzy9Gh8oY1hNt/Dvxw3J6Rbc28cVoYWQaC1S3YI4xwkF9ZWcjDLscbZlY9hISMr66RFzZagLsA=="
}
}
},
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
@ -5929,6 +5950,11 @@
"mime-types": "^2.1.12"
}
},
"format-string-by-pattern": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/format-string-by-pattern/-/format-string-by-pattern-1.1.1.tgz",
"integrity": "sha512-iMhINdUh3WzZ0lCtFpIJnbwmKRGliJ/xhhhB+ORcVgFuyMe2fub6AKl6hJsttAwpTEfLFVWUXn4ZOtknejMAWw=="
},
"forwarded": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
@ -8798,11 +8824,6 @@
}
}
},
"moment": {
"version": "2.24.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
},
"move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
@ -11083,6 +11104,11 @@
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.4.tgz",
"integrity": "sha512-ueZzLmHltszTshDMwyfELDq8zOA803wQ1ZuzCccXa1m57k1PxSHfflPD5W9YIiTXLs0JTLzoj6o1LuM5N6zzNA=="
},
"react-fast-compare": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-2.0.4.tgz",
"integrity": "sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw=="
},
"react-is": {
"version": "16.12.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.12.0.tgz",
@ -11216,6 +11242,35 @@
"workbox-webpack-plugin": "4.3.1"
}
},
"react-semantic-ui-datepickers": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/react-semantic-ui-datepickers/-/react-semantic-ui-datepickers-2.3.0.tgz",
"integrity": "sha512-H6PZzvkyaz2G8IKPQWltSnfb+iO0c3vR8T/2zIwGeqsckfy5ySL/ED5cgF+xXUbeD9oN05ArWvAN3fb7v9HiJw==",
"requires": {
"@babel/runtime": "7.8.0",
"classnames": "2.2.6",
"core-js": "3.6.3",
"date-fns": "1.30.1",
"dayzed": "3.1.0",
"format-string-by-pattern": "1.1.1",
"react-fast-compare": "2.0.4"
},
"dependencies": {
"@babel/runtime": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.0.tgz",
"integrity": "sha512-Z7ti+HB0puCcLmFE3x90kzaVgbx6TRrYIReaygW6EkBEnJh1ajS4/inhF7CypzWeDV3NFl1AfWj0eMtdihojxw==",
"requires": {
"regenerator-runtime": "^0.13.2"
}
},
"core-js": {
"version": "3.6.3",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.3.tgz",
"integrity": "sha512-DOO9b18YHR+Wk5kJ/c5YFbXuUETreD4TrvXb6edzqZE3aAEd0eJIAWghZ9HttMuiON8SVCnU3fqA4rPxRDD1HQ=="
}
}
},
"read-pkg": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz",
@ -11827,17 +11882,6 @@
"node-forge": "0.9.0"
}
},
"semantic-ui-calendar-react": {
"version": "0.15.3",
"resolved": "https://registry.npmjs.org/semantic-ui-calendar-react/-/semantic-ui-calendar-react-0.15.3.tgz",
"integrity": "sha512-cXlg/dJf0z/dydnol1GCy9ssccXBAGYhmka9W2KNXqqW+B0mgPhu6ugWOjGD4i99e3dnNl1QVqYvQpQcpkcEIg==",
"requires": {
"keyboard-key": "^1.0.2",
"lodash": "^4.17.15",
"moment": "^2.22.2",
"prop-types": "^15.6.2"
}
},
"semantic-ui-react": {
"version": "0.88.2",
"resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-0.88.2.tgz",

View File

@ -12,7 +12,7 @@
"react-minimal-pie-chart": "^6.0.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.3.0",
"semantic-ui-calendar-react": "^0.15.3",
"react-semantic-ui-datepickers": "^2.3.0",
"semantic-ui-react": "^0.88.2",
"use-global-hook": "^0.1.12"
},

View File

@ -30,7 +30,8 @@
width: 4rem;
height: 1.5rem;
background-color: #00bb00;
border-radius: 15%;
font-weight: 600;
/* border-radius: 15%; */
margin-right: 1rem;
}

View File

@ -10,7 +10,8 @@ import {
Dimmer,
Loader
} from "semantic-ui-react";
import { DateInput } from "semantic-ui-calendar-react";
// import { DateInput } from "semantic-ui-calendar-react";
import SemanticDatepicker from "react-semantic-ui-datepickers";
import { useHistory } from "react-router-dom";
import axios, { post } from "axios";
@ -57,6 +58,20 @@ function AddMetadata() {
});
};
const get_mata_data_obj = () => {
const products = productsFromPhoto;
products.forEach(product => {
product.price = parseFloat(product.price.replace(",", "."));
});
console.log(products);
const date = pickedDate.toISOString().slice(0, 10);
return {
shop: pickedShop,
date,
products
};
};
const fileUploadRequest = (file, get_products = false) => {
let url = `${config.api_url}/api/photo/`;
if (!get_products) {
@ -77,7 +92,7 @@ function AddMetadata() {
//set date to current day
useEffect(() => {
const todayDate = new Date().toISOString().slice(0, 10);
let todayDate = new Date();
setPickedDate(todayDate);
}, []);
@ -100,12 +115,11 @@ function AddMetadata() {
});
}, []);
const handleDateChange = (event, { name, value }) => {
setPickedDate(value);
const handleDateChange = (event, data) => {
setPickedDate(data.value);
};
const handleShopChange = event => {
console.log(event.target.value);
changePickedShop(event.target.value);
};
return (
@ -122,12 +136,13 @@ function AddMetadata() {
</Dimmer>
)}
<Container>
<DateInput
fluid
name="date"
placeholder="Data zakupu"
value={pickedDate}
<SemanticDatepicker
onChange={handleDateChange}
placeholder="Data zakupu"
filterDate={date => {
return new Date() > date;
}}
value={pickedDate}
/>
<Input
onChange={handleShopChange}
@ -166,11 +181,7 @@ function AddMetadata() {
disabled={pickedDate === "" || pickedShop === ""}
color="olive"
onClick={() => {
history.push("/home/add_receipt/list", {
shop: pickedShop,
date: pickedDate,
products: productsFromPhoto
});
history.push("/home/add_receipt/list", get_mata_data_obj());
}}
className="add-product-btn"
>

View File

@ -24,12 +24,18 @@ function ProductsList() {
useEffect(() => {
const meta_products = history.location.state.products;
console.log(meta_products);
const new_products = [];
for (let i = 0; i < meta_products.length; i++) {
new_products.push({ name: meta_products[i].name, price: 0.0, tags: [] });
if (meta_products) {
const new_products = [];
for (let i = 0; i < meta_products.length; i++) {
new_products.push({
name: meta_products[i].name,
price: meta_products[i].price,
tags: []
});
}
console.log(new_products);
setProducts(new_products);
}
console.log(new_products);
setProducts(new_products);
}, []);
const meta_info = history.location.state;
const addItem = item => {