Skip to content

Commit

Permalink
no star for own company
Browse files Browse the repository at this point in the history
  • Loading branch information
BelousSofiya committed Nov 23, 2023
1 parent 421d98b commit aa9ad1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ const CompanyCard = ({ companyData, isAuthorized }) => {
}

setUsersSavedList(NewList);
if (companyData.id == isAuthorized.UserId) {
setStar(false);
setIsSaved(false);
setSearchPerformed(true);
} else {
if (usersSavedList.includes(companyData.id)) {
setStar(filledStar);
setIsSaved(true);
Expand All @@ -64,7 +69,7 @@ const CompanyCard = ({ companyData, isAuthorized }) => {
setStar(outlinedStar);
}
setSearchPerformed(true);
}
}}

const { trigger } = useSWRMutation(
`${process.env.REACT_APP_BASE_API_URL}/api/saved-list/`,
Expand Down
10 changes: 6 additions & 4 deletions FrontEnd/src/hooks/useProvideAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ 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 {
await axios.get(
const userData = 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) {
Expand Down Expand Up @@ -62,6 +65,5 @@ export default function useProvideAuth() {
}
});
});

return { login, logout, isAuth, isLoading };
return { login, logout, isAuth, isLoading, UserId };
}

0 comments on commit aa9ad1f

Please sign in to comment.