Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #35

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ import AdminApplication from "./components/applications/AdminApplication";
import PartnerApplications from "./components/applications/PartnerApplications";
import PartnerApplication from "./components/applications/PartnerApplication";
import PartnerNegotiation from "./components/applications/PartnerNegotiation";
<<<<<<< HEAD
import PartnerTaskForm from "./components/tasks/Partner'sTaskForm"
=======

>>>>>>> 816cafad48c43ed1e7508eec07b81361d0753494
import editapp from "./components/edit-profile/editapp";
import AddPastEvents from"./components/edit-profile/AddPastEvents";

import AdminNegotiation from "./components/applications/AdminNegotiation";

Expand Down Expand Up @@ -114,6 +119,15 @@ class App extends Component {
component={EditPartner}
/>
</Switch>

<Switch>
<PrivateRoute
exact
path="/api/tasks/member/addpastevent/:id"
component={AddPastEvents}
/>
</Switch>

<Switch>
<PrivateRoute exact path="/dashboard" component={dashboard} />
</Switch>
Expand All @@ -137,7 +151,15 @@ class App extends Component {
path="/api/applications/consultant/:id/:appID"
component={Application}
/>

<Switch>
<PrivateRoute
exact
path="/api/tasks/partner/:id"
component={PartnerTaskForm}
/>
</Switch>
<Switch>
<PrivateRoute
exact
path="/api/profiles/partner/applications/:id"
Expand Down
23 changes: 23 additions & 0 deletions client/src/actions/memberActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,26 @@ export const addSkillMember = (memberData, history) => async dispatch => {
});
}
};

// add pasteventss
export const addpastevents = (memberData, history) => async dispatch => {
const body = JSON.stringify(memberData);
const res = await fetch("http://localhost:5000/api/profiles/member/past-events", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: localStorage.getItem("jwtToken")
},
body: body
});
const json = await res.json();
if (json.msg) {
history.push("/dashboard");
} else {
dispatch({
type: GET_ERRORS,
payload: json
});
}
};

2 changes: 1 addition & 1 deletion client/src/actions/organizationActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const createOrganization = (
const part = "Partner";
switch (value) {
case part:
history.push("/cp/" + json.data._id);
history.push(`/cp/${json.data._id}`);
break;
default:
dispatch({
Expand Down
4 changes: 2 additions & 2 deletions client/src/actions/taskActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
const fetch = require("node-fetch");

// Post Task
export const postTask = (taskData, history) => async dispatch => {
export const PartnerPostTask = (taskData,appid,history) => async dispatch => {
const body = JSON.stringify(taskData);
const res = await fetch(
`http://localhost:5000/api/tasks/partner/${taskData.ID}/${taskData.application}`,
`http://localhost:5000/api/tasks/partner/${appid}`,
{
method: "POST",
headers: {
Expand Down
7 changes: 7 additions & 0 deletions client/src/components/applications/PartnerApplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PropTypes from "prop-types";
import { getPartnerApplication } from "../../actions/applicationActions";
import Spinner from "../common/Spinner";


class PartnerApplication extends Component {
componentDidMount() {
const { id } = this.props.match.params;
Expand Down Expand Up @@ -79,6 +80,12 @@ class PartnerApplication extends Component {
Negotiate
</Link>
</div>
<Link
to={`/api/tasks/partner/${application._id}`}
className="btn btn-lg btn-info"
>
create a task
</Link>
</div>
</div>
);
Expand Down
15 changes: 8 additions & 7 deletions client/src/components/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class dashboard extends Component {
className="btn btn-lg btn-info"
>
My Tasks
</Link>{" "}
<Link
to={`/api/tasks/member/addpastevent/${profile2._id}`}
className="btn btn-lg btn-info"
>
add past event
</Link>
</div>
);
Expand All @@ -73,7 +79,7 @@ class dashboard extends Component {
to={`/api/profiles/partner/${profile2._id}`}
>
Show Profile:{profile2.name}
</Link>
</Link>{" "}
<Link
to="/api/profiles/Edit-Partner"
className="btn btn-lg btn-info"
Expand All @@ -92,12 +98,7 @@ class dashboard extends Component {
>
Post Application
</Link>{" "}
<Link to="/Partner-TaskForm" className="btn btn-lg btn-info">
Partner create task
</Link>{" "}
<Link to="/Consultant-TaskForm" className="btn btn-lg btn-info">
consultant create task
</Link>

</div>
);
} else {
Expand Down
28 changes: 11 additions & 17 deletions client/src/components/edit-profile/AddPastEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class AddPastEvents extends Component {
}
componentDidMount() {
this.props.getCurrentMember();
console.log(this.props)
}
}
componentWillReceiveProps(nextProps) {
if (nextProps.errors) {
this.setState({ errors: nextProps.errors });
Expand All @@ -37,7 +36,7 @@ class AddPastEvents extends Component {
description: this.state.description,
location: this.state.location,
};

this.props.addpastevents(memberData, this.props.history);
};

Expand All @@ -46,30 +45,25 @@ class AddPastEvents extends Component {
}

render() {
const { errors } = this.state;
// const { errors } = this.state;

return (
<div className="create-profile">
<div className="container">
<div className="row">
<div className="col-md-8 m-auto">
<h1 className="display-4 text-center">Edit Member Profile</h1>
<h1 className="display-4 text-center"> Add Past-Event </h1>
<p className="lead text-center">
Only fill fields you wish to update
Fill in the info about the event
</p>
<form onSubmit={this.onSubmit}>
<TextFieldGroup
placeholder="Name"
name="name"
<TextFieldGroup
placeholder="title"
name="title"
value={this.state.title}
onChange={this.onChange}
// error={
// errors.error == '"name" is required'
// ? errors.error
// : errors.error == '"name" is not allowed to be empty'
// ? errors.error
// : errors.error ==
// '"name" length must be at least 3 characters long'
// errors.error == '"age" must be a number'
// ? errors.error
// : null
// }
Expand Down Expand Up @@ -113,13 +107,13 @@ class AddPastEvents extends Component {
AddPastEvents.propTypes = {
addpastevents: PropTypes.func.isRequired,
getCurrentMember: PropTypes.func.isRequired,
// profile: PropTypes.object.isRequired,
profile: PropTypes.object.isRequired,
errors: PropTypes.object.isRequired
};

const mapStateToProps = state => ({
profile: state.member,
errors: state.errors
// errors: state.errors
});

export default connect(
Expand Down
3 changes: 0 additions & 3 deletions client/src/components/tasks/Consultant'sTaskform.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<<<<<<< HEAD:client/src/components/tasks/Consultant'sTaskform.js
import React, { Component } from 'react'
import { connect } from "react-redux";
import { withRouter } from "react-router-dom";
Expand Down Expand Up @@ -129,5 +128,3 @@ ConsultantTaskForm.propTypes = {
mapStateToProps,
{ ConsultantPostTask }
)(withRouter(ConsultantTaskForm));
=======
>>>>>>> e14a9fe0eda7a7e26405794ec21250d57be13e77:client/src/components/tasks/TaskForm.js
38 changes: 16 additions & 22 deletions client/src/components/tasks/Partner'sTaskForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import PropTypes from "prop-types";
import TextFieldGroup from "../common/TextFieldGroup";
import TextFieldGroupIcon from "../common/TextFieldGroupIcon";
import { PartnerPostTask } from "../../actions/taskActions"
import { getCurrentMember } from "../../actions/memberActions";
import store from '../../store';


class PartnerTaskForm extends Component {
constructor(props) {
Expand All @@ -28,22 +27,26 @@ import store from '../../store';
this.setState({ errors: nextProps.errors });
}
}
onChange(e) {
this.setState({ [e.target.name]: e.target.value });
}

onSubmit(e) {
e.preventDefault();



const { application } = this.props.application;
const id = application._id;

const taskData = {
levelOfCommitment : this.state.levelOfCommitment,
monetaryCompensation : this.state.monetaryCompensation,
experienceLevel : this.state.experienceLevel,
skills: this.state.skills
};
console.log(this.state.appid)
this.props.PartnerPostTask(taskData,this.state.appid,this.props.history);
this.props.PartnerPostTask(taskData,id,this.props.history);
}
onChange(e) {
this.setState({ [e.target.name]: e.target.value });
}



render() {
Expand All @@ -59,17 +62,6 @@ import store from '../../store';
<small className="d-block pb-3">* = required fields</small>
<form onSubmit={this.onSubmit}>

<TextFieldGroup
placeholder="* appid"
name="appid"
value={this.state.appid}
onChange={this.onChange}
// error={
// errors.error == '"age" must be a number'
// ? errors.error
// : null
// }
/>

<TextFieldGroup
placeholder="* levelOfCommitment"
Expand Down Expand Up @@ -133,14 +125,16 @@ import store from '../../store';
}
}
PartnerTaskForm.propTypes = {
task: PropTypes.object.isRequired
application: PropTypes.object.isRequired,
// errors: PropTypes.object.isRequired
};

const mapStateToProps = state => ({
task: state.task
application: state.application,
// errors: state.errors
});

export default connect(
mapStateToProps,
{ PartnerPostTask , getCurrentMember }
{ PartnerPostTask }
)(withRouter(PartnerTaskForm));
4 changes: 2 additions & 2 deletions server/routes/api/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ router.delete(
}
}
);

// @route POST api/tasks/partner/:id
// @desc Partner Posts a Task
// @access private
Expand All @@ -165,7 +164,6 @@ router.post(
const organization = await Organization.findOne({user : req.user.id})
const partner = await Partner.findOne({organization: organization._id});
if (!partner) return res.status(404).send({ error: "Partner not found" });

const application = await Application.findById(req.params.id);
if (!application)
return res.status(404).send({ error: "Application not found" });
Expand Down Expand Up @@ -215,6 +213,8 @@ router.post(
}
);



// @route POST api/tasks/partner/respond/:id/:id2/:taskID
// @desc Partner Responds to Member Applications
// @access Private
Expand Down