import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { CheckboxComponent, CircularIcon, SecondaryButton } from "..";
import DynamicEducationCard from "../AssignmentIdealProfileSelectionCard/DynamicEducationCard";
import ProfileDynamicExperienceCard from "../AssignmentIdealProfileSelectionCard/ProfileDynamicExperienceCard";
import BadgeWithCount from "../BadgeWithCount";
import "./style.scss";
const PeopleCard = ({ count, profile, checked, onCheckClick, onExperienceCompanyClick, onDetailsClick, expIndustries = [], expSkills = [], filteredEducation = [], }) => {
    const exp = profile.experience
        ? profile.experience?.map((experience) => experience?.experienceDetails?.map((exp, key) => {
            const locationChange = experience.experienceDetails.at(key ? key - 1 : key)?.location;
            return {
                showCompany: key === 0,
                iconUrl: experience.companyLogo ?? "",
                iconAltText: exp.companyName,
                position: exp.title || "Full stack engineer",
                company: exp.companyName,
                from: exp.start,
                to: exp.end ? exp.end : "Now",
                separator: "-",
                universalName: exp?.universalName || "",
                urn: exp?.urn || "",
                industries: exp?.industries,
                location: key === 0 || exp.location !== locationChange ? exp?.location : "",
            };
        }))
        : [];
    const transformEducations = (edus) => {
        const cleanedEducations = edus?.filter((edu) => {
            return !!edu.degreeName || !!edu.schoolName;
        });
        return cleanedEducations.map((edu) => ({
            iconAltText: "",
            institue: !!edu?.schoolName ? edu.schoolName : "",
            degree: !!edu?.degreeName ? edu.degreeName : "",
            from: edu.start,
            to: edu.end,
        }));
    };
    return (_jsxs("div", { className: "peopleCardContainer", children: [_jsx("div", { className: "header", children: _jsxs("div", { children: [_jsx("span", { children: count }), _jsx(CheckboxComponent, { checked: checked, onClick: () => onCheckClick(profile._id) })] }) }), _jsxs("div", { className: "peopleCard", children: [_jsx("div", { className: "peopleCardLeft", children: _jsxs("div", { children: [_jsx(CircularIcon, { iconPath: profile.imageUrl, iconSize: "120", altImageType: "profile" }, `${profile?.publicIdentifier}-${profile?.updatedAtEs}`), _jsxs("div", { className: "peopleCardNameSection", children: [_jsx("p", { className: "titleSection", children: profile.fullName }), _jsx(BadgeWithCount, { count: profile?.assignmentCount, toolTipContent: `Added to ${profile.assignmentCount} assignments`, iconType: "briefcase", iconSize: "16" })] }), _jsx("div", { className: "title", children: _jsxs("p", { children: [_jsx("span", { className: "titleText", children: profile.title }), !!profile?.experience?.[0]?.experienceDetails[0]
                                                .companyName && _jsx("span", { children: " at " }), _jsx("span", { onClick: () => {
                                                    onExperienceCompanyClick(profile?.experience?.[0]?.experienceDetails[0]
                                                        ?.universalName || "", profile?.experience?.[0]?.experienceDetails[0]?.urn || "");
                                                }, className: "company", children: profile?.experience?.[0]?.experienceDetails[0].companyName })] }) }), _jsx("p", { className: "location", children: profile.locality }), _jsx(SecondaryButton, { onClick: () => onDetailsClick(profile._id), sizeVariant: "sm", colorVariant: "orange", children: "View full profile" })] }) }), _jsxs("div", { className: "peopleCardRight", children: [profile.experience?.length !== 0 && (_jsxs("div", { className: "experienceWrapper", children: [_jsx("p", { children: "Experience" }), _jsx(ProfileDynamicExperienceCard, { experiences: exp, initialItemsToShow: 3, onCompanyClick: onExperienceCompanyClick, expIndustries: expIndustries, expSkills: expSkills })] })), filteredEducation?.length !== 0 && (_jsxs("div", { className: "educationContainer", children: [_jsx("p", { children: "Education" }), _jsx(DynamicEducationCard, { educations: transformEducations(filteredEducation), initialItemsToShow: 3 })] }))] })] })] }));
};
export default PeopleCard;
