- {/*
-
- */}
-
-
-
- -
-
-
-
-
-
- -
-
-

+ return (
+
+
+
+
-
- );
- }
+
+
+ );
+ }
}
const mapStateToProps = (state) => {
-return {
+ return {
authMessage: state.auth.authMessage,
userData: state.auth.userData,
- };
+ };
};
const mapDispatchToProps = (dispatch) => {
- return {
- signOut: () => dispatch(signOut()),
- userDetail: () => dispatch(userDetail()),
- };
+ return {
+ signOut: () => dispatch(signOut()),
+ userDetail: () => dispatch(userDetail()),
+ };
};
- export default connect(mapStateToProps, mapDispatchToProps)(Header);
+export default connect(mapStateToProps, mapDispatchToProps)(Header);
diff --git a/frontend/src/pages/MainPage/index.js b/frontend/src/pages/MainPage/index.js
index e388eed..c31c37c 100644
--- a/frontend/src/pages/MainPage/index.js
+++ b/frontend/src/pages/MainPage/index.js
@@ -2,249 +2,239 @@ import React from "react";
import { connect } from "react-redux";
import Header from "./header-index";
import Footer from "./footer-index";
-import "../assets/css/bootstrap.css";
-import "../assets/css/bootstrap.min.css";
-import "../assets/css/mdb.css";
-import "../assets/css/mdb.lite.css";
-import "../assets/css/mdb.lite.min.css";
-import "../assets/css/mdb.min.css";
-import "../assets/css/style.min.css";
-// import {Helmet} from "react-helmet";
-import "./style.css";
import { ImageTable, Pagination } from "../../components";
import { ListGroup } from "../../components/common";
import { getImages } from "../../actions/imageAction";
-import { getGenres ,getAllGenres} from "../../actions/imageAction";
-
-class MainPage extends React.Component{
-
- state = {
- genres: [],
- pageSize: 12,
- currentPage: 1,
- currentGenre : "All",
- filteredGenres: [],
- showOptions: false,
- userInput: '',
- isGenreDisplay : false,
-
-
- };
-
-componentDidMount() {
-
+import { getGenres, getAllGenres } from "../../actions/imageAction";
+import "./style.css";
+
+class MainPage extends React.Component {
+ state = {
+ genres: [],
+ pageSize: 12,
+ currentPage: 1,
+ currentGenre: "All",
+ filteredGenres: [],
+ showOptions: false,
+ userInput: "",
+ isGenreDisplay: false,
+ };
+
+ componentDidMount() {
this.props.getGenres();
this.props.getAllGenres();
this.props.getImages(this.state.currentGenre);
-
-}
-
+ }
-handleChange = (name ,value) => {
- this.setState({[name]: value, currentPage: 1});
+ handleChange = (name, value) => {
+ this.setState({ [name]: value, currentPage: 1 });
// console.log("CG",this.state.currentGenre);
this.props.getImages(value);
-};
+ };
-onPageChange = (page) => {
+ onPageChange = (page) => {
this.setState({ currentPage: page });
};
onOpenGenre = (e) => {
// console.log(e.target.id);
- this.setState({userInput : e.target.id});
- this.setState({isGenreDisplay : true});
+ this.setState({ userInput: e.target.id });
+ this.setState({ isGenreDisplay: true });
this.props.getImages(e.target.id);
- }
-
+ };
-showSearchList(){
+ showSearchList() {
const showOptions = this.state.showOptions;
const userInput = this.state.userInput;
const filteredGenres = this.state.filteredGenres;
-// console.log(filteredGenres);
+ // console.log(filteredGenres);
if (showOptions && userInput) {
- if (filteredGenres.length) {
- return (
-
- {filteredGenres.map((optionName) => {
- // console.log(optionName);
- return (
- -
+ {filteredGenres.map((optionName) => {
+ // console.log(optionName);
+ return (
+
-
- {optionName}
-
- );
- })}
-
- );
- } else {
- return (
-
-
No Option!
-
- );
- }
+ >
+ {optionName}
+
+ );
+ })}
+
+ );
+ } else {
+ return (
+
+
No Option!
+
+ );
}
-}
+ }
+ }
-changeSearchList = (e) =>{
+ changeSearchList = (e) => {
// console.log(e.target.value);
- if(e.target.value === ''){
- this.setState({currentGenre : "All", currentPage: 1});
- this.props.getImages("All");
-
- this.setState({
- filteredGenres : [],
- showOptions: false,
- userInput : '',
- isGenreDisplay : false
- });
-
- return;
- }
-
- const options = this.props.genreList;
- const userInput = e.target.value;
-
- const filteredGenres = options.filter(
- (optionName) =>
- optionName.toLowerCase().indexOf(userInput.toLowerCase()) > -1
- );
- // console.log(filteredGenres);
-
- this.setState({
- filteredGenres,
- showOptions: true,
- userInput
- });
+ if (e.target.value === "") {
+ this.setState({ currentGenre: "All", currentPage: 1 });
+ this.props.getImages("All");
+
+ this.setState({
+ filteredGenres: [],
+ showOptions: false,
+ userInput: "",
+ isGenreDisplay: false,
+ });
+
+ return;
+ }
-}
+ const options = this.props.genreList;
+ const userInput = e.target.value;
+ const filteredGenres = options.filter(
+ (optionName) =>
+ optionName.toLowerCase().indexOf(userInput.toLowerCase()) > -1
+ );
+ // console.log(filteredGenres);
-render(){
- const {
- currentPage,
- pageSize,
+ this.setState({
+ filteredGenres,
+ showOptions: true,
+ userInput,
+ });
+ };
- } = this.state;
- const { images,genres,loggedIn} = this.props;
+ render() {
+ const { currentPage, pageSize } = this.state;
+ const { images, genres, loggedIn } = this.props;
if (!loggedIn) this.props.history.push("/login");
let filteredImages = [];
filteredImages = images;
// console.log("imagesgenres");
// console.log(images);
- return(
-
-
-
-
-
-
-
- {/* Home Page
+ return (
+
+
+
+
+
+
+
+ {/* Home Page
/ */}
- Dashboard
-
-
+
+ {this.showSearchList()}
- {/*
Basic dropdown */}
-
- {
- this.state.isGenreDisplay
- ?
-
-
-
-
-
-
+
+
+
+
+
+ {this.state.isGenreDisplay ? (
+
+
+
+
+
+
+
- :
-
+
+ ) : (
+
+
this.handleChange("currentGenre",val)}
+ onChange={(val) => this.handleChange("currentGenre", val)}
options={genres}
- />
-
- }
-
-
-
-
- {!!filteredImages.length ? `${filteredImages.length} ` : "0 "}
- Images found.
-
-
- {!!filteredImages ? (
-
- ) : (
-
No Images
- )}
-
-
+
+ )}
+
+ {!!filteredImages.length ? `${filteredImages.length} ` : "0 "}
+ Images found.
+
+
+
+
+
+
+
+ {!!filteredImages ? (
+
-
-
-
-
+ )
+
+
+ : (
+
No Images
+ )}
+
+
+
+
-
- );
- }
+
+
+
+
+ );
+ }
}
-
const mapDispatchToProps = (dispatch) => {
- return {
- getImages: (genre) => dispatch(getImages(genre)),
- getGenres: () => dispatch(getGenres()),
- getAllGenres: () => dispatch(getAllGenres()),
- };
+ return {
+ getImages: (genre) => dispatch(getImages(genre)),
+ getGenres: () => dispatch(getGenres()),
+ getAllGenres: () => dispatch(getAllGenres()),
};
+};
const mapStateToProps = (state) => {
- return {
- images: state.image.images,
- genres: state.image.genres,
- genreList: state.image.genreList,
- loggedIn: state.auth.loggedIn,
- };
+ return {
+ images: state.image.images,
+ genres: state.image.genres,
+ genreList: state.image.genreList,
+ loggedIn: state.auth.loggedIn,
};
-
+};
-
-export default connect(mapStateToProps, mapDispatchToProps)(MainPage);
\ No newline at end of file
+export default connect(mapStateToProps, mapDispatchToProps)(MainPage);
diff --git a/frontend/src/pages/Register/index.js b/frontend/src/pages/Register/index.js
index 84da0fc..216e131 100644
--- a/frontend/src/pages/Register/index.js
+++ b/frontend/src/pages/Register/index.js
@@ -2,7 +2,7 @@ import React from "react";
import Joi from "@hapi/joi";
import { connect } from "react-redux";
import { getOTP, signUpandVerify } from "../../actions/authAction";
-import "./style.css";
+
import { Helmet } from "react-helmet";
@@ -93,9 +93,11 @@ class RegisterForm extends React.Component {
saveUserDetais(user, loggedIn) {
console.log(user);
+ if(user.userData===undefined){return;}
if (loggedIn) {
localStorage.setItem('loggedIn', true);
if (localStorage.getItem('loggedIn') === 'true') {
+ console.log('hello');
localStorage.setItem('name', user.userData._id);
}
}
diff --git a/routes/vision.js b/routes/vision.js
index e0180da..d166f01 100644
--- a/routes/vision.js
+++ b/routes/vision.js
@@ -15,7 +15,8 @@ const getAllGenres = new GetAllGenres();
const storage = multer.diskStorage({
destination: (req, file, callback) => {
- callback(null, "./uploads/");
+ console.log("multer")
+ callback(null, "./uploads");
},
filename: (req, file, callback) => {
callback(null, Date.now() + "-" + file.originalname);