Skip to content

Commit

Permalink
revoked company
Browse files Browse the repository at this point in the history
  • Loading branch information
a.o.panin committed Oct 10, 2023
1 parent abf323e commit 0f5e8de
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions telehire-client/src/components/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,32 @@ import { User } from '@/models/User';
import { ResumeAction } from '@/store/resume/ResumeActions';
import { history } from '@/utils/history';
import { FC, useMemo } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useDispatch } from 'react-redux';
import { CVWrapper, InactiveWrapper } from './Profile.styles';
import { selectCurrentCompany } from '@/store/company/CompanySelectors';

type Props = {
user: User;
};

const Profile: FC<Props> = ({ user }) => {
const dispatch = useDispatch();
const company = useSelector(selectCurrentCompany);

useMainButton({
onClick: () => history.push('/create-resume'),
text: 'Create new resume',
condition: user.loggedInAs === 'applicant',
});

const company = useMemo(() => {
const currentCompanyId = localStorage.getItem(CURRENT_COMPANY_ID);

if (currentCompanyId && user.loggedInAs === 'company') {
return user?.companyList?.find(
(innerCompany: Company) => innerCompany.id === Number(currentCompanyId),
);
}
}, [user]);

const activeResume = useMemo(() => {
return user.resumes!.find(
(innerResume) => innerResume.id === user.activeResumeId,
Expand All @@ -54,7 +62,7 @@ const Profile: FC<Props> = ({ user }) => {
<SmallWrapper>
<CompanyItem
onClick={() => history.push('/companies/' + company?.id)}
company={company ?? undefined}
company={company}
/>
</SmallWrapper>
</BigWrapper>
Expand Down

0 comments on commit 0f5e8de

Please sign in to comment.