Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #30

Open
wants to merge 119 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
3bc6468
Merge branch 'RickDeb2004:main' into map
Animesh239 Jun 14, 2024
21d42ef
Merge pull request #1 from Animesh239/map
Animesh239 Jun 14, 2024
cbdd602
Merge pull request #2 from RickDeb2004/line-chart
RickDeb2004 Jun 15, 2024
d6fd276
Refactor bar chart && fix totalRevenue
RickDeb2004 Jun 15, 2024
b916a14
Merge pull request #3 from RickDeb2004/bar-chart
RickDeb2004 Jun 15, 2024
9197bcf
chore: Update Firebase dependencies and fetch sales per unit data for…
Animesh239 Jun 15, 2024
90a3ccd
Merge pull request #4 from Animesh239/map
Animesh239 Jun 15, 2024
a8285a8
chore: Update GeographyChart component to accept isDashboard prop and…
Animesh239 Jun 15, 2024
347d5be
chore: Update GeographyChart component to accept isDashboard prop and…
Animesh239 Jun 15, 2024
5c9a443
Merge pull request #5 from Animesh239/map
Animesh239 Jun 16, 2024
41d9e7d
chore: Update Login component to fetch and record user activity on si…
Animesh239 Jun 22, 2024
c3a4634
chore: Add role property to user object on login
Animesh239 Jun 22, 2024
b2f6019
Merge pull request #6 from Animesh239/login
Animesh239 Jun 24, 2024
79e2df0
password sent to db
Animesh239 Jun 24, 2024
ac632d9
chore: Update Login component to fetch and record user activity on si…
Animesh239 Jun 24, 2024
c9de642
feat added download feature
RickDeb2004 Jun 24, 2024
37527a7
Merge pull request #7 from RickDeb2004/download/report
RickDeb2004 Jun 24, 2024
0e4d30e
feedback form updated
Animesh239 Jun 24, 2024
88f5035
Merge pull request #8 from Animesh239/admin-feedback
RickDeb2004 Jun 25, 2024
35371bd
removed toggle button from login page
RickDeb2004 Jun 25, 2024
2c53bf3
Merge pull request #10 from RickDeb2004/newlogin
RickDeb2004 Jun 25, 2024
d822b5c
feat: added team CRUD operation
RickDeb2004 Jun 25, 2024
52593de
Merge pull request #11 from RickDeb2004/team/management
RickDeb2004 Jun 25, 2024
1c32553
feat added team info
RickDeb2004 Jun 25, 2024
2767cc6
feat added team info
RickDeb2004 Jun 26, 2024
db24e59
added header title
RickDeb2004 Jun 26, 2024
cd95707
feat added textfield glow
RickDeb2004 Jun 26, 2024
63e54f5
Merge pull request #12 from RickDeb2004/team/info
RickDeb2004 Jun 26, 2024
bbbf90a
feat added glow to boxes in dsahboard & tea,m management & added theme
RickDeb2004 Jun 26, 2024
06dec00
feat added ui
RickDeb2004 Jun 26, 2024
e16ff9f
Merge pull request #13 from RickDeb2004/ui-change/deb
RickDeb2004 Jun 26, 2024
01736b5
added lamp effect
RickDeb2004 Jun 27, 2024
e730a41
changed glow effect to grey
RickDeb2004 Jun 27, 2024
eab388c
fixed lamp effect in form
RickDeb2004 Jun 27, 2024
6b81522
added delete icon
RickDeb2004 Jun 27, 2024
dde184a
Merge pull request #14 from RickDeb2004/ui-change-team-info
RickDeb2004 Jun 27, 2024
7359d3c
local storage caching user data
Animesh239 Jun 27, 2024
3aefe3e
login UI updated
Animesh239 Jun 27, 2024
32c931c
bug resolved ( navigation to '/dashboard')
Animesh239 Jun 27, 2024
ede5d22
navigation problems resolved
Animesh239 Jun 27, 2024
d98258c
admin team management, activity not duplicated
Animesh239 Jun 27, 2024
9f42855
Merge pull request #15 from Animesh239/cache
Animesh239 Jun 27, 2024
5c7c47a
Refactor UI of team management
RickDeb2004 Jun 27, 2024
a7a9a71
Merge pull request #16 from RickDeb2004/small-ui-changes
RickDeb2004 Jun 27, 2024
a1a977e
feat added event to db for calender
RickDeb2004 Jun 27, 2024
0ad1e79
removal faq
RickDeb2004 Jun 27, 2024
f7e9e64
added lampeffect to the form
RickDeb2004 Jun 28, 2024
a7de21c
Merge pull request #17 from RickDeb2004/calender
RickDeb2004 Jun 28, 2024
cb1ed0f
added dashboard image & fixed feedback cards
RickDeb2004 Jun 28, 2024
fb9d43c
Merge pull request #18 from RickDeb2004/dashboard/image
RickDeb2004 Jun 28, 2024
5671d38
feedback
Animesh239 Jun 28, 2024
6f9e8dd
Merge pull request #19 from Animesh239/admin-feedback
RickDeb2004 Jun 28, 2024
7cdbf4c
feat added form UI & sidebar & topbar
RickDeb2004 Jun 28, 2024
70ca33b
Merge branch 'main' into profile-form/debanjan
RickDeb2004 Jun 28, 2024
bf4bc88
fixed bug
RickDeb2004 Jun 28, 2024
7e47ab4
Merge pull request #20 from RickDeb2004/profile-form/debanjan
RickDeb2004 Jun 28, 2024
ad15ca8
fixed auth
RickDeb2004 Jun 29, 2024
33ea042
statbox added to db
RickDeb2004 Jun 29, 2024
117e947
Merge pull request #22 from RickDeb2004/stat-box
RickDeb2004 Jun 29, 2024
9dbfdab
fixed stat box
RickDeb2004 Jun 29, 2024
05411af
Latest feedback
Animesh239 Jun 29, 2024
2eba5ba
feat added pie chart to backend
RickDeb2004 Jun 29, 2024
5c6b41c
Merge pull request #23 from RickDeb2004/pie
RickDeb2004 Jun 29, 2024
ce06a62
add admin feedback
Animesh239 Jun 29, 2024
e4ed362
added del button in team management
RickDeb2004 Jun 29, 2024
e8d13ed
Merge pull request #25 from RickDeb2004/team/del
RickDeb2004 Jun 29, 2024
bf76774
Merge pull request #24 from Animesh239/admin-feedback
RickDeb2004 Jun 29, 2024
786f3c9
form submissions listed
Animesh239 Jun 29, 2024
3619037
Add edit form and reset after each submission
Animesh239 Jun 29, 2024
8830de1
added chat header & remove biew profile button & added glow effect
RickDeb2004 Jun 30, 2024
484cad4
Merge pull request #27 from RickDeb2004/admin-list-ui
RickDeb2004 Jun 30, 2024
e3150cc
Merge pull request #26 from Animesh239/editform
RickDeb2004 Jun 30, 2024
e694e07
feat added chat feature
RickDeb2004 Jun 30, 2024
0052ed6
fixed position of dialouge box
RickDeb2004 Jun 30, 2024
f686620
Merge pull request #28 from RickDeb2004/new
RickDeb2004 Jun 30, 2024
13be486
feat added page for user
RickDeb2004 Jun 30, 2024
4312dfe
fixed link
RickDeb2004 Jun 30, 2024
7d65ffc
feat added glow
RickDeb2004 Jun 30, 2024
98dcbe6
Merge pull request #29 from RickDeb2004/users/page
RickDeb2004 Jun 30, 2024
527a8b3
feat added admin and rolemail db in adminlist
RickDeb2004 Jul 2, 2024
fa10894
blank
RickDeb2004 Jul 2, 2024
5e1cc36
feat added admin database rolemail and admins , fetch login from there
RickDeb2004 Jul 3, 2024
765138d
feat added superadmin login , fetching from users
RickDeb2004 Jul 3, 2024
0a3c9a3
feat added add member in UserList & login of user by spliting ID
RickDeb2004 Jul 3, 2024
f87961a
feat added blocked feat
RickDeb2004 Jul 3, 2024
d99d0ec
Feat added admins db to form
RickDeb2004 Jul 3, 2024
a411eef
feat updated contacts db
RickDeb2004 Jul 3, 2024
58e784f
local session storage max level
Animesh239 Jul 4, 2024
59055a8
Merge pull request #31 from Animesh239/develop-v2
Animesh239 Jul 4, 2024
10ff0c8
feat added feeback as array in the admins db & fixed styling
RickDeb2004 Jul 4, 2024
6467b47
feat added admin uid to the events db & fixed calebder sidebar styling
RickDeb2004 Jul 4, 2024
eb9a320
feat added admins db to bar chart & geo & remove the login header for…
RickDeb2004 Jul 4, 2024
109426e
Added admins db to linechart
RickDeb2004 Jul 4, 2024
9304df1
Added admins db to pie chart
RickDeb2004 Jul 4, 2024
5030e0d
fixed barchart
RickDeb2004 Jul 4, 2024
2cc9bc6
fixed sidebar with admins db
RickDeb2004 Jul 4, 2024
3835ecd
feat added server with client using firebase admin sdk
RickDeb2004 Jul 5, 2024
299d9b0
added .gitignore
RickDeb2004 Jul 5, 2024
b66b2f7
Merge branch 'main' into develop
Animesh239 Jul 5, 2024
a746c76
feat added contacts again in db
RickDeb2004 Jul 5, 2024
f2cde4d
create team member
Animesh239 Jul 5, 2024
124d36d
Merge pull request #32 from Animesh239/develop-new
Animesh239 Jul 5, 2024
79fff02
admin page fixed
Animesh239 Jul 5, 2024
8a1046e
Merge pull request #33 from Animesh239/develop-new
Animesh239 Jul 5, 2024
9a8d8e4
update signin Time
Animesh239 Jul 5, 2024
8aec2d2
Merge pull request #35 from Animesh239/develop-login
Animesh239 Jul 5, 2024
b5e3740
feat added chat with superadmin
RickDeb2004 Jul 5, 2024
2fc5268
fixed styling of chat
RickDeb2004 Jul 5, 2024
88328f1
Merge pull request #36 from RickDeb2004/develop2.0
RickDeb2004 Jul 5, 2024
327cff2
feat reduced the glow effect
RickDeb2004 Jul 5, 2024
e780890
feedback
Animesh239 Jul 5, 2024
28fe2dd
Merge pull request #38 from Animesh239/develop-feed
RickDeb2004 Jul 5, 2024
7f9305c
Reduced glow effect in the profile form
RickDeb2004 Jul 6, 2024
5e962e6
fixed feedback card limit and styling
RickDeb2004 Jul 6, 2024
c74f00a
fixed: increase the font size
RickDeb2004 Jul 8, 2024
ea87f35
fixed messageCount in the chatIcon badgeContentSection
RickDeb2004 Jul 8, 2024
3eef4ae
fix handleformsubmit for editing userData
RickDeb2004 Jul 9, 2024
2863152
fixed changed the order of transaction id and name
RickDeb2004 Jul 11, 2024
4980972
Update README.md
RickDeb2004 Jul 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat added add member in UserList & login of user by spliting ID
RickDeb2004 committed Jul 3, 2024
commit 0a3c9a31fc5437766f90ce2ba45e5c9c634e6df4
46 changes: 39 additions & 7 deletions src/scenes/login/index.jsx
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ const Login = ({ handleLoginSuccess }) => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState("");
const [userUID, setUserUID] = useState("");

const handleLogin = async () => {
try {
@@ -24,9 +25,10 @@ const Login = ({ handleLoginSuccess }) => {

// Fetch the role from the rolemail node
const roleMailRef = ref(database, "rolemail");

const roleMailSnapshot = await get(roleMailRef);
console.log("roleMailRef",roleMailRef);
console.log("roleMailSnapshot",roleMailSnapshot);
console.log("roleMailRef", roleMailRef);
console.log("roleMailSnapshot", roleMailSnapshot);

if (roleMailSnapshot.exists()) {
const roleMailData = roleMailSnapshot.val();
@@ -37,17 +39,17 @@ const Login = ({ handleLoginSuccess }) => {
if (userEntry) {
const [userId, userInfo] = userEntry;
const { role } = userInfo;
console.log("userentry",userEntry,userInfo);
console.log("userentry", userEntry, userInfo);

if (role === "superadmin") {
// Fetch the user details from the users database for superadmin
const userRef = ref(database, "users/" + userId);
console.log("userref",userRef);
console.log("userref", userRef);
const userSnapshot = await get(userRef);
console.log("usersnapshot",userSnapshot);
console.log("usersnapshot", userSnapshot);
if (userSnapshot.exists()) {
const userData = userSnapshot.val();
console.log("userdata",userData);
console.log("userdata", userData);
if (userData.password === password) {
// Superadmin authenticated successfully
handleLoginSuccess(role);
@@ -88,8 +90,38 @@ const Login = ({ handleLoginSuccess }) => {
setError("Admin not found");
return;
}
} else if (role === "user") {
// For admin, check the password in the admins node
const useridSplit = userId.split("_")[0];
console.log("useridSplit", useridSplit);
const useRef = ref(
database,
"userList/" + useridSplit + "/" + userId
);

const useSnapshot = await get(useRef);
console.log("useSnapshot", useSnapshot);
if (useSnapshot.exists()) {
const useData = useSnapshot.val();
if (useData.password === password) {
// Admin authenticated successfully
handleLoginSuccess(role);
// Store user information in localStorage
localStorage.setItem(
"user",
JSON.stringify({ uid: userId, role })
);
return;
} else {
setError("Invalid user credentials");
return;
}
} else {
setError("user not found");
return;
}
} else {
setError("Not an admin or superadmin account");
setError("Not an admin or superadmin or user account");
return;
}
} else {
215 changes: 111 additions & 104 deletions src/scenes/team/index.jsx
Original file line number Diff line number Diff line change
@@ -48,21 +48,28 @@ const Team = () => {
role: "user",
});
const [currentUserRole, setCurrentUserRole] = useState(null);
const [adminName, setAdminName] = useState("");
const [adminID, setAdminID] = useState("");

const user = auth.currentUser;

// fetch userRole from the database
// Fetch userRole and admin name from the database
useEffect(() => {
if (user) {
const userRoleRef = ref(database, "users/" + user.uid + "/role");
const getUserRole = async () => {
const snapshot = await get(userRoleRef);
if (snapshot.exists()) {
setCurrentUserRole(snapshot.val());
console.log(snapshot.val());
const adminRef = ref(database, "admins/" + user.uid);

const getAdminData = async () => {
const adminSnapshot = await get(adminRef);

if (adminSnapshot.exists()) {
const adminData = adminSnapshot.val();
setCurrentUserRole(adminData.role);
setAdminName(adminData.name);
setAdminID(user.uid);
}
};
getUserRole();

getAdminData();
}
}, [user]);

@@ -128,82 +135,82 @@ const Team = () => {
},
];

if (currentUserRole === "admin") {
columns.push({
field: "blocked",
headerName: "Blocked",
flex: 1,
renderCell: ({ row }) => (
<Button
onClick={() => handleBlockUser(row.id, !row.blocked)}
sx={{ color: row.blocked ? "green" : "red" }}
>
{row.blocked ? "Unblock" : "Block"}
</Button>
),
});
columns.push({
field: "actions",
headerName: "Actions",
flex: 1,
renderCell: ({ row }) => (
<Button
onClick={() => handleEditUser(row)}
sx={{ color: colors.grey[100] }}
>
Edit
</Button>
),
});
}
columns.push({
field: "blocked",
headerName: "Blocked",
flex: 1,
renderCell: ({ row }) => (
<Button
onClick={() => handleBlockUser(row.id, !row.blocked)}
sx={{ color: row.blocked ? "green" : "red" }}
>
{row.blocked ? "Unblock" : "Block"}
</Button>
),
});
columns.push({
field: "actions",
headerName: "Actions",
flex: 1,
renderCell: ({ row }) => (
<Button
onClick={() => handleEditUser(row)}
sx={{ color: colors.grey[100] }}
>
Edit
</Button>
),
});

useEffect(() => {
const userActivityRef = ref(database, "userActivity");
if (adminID) {
const userListRef = ref(database, `userList/${adminID}`);

const handleChildAddedOrChanged = (snapshot) => {
const data = snapshot.val();
setUserData((prevUserData) => {
const existingIndex = prevUserData.findIndex(
(item) => item.id === snapshot.key
);
if (existingIndex !== -1) {
const updatedUserData = [...prevUserData];
updatedUserData[existingIndex] = { id: snapshot.key, ...data };
return updatedUserData;
} else {
return [...prevUserData, { id: snapshot.key, ...data }];
}
});
};

const handleChildAddedOrChanged = (snapshot) => {
const data = snapshot.val();
setUserData((prevUserData) => {
const existingIndex = prevUserData.findIndex(
(item) => item.id === snapshot.key
const handleChildRemoved = (snapshot) => {
setUserData((prevUserData) =>
prevUserData.filter((item) => item.id !== snapshot.key)
);
if (existingIndex !== -1) {
const updatedUserData = [...prevUserData];
updatedUserData[existingIndex] = { id: snapshot.key, ...data };
return updatedUserData;
} else {
return [...prevUserData, { id: snapshot.key, ...data }];
}
});
};
};

const handleChildRemoved = (snapshot) => {
setUserData((prevUserData) =>
prevUserData.filter((item) => item.id !== snapshot.key)
const childAddedListener = onChildAdded(
userListRef,
handleChildAddedOrChanged
);
const childChangedListener = onChildChanged(
userListRef,
handleChildAddedOrChanged
);
const childRemovedListener = onChildRemoved(
userListRef,
handleChildRemoved
);
};

const childAddedListener = onChildAdded(
userActivityRef,
handleChildAddedOrChanged
);
const childChangedListener = onChildChanged(
userActivityRef,
handleChildAddedOrChanged
);
const childRemovedListener = onChildRemoved(
userActivityRef,
handleChildRemoved
);

return () => {
off(userActivityRef, "child_added", childAddedListener);
off(userActivityRef, "child_changed", childChangedListener);
off(userActivityRef, "child_removed", childRemovedListener);
};
}, []);
return () => {
off(userListRef, "child_added", childAddedListener);
off(userListRef, "child_changed", childChangedListener);
off(userListRef, "child_removed", childRemovedListener);
};
}
}, [adminID]);

const handleBlockUser = async (userId, blockStatus) => {
const userRef = ref(database, `userActivity/${userId}`);
const userRef = ref(database, `userList/${adminID}/${userId}`);
await update(userRef, { blocked: blockStatus });
};

@@ -225,54 +232,54 @@ const Team = () => {
};

const handleFormSubmit = async () => {
if (selectedUser) {
// Updating an existing user
const userRef = ref(database, `userActivity/${selectedUser.id}`);
const updates = { ...formData };
if (!formData.password) delete updates.password; // Do not update password if it's empty
await update(userRef, updates);
const userId = selectedUser ? selectedUser.id : `${adminID}_${uuidv4()}`;

const userRef = ref(database, `userList/${adminID}/${userId}`);
const roleMailRef = ref(database, `rolemail/${userId}`);

const userData = {
...formData,
signInTime: new Date().toISOString(),
blocked: false,
};

const userRefUsers = ref(database, `users/${selectedUser.id}`);
await update(userRefUsers, updates);
if (selectedUser) {
if (!formData.password) delete userData.password; // Do not update password if it's empty
await update(userRef, userData);
await update(roleMailRef, {
email: formData.email,
role: formData.role,
});
} else {
// Adding a new user
try {
const userCredential = await createUserWithEmailAndPassword(
await createUserWithEmailAndPassword(
auth,
formData.email,
formData.password
);
const newUser = userCredential.user;
const userRef = ref(database, `userActivity/${newUser.uid}`);
await set(userRef, {
...formData,
signInTime: new Date().toISOString(),
blocked: false,
});

const userRefUsers = ref(database, `users/${newUser.uid}`);
await set(userRefUsers, {
...formData,
signInTime: new Date().toISOString(),
blocked: false,
await set(userRef, userData);
await set(roleMailRef, {
email: formData.email,
role: formData.role,
});
} catch (error) {
console.error("Error adding new user:", error);
}
}
handleDialogClose();
};
const handleConfirmDelete = async (users) => {

const handleConfirmDelete = async (user) => {
try {
const userActivityRef = ref(database, `userActivity/${users.id}`);
await remove(userActivityRef);
const userRef = ref(database, `users/${user.id}`);
const userRef = ref(database, `userList/${adminID}/${user.id}`);
const roleMailRef = ref(database, `rolemail/${user.id}`);
await remove(userRef);
await remove(roleMailRef);
setUserData((prevUserData) =>
prevUserData.filter((user) => user.id !== users.id)
prevUserData.filter((u) => u.id !== user.id)
);
} catch (error) {
console.error("Error deleting contact:", error);
console.error("Error deleting user:", error);
}
};
const lampEffectStyle = {