Skip to content

Commit

Permalink
CodeQL fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajat Saxena committed Oct 8, 2024
1 parent d4eb3c3 commit 14b7eaf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
43 changes: 24 additions & 19 deletions apps/web/app/dashboard2/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
PROFILE_SECTION_DETAILS_NAME,
PROFILE_SECTION_DISPLAY_PICTURE,
} from "@ui-config/strings";
import { FormEvent, useContext, useState } from "react";
import { FormEvent, useContext, useEffect, useState } from "react";

export default function Page() {
const [bio, setBio] = useState("");
Expand All @@ -42,8 +42,9 @@ export default function Page() {
const profile = useContext(ProfileContext);
const address = useContext(AddressContext);

const getUser = async function (userId: string) {
const query = `
useEffect(() => {
const getUser = async function (userId: string) {
const query = `
query {
user: getUser(userId: "${userId}") {
name,
Expand All @@ -63,25 +64,29 @@ export default function Page() {
}
}
`;
const fetch = new FetchBuilder()
.setUrl(`${address.backend}/api/graph`)
.setPayload(query)
.setIsGraphQLEndpoint(true)
.build();
const fetch = new FetchBuilder()
.setUrl(`${address.backend}/api/graph`)
.setPayload(query)
.setIsGraphQLEndpoint(true)
.build();

try {
const response = await fetch.exec();
if (response.user) {
setUser(response.user);
setName(response.user.name);
setBio(response.user.bio);
setAvatar(response.user.avatar);
setSubscribedToUpdates(response.user.subscribedToUpdates);
try {
const response = await fetch.exec();
if (response.user) {
setUser(response.user);
setName(response.user.name);
setBio(response.user.bio);
setAvatar(response.user.avatar);
setSubscribedToUpdates(response.user.subscribedToUpdates);
}
} catch (err: any) {
console.error(`Profile page: ${err.message}`);
}
} catch (err: any) {
console.error(`Profile page: ${err.message}`);
};
if (profile.userId && address.backend) {
getUser(profile.userId);
}
};
}, [profile, address.backend]);

const updateProfilePic = async (media?: Media) => {
const mutation = `
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/dashboard2/users/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { useCallback, useContext, useEffect, useState } from "react";

export default function Page({ params }: { params: { id: string } }) {
const [userData, setUserData] = useState<UserWithAdminFields>();
const [enrolledCourses, setEnrolledCourses] = useState([]);
const [_, setEnrolledCourses] = useState([]);
const [tags, setTags] = useState([]);
const address = useContext(AddressContext);
const { id } = params;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/dashboard2/users/users-hub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function UsersHub() {
const tab = searchParams?.get("tab") || "Users";

const [page, setPage] = useState(1);
const [rowsPerPage, setRowsPerPage] = useState(10);
const [rowsPerPage, _] = useState(10);
const [users, setUsers] = useState<User[]>([]);
const [filters, setFilters] = useState<UserFilter[]>([]);
const [filtersAggregator, setFiltersAggregator] =
Expand Down

0 comments on commit 14b7eaf

Please sign in to comment.