minor fix

This commit is contained in:
lion
2019-01-30 14:35:19 +01:00
parent be39fb3043
commit 25663ddf4a
4 changed files with 12 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
const Sequelize = require("sequelize");
const sequelize = new Sequelize("sql7274844", "sql7274844", "upMgevlgak", {
const sequelize = new Sequelize("sql7276322", "sql7276322", "RS53ihYlg9", {
host: "sql7.freemysqlhosting.net",
dialect: "mysql",
operatorsAliases: false

View File

@@ -12,7 +12,7 @@ app.use(bodyParser.urlencoded({ extended: true }));
const port = process.env.PORT || 5000;
app.get("/api/sendnotifications", async function(req, res) {
app.get("/sendnotifications", async function(req, res) {
let marketAlerts = await MarketAlert.findAll();
let lastDateUpdate = await Promise.all(
@@ -33,7 +33,7 @@ app.get("/api/sendnotifications", async function(req, res) {
);
});
app.get("/api/:url", async (req, res) => {
app.get("/items/:url", async (req, res) => {
let url =
"https://www.olx.ba/pretraga?" +
req.params.url +
@@ -45,7 +45,7 @@ app.get("/api/:url", async (req, res) => {
});
});
app.post("/api/marketalerts", function(req, res) {
app.post("/marketalerts", function(req, res) {
const { email, last_date, olx_url } = req.body;
sequelize.sync().then(() =>
MarketAlert.create({

View File

@@ -49,7 +49,7 @@ class App extends React.Component {
onUserDataChange({ info: "olx_url", value: url });
if (url) {
axios
.get(`/api/${url}`)
.get(`/items/${url}`)
.then(response => {
onItemsChanged(response.data.items);
onUserDataChange({

View File

@@ -57,7 +57,7 @@ class NotificationModal extends React.Component {
userdata: { email, last_date, olx_url }
} = this.props;
axios
.post("/api/marketalerts", {
.post("/marketalerts", {
email,
last_date,
olx_url
@@ -138,7 +138,12 @@ class NotificationModal extends React.Component {
</DialogContent>
<DialogActions className={classes.modalFooter}>
{validEmail ? (
<Button className={classes.saveButton}>Save</Button>
<Button
onClick={this.handleSaveMarketAlert}
className={classes.saveButton}
>
Save
</Button>
) : (
<Tooltip
title="Provide a valid email"