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

Add to saved button hidden for profile owner #319

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Changes from all commits
Commits
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
26 changes: 14 additions & 12 deletions FrontEnd/src/components/ProfileDetail/MainInfo/TitleInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function TitleInfo({ isAuthorized, data }) {
};
}, [data]);

const ownProfile = user && user.id === profile.personId;

async function sendRequest(url, { arg: data }) {
const authToken = localStorage.getItem('Token');
return fetch(url, {
Expand Down Expand Up @@ -61,9 +63,8 @@ function TitleInfo({ isAuthorized, data }) {
await trigger(
{ company_pk: profile.id },
{ optimisticData: () => {
if (user.id !== profile.personId)
{setIsSaved(!isSaved);
}}
setIsSaved(!isSaved);
}
}
);
} catch (error) {
Expand Down Expand Up @@ -132,15 +133,16 @@ function TitleInfo({ isAuthorized, data }) {
</div>
<div className={classes['title-block__company_region']}>{profile.region}</div>
</div>
{isAuthorized && (
<button
onClick={handleClick}
type="button"
className={`${classes['title-block__button']} ${isSaved && classes['added_to_saved__button']}`}
>
<span className={`${classes['title-block__button--text']} ${isSaved && classes['added_to_saved__button--text']}`}>{!isSaved ? 'Додати в збережені' : 'Додано в збережені'}</span>
{isAuthorized ? (isSaved ? filledStar : outlinedStar) : null}
</button>)}
{isAuthorized && !ownProfile ? (
<button
onClick={handleClick}
type="button"
className={`${classes['title-block__button']} ${isSaved && classes['added_to_saved__button']}`}
>
<span className={`${classes['title-block__button--text']} ${isSaved && classes['added_to_saved__button--text']}`}>{!isSaved ? 'Додати в збережені' : 'Додано в збережені'}</span>
{isAuthorized ? (isSaved ? filledStar : outlinedStar) : null}
</button>
) : null}
</div>
);
}
Expand Down
Loading