diff --git a/client/package.json b/client/package.json index 95e136a..68f91a6 100644 --- a/client/package.json +++ b/client/package.json @@ -43,10 +43,12 @@ "react-router-dom": "^5.0.0", "react-scripts": "2.1.8", "react-scroll": "^1.7.11", + "react-select": "^2.0.0-beta.7", "react-simple-animate": "^2.6.5", "react-stepper-horizontal": "^1.0.11", "react-tap-event-plugin": "^3.0.3", "react-validation": "^3.0.7", + "react-virtualized-select": "^3.1.3", "redux": "^4.0.1", "redux-thunk": "^2.3.0", "semantic-ui-react": "^0.86.0", diff --git a/client/src/App.js b/client/src/App.js index f564e48..ef12697 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -36,7 +36,7 @@ import ForgotPassword from './containers/ForgotPassword'; import ResetPassword from './containers/ResetPassword'; import About from './components/pages/about'; import ApprovedCompanies from './components/pages/ApprovedCompanies'; -import companyPDF from './components/pages/companyPdf'; +import CompanyPDF from './components/pages/companyPdf'; import CreateANewCompany from './components/pages/CreateANewCompany'; import AttributeArray from './components/pages/AttributeArray'; import InProgressInvestorCases from './components/pages/inProgressInvestorCases'; @@ -187,7 +187,7 @@ class App extends Component { } + render={(props) => } /> { - var { suggestions } = this.props; - console.log('Sugeestions:',suggestions) - const userInput = e.currentTarget.value; - - // Filter our suggestions that don't contain the user's input - const filteredSuggestions = suggestions.filter( - suggestion => - suggestion.toLowerCase().indexOf(userInput.toLowerCase()) > -1 - ); - - // Update the user input and filtered suggestions, reset the active - this.setState({ - activeSuggestion: 0, - filteredSuggestions, - showSuggestions: true, - userInput: e.currentTarget.value - }); - }; - - //Add to Skills Array in Form - onClick = e => { - //saving el skills - this.props.addSkill(e.currentTarget.innerText) - //kam haga malhash lazma - var index=this.props.suggestions.indexOf(e.currentTarget.innerText) - if(index>-1){ - this.props= this.props.suggestions.splice(index,1) - - } - this.setState({ - activeSuggestion: 0, - filteredSuggestions: [], - showSuggestions: false, - userInput: '' - }); - }; - - // Event fired when the user presses a key down - onKeyDown = e => { - const { activeSuggestion, filteredSuggestions } = this.state; - - // User pressed the enter key, update the input and close the - // suggestions - if (e.keyCode === 13) { - this.setState({ - activeSuggestion: 0, - showSuggestions: false, - userInput: filteredSuggestions[activeSuggestion] - }); - } - // navigate up ya user - else if (e.keyCode === 38) { - if (activeSuggestion === 0) { - return; - } - - this.setState({ activeSuggestion: activeSuggestion - 1 }); - } - // navigate down ya user - else if (e.keyCode === 40) { - if (activeSuggestion - 1 === filteredSuggestions.length) { - return; - } - - this.setState({ activeSuggestion: activeSuggestion + 1 }); - } - }; - - render() { - const { - onChange, - onClick, - onKeyDown, - state: { - activeSuggestion, - filteredSuggestions, - showSuggestions, - userInput - } - } = this; - - let suggestionsListComponent; - - if (showSuggestions && userInput) { - if (filteredSuggestions.length) { - suggestionsListComponent = ( -
    - {filteredSuggestions.map((suggestion, index) => { - let className; - - // kamel wala yhmak - if (index === activeSuggestion) { - className = "suggestion-active"; - } - - return ( -
  • - {suggestion} -
  • - ); - })} -
- ); - } else { - //mafeesh haga 3'oor f dahya - suggestionsListComponent = ( -
- No suggestions, you're on your own! -
- ); - } - } - - return ( - - - {suggestionsListComponent} - - ); - } -} - -export default Autocomplete; \ No newline at end of file diff --git a/client/src/components/form/GetFormByCompanyName.js b/client/src/components/form/GetFormByCompanyName.js index 3be1c0e..330d0d7 100644 --- a/client/src/components/form/GetFormByCompanyName.js +++ b/client/src/components/form/GetFormByCompanyName.js @@ -13,7 +13,10 @@ import { Button } from "react-bootstrap"; import html2canvas from "html2canvas"; import styled, { css } from "styled-components"; import trans from "../translations/searchCompanyTranslation"; -import Autocomplete from "Autocomplete"; +import Select from "react-select"; +import {components} from "react-select" +import options from "react-select" +import search from '../../back.jpg'; //import { Dropdown } from 'semantic-ui-react'; import axios from "axios"; @@ -24,7 +27,7 @@ class MyCompany extends Component { state = { companyName: "", companies: [], - viewedComp: [] + viewedComp: [] , }; componentDidMount = () => { @@ -36,11 +39,18 @@ class MyCompany extends Component { this.setState({ companies: res.data.data }); + { + this.state.companies.map((nat,index) =>{ + var o = {label:nat.companyName,value:index} + this.state.viewedComp.push(o) + } + ); + } + // console.log(this.state.companies) + console.log(this.state.viewedComp); }); }; - //do you mean get all forms? - tabRow() { return this.state.companies.map(function(company, i) { return ( @@ -55,29 +65,28 @@ class MyCompany extends Component { this.setState({ [event.target.name]: { value: event.target.value } }); }; - handleClick(event) { - axios.defaults.headers.common["Authorization"] = - "Bearer " + localStorage.getItem("jwtToken"); - var apiBaseUrl = "/routes/api/admins/getByCompanyName/"; - - axios - .get(apiBaseUrl + this.state.companyName.value, { - headers: { Authorization: localStorage.getItem("jwtToken") } - }) - .then(res => { - this.setState({ viewedComp: res.data.data }); - }); + handleClick=(opt)=> { + this.setState({value:opt.label}) } getAttributes = () => { - return this.state.viewedComp.map((Form, index) => { + var Form; + console.log(this.state.companies) + for(let i=0;i + //
+ {KEYS.map((key, index) => { if ( @@ -87,7 +96,7 @@ class MyCompany extends Component { key !== "investorId" && key !== "lawyerId" && key !== "reviewerId" && - key !== "__v" + key !== "__v" ) { var constraints = Form[key]; if (Array.isArray(constraints)) { @@ -114,53 +123,63 @@ class MyCompany extends Component { })} + //
); - }); }; + render() { trans.setLanguage(this.props.lang); - return ( - //
-
- - - - - -
- + const { Option } = components; + const IconOption = (props) => ( + +); +// var n = ( +//
+// +//
+// ) + return ( + +
+ +
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+ +
+ +
{this.getAttributes()}
+ +
-
-
{this.getAttributes()}\
- + +
+
+
- - ); } } // ReactDOM.render(, document.getElementById('root')); -export default MyCompany; +export default MyCompany; \ No newline at end of file diff --git a/client/src/components/pages/ApprovedCompanies.js b/client/src/components/pages/ApprovedCompanies.js index ffcde66..d69937c 100644 --- a/client/src/components/pages/ApprovedCompanies.js +++ b/client/src/components/pages/ApprovedCompanies.js @@ -1,266 +1,164 @@ -import React, { Component } from 'react'; -import axios from 'axios'; -import '../../App.css'; +import React, { Component } from "react"; +import axios from "axios"; +import "../../App.css"; // import ApprovedCompaniesFields from '../user/ApprovedCompaniesFields'; -import Table from 'react-bootstrap/Table' -import Navbar from 'react-bootstrap/Navbar' -import {Badge} from 'react-bootstrap' -import trans from '../translations/approvedTranslation' -import jsPDF from 'jspdf' -import html2canvas from 'html2canvas' -import styled, { css } from 'styled-components' -import style from 'material-ui/RaisedButton'; -import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; -import RaisedButton from 'material-ui/RaisedButton'; -import {MDBIcon } from "mdbreact"; -import {Button,Card} from"react-bootstrap" -import egypt from '../../egypt.jpeg' -import gafi from '../../gafi.jpeg' +import Table from "react-bootstrap/Table"; +import Navbar from "react-bootstrap/Navbar"; +import { Badge } from "react-bootstrap"; +import trans from "../translations/approvedTranslation"; +import jsPDF from "jspdf"; +import html2canvas from "html2canvas"; +import styled, { css } from "styled-components"; +import style from "material-ui/RaisedButton"; +import MuiThemeProvider from "material-ui/styles/MuiThemeProvider"; +import RaisedButton from "material-ui/RaisedButton"; +import { MDBIcon } from "mdbreact"; +import { Button, Card } from "react-bootstrap"; +import egypt from "../../egypt.jpeg"; +import gafi from "../../gafi.jpeg"; - class ApprovedCompanies extends Component { - state = { - approvedCompanies:[] - } - componentDidMount(){ - - axios.defaults.headers.common['Authorization'] = 'Bearer ' + localStorage.getItem('jwtToken'); - axios.get('/routes/api/userDynamicForms/getInvestorApprovedCompanies',{headers: { "Authorization": localStorage.getItem('jwtToken') }}) - .then(res => { - if(Array.isArray(res.data.data)){ - this.setState({approvedCompanies: res.data.data,sscManagers:[]}) - - } + state = { + approvedCompanies: [], + companyname: "", + }; + componentDidMount() { + axios.defaults.headers.common["Authorization"] = + "Bearer " + localStorage.getItem("jwtToken"); + axios + .get("/routes/api/userDynamicForms/getInvestorApprovedCompanies", { + headers: { Authorization: localStorage.getItem("jwtToken") } }) - } - // tabRow(){ - // return ( - // this.state.approvedCompanies.map(function(approvedCompany,i){ - // return }) - // ) - // } - - printDocument() { - const input = document.getElementById('divToPrint'); - - html2canvas(input) - .then((canvas) => { - const imgData = canvas.toDataURL('image/jpeg'); - const img = new Image(); - var path = require("path"); - img.src = path.resolve(egypt); - const img2 = new Image(); - var path2 = require("path"); - img2.src = path2.resolve(gafi); - var pdf = new jsPDF({ - orientation: 'landscape', - unit: 'in', - format: [900, 1100] - }) - - pdf.addImage(imgData, 'JPEG', 1, 1); - pdf.addImage(img, 'JPEG', 1, 1); - pdf.addImage(img2, 'JPEG', 13.2, 1); - - pdf.setFont("helvetica"); - pdf.setFontType("bold"); - pdf.setFontSize(30); - pdf.text(6.2, 3, 'Your Company'); - - pdf.setFont("helvetica"); - pdf.setFontType("normal"); - pdf.setFontSize(15); - pdf.text(1, 12, '© 2019 Copyright: GAFI'); - - // pdf.output('dataurlnewwindow') - pdf.save("download.pdf") - }) - - } - - getAttributes = () => { - - return this.state.approvedCompanies.map((Form, index) => { - var KEYS = []; - // console.log(Form) - for (var key in Form) { - KEYS.push(key); - } - return( - - - {KEYS.map((key, index) => { - if ( - key !== "_proto" && - key !== "_id" && - key !== "formType" && - key !== "investorId" && - key !== "lawyerId" && - key !== "reviewerId" && - key !== "__v" && - key !== "reviewerComments" - ) { - var constraints = Form[key]; - if (Array.isArray(constraints)) { - if(!constraints["0"]) return - var keys = [] - for (var att in constraints["0"]) { - keys.push(att); - } - } - return ( -
-
-

- {key} : {constraints}{" "} -

-
- -
- ); - }}) - } -
-
- - ) - } - )} - - render(){ - trans.setLanguage(this.props.lang) - return ( -
- {/*
{trans.title}
- - - - - - - - - - - - - - - - - - {this.tabRow()} - -
{trans.name}{trans.nameInEnglish}{trans.governorate}{trans.city}{trans.address}{trans.telephone}{trans.fax}{trans.currency}{trans.capital}{trans.type}{trans.date}
*/} - - (
- -
- - - - - - - {/* */} -
-
-
-
-
-
-
-
-
-
-
- {this.getAttributes()} + .then(res => { + if (Array.isArray(res.data.data)) { + this.setState({ approvedCompanies: res.data.data, sscManagers: [] }); + } + }); + console.log(this.state.approvedCompanies); + } + changeHandler = event => { + this.setState({ [event.target.name]: { value: event.target.value } }); + }; - {/* {this.state.approvedCompanies.map(el => { - return
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{trans.name}{trans.nameInEnglish}{trans.governorate}{trans.city}{trans.address}{trans.telephone}{trans.fax}{trans.currency}{trans.capital}{trans.type}{trans.date}
{el.companyName}{el.companyNameInEnglish}{el.companyGovernorate}{el.companyCity}{el.companyAddress}{el.companyTelephone}{el.companyFax}{el.currency}{el.equityCapital}{el.type}{el.creationDate}
*/} - {/*
- - })} */} - - -
- -
- -
- ) + getAttributes = () => { + return this.state.approvedCompanies.map((Form, index) => { + + var b = ( + + ); + var KEYS = []; + // console.log(Form) + for (var key in Form) { + KEYS.push(key); } - } - export default ApprovedCompanies + return ( + + + {KEYS.map((key, index) => { + if ( + key !== "_proto" && + key !== "_id" && + key !== "formType" && + key !== "investorId" && + key !== "lawyerId" && + key !== "reviewerId" && + key !== "__v" && + key !== "reviewerComments" + ) { + var constraints = Form[key]; + if (Array.isArray(constraints)) { + if (!constraints["0"]) return; + var keys = []; + for (var att in constraints["0"]) { + keys.push(att); + } + } + return ( +
+
+

+ {" "} + {key} : {constraints}{" "} +

+
+
+ ); + } + })} +
+ {this.state.approvedCompanies.length > 0 ? b : null} +
+ ); + }); + }; + render() { + trans.setLanguage(this.props.lang); + + return ( +
+ ( +
+
+
+
+
+
+
+
+
+
+
+
+ {this.getAttributes()} + +
+
+
+ ); + } +} +export default ApprovedCompanies; diff --git a/client/src/components/pages/companyPdf.js b/client/src/components/pages/companyPdf.js index 9296e32..566f25e 100644 --- a/client/src/components/pages/companyPdf.js +++ b/client/src/components/pages/companyPdf.js @@ -11,7 +11,7 @@ import { MDBRow, MDBCol, MDBInput, MDBBtn, MDBIcon } from "mdbreact"; import jsPDF from "jspdf"; import html2canvas from "html2canvas"; import styled, { css } from "styled-components"; -import { Button} from "react-bootstrap"; +import { Button } from "react-bootstrap"; import egypt from "../../egypt.jpeg"; import gafi from "../../gafi.jpeg"; @@ -27,6 +27,21 @@ class PDF extends Component { viewedComp: [] }; + componentDidMount() { + axios.defaults.headers.common["Authorization"] = + "Bearer " + localStorage.getItem("jwtToken"); + axios + .get("/routes/api/userDynamicForms/getInvestorApprovedCompanies", { + headers: { Authorization: localStorage.getItem("jwtToken") } + }) + .then(res => { + if (Array.isArray(res.data.data)) { + this.setState({ companies: res.data.data, sscManagers: [] }); + } + }); + console.log(localStorage.getItem("PDFcomp")); + } + changeHandler = event => { this.setState({ [event.target.name]: { value: event.target.value } }); }; @@ -68,29 +83,23 @@ class PDF extends Component { } getAttributes = () => { - var compname = localStorage.getItem('PDFcomp') - axios.defaults.headers.common["Authorization"] = - "Bearer " + localStorage.getItem("jwtToken"); - var apiBaseUrl = "/routes/api/userDynamicForms/getByCompanyName/"; - - axios - .get(apiBaseUrl + localStorage.getItem('PDFcomp'), { - headers: { Authorization: localStorage.getItem("jwtToken") } - }) - .then(res => { - this.setState({ viewedComp: res.data.data }); - - - }); - console.log(localStorage.getItem('PDFcomp')) - console.log(this.state.viewedComp); - - return this.state.viewedComp.map((Form, index) => { - var KEYS = []; - // console.log(Form) - for (var key in Form) { - KEYS.push(key); - } + var Form; + console.log(this.state.companies); + for (let i = 0; i < this.state.companies.length; i++) { + if ( + this.state.companies[i].companyName === localStorage.getItem("PDFcomp") + ) + Form = this.state.companies[i]; + } + console.log(localStorage.getItem("PDFcomp")); + // console.log(this.state.viewedComp); + + var KEYS = []; + // console.log(Form) + for (var key in Form) { + KEYS.push(key); + } + if (Form) return ( @@ -127,60 +136,68 @@ class PDF extends Component { ); } })} - - - ); - }); }; render() { return ( - //
+
- {/* - - - - - -
- - this.handleClick(event)} - /> - + +

SAVE YOUR DOCUMENT

+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+ {this.getAttributes()} +
-
*/} -
{this.getAttributes()}
); }