Skip to content

Commit

Permalink
Merge pull request #126 from FAC-Sixteen/Fixes/bugs
Browse files Browse the repository at this point in the history
Fixes/bugs
  • Loading branch information
misterrodger authored Jun 28, 2019
2 parents 41b3a77 + a65597d commit 0fe9d6d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 94 deletions.
6 changes: 4 additions & 2 deletions src/components/LoginRegister/LoginPortal/LoginPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ const LoginPortal = props => {
} catch (error) {
console.error(error);
}
};
validate();
}
validate()
setDetails({ email: "", password: "" });
setText({text:"Please enter your information"});
};

return (
Expand Down
128 changes: 43 additions & 85 deletions src/components/LoginRegister/RegisterPortal/RegisterPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import axios from "axios";

const RegisterPortal = props => {
const [user, setUser] = useState("");
const [data, setData] = useState({
const [details, setDetails] = useState({
userName: "",
email: "",
password: "",
Expand All @@ -16,32 +16,36 @@ const RegisterPortal = props => {
courseStudied: "",
skills: "",
aboutYou: "",
LinkedinURL: ""
LinkedinURL: "",
photoURL: "",
text: "Please press submit when complete"
});

const handleChange = event => {
setData({
...data,
setDetails({
...details,
[event.target.name]: event.target.value,
userType: user
});
};

const handleSubmit = event => {
event.preventDefault();
console.log(data);
console.log(details);
console.log(user);
console.log(props);

const addRegister = async () => {
console.log(`Fake submitting: ${data}`);
console.log(`Fake submitting: ${details}`);
console.log(user);
try {
const response = await axios.post(`/api/${user}/sign-up`, data);
const response = await axios.post(`/api/${user}/sign-up`, details)
if (response.status === 200) {
// check if response status is ok
props.history.push("/StudentDashboard");
//success scenario
} else if (response.status === 400) {
setDetails({ text: data.msg })
}
} catch (error) {
console.error(error);
Expand All @@ -50,7 +54,7 @@ const RegisterPortal = props => {
addRegister();
// props.history.push("/StudentDashboard");

setData({
setDetails({
userName: "",
email: "",
password: "",
Expand All @@ -61,7 +65,9 @@ const RegisterPortal = props => {
courseStudied: "",
skills: "",
aboutYou: "",
LinkedinURL: ""
LinkedinURL: "",
photoURL: "",
text: ""
});
};

Expand Down Expand Up @@ -93,91 +99,43 @@ const RegisterPortal = props => {
</fieldset>

<h2 className="form--el form--input__title">Name</h2>
<input
className="form--el input"
type="text"
onChange={handleChange}
name="userName"
value={data.userName}
/>
<input className="form--el input" type="text" onChange={handleChange}
name="userName" value={details.userName} />
<h2 className="form--el form--input__title">Email</h2>
<input
className="form--el input"
type="text"
onChange={handleChange}
name="email"
value={data.email}
/>
<input className="form--el input" type="text" onChange={handleChange}
name="email" value={details.email} />
<h2 className="form--el form--input__title">Password</h2>
<input
className="form--el input"
type="text"
onChange={handleChange}
name="password"
value={data.password}
/>
<input className="form--el input" type="text" onChange={handleChange}
name="password" value={details.password} />
<h2 className="form--el form--input__title">Phone</h2>
<input
className="form--el input"
type="text"
onChange={handleChange}
name="phoneNumber"
value={data.phoneNumber}
/>
<input className="form--el input" type="text" onChange={handleChange}
name="phoneNumber" value={details.phoneNumber} />
<h2 className="form--el form--input__title">University</h2>
<input
className="form--el input"
type="text"
onChange={handleChange}
name="university"
value={data.university}
/>
<input className="form--el input" type="text" onChange={handleChange}
name="university" value={details.university} />
<h2 className="form--el form--input__title">Year of Study</h2>
<input
className="form--el input"
type="text"
onChange={handleChange}
name="yearOfStudy"
value={data.yearOfStudy}
/>
<input className="form--el input" type="text" onChange={handleChange}
name="yearOfStudy" value={details.yearOfStudy} />
<h2 className="form--el form--input__title">Course of Study</h2>
<input
className="form--el input"
type="text"
onChange={handleChange}
name="courseStudied"
value={data.courseStudied}
/>
<input className="form--el input" type="text" onChange={handleChange}
name="courseStudied" value={details.courseStudied} />
<h2 className="form--el form--input__title">Skills</h2>
<input
className="form--el input"
type="text"
onChange={handleChange}
name="skills"
value={data.skills}
/>
<input className="form--el input" type="text" onChange={handleChange}
name="skills" value={details.skills} />
<h2 className="form--el form--input__title">About You</h2>
<input
className="form--el input"
type="text"
onChange={handleChange}
name="aboutYou"
value={data.aboutYou}
/>
<input className="form--el input" type="text" onChange={handleChange}
name="aboutYou" value={details.aboutYou} />
<h2 className="form--el form--input__title">LinkedIn:</h2>
<input
className="form--el input"
type="text"
onChange={handleChange}
name="LinkedinURL"
value={data.LinkedinURL}
/>
<input
className="form--button"
type="submit"
name="submit"
value="Register"
/>
<input className="form--el input" type="text" onChange={handleChange}
name="LinkedinURL" value={details.LinkedinURL} />
<h2 className="form--el form--input__title">Photo URL:</h2>
<input className="form--el input" type="text" onChange={handleChange}
name="photoURL" value={details.photoURL} />

<h3>{details.text}</h3>

<input className="form--button" type="submit" name="submit"
value="Register" />
</form>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ const StudentCurrentJobCard = props => {
const [data, setData] = useState([]);
useEffect(() => {
const fetchData = async () => {
const result = await axios("/api/client/all-briefs");
const result = await axios("/api/brief/brief-get/5d1286b8a0aa563dc52dbbe7");
setData(result.data);
};
fetchData();
}, []);

return (
<ul className={props.StudentCurrentJobCard ? "showing" : "hidden"}>
{data.map((value, index) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/StudentDashboard/NewJobCard/NewJobCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const StudentNewJobCard = props => {
const [data, setData] = useState([]);
useEffect(() => {
const fetchData = async () => {
const result = await axios("/api/client/all-briefs");
const result = await axios("/api/brief/all-briefs");
setData(result.data);
};
fetchData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const ShortStudentProfile = ({ name, course, university, year }) => {
<div>
<img
className="StudentProfileCard--image"
src="https://user-images.githubusercontent.com/32282170/59887196-0bf8a700-93cb-11e9-9016-e046470cb8e9.jpg"
src="https://user-images.githubusercontent.com/32282170/60135235-ed6b2500-97a9-11e9-8d60-5affb9149370.jpg"
/>
<h4>{name}</h4>
<h4>{course}</h4>
<h4>Course: {course}</h4>
<h4>{university}</h4>
<h4>Year {year}</h4>
<h4>Year: {year}</h4>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const ShortStudentProfileCard = () => {

useEffect(() => {
const fetchData = async () => {
const result = await axios("/api/student/get-student/5d0eae4b3065ec1b9fc1a7e4");
console.log(result.data);
const result = await axios("/api/student/get-student/5d1286b8a0aa563dc52dbbe7");
console.log("Results: ", result.data.completedJobs);
setProfile(result.data);
};

Expand Down

0 comments on commit 0fe9d6d

Please sign in to comment.