diff --git a/FrontEnd/src/components/SearchPage/Search.jsx b/FrontEnd/src/components/SearchPage/Search.jsx
index 438c8fd3d..620ed747d 100644
--- a/FrontEnd/src/components/SearchPage/Search.jsx
+++ b/FrontEnd/src/components/SearchPage/Search.jsx
@@ -13,9 +13,10 @@ import PropTypes from 'prop-types';
const ITEMS_PER_PAGE = 6;
-export function Search({ isAuthorized }) {
+export function Search({ isAuthorized, userData }) {
Search.propTypes = {
isAuthorized: PropTypes.any.isRequired,
+ userData: PropTypes.any.isRequired,
};
const [searchResults, setSearchResults] = useState([]);
@@ -94,6 +95,7 @@ export function Search({ isAuthorized }) {
searchPerformed={searchPerformed}
displayedResults={displayedResults}
isAuthorized={isAuthorized}
+ userData={userData}
/>
>
diff --git a/FrontEnd/src/components/SearchPage/search_field/SearchResults.jsx b/FrontEnd/src/components/SearchPage/search_field/SearchResults.jsx
index 36e4dde41..38c6817b3 100644
--- a/FrontEnd/src/components/SearchPage/search_field/SearchResults.jsx
+++ b/FrontEnd/src/components/SearchPage/search_field/SearchResults.jsx
@@ -2,11 +2,12 @@ import CompanyCard from './companies/CompanyCard';
import styles from './Text.module.css';
import PropTypes from 'prop-types';
-const SearchResults = ({ results, displayedResults, isAuthorized }) => {
+const SearchResults = ({ results, displayedResults, isAuthorized, userData }) => {
SearchResults.propTypes = {
results: PropTypes.array,
displayedResults: PropTypes.array,
isAuthorized: PropTypes.object,
+ userData: PropTypes.any.isRequired,
};
let error = null;
@@ -22,7 +23,7 @@ const SearchResults = ({ results, displayedResults, isAuthorized }) => {
{displayedResults.map((result, resultIndex) => (
-
+
))}
diff --git a/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.jsx b/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.jsx
index 944bed456..4a41bee10 100644
--- a/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.jsx
+++ b/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.jsx
@@ -7,10 +7,11 @@ import axios from 'axios';
import styles from './CompanyCard.module.css';
import PropTypes from 'prop-types';
-const CompanyCard = ({ companyData, isAuthorized }) => {
+const CompanyCard = ({ companyData, isAuthorized, userData }) => {
CompanyCard.propTypes = {
companyData: PropTypes.object,
isAuthorized: PropTypes.object,
+ userData: PropTypes.any.isRequired,
};
const { mutate } = useSWRConfig();
@@ -56,7 +57,7 @@ const CompanyCard = ({ companyData, isAuthorized }) => {
}
setUsersSavedList(NewList);
- if (companyData.id == isAuthorized.UserId) {
+ if (companyData.id == userData.id) {
setStar(false);
setIsSaved(false);
setSearchPerformed(true);
diff --git a/FrontEnd/src/components/basicPage/BasicPage.jsx b/FrontEnd/src/components/basicPage/BasicPage.jsx
index 7e9c83115..36a22e38d 100644
--- a/FrontEnd/src/components/basicPage/BasicPage.jsx
+++ b/FrontEnd/src/components/basicPage/BasicPage.jsx
@@ -23,10 +23,13 @@ import { RestorePasswordFailedPage } from '../RestorePassword/pages/RestorePassw
import ScrollToTopButton from '../PrivacyPolicyPage/privacy/ScrollToTopButton';
import TermsAndConditions from '../terms-and-conditions-app/terms_conditions/TermsAndConditionsComponent';
import { useAuth } from '../../hooks';
+import { useUser } from '../../hooks';
import { Search } from '../SearchPage/Search';
function BasicPage() {
const auth = useAuth();
+ const user = useUser();
+ const userData = user.user;
return (
} />
} />
} />
- } />
+ } />
diff --git a/FrontEnd/src/hooks/useProvideAuth.js b/FrontEnd/src/hooks/useProvideAuth.js
index 491cbcba8..b21c6f2e3 100644
--- a/FrontEnd/src/hooks/useProvideAuth.js
+++ b/FrontEnd/src/hooks/useProvideAuth.js
@@ -4,19 +4,16 @@ import axios from 'axios';
export default function useProvideAuth() {
const [isAuth, setIsAuth] = useState(false);
const [isLoading, setLoading] = useState(true);
- const [UserId, setUserId] = useState(null);
const validateToken = async (authToken) => {
try {
- const userData = await axios.get(
+ await axios.get(
`${process.env.REACT_APP_BASE_API_URL}/api/auth/users/me/`,
{
headers: {
Authorization: `Token ${authToken}`,
},
}
- )
- .then((res) => res.data);
- setUserId(userData.id);
+ );
return true;
} catch (error) {
if (error.response && error.response.status === 401) {
@@ -65,5 +62,5 @@ export default function useProvideAuth() {
}
});
});
- return { login, logout, isAuth, isLoading, UserId };
+ return { login, logout, isAuth, isLoading };
}