Skip to content

Commit

Permalink
Merge pull request #27 from HackYourFuture-CPH/frontend-navbar/meraj
Browse files Browse the repository at this point in the history
done done
  • Loading branch information
MerajSharifi authored Apr 21, 2024
2 parents 21a96af + 60dc1f5 commit d1d7116
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 78 deletions.
7 changes: 3 additions & 4 deletions packages/client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import Dashboard from './containers/Dashboard/Dashboard';
// TODO: put back comment after the login flow is down
// import { LandingPageContainer } from './containers/LandingPage/LandingPage';
import { LandingPageContainer } from './containers/LandingPage/LandingPage';
import { PageNotFound } from './containers/PageNotFound/PageNotFound';

Check warning on line 5 in packages/client/src/App.js

View workflow job for this annotation

GitHub Actions / build

'PageNotFound' is defined but never used
import { CheckinQuestions } from './containers/LandingPage/CheckinQuestionsPage/CheckinQuestions';
import { TeamIdContextProvider } from './hooks/contextHook';
Expand All @@ -14,10 +13,10 @@ function App() {
<Router>
<Routes>
{/* TODO: put back comment after the login flow is down */}
{/* <Route path="/" element={<LandingPageContainer />} /> */}
<Route path="/" element={<LandingPageContainer />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/questions" element={<CheckinQuestions />} />
<Route path="*" element={<PageNotFound />} />
{/* <Route path="*" element={<PageNotFound />} /> */}
</Routes>
</Router>
</TeamIdContextProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { IconButton } from '@mui/material';
import EditIcon from '@mui/icons-material/Edit';
import DeleteIcon from '@mui/icons-material/Delete';
import Dashboard from '../../containers/Dashboard/Dashboard';

Check warning on line 6 in packages/client/src/components/Dashboard/TeamMemberListItem.jsx

View workflow job for this annotation

GitHub Actions / build

'Dashboard' is defined but never used

const TeamMemberListItem = ({
member,
Expand All @@ -11,8 +12,8 @@ const TeamMemberListItem = ({
}) => {
return (
<li key={member.member_id}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ flexGrow: 1 }}>
<div className="member-info-container">
<div className="member-info">
{member.first_name} {member.last_name}
</div>
<div>
Expand Down
55 changes: 33 additions & 22 deletions packages/client/src/components/Dashboard/TeamMembers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { AddTeamMemberModal } from '../../containers/LandingPage/AddTeamMemberMo
import { Typography, Button } from '@mui/material';
import TeamMemberListItem from './TeamMemberListItem';
import EditingMember from './EditingMember'; // Import the newly created component
import { useTeamIdContext } from '../../hooks/contextHook';

const TeamMembers = () => {
const { teamId } = useTeamIdContext();
const [teamMembers, setTeamMembers] = useState([]);
const [editMemberId, setEditMemberId] = useState(null);
const [editMemberFirstName, setEditMemberFirstName] = useState('');
Expand All @@ -20,7 +22,7 @@ const TeamMembers = () => {

const fetchTeamMembers = async () => {
try {
const response = await fetch(`${apiURL()}/teamMembers`);
const response = await fetch(`${apiURL()}/teamMembers/${teamId}/members`);
if (!response.ok) {
throw new Error('Failed to fetch team members');
}
Expand All @@ -44,9 +46,12 @@ const TeamMembers = () => {
);
if (confirmDelete) {
try {
const response = await fetch(`${apiURL()}/teamMembers/${id}`, {
method: 'DELETE',
});
const response = await fetch(
`${apiURL()}/teamMembers/${teamId}/members/${id}`,
{
method: 'DELETE',
},
);
if (!response.ok) {
throw new Error('Failed to delete team member');
}
Expand All @@ -65,16 +70,19 @@ const TeamMembers = () => {
return;
}
try {
const response = await fetch(`${apiURL()}/teamMembers/addMember`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
const response = await fetch(
`${apiURL()}/teamMembers/${teamId}/members`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
first_name: newMemberFirstName,
last_name: newMemberLastName,
}),
},
body: JSON.stringify({
first_name: newMemberFirstName,
last_name: newMemberLastName,
}),
});
);
if (!response.ok) {
throw new Error('Failed to add team member');
}
Expand All @@ -89,16 +97,19 @@ const TeamMembers = () => {

const handleEditSave = async () => {
try {
const response = await fetch(`${apiURL()}/teamMembers/${editMemberId}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
const response = await fetch(
`${apiURL()}/teamMembers/${teamId}/members/${editMemberId}`,
{
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
first_name: editMemberFirstName,
last_name: editMemberLastName,
}),
},
body: JSON.stringify({
first_name: editMemberFirstName,
last_name: editMemberLastName,
}),
});
);
if (!response.ok) {
throw new Error('Failed to edit team member');
}
Expand Down
15 changes: 12 additions & 3 deletions packages/client/src/containers/Dashboard/Dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

body {
height: 100vh;
background-color: var(--background-color);
background-color: #f7f7f7;
}

.dashboard-container {
Expand Down Expand Up @@ -114,7 +114,7 @@ body {
list-style-type: none; /* Remove default list styles */
padding: 0; /* Remove default padding */
background: var(--primary-background-color);
padding: 20px 20px 20px 20px;
padding: 20px;
}

.team-members-container ul li {
Expand Down Expand Up @@ -151,7 +151,7 @@ body {
flex-direction: column;
margin-top: 20px;
background-color: #fff;
padding: 20px 20px;
padding: 20px;
border: #8a8a8a 1px solid;
}

Expand Down Expand Up @@ -190,3 +190,12 @@ body {
display: flex;
justify-content: flex-end;
}

.member-info-container {
display: flex;
align-items: center;
}
.member-info {
flex-grow: 1;
border: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
display: flex;
flex-direction: column;
align-items: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 300px;
background-color: white;
border: none;
box-shadow: 24;
padding: 20px;
}

.add-member {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,14 @@ export const AddTeamMemberModal = ({
return null;
}

const style = {
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
width: 350,
bgcolor: 'background.paper',
border: `none`,
boxShadow: 24,
p: 4,
};

return (
<Modal
open={showAddModal}
onClose={() => setShowAddModal(false)}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box sx={style} className="modal-container">
<Box className="modal-container">
{' '}
<Typography id="modal-modal-title" variant="h6" component="h2">
Add Team Member
Expand Down
10 changes: 2 additions & 8 deletions packages/client/src/containers/LandingPage/LandingPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
--text-color: #fffff;
}

* {
padding: 0;
margin: 0;
box-sizing: border-box;
}

body {
.landing-page {
margin: 0;
display: flex;
justify-content: center; /* Horizontally center content */
align-items: center; /* Vertically center content */
height: 100vh; /* Set body height to full viewport height */
background: var(--background-color);
background: #1d4ed8;
}

.landing-page {
Expand Down
26 changes: 0 additions & 26 deletions packages/client/src/containers/LandingPage/Teams.Container.js

This file was deleted.

0 comments on commit d1d7116

Please sign in to comment.