This commit is contained in:
Maciej Kotowski committed 2021-10-07 20:47:45 +02:00
1 parent aa9080fbb4
commit 7f60f98993
7 files changed
+23 -32

No files matched your search

@@ -2,7 +2,9 @@ import { BIcon } from "../BIcon";
import styles from "./index.module.scss";
import { EventType } from "../EventType";
import { API_CLIENT } from "../../constants";
import { useHistory } from "react-router-dom";
export const EventPreviewEdit = (props) => {
const history = useHistory();
const getDate = (time) => {
let date = new Date(time);
return date.toLocaleDateString(navigator.language);
@@ -17,6 +19,7 @@ export const EventPreviewEdit = (props) => {
const deleteItem = (arg) => {
console.log("deleting..." + arg);
API_CLIENT.deleteEvent({ id: arg });
history.push("/");
};
return (
<div className={styles.link}>
@@ -3,7 +3,7 @@
.title {
color: $accent;
text-align: center;
font-size: 2.1em;
font-size: 1.8em;
font-weight: bold;
}
+3 -2
View File
@@ -1,4 +1,4 @@
// import styles from "./index.module.scss";
import styles from "./index.module.scss";
import { Stack } from "react-bootstrap";
import { useState, useEffect } from "react";
import { API_CLIENT } from "../../constants";
@@ -16,7 +16,7 @@ export const Dashboard = () => {
if (data !== "not logged") {
API_CLIENT.getUserEvents(data.email).then((events) => {
if (events) {
array.push(events);
array = events;
console.log(array);
render();
}
@@ -51,6 +51,7 @@ export const Dashboard = () => {
};
return (
<div className={container}>
<p className={styles.title}>Tu możesz zarządzać swoimi wydarzeniami</p>
<Stack gap={1}>{list}</Stack>
</div>
);
@@ -0,0 +1,8 @@
@import "../../index.scss";
.title {
color: $accent;
text-align: center;
font-size: 1.8em;
font-weight: bold;
}
+5 -7
View File
@@ -73,7 +73,6 @@ app.get("/api/getEvents", async (req, res) => {
try {
const event = await events.find();
if (!event) throw Error("something went wrong");
console.log(event);
res.status(200).json(event);
} catch (err) {
res.status(400).json({ msg: err });
@@ -81,21 +80,19 @@ app.get("/api/getEvents", async (req, res) => {
});
app.post("/api/deleteEvent", async (req, res) => {
try {
console.log("event");
const event = await events.remove({_id: req.body.id});
const event = await events.deleteOne({_id: req.body.id});
if (!event) throw Error("something went wrong");
res.status(200).json("ok");
} catch (err) {
res.status(400).json({ msg: err });
}
});
app.post("/api/getUserEvents", async (req, res) => {
try {
console.log(req.user+"fweg");
const userEvents = await events.findOne({user:req.body.email});
console.log(userEvents);
console.log("____");
const userEvents = await events.find({user:req.body.email});
console.log(userEvents)
res.status(200).json(userEvents);
} catch (err) {
res.status(400).json({ msg: err });
@@ -105,6 +102,7 @@ app.post("/api/getUserEvents", async (req, res) => {
app.post("/api/createEvent", (req, res) => {
let data = {
name: req.body.name,
user:req.body.user,
type: req.body.type,
description: req.body.description,
address: req.body.address,
-19
View File
@@ -13,25 +13,6 @@ const UserSchema = new mongoose.Schema(
password: {
type: String
},
referral_code: {
type: String,
default: function() {
let hash = 0;
for (let i = 0; i < this.email.length; i++) {
hash = this.email.charCodeAt(i) + ((hash << 5) - hash);
}
let res = (hash & 0x00ffffff).toString(16).toUpperCase();
return "00000".substring(0, 6 - res.length) + res;
}
},
referred_by: {
type: String,
default: null
},
date: {
type: Date,
default: Date.now
}
},
{ strict: false }
);
+3 -3
View File
@@ -19,7 +19,7 @@ passport.use(
// Match User
User.findOne({ email: email })
.then(user => {
/* // Create new User
// Create new User
if (!user) {
const newUser = new User({ email, password });
// Hash password before saving in database
@@ -38,7 +38,7 @@ passport.use(
});
});
// Return other user
} else {*/
} else {
// Match password
bcrypt.compare(password, user.password, (err, isMatch) => {
if (err) throw err;
@@ -49,7 +49,7 @@ passport.use(
return done(null, false, { message: "Wrong password" });
}
});
/*}*/
}
})
.catch(err => {
return done(null, false, { message: err });