diff --git a/backend/timesheets/routes.py b/backend/timesheets/routes.py index a85e0b86..5593e052 100644 --- a/backend/timesheets/routes.py +++ b/backend/timesheets/routes.py @@ -346,6 +346,47 @@ def post(self): +class SalaryViewForCurrentConsultant(MethodView): + def get(self): + + user_id = session.get("user_id") + consultant = Consultant.query.filter_by(id=user_id).first() + + if consultant == None: + return jsonify({"Error": "Unauthorized"}), 400 + timesheets = Timesheet.query.filter_by(consultant_id=user_id).all() + + salary = 0 + + for timesheet in timesheets: + + salary += timesheet.hours_worked * consultant.hourly_rate + + return jsonify({"salary": salary}), 200 + + +class FinanceTeamView(MethodView): + + # POST method to set the hourly rate for a specific consultant + def post(self, consultant_username,): + data = request.json + consultant = Consultant.query.filter_by(username=consultant_username).first() + + if consultant == None: + return jsonify({"error": "Consultant not found"}), 404 + + rate = data["hourly_rate"] + consultant.hourly_rate = rate + # Assuming instantiation and authorization logic is handled elsewhere + finance_team_member = FinanceTeamMember() + finance_team_member.set_hourly_rate(consultant, float(rate)) + db.session.commit() + return jsonify({"message": "Hourly rate updated successfully", "consultant_id": consultant.id, "new_hourly_rate": rate}), 200 + + + + + # Registering the views timesheets_view = TimesheetView.as_view("timesheet_view") app.add_url_rule("/", view_func=HomeView.as_view("home_view")) @@ -371,4 +412,9 @@ def post(self): app.add_url_rule("/list_consultants", view_func=ListConsultantsView.as_view("list_consultants_view"), methods=["GET"]) +app.add_url_rule("/current_consultant_payslip", view_func=SalaryViewForCurrentConsultant.as_view("salary_view_for_current_consultant"), methods=["GET"]) + + + +app.add_url_rule("/set_hourly_rate/", view_func=FinanceTeamView.as_view("finance_team_view"), methods=["POST"]) \ No newline at end of file diff --git a/frontend/public/Home_Page_Icons/logout.svg b/frontend/public/Home_Page_Icons/logout.svg new file mode 100644 index 00000000..1b6b9710 --- /dev/null +++ b/frontend/public/Home_Page_Icons/logout.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/Components/Finance_Team_Page/SetHourlyRate.js b/frontend/src/Components/Finance_Team_Page/SetHourlyRate.js index 5e8ddc1d..eca79ab5 100644 --- a/frontend/src/Components/Finance_Team_Page/SetHourlyRate.js +++ b/frontend/src/Components/Finance_Team_Page/SetHourlyRate.js @@ -3,8 +3,8 @@ import styles from "./SetHourlyRate.module.css"; // Import the CSS file import Navbar from "../../Components/Global/Navbar"; function SetHourlyRate() { - let links = [{pageName : "Set Hourly Rate Page", pageLink : "/set_hourly_rate", iconPath : "./Home_Page_Icons/Consultant/record_timesheet.svg"}, - {pageName : "View Timesheet Page", pageLink : "/view_timesheet", iconPath : "./Home_Page_Icons/Consultant/view_timesheet.svg"}] + let links = [{ pageName: "Set Hourly Rate Page", pageLink: "/set_hourly_rate", iconPath: "./Home_Page_Icons/Consultant/record_timesheet.svg" }, + { pageName: "View Timesheet Page", pageLink: "/view_timesheet", iconPath: "./Home_Page_Icons/Consultant/view_timesheet.svg" }] const [consultantName, setConsultantName] = useState(""); const [hourlyRate, setHourlyRate] = useState(""); @@ -27,13 +27,12 @@ function SetHourlyRate() { return ( <> - +

Set Hourly Rate

-
+
-
-
+ return(
+ +

Logout

); } diff --git a/frontend/src/Components/Global/LogoutButton.module.css b/frontend/src/Components/Global/LogoutButton.module.css index 9b8d8f89..31795514 100644 --- a/frontend/src/Components/Global/LogoutButton.module.css +++ b/frontend/src/Components/Global/LogoutButton.module.css @@ -1,11 +1,10 @@ .Logout{ padding: 0.7pc 0.1pc; - width: 100px; + width: 50px; + max-height: 35px; cursor: pointer; border: none; - background-image: linear-gradient(to right, blue, purple); - left: 20%; - border-radius: 25px; + border-radius: 10px; color: white; height: 3rem; text-align: center; @@ -13,4 +12,9 @@ padding-top: 0.5rem; font-family: Arial, Helvetica, sans-serif; font-size: 1rem; + margin-left: 0.35rem; +} + +.logoutText{ + margin-left: 0.5rem; } \ No newline at end of file diff --git a/frontend/src/Components/Global/Navbar.js b/frontend/src/Components/Global/Navbar.js index 8cf59067..b979d186 100644 --- a/frontend/src/Components/Global/Navbar.js +++ b/frontend/src/Components/Global/Navbar.js @@ -1,5 +1,6 @@ import { Link } from 'react-router-dom' import styles from './Navbar.module.css' +import Logout from '../Global/LogoutButton' export default function Navbar(props) { let linksArray = props.links @@ -21,6 +22,10 @@ export default function Navbar(props) { ))} + +
+ +
) } \ No newline at end of file diff --git a/frontend/src/Components/Global/Navbar.module.css b/frontend/src/Components/Global/Navbar.module.css index c4b66112..7a1641f3 100644 --- a/frontend/src/Components/Global/Navbar.module.css +++ b/frontend/src/Components/Global/Navbar.module.css @@ -1,6 +1,7 @@ .navbar{ - background-color: #D9D9D9; - width: 5rem; + background: linear-gradient(360deg, rgb(52, 68, 0) 0%, rgb(130, 170, 0) 100%); + border-right: solid 5pt #1e1e1e; + width: 4rem; height: 100vh; display: flex; flex-direction: column; @@ -8,10 +9,11 @@ transition: width 200ms ease; overflow: hidden; position: fixed; + font-family: "Roboto", sans-serif; } .navbar:hover{ - width: 16rem; + width: 20rem; } .navbar:hover body{ @@ -28,6 +30,7 @@ } .navContainer{ + margin-top: 0; padding: 0; list-style-type: none; } @@ -35,7 +38,7 @@ .navLink{ display: flex; align-items: center; - height: 5rem; + height: 4rem; } .navText{ @@ -48,7 +51,11 @@ } .icon{ - min-width: 3rem; + min-width: 1rem; margin: 0 1rem; width: 2rem; +} + +.logoutButton{ + margin-top: auto; } \ No newline at end of file diff --git a/frontend/src/Components/IT_Technician_Page/UserAccountCreation.js b/frontend/src/Components/IT_Technician_Page/UserAccountCreation.js index e8fe9360..43b0cff8 100644 --- a/frontend/src/Components/IT_Technician_Page/UserAccountCreation.js +++ b/frontend/src/Components/IT_Technician_Page/UserAccountCreation.js @@ -5,11 +5,12 @@ import { useNavigate } from 'react-router-dom'; function UserAccountCreation() { const [showPassword, setShowPassword] = useState(false); const [showConfirmPassword, setShowConfirmPassword] = useState(false); - const [userType, setUserType] = useState("Consultant"); + const [userType, setUserType] = useState("consultant"); const [firstname, setFirstName] = useState(""); const [lastname, setLastName] = useState(""); const [username, setUsername] = useState(""); - const [lineManagerUsername, setLineManagerUsername] = useState(""); + const [line_manager_username, setLineManagerUsername] = useState(""); + const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); @@ -64,8 +65,10 @@ function UserAccountCreation() { e.preventDefault(); var accountDetails; - if (userType=="Consultant") { - accountDetails = { userType, firstname, lastname, username, lineManagerUsername, email, password }; + console.log(userType) + if (userType=="consultant") { + accountDetails = { userType, firstname, lastname, username, line_manager_username, email, password }; + console.log(accountDetails) } else { accountDetails = { userType, firstname, lastname, username, email, password }; } @@ -113,9 +116,9 @@ function UserAccountCreation() { - - {userType == "Consultant" && - + + {userType == "consultant" && + } diff --git a/frontend/src/Components/IT_Technician_Page/UserAccountCreation.module.css b/frontend/src/Components/IT_Technician_Page/UserAccountCreation.module.css index 92001d39..def5cc38 100644 --- a/frontend/src/Components/IT_Technician_Page/UserAccountCreation.module.css +++ b/frontend/src/Components/IT_Technician_Page/UserAccountCreation.module.css @@ -13,10 +13,10 @@ justify-content: center; align-items: center; text-align: center; - background-color: white; + background-color: #1e1e1e; border-top-right-radius: 15px; border-bottom-right-radius: 15px; - box-shadow: 0 0 15px white; + box-shadow: 0 0 15px #c5ff00; width: 30%; height: 85%; padding-left: 2%; @@ -25,7 +25,7 @@ .userAccountForm label, .userAccountForm h2 { font-family: "Poppins", serif; - color: #012E6E; + color: white; } .userAccountForm p { @@ -37,7 +37,7 @@ .userAccountForm h2 { margin: 0; - color: #012E6E; + color: #8ab400; } .main_img { @@ -45,8 +45,8 @@ height: 85%; border-top-left-radius: 15px; border-bottom-left-radius: 15px; - background-color: #002252; - box-shadow: 0 0 15px white; + background-color: #111111; + box-shadow: 0 0 15px #c5ff00; } .input, .selectInput{ @@ -97,7 +97,7 @@ cursor: pointer; } -.userAccountForm input[type=submit]{ +/* .userAccountForm input[type=submit]{ width: 70%; margin-top: 5%; cursor: pointer; @@ -110,9 +110,40 @@ border-radius: 10px; margin-top: 5%; margin-bottom: 5%; -} +} */ ::placeholder { color: rgba(255, 255, 255, 0.704); } + .userAccountForm input[type=submit] { + font-family: "Poppins", sans-serif; + width: 50%; + padding: 1%; + margin: 3%; + border-radius: 50px; + cursor: pointer; + border: 0; + background-color: white; + box-shadow: rgb(0 0 0 / 5%) 0 0 8px; + letter-spacing: 1.5px; + text-transform: uppercase; + font-size: 15px; + transition: all 0.5s ease; + } + + .userAccountForm input[type=submit]:hover { + letter-spacing: 2px; + background-color: #1e1e1e; + color: hsl(0, 0%, 100%); + box-shadow: #c5ff00 0px 3px 29px 0px; + } + + .userAccountForm input[type=submit]:active { + letter-spacing: 2px; + background-color: #1e1e1e; + color: white; + box-shadow: #c5ff00 0px 0px 0px 0px; + transform: translateY(10px); + transition: 100ms; + } diff --git a/frontend/src/Components/Line_Manager_Home_Page/ConsultantCard.js b/frontend/src/Components/Line_Manager_Home_Page/ConsultantCard.js index 51710e77..d7817028 100644 --- a/frontend/src/Components/Line_Manager_Home_Page/ConsultantCard.js +++ b/frontend/src/Components/Line_Manager_Home_Page/ConsultantCard.js @@ -3,7 +3,7 @@ import styles from './ConsultantCard.module.css'; export default function ConsultantCard (props) { return(
-
+

{props.name}

diff --git a/frontend/src/Components/Line_Manager_Home_Page/ConsultantCard.module.css b/frontend/src/Components/Line_Manager_Home_Page/ConsultantCard.module.css index 99d0b9eb..cb4ae7a9 100644 --- a/frontend/src/Components/Line_Manager_Home_Page/ConsultantCard.module.css +++ b/frontend/src/Components/Line_Manager_Home_Page/ConsultantCard.module.css @@ -1,10 +1,14 @@ .cardContainer{ + display: flex; + flex-direction: column; + align-items: center; background-color: #AEAEAE; padding: 1em; border-radius: 1.5em; box-shadow: -0.2em 0.2em 0.2em hsla(0, 0%, 24%, 0.753); margin: 1pc; - max-height: 60%; + max-height: 11rem; + min-height: 11rem; width: 50%; flex-shrink: 0; } @@ -13,9 +17,17 @@ width: 95%; } +.iconContainer{ + margin-bottom: 0; + margin-top: 0; +} + .name{ color: black; text-align: center; + margin-top: 1rem; + margin-bottom: 0; + width: 20rem; } .viewTimesheetBtn{ @@ -25,6 +37,6 @@ padding: 0.55em; font-size: 1em; cursor: pointer; - position: absolute; - bottom: 60%; + margin-top: 1rem; + margin-bottom: 3rem; } \ No newline at end of file diff --git a/frontend/src/Components/Line_Manager_Home_Page/ConsultantFinder.js b/frontend/src/Components/Line_Manager_Home_Page/ConsultantFinder.js index 419b62a4..d2452289 100644 --- a/frontend/src/Components/Line_Manager_Home_Page/ConsultantFinder.js +++ b/frontend/src/Components/Line_Manager_Home_Page/ConsultantFinder.js @@ -1,4 +1,4 @@ -import { useState } from "react" +import { useState, useEffect } from "react" import styles from './ConsultantFinder.module.css'; import ConsultantCard from "./ConsultantCard"; @@ -18,10 +18,50 @@ const consultantPlaceholderNames = [ ]; //a +//localhost:5000/list_consultants + function ConsultantFinder() { + const [foundConsultants, setFoundConsultants] = useState([]) const [search, setSearch] = useState('') const [searchResults, setSearchResults] = useState([]) + + useEffect(() => { + const fetchData = async () =>{ + try{ + await fetch('http://127.0.0.1:5000/list_consultants', { + method: "GET", + headers: { "Content-Type": "application/json" }, + credentials: 'include', + }).then(response => { + if (response.ok) { + return response.json(); + } + else { + throw new Error('Fetching Consultant Failed with Status: ' + response.status); + } + }).then(data => { + // Data fetched successfully + console.log(data) + setFoundConsultants(data); + }).catch(error => { + console.error(error); + }); + } catch(error) { + console.log("error fetching data") + } + }; + fetchData(); + }, []); + + if(foundConsultants === null) { + return( +

Loading data

+ ) + } + console.log("stored stuff:",foundConsultants) + + const handleSearchChange = (e) => { const searchText = e.target.value; setSearch(searchText); diff --git a/frontend/src/Components/Line_Manager_Home_Page/ConsultantFinder.module.css b/frontend/src/Components/Line_Manager_Home_Page/ConsultantFinder.module.css index c736e7f8..2f5f6fbd 100644 --- a/frontend/src/Components/Line_Manager_Home_Page/ConsultantFinder.module.css +++ b/frontend/src/Components/Line_Manager_Home_Page/ConsultantFinder.module.css @@ -33,7 +33,7 @@ display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); grid-template-rows: 1fr; - align-items: center; + align-items: flex-start; justify-items: center; gap: 0px; z-index: 1; @@ -43,6 +43,7 @@ position: absolute; left: 10%; background-color: #D9D9D9; + min-height: 35em; } .searchResultsContainer{ diff --git a/frontend/src/Components/LoginForm/LoginForm.module.css b/frontend/src/Components/LoginForm/LoginForm.module.css index d63a0087..c0a7b433 100644 --- a/frontend/src/Components/LoginForm/LoginForm.module.css +++ b/frontend/src/Components/LoginForm/LoginForm.module.css @@ -1,12 +1,13 @@ -html{ - background-image: none ; - background-color: #012E6E; +html { + background-image: none; + background: rgb(2, 0, 36); + background: radial-gradient(circle, #000000 0%, rgba(24, 31, 0, 1) 100%); } -.LoginForm{ +.LoginForm { width: 20%; text-align: center; border-radius: 0.4pc; @@ -16,32 +17,32 @@ html{ background-color: white; } -.LoginFormList{ +.LoginFormList { display: inline; list-style-type: none; background-color: white; } -.LoginFormListElement{ +.LoginFormListElement { padding: 0.4pc; font-family: "Roboto", sans-serif; } -.UserIcon{ +.UserIcon { display: inline; width: 25%; position: relative; margin-left: 85px; } -.input{ +.input { width: 10pc; padding: 0.5em; background-color: #012E6E; color: white; } -.SelectInput{ +.SelectInput { background-color: #012E6E; padding: 0.6em; width: 42%; @@ -52,12 +53,12 @@ html{ appearance: none; } -#ForgotPass{ +#ForgotPass { text-decoration: none; color: #012E6E; } -.Submit{ +.Submit { padding: 0.7pc 0.1pc; width: 100px; cursor: pointer; diff --git a/frontend/src/Pages/Consultant/TimesheetRecordingPage.module.css b/frontend/src/Pages/Consultant/TimesheetRecordingPage.module.css index f4be51f3..6944c54e 100644 --- a/frontend/src/Pages/Consultant/TimesheetRecordingPage.module.css +++ b/frontend/src/Pages/Consultant/TimesheetRecordingPage.module.css @@ -14,7 +14,7 @@ body{ .mainContainer { margin-left: 5rem; padding: 1rem; - width: 100%; + width: 90%; display: flex; flex-direction: column; justify-content: center; diff --git a/frontend/src/Pages/Consultant/consultant_home_page.js b/frontend/src/Pages/Consultant/consultant_home_page.js index 0d339bbc..d84332d1 100644 --- a/frontend/src/Pages/Consultant/consultant_home_page.js +++ b/frontend/src/Pages/Consultant/consultant_home_page.js @@ -13,7 +13,6 @@ function ConsultantHomePage () {

Consultant Home Page

-
) diff --git a/frontend/src/Pages/IT_Technician/it_technician_home_page.js b/frontend/src/Pages/IT_Technician/it_technician_home_page.js index e1657ce7..d5f8673b 100644 --- a/frontend/src/Pages/IT_Technician/it_technician_home_page.js +++ b/frontend/src/Pages/IT_Technician/it_technician_home_page.js @@ -1,7 +1,5 @@ import styles from "./it_technician_home_page.module.css"; import Navbar from "../../Components/Global/Navbar"; -import LogoutButton from "../../Components/Global/LogoutButton"; - function IT_Technician_HomePage() { document.title = "IT Technician Home Page"; @@ -15,7 +13,6 @@ function IT_Technician_HomePage() {

Home

-
) diff --git a/frontend/src/Pages/IT_Technician/it_user_creation_page.module.css b/frontend/src/Pages/IT_Technician/it_user_creation_page.module.css index f12ed881..a56bbaae 100644 --- a/frontend/src/Pages/IT_Technician/it_user_creation_page.module.css +++ b/frontend/src/Pages/IT_Technician/it_user_creation_page.module.css @@ -1,8 +1,4 @@ -.container { - background: #012E6E; -} - body{ margin: 0; padding: 0;