Skip to content

Commit

Permalink
backend and popups
Browse files Browse the repository at this point in the history
  • Loading branch information
YoussrAbouYoussif committed May 3, 2019
1 parent 66e03da commit dbd6bbc
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 41 deletions.
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"redux-thunk": "^2.3.0",
"semantic-ui-react": "^0.86.0",
"styled-components": "^4.2.0",
"sweetalert": "^2.1.2",
"validator": "^10.11.0"
},
"scripts": {
Expand Down
7 changes: 5 additions & 2 deletions client/src/components/pages/ApprovedCompanies.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {MDBIcon } from "mdbreact";
import {Button,Card} from"react-bootstrap"
import egypt from '../../egypt.jpeg'
import gafi from '../../gafi.jpeg'
import swal from 'sweetalert';


class ApprovedCompanies extends Component {
Expand All @@ -27,9 +28,11 @@ class ApprovedCompanies extends Component {
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)){
if(Array.isArray(res.data.data)&& res.data.data.length>0){
this.setState({approvedCompanies: res.data.data,sscManagers:[]})

}
else{
swal('You do not have any Approved Companies yet!')
}
})
}
Expand Down
72 changes: 72 additions & 0 deletions client/src/components/pages/Delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React, { Component } from 'react';
import { Button } from 'react-bootstrap';
import { Modal } from 'react-bootstrap';
import '../../App.css';
import axios from 'axios';
import Mongoose from 'mongoose';

class Delete extends Component
{
constructor(props)
{
super(props);
}

DeleteForm = (formId) => {
axios.defaults.headers.common['Authorization'] = localStorage.getItem('jwtToken');
axios
.delete('/routes/api/userDynamicForms/investorDeleteForm/' + Mongoose.Types.ObjectId(formId), {
headers: { Authorization: localStorage.getItem('jwtToken') }
})
.then((res) => {
//document.getElementById('Flip').flipOnClick = false;
alert('This case has been deleted successfully!!');
document.location.href = '/investorInProgressform';
})
.catch((err) => {
console.log(err);
});
};

render() {

return (
<div >

<Modal
{...this.props}
size="lg"
aria-labelledby="contained-modal-title-vcenter"
centered

>

<Modal.Header closeButton >
<Modal.Title id="contained-modal-title-vcenter" style={{color:'#64b9e0'}}>
Are you sure you want to delete this form?
</Modal.Title>
</Modal.Header>
<Modal.Footer>
<Button
variant="dark"
type="button"
onClick={() => (
this.DeleteForm(this.props.formId)
)}
class="btn btn-info"

>
<h3 style={{ color: '#64b9e0', fontSize: '15px' }}>
Delete<br />
{/* <i class="fas fa-trash" /> */}
</h3>
</Button>
<Button variant='dark' onClick={this.props.onHide} ><h3 style={{ color: '#64b9e0', fontSize: '15px' }} >Cancel</h3></Button>
</Modal.Footer>
</Modal>
</div>
)
}
}

export default Delete;
6 changes: 5 additions & 1 deletion client/src/components/pages/GetCaseReviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import GetAllReviewerForms from "../form/GetAllReviewerForms";
import { Dropdown } from "react-bootstrap";
import { blue200 } from "material-ui/styles/colors";
import trans from '../translations/getReviewerTranslation'
import swal from "sweetalert";
const mongoose = require('mongoose')
var $ = require("jquery")(window);

Expand All @@ -27,9 +28,12 @@ class Companies extends Component {
{ headers: { Authorization: localStorage.getItem("jwtToken") } }
)
.then(res => {
if (Array.isArray(res.data.data)) {
if (Array.isArray(res.data.data)&&res.data.data.length>0) {
this.setState({ companies: res.data.data });
}
else{
swal('You do not have any In Progress Cases yet!')
}
});
}

Expand Down
6 changes: 5 additions & 1 deletion client/src/components/pages/assignToReviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'mdbreact/dist/css/mdb.css';
import { Button } from 'react-bootstrap';
import Flippy, { FrontSide, BackSide } from 'react-flippy';
import trans from '../translations/unassignedRevTranslation';
import swal from 'sweetalert';
const Mongoose = require('mongoose');
class assignToReviewer extends Component {
state = {
Expand All @@ -17,9 +18,12 @@ class assignToReviewer extends Component {
headers: { Authorization: localStorage.getItem('jwtToken') }
})
.then((res) => {
if (Array.isArray(res.data.data)) {
if (Array.isArray(res.data.data)&&res.data.data.length>0) {
this.setState({ certainFormType: res.data.data });
}
else{
swal('There are no cases to pick right now!')
}
});
}
AssignReviewer = (formId) => {
Expand Down
6 changes: 5 additions & 1 deletion client/src/components/pages/getCaseLawyer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import GetAllUserForms from '../form/GetAllUserForms';
import { Dropdown, Card } from 'react-bootstrap';
import { MDBProgress } from 'mdbreact';
import { blue200 } from 'material-ui/styles/colors';
import swal from 'sweetalert';
import trans from '../translations/getCaseLawyerTranslation'
const mongoose = require('mongoose');
var $ = require('jquery')(window);
Expand Down Expand Up @@ -39,9 +40,12 @@ class Companies extends Component {
headers: { Authorization: localStorage.getItem('jwtToken') }
})
.then((res) => {
if (Array.isArray(res.data.data)) {
if (Array.isArray(res.data.data)&&res.data.data.length>0) {
this.setState({ companies: res.data.data });
}
else{
swal('You do not have any In Progress Cases yet!')
}
console.log(this.state.companies);
})
.catch((err) => {
Expand Down
67 changes: 41 additions & 26 deletions client/src/components/pages/inProgressInvestorCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import Flippy, { FrontSide, BackSide } from 'react-flippy';
import 'mdbreact/dist/css/mdb.css';
import Mongoose from 'mongoose';
import { MDBProgress } from 'mdbreact';
import { Button } from 'react-bootstrap';
import { Button ,ButtonToolbar} from 'react-bootstrap';
import trans from '../translations/inProgressInvestorTranslation';
import swal from 'sweetalert';
import Delete from './Delete';
import { fromRenderProps } from 'recompose';
class InProgressInvestorCases extends Component {
state = {
certainFormType: [],
isFlipped: true
isFlipped: true ,
modalShow: false
};
componentDidMount() {
axios.defaults.headers.common['Authorization'] = 'Bearer ' + localStorage.getItem('jwtToken');
Expand All @@ -20,9 +24,12 @@ class InProgressInvestorCases extends Component {
})
.then((res) => {
console.log(res);
if (Array.isArray(res.data.data)) {
if (Array.isArray(res.data.data)&& res.data.data.length>0) {
this.setState({ certainFormType: res.data.data });
}
else{
swal('You do not have any In Progress Companies yet!')
}
})
.catch((err) => console.log(err));
}
Expand All @@ -40,28 +47,15 @@ class InProgressInvestorCases extends Component {
console.log(err);
});
};
DeleteForm = (formId) => {
axios.defaults.headers.common['Authorization'] = localStorage.getItem('jwtToken');
axios
.delete('/routes/api/userDynamicForms/investorDeleteForm/' + Mongoose.Types.ObjectId(formId), {
headers: { Authorization: localStorage.getItem('jwtToken') }
})
.then((res) => {
//document.getElementById('Flip').flipOnClick = false;
alert('This case has been deleted successfully!');
document.location.href = '/investorInProgressform';
})
.catch((err) => {
console.log(err);
});
};

redirectEdit(formId, formType) {
console.log(formType);
localStorage.setItem('formId', formId);
localStorage.setItem('formType', formType);
document.location.href = '/editinvcompany';
}
getAttributes = () => {
let modalClose = () => this.setState({ modalShow: false });
return this.state.certainFormType.map((Form, index) => {
var KEYS = [];
for (var key in Form) {
Expand All @@ -76,6 +70,8 @@ class InProgressInvestorCases extends Component {
ref={(r) => (this.flippy = r)}
style={{ width: '100%', height: '970px' }}
>


<FrontSide
style={{
borderStyle: 'solid',
Expand Down Expand Up @@ -138,9 +134,18 @@ class InProgressInvestorCases extends Component {
{Form.status === 'In progress Reviewer' ? (
<MDBProgress material value={95} color="dark" height="63px">
<h3 style={{ color: '#64b9e0', fontSize: '30px' }}>
{trans.reviewerP} <br /> 95%
{trans.reviewerP} <br /> 85%
</h3>
</MDBProgress>
) : null}
{Form.status === 'Reviewer accepted' ? (
<MDBProgress material value={95} color="dark" height="63px">
<h3 style={{ color: '#64b9e0', fontSize: '30px' }}>
{trans.reviewerA} <br /> 99%
</h3>
</MDBProgress>


) : null}
{Form.status === 'Approved' ? (
<MDBProgress material value={65} color="dark" height="63px">
Expand All @@ -160,19 +165,27 @@ class InProgressInvestorCases extends Component {
<i class="fas fa-edit" />
</h3>
</Button>

<Button
variant="dark"
type="button"
onClick={() => (
this.DeleteForm(Form._id)
)}
onClick={() => this.setState({ modalShow: true })}
class="btn btn-info"
// {() => (
// this.DeleteForm(Form._id)
// )}
>
<h3 style={{ color: '#64b9e0', fontSize: '15px' }}>
{trans.delete}<br />
<i class="fas fa-trash" />
</h3>
</Button>
<Delete
show={this.state.modalShow}
onHide={modalClose}
formId={Form._id}
/>

</div>
) : null}
{Form.status === 'Lawyer rejected' ? (
Expand Down Expand Up @@ -201,7 +214,8 @@ class InProgressInvestorCases extends Component {
paddingLeft: '60px'
}}
>
<div>

<div>
{KEYS.map((key, index) => {
if (
key !== '_proto' &&
Expand All @@ -219,7 +233,6 @@ class InProgressInvestorCases extends Component {
for (var att in constraints['0']) {
keys.push(att);
}

if (key === 'lawyerComments') {
return (
<div>
Expand Down Expand Up @@ -254,7 +267,9 @@ class InProgressInvestorCases extends Component {
})}
</div>
);
} else {
}

else {
return (
<div>
{' '}
Expand All @@ -266,7 +281,7 @@ class InProgressInvestorCases extends Component {
return (
<h5 style={{ paddingLeft: '5%' , fontSize:"15px"}}>
<i class="fas fa-circle" /> {att} :
{constraints['0'][att]}
{constraints['0'][att] }
</h5>
);
})}
Expand Down
6 changes: 5 additions & 1 deletion client/src/components/pages/unassignedForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import '../../App.scss';
import { Button } from 'react-bootstrap';
import 'mdbreact/dist/css/mdb.css';
import Flippy, { FrontSide, BackSide } from 'react-flippy';
import swal from 'sweetalert';
import trans from '../translations/unassignedTranslation';
const mongoose = require('mongoose');
class unassignedForm extends Component {
Expand All @@ -18,9 +19,12 @@ class unassignedForm extends Component {
headers: { Authorization: localStorage.getItem('jwtToken') }
})
.then((res) => {
if (Array.isArray(res.data.data)) {
if (Array.isArray(res.data.data)&&res.data.data.length>0) {
this.setState({ certainFormType: res.data.data });
}
else{
swal('There are no cases to pick right now!')
}
});
}
AssignCase = (formId) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let strings = new LocalizedStrings({
lawyerR:"Lawyer Rejected",
lawyerA:"Lawyer Accepted",
reviewerP:"In Progress Reviewer",
reviewerA:"Reviewer Accepted",
approved:"Approved",
edit:"Edit Form",
delete:"Delete Form"
Expand All @@ -19,6 +20,7 @@ let strings = new LocalizedStrings({
lawyerR:"المحامي رفضها",
lawyerA:"المحامي وافق عليها",
reviewerP:"المتابع يعمل عليها",
reviewerA:"المتابع قد وافق",
approved:"تم الموافقة",
edit:"تعديل",
delete:"حذف"
Expand Down
2 changes: 1 addition & 1 deletion controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exports.registerInvestor = async function registerInvestor(body) {

// const user = await User.findOne({body:email})
if (user) return { error: 'Account already exists' };

body.financialBalance = 0
const newUser = await User.create(body)
.then((res) => {
return res;
Expand Down
2 changes: 1 addition & 1 deletion models/DynamicForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const Schema = mongoose.Schema;
var ObjectId = mongoose.Schema.Types.ObjectId;

const DynamicForm = new Schema({
status:{type: String,enum:['Unassigned','In progress Lawyer','Laywer rejected','Lawyer accepted','In progress Reviewer','Reviewer rejected','Approved','Rejected']},
status:{type: String,enum:['Unassigned','In progress Lawyer','Laywer rejected','Lawyer accepted','In progress Reviewer','Reviewer accepted','Reviewer rejected','Approved','Rejected']},
creationDate:{type: Date,required: true},
lawyerComments:{type:[String]},
reviewerComments:{type:[String]},
Expand Down
Loading

0 comments on commit dbd6bbc

Please sign in to comment.