-
+
- React App
+ Geeks Hub
diff --git a/Geeks code with firebase/geeks/public/logo192.png b/Geeks code with firebase/geeks/public/logo192.png
deleted file mode 100644
index fc44b0a3..00000000
Binary files a/Geeks code with firebase/geeks/public/logo192.png and /dev/null differ
diff --git a/Geeks code with firebase/geeks/public/logo512.png b/Geeks code with firebase/geeks/public/logo512.png
deleted file mode 100644
index a4e47a65..00000000
Binary files a/Geeks code with firebase/geeks/public/logo512.png and /dev/null differ
diff --git a/Geeks code with firebase/geeks/src/ActiveUsers.js b/Geeks code with firebase/geeks/src/ActiveUsers.js
index f665e77c..6f8cb37e 100644
--- a/Geeks code with firebase/geeks/src/ActiveUsers.js
+++ b/Geeks code with firebase/geeks/src/ActiveUsers.js
@@ -109,10 +109,10 @@ function ActiveUsers() {
trial.RemaningHours = 0;
trial.isSub = false;
- price = Math.round(time * 10) ;
+ price = Math.round(time * 100)/100 ;
}
} else {
- price = Math.round(time * 10) ;
+ price = Math.round(time * 100)/100 ;
}
console.log("price i" + price);
diff --git a/Geeks code with firebase/geeks/src/EmployeesAdmin.js b/Geeks code with firebase/geeks/src/EmployeesAdmin.js
index cf3432b9..195f3f04 100644
--- a/Geeks code with firebase/geeks/src/EmployeesAdmin.js
+++ b/Geeks code with firebase/geeks/src/EmployeesAdmin.js
@@ -29,14 +29,14 @@ const{authUserData , setauthUserData, update , setUpdate} = useContext(UserConte
//this is the state for the modal that shows when the user is is active status is updated
const [showModal, setShowModal] = useState(false);
-// this is the state shown in the modal of the add employee modal
-const [showAddEmployeeModal, setShowAddEmployeeModal] = useState(false);
+// show the modal for the add employee
+const [showAddModal, setShowAddModal] = useState(false);
+
+//this is the state for the email of the new employee
+const [email, setEmail] = useState('');
+
-//this is for the new employee email
-const [newEmployeeEmail, setNewEmployeeEmail] = useState('');
-//this is for the new employee data
-const [empData,setEmpData] = useState({});
@@ -73,15 +73,63 @@ const [empData,setEmpData] = useState({});
await updateDoc(userRef, {
isWorking: false,
thisMonth : activeShift.thisMonth + 1,
+
});
await setUpdate(update + 1);
setShowModal(true);
+
}
+ // this is the function for the admin to add a new employee by search in users collection by emaail an check that the user is not already an employee the add him to emplyee collection
+ const addEmployee = async (email) => {
+ //get all users docs
+ const users = collection(db, 'users');
+ const data = await getDocs(users);
+ //filter the user by email
+ const filteredData = data.docs.map((doc) => ({
+ id: doc.id,
+
+ ...doc.data()
+ })).filter((user) => user.Email === email);
+ //if the user is found add him to the employee collection
+ if (filteredData.length > 0) {
+ const userRef = doc(db, 'users', filteredData[0].id);
+ const employeeRef = doc(db, 'employees', filteredData[0].id);
+ const employeeDocSnap = await getDoc(employeeRef);
+ if (!employeeDocSnap.exists()) {
+ await setDoc(employeeRef, {
+ name: filteredData[0].Name,
+ email: filteredData[0].Email,
+ isWorking: false,
+ thisMonth: 0,
+ prevMonth: 0,
+ }
+
+
+ );
+
+ await updateDoc(userRef, {
+ isEmployee: true,
+
+ });
+
+ setShowAddModal(false);
+
+
+ }
+ else {
+ alert('this user is already an employee');
+ }
+
+
+
+ }
+}
+
// this is the function for the admin to add a new employee
@@ -144,7 +192,47 @@ const [empData,setEmpData] = useState({});
>
) : null}
-
+{showAddModal ? (
+ <>
+