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

bt-850: Create talent profile for employer #870

Merged
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { type Control } from 'react-hook-form';

import { type Company } from '~/bundles/chat/types/types.js';
import {
Button,
FormControl,
Grid,
RadioGroup,
Typography,
} from '~/bundles/common/components/components.js';

import styles from '../styles.module.scss';

type Properties = {
company?: Company | Record<string, never>;
aboutInfo: string;
onHireSubmit: () => void;
onShareCVButtonClick: () => void;
talentIsHired: boolean;
control: Control<{ hire: 'Yes' | 'No' }, null>;
hasSharedContacts: boolean;
};

const CompanyEmployer: React.FC<Properties> = ({
company,
aboutInfo,
onHireSubmit,
onShareCVButtonClick,
talentIsHired,
control,
hasSharedContacts,
}) => {
const options = [
{
value: 'Yes',
label: 'Yes',
},
{
value: 'No',
label: 'No',
},
];
return (
<Grid className={styles.contentWrapper}>
<Grid className={styles.content}>
<Typography className={styles.contentHeading} variant="h6">
About {company?.companyName}
</Typography>
<Typography className={styles.about} variant="body1">
{aboutInfo}
</Typography>
{company?.companyWebsite && (
<>
<Typography
className={styles.contentHeading}
variant="h6"
>
Company Website
</Typography>
<Typography
variant="body1"
className={styles.linkWrapper}
>
<a
href={
company.companyWebsite.startsWith(
'http://',
) ||
company.companyWebsite.startsWith(
'https://',
)
? company.companyWebsite
: `http://${company.companyWebsite}`
}
rel="noreferrer"
target="_blank"
className={styles.companyLink}
>
{company.companyWebsite}
</a>
</Typography>
</>
)}
</Grid>

<Grid className={styles.buttons}>
<Button
className={styles.mainBtn}
label="Share your contact and CV"
onClick={onShareCVButtonClick}
isDisabled={hasSharedContacts}
/>
<FormControl className={styles.hireCandidates}>
{!talentIsHired && (
<>
<Typography variant="label">
Have the company hired you?
</Typography>
<RadioGroup
control={control}
options={options}
name={'hire'}
className={styles.radio}
/>
</>
)}
{talentIsHired && (
<Typography
variant="label"
className={styles.hiredLabel}
>
You have been hired by this company
</Typography>
)}
<Button
label="Submit"
className={styles.mainBtn}
onClick={onHireSubmit}
isDisabled={talentIsHired}
/>
</FormControl>
</Grid>
</Grid>
);
};

export { CompanyEmployer };
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { type Company } from '~/bundles/chat/types/types.js';
import { type UserDetails } from '~/bundles/chat/types/user-details/user-details.js';
import {
Avatar,
Grid,
Typography,
} from '~/bundles/common/components/components.js';
import { UserRole } from '~/bundles/common/enums/enums.js';

import styles from '../styles.module.scss';

type Properties = {
role: string;
talent?: UserDetails | null;
company?: Company | Record<string, never>;
};

const CompanyHeader: React.FC<Properties> = ({ company, role, talent }) => {
return (
<Grid className={styles.header}>
<Avatar
alt={
(role === UserRole.TALENT
? company?.companyName
: talent?.fullName) ?? ''
}
src={
(role === UserRole.TALENT
? company?.logoUrl
: talent?.photoId) ?? ''
}
isSmall
/>

<Grid className={styles.headerInfo}>
<Typography className={styles.companyName} variant="h3">
{role === UserRole.TALENT
? company?.companyName
: talent?.profileName}
</Typography>
{role === UserRole.TALENT ? (
<Typography
className={styles.companyRepresentative}
variant="body1"
>
({company?.employerName}, {company?.employerPosition})
</Typography>
) : (
<Typography
className={styles.companyRepresentative}
variant="body1"
>
Job title: {talent?.jobTitle}
</Typography>
)}
</Grid>
</Grid>
);
};

export { CompanyHeader };
158 changes: 36 additions & 122 deletions frontend/src/bundles/chat/components/company-info/company-info.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { actions as candidateActions } from '~/bundles/candidate-details/store/candidate.js';
import { actions as chatActions } from '~/bundles/chat/store/chat.js';
import {
Avatar,
Button,
FormControl,
Grid,
Logo,
RadioGroup,
Typography,
} from '~/bundles/common/components/components.js';
import { Grid, Logo } from '~/bundles/common/components/components.js';
import { UserRole } from '~/bundles/common/enums/enums.js';
import {
useAppDispatch,
useAppForm,
Expand All @@ -17,50 +10,51 @@ import {
useEffect,
} from '~/bundles/common/hooks/hooks.js';
import { actions as hiringInfoActions } from '~/bundles/hiring-info/store/hiring-info.js';
import { actions as talentActions } from '~/bundles/talent-onboarding/store/talent-onboarding.js';
import { userDetailsApi } from '~/bundles/user-details/user-details.js';

import {
CompanyEmployer,
CompanyHeader,
CompanyTalent,
} from '../components.js';
import styles from './styles.module.scss';

type Properties = {
role: string;
className?: string;
};

const options = [
{
value: 'Yes',
label: 'Yes',
},
{
value: 'No',
label: 'No',
},
];
const CompanyInfo: React.FC<Properties> = ({ className }) => {
const CompanyInfo: React.FC<Properties> = ({ className, role }) => {
const {
company,
hasSharedContacts,
talentId,
talent,
talentIsHired,
companyId,
currentChatId,
} = useAppSelector(({ chat }) => ({
company: chat.current.employerDetails,
hasSharedContacts: chat.current.talentHasSharedContacts,
talentId: chat.current.talentId,
companyId: chat.current.employerDetails.employerId,
currentChatId: chat.current.chatId,
talent: chat.current.userDetails,
companyId: chat.current.employerDetails.employerId,
talentIsHired: chat.current.talentIsHired,
}));

const dispatch = useAppDispatch();

const {
logoUrl,
companyName,
employerName,
employerPosition,
about,
companyWebsite,
} = company;
useEffect(() => {
if (role === UserRole.EMPLOYER) {
void dispatch(
talentActions.getTalentDetails({ userId: talentId as string }),
);
}
}, [dispatch, role, talentId]);

const { about } = company;

const handleShareCVButtonClick = useCallback(() => {
const createNotificationMessage = async (): Promise<void> => {
Expand Down Expand Up @@ -118,100 +112,20 @@ const CompanyInfo: React.FC<Properties> = ({ className }) => {
const aboutInfo = about ?? 'No information provided';
return currentChatId ? (
<Grid className={styles.wrapper}>
<Grid className={styles.header}>
<Avatar
alt={companyName ?? 'company name'}
src={logoUrl ?? ''}
isSmall
<CompanyHeader role={role} company={company} talent={talent} />
{role === UserRole.EMPLOYER ? (
<CompanyTalent talent={talent} />
) : (
<CompanyEmployer
aboutInfo={aboutInfo}
company={company}
onHireSubmit={handleHireSubmit}
onShareCVButtonClick={handleShareCVButtonClick}
talentIsHired={talentIsHired}
control={control}
hasSharedContacts={hasSharedContacts}
/>
<Grid className={styles.headerInfo}>
<Typography className={styles.companyName} variant="h3">
{companyName}
</Typography>
<Typography
className={styles.companyRepresentative}
variant="body1"
>
{employerName}, {employerPosition}
</Typography>
</Grid>
</Grid>

<Grid className={styles.contentWrapper}>
<Grid className={styles.content}>
<Typography className={styles.contentHeading} variant="h6">
About {companyName}
</Typography>
<Typography className={styles.about} variant="body1">
{aboutInfo}
</Typography>
{companyWebsite && (
<>
<Typography
className={styles.contentHeading}
variant="h6"
>
Company Website
</Typography>
<Typography
variant="body1"
className={styles.linkWrapper}
>
<a
href={
companyWebsite.startsWith('http://') ||
companyWebsite.startsWith('https://')
? companyWebsite
: `http://${companyWebsite}`
}
rel="noreferrer"
target="_blank"
className={styles.companyLink}
>
{companyWebsite}
</a>
</Typography>
</>
)}
</Grid>
<Grid className={styles.buttons}>
<Button
className={styles.mainBtn}
label="Share your contact and CV"
onClick={handleShareCVButtonClick}
isDisabled={hasSharedContacts}
/>
<FormControl className={styles.hireCandidates}>
{!talentIsHired && (
<>
<Typography variant="label">
Have the company hired you?
</Typography>
<RadioGroup
control={control}
options={options}
name={'hire'}
className={styles.radio}
/>
</>
)}
{talentIsHired && (
<Typography
variant="label"
className={styles.hiredLabel}
>
You have been hired by this company
</Typography>
)}
<Button
label="Submit"
className={styles.mainBtn}
onClick={handleHireSubmit}
isDisabled={talentIsHired}
/>
</FormControl>
</Grid>
</Grid>
)}
</Grid>
) : (
<Grid className={className}>
Expand Down
Loading
Loading