Skip to content

Commit

Permalink
New Architecture Ready
Browse files Browse the repository at this point in the history
  • Loading branch information
jaison080 committed Dec 31, 2022
1 parent 2e7eff4 commit 95c9426
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 155 deletions.
7 changes: 4 additions & 3 deletions src/Components/DescriptionDetails/DescriptionDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import { FaPhoneAlt } from "react-icons/fa";
import { FiEdit } from "react-icons/fi";

const DescriptionDetails = (props) => {
const { fetchData } = useContext(ProjectContext);
const { fetchData, devHash } = useContext(ProjectContext);
const { currentUser } = useContext(AuthContext);
const [canModifyProject, setCanModifyProject] = useState(false);
const [showNewProjectModal, setShowNewProjectModal] = useState(false);
const [displayConfirmationModal, setDisplayConfirmationModal] = useState(
false
);

const history = useHistory();
const submitDelete = (id) => {
doDeleteProject(id, () => {
Expand All @@ -31,6 +32,7 @@ const DescriptionDetails = (props) => {
setDisplayConfirmationModal(false);
history.go(0);
};
//create a map of developers with their email as key and name as value

const hideConfirmationModal = () => {
setDisplayConfirmationModal(false);
Expand All @@ -45,7 +47,6 @@ const DescriptionDetails = (props) => {
function deleteProj() {
setDisplayConfirmationModal(true);
}

return (
<>
<div className="description__container">
Expand Down Expand Up @@ -80,7 +81,7 @@ const DescriptionDetails = (props) => {
<div className="description__other-members">
{props.selectedProject.teamMembers.map((member, index) => (
<div className="description__other-member" key={index}>
{index + 1}. {member}
{index + 1}. {devHash[member] || member}
</div>
))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ProjectModal/ProjectModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ const NewProjectForm = ({ onClose, project,setVariable,variable }) => {
placeholder="Enter Team members name..."
/>
<Form.Text className="text-right helperText">
Please separate the names using commas
Please separate the emails using commas and include your email too.
</Form.Text>
<Form.Text className="text-danger">
{props.touched.teamMembers && props.errors.teamMembers}
Expand Down
4 changes: 2 additions & 2 deletions src/Firebase/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export const acceptRequest = async (invite) => {
console.log(project.val());
let p = project.val();
let users = p.teamMembers;
users.push(invite.sender);
users.push(invite.sender_email);
firebase
.database()
// .ref(`projects/${invite.project_id}/members/${invite.sender_id}`)
Expand Down Expand Up @@ -394,7 +394,7 @@ export const acceptInvite = async (invite) => {
console.log(project.val());
let p = project.val();
let users = p.teamMembers;
users.push(invite.receiver);
users.push(invite.receiver_email);
firebase
.database()
// .ref(`projects/${invite.project_id}/members/${invite.sender_id}`)
Expand Down
61 changes: 30 additions & 31 deletions src/Pages/DeveloperDetail/DeveloperDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import { TbNetwork } from "react-icons/tb";
import { GoMarkGithub } from "react-icons/go";
import { HiUserAdd } from "react-icons/hi";
import { BsArrowLeftCircleFill } from "react-icons/bs";
import { ProjectContext } from "../../contexts/ProjectContext";

function DeveloperDetails() {
let { id } = useParams();
const history = useHistory();
const { currentUser } = useContext(AuthContext);
const [selectedUser, setSelectedUser] = useState({});
const [loading, setLoading] = useState(true);

const {projects}=useContext(ProjectContext)
const [open, setOpen] = useState(false);
const defaultOptions = {
loop: true,
Expand Down Expand Up @@ -214,37 +215,35 @@ function DeveloperDetails() {
</div>
<div className="developer_details_body_right_content">
<div className="developer_details_body_right_content_projects">
{selectedUser.projects ? (
selectedUser.projects.map((project, index) => {
return (
<div
className="developer_details_body_right_content_project"
key={index}
onClick={() => {
history.push(`/projects/${project.id}`);
}}
>
<div className="developer_details_body_right_content_project_img">
<img
src={
project.projectPhoto ||
"https://images.unsplash.com/photo-1639413665566-2f75adf7b7ca?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwyN3x8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60"
}
alt=""
/>
</div>
<div className="developer_details_body_right_content_project_title">
{project.name}
</div>
<div className="developer_details_body_right_content_project_lead">
{project.leader_name}
</div>
{projects.map((project, index) => {
return project.teamMembers?.find(
(member) => member === selectedUser.email
) ? (
<div
className="developer_details_body_right_content_project"
key={index}
onClick={() => {
history.push(`/projects/${project.id}`);
}}
>
<div className="developer_details_body_right_content_project_img">
<img
src={
project.projectPhoto ||
"https://images.unsplash.com/photo-1639413665566-2f75adf7b7ca?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwyN3x8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60"
}
alt=""
/>
</div>
);
})
) : (
<div className="skill">No Projects Added</div>
)}
<div className="developer_details_body_right_content_project_title">
{project.name}
</div>
<div className="developer_details_body_right_content_project_lead">
{project.leader_name}
</div>
</div>
) : null;
})}
</div>
</div>
</div>
Expand Down
75 changes: 1 addition & 74 deletions src/Pages/MyProfile/EditProfileModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ const NewUserForm = ({ onClose, user }) => {
);
const [profilePhoto, setProfilePhoto] = useState(user?.profilePhoto || "");
// const [projects, setProjects] = useState([]);
const { projects, fetchUserProfile } = useContext(ProjectContext);
const [acValue, setACValue] = useState(user?.projects || []);
const [remainProjects, setRemainProjects] = useState([]);
const { fetchUserProfile } = useContext(ProjectContext);
const [skills, setSkills] = useState([]);
const [skill, setSkill] = useState();
const [acValue1, setACValue1] = useState(user?.skills || []);
Expand All @@ -43,7 +41,6 @@ const NewUserForm = ({ onClose, user }) => {
year: user?.year || "",
about: user?.about || "",
skills: user?.skills || "",
projects: user?.projects || "",
achievements: user?.achievements || "",
contact: user?.contact || "",
email: user?.email || "",
Expand All @@ -63,22 +60,6 @@ const NewUserForm = ({ onClose, user }) => {
// });
// };

useEffect(() => {
// getWorks();
getRemainProjects();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [projects, acValue]);

function getRemainProjects() {
let temp = [];
projects?.forEach((project) => {
if (!acValue.find((item) => item.id === project.id)) temp.push(project);
});
setRemainProjects(temp);
//console.log(acValue)

//console.log(temp)
}
function getRemainSkills() {
let temp1 = [];
skills?.forEach((skill) => {
Expand Down Expand Up @@ -172,7 +153,6 @@ const NewUserForm = ({ onClose, user }) => {

const formValues = {
...values,
projects: acValue,
skills: acValue1,
profilePhoto,
profilePhotoName,
Expand Down Expand Up @@ -325,59 +305,6 @@ const NewUserForm = ({ onClose, user }) => {
</Form.Text>
</Form.Group>
</Row>
<br />
<Form.Group
controlid="formProjects"
style={{
border: "none",
}}
>
<ThemeProvider theme={theme}>
<Autocomplete
multiple
onChange={(event, value) => {
setACValue(value);
}}
id="checkboxes-tags-demo"
value={acValue}
options={remainProjects}
filterSelectedOptions
getOptionLabel={(option) => option.name}
renderOption={(props, option) => (
<li
style={{ fontFamily: "Nunito", color: "#9e0000" }}
{...props}
>
{option.name}
</li>
)}
sx={{ fontFamily: "Nunito" }}
renderInput={(params) => (
<TextField
size="small"
{...params}
label="Projects Worked In"
className={theme.root}
sx={{
"& .MuiInputLabel-root": {
color: "#9E0000",
fontFamily: "Nunito",
fontWeight: "600",
},
"& label.Mui-focused": {
color: "#9E0000",
},
}}
variant="outlined"
/>
)}
/>
</ThemeProvider>

<Form.Text className="text-danger">
{props.touched.projects && props.errors.projects}
</Form.Text>
</Form.Group>
<Form.Group controlid="formAboutMe">
<Form.Label>About Me*</Form.Label>
<Form.Control
Expand Down
Loading

0 comments on commit 95c9426

Please sign in to comment.