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

Feat/project contributions #1484

Merged
merged 9 commits into from
Nov 7, 2023
4 changes: 2 additions & 2 deletions apps/web-api/src/projects/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ProjectsService {
}

async updateProjectByUid(
uid: string,
uid: string,
project: Prisma.ProjectUncheckedUpdateInput,
userEmail: string
) {
Expand Down Expand Up @@ -64,7 +64,7 @@ export class ProjectsService {
this.handleErrors(err, `${uid}`);
}
}

async getProjects(queryOptions: Prisma.ProjectFindManyArgs) {
try {
queryOptions.where = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,18 @@ function AddMemberExperienceForm(props) {
return <>
<div key={`${expIndex}-exp`} className="my-[8px]">
<div className="w-full">

{/******************************** HEAD ***********************************/}
<div className={`rounded-[4px] ${errors.length === 0 ? 'bg-[#F1F5F9]': 'bg-[#ef44441a]'} ${errors.length > 0 ? 'border-[1px] border-solid border-[#ED6E68]': ''} h-[32px] flex items-center justify-between px-[8px]`}>
<div className="flex gap-[10px] mr-[16px]">
{expIndex === expandedId && <img className="cursor-pointer" onClick={() => onToggleExpansion(expIndex)} src="/assets/images/icons/collapse-blue.svg" />}
{expIndex !== expandedId && <img className="cursor-pointer" onClick={() => onToggleExpansion(expIndex)} src="/assets/images/icons/expand-blue.svg" />}
<img onClick={() => onDeleteExperience(expIndex)} className="cursor-pointer" src="/assets/images/icons/delete-icon.svg" />
</div>
{exp.companyName.trim() === '' && <h2 className="text-[#0F172A] flex-1 font-[600] text-[14px]">{`Company ${expIndex + 1}`}</h2>}
{exp.companyName.trim() === '' && <h2 className="text-[#0F172A] flex-1 font-[600] text-[14px]">{`Project ${expIndex + 1}`}</h2>}
{exp.companyName.trim() !== '' && <h2 className="text-[#0F172A] flex-1 font-[600] text-[14px]">{`${exp.companyName.trim()}`}</h2>}
<div className="flex flex-row items-center gap-[8px]">
<Switch nonEditable={exp.currentTeam === false && currentCompaniesCount === 3} initialValue={exp.currentTeam} onChange={(val) => onItemChange(expIndex, 'currentTeam', val)} key={`${expIndex}-switch`} />
<label className="text-[12px] font-[600]">Current Team</label>
<label className="text-[12px] font-[600]">Current Project</label>
</div>
</div>

Expand All @@ -144,8 +143,8 @@ function AddMemberExperienceForm(props) {
</div>}
</div>}
<div className="flex-1">
<label className="text-[14px] font-[600]">Company Name*</label>
<input maxLength={100} placeholder="Ex: Microsoft" className="text-[14px] mt-[12px] border-solid border-[1px] border-[#CBD5E1] px-[12px] py-[8px] rounded-[8px] w-full" type="text" value={exp.companyName} onChange={(e) => onItemChange(expIndex, 'companyName', e.target.value)} />
<label className="text-[14px] font-[600]">Project Name*</label>
<input maxLength={100} placeholder="Ex: Filecoin" className="text-[14px] mt-[12px] border-solid border-[1px] border-[#CBD5E1] px-[12px] py-[8px] rounded-[8px] w-full" type="text" value={exp.companyName} onChange={(e) => onItemChange(expIndex, 'companyName', e.target.value)} />
</div>
</div>
<div className="mt-8px flex gap-[8px]">
Expand All @@ -154,9 +153,9 @@ function AddMemberExperienceForm(props) {

</div>

{/******************************** TITLE ***********************************/}
{/******************************** ROLE ***********************************/}
<div className="my-[20px]">
<label className="text-[14px] font-[600]">Title*</label>
<label className="text-[14px] font-[600]">Role*</label>
<input maxLength={100} placeholder="Ex: Senior Architect" className="text-[14px] mt-[12px] border-solid border-[1px] border-[#CBD5E1] px-[12px] py-[8px] rounded-[8px] w-full" type="text" value={exp.title} onChange={(e) => onItemChange(expIndex, 'title', e.target.value)} />
</div>

Expand Down Expand Up @@ -189,7 +188,7 @@ function AddMemberExperienceForm(props) {

{/******************************** DESCRIPTION ***********************************/}
<div className="mt-[20px]">
<label className="text-[14px] font-[600]">Description</label>
<label className="text-[14px] font-[600]">Contribution</label>
<textarea rows={5} maxLength={2000} ref={descriptionRef} placeholder="" className="text-[14px] mt-[12px] border-solid border-[1px] border-[#CBD5E1] px-[12px] py-[8px] rounded-[8px] w-full" value={exp.description} onChange={(e) => onItemChange(expIndex, 'description', e.target.value)} />
{descriptionRef.current && <p className="text-[#475569] font-[500] text-[12px]">{`${descriptionRef?.current?.value?.length} of 2000 characters used`}</p>}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function AddMemberExperience(props) {
<p className="hidden">{`Total experiences ${experiences.length}`}</p>
<button onClick={onAddExperience} className="flex items-center justify-center">
<img src="/assets/images/icons/add-company-icon.svg" />
<span className="text-blue-600 font-[500] text-[13px]" >Click to add company</span>
<span className="text-blue-600 font-[500] text-[13px]" >Click to add Project contributions</span>
</button>

</div>
Expand All @@ -84,9 +84,9 @@ function AddMemberExperience(props) {
{(experiences.length > 0 ) && <div className="flex justify-start">
{experiences.length <= 6 && <button onClick={onAddExperience} className="flex items-center justify-center text-[14px]">
<img className="" src="/assets/images/icons/expand-blue.svg" />
<span className="text-blue-600 mx-[4px]">Add Company</span>
<span className="text-blue-600 mx-[4px]">Add Contribution</span>
</button>}
<p className="text-[14px] text-[#94A3B8]">(max 7 companies)</p>
<p className="text-[14px] text-[#94A3B8]">(max 7 Contributions)</p>
</div>}
{isLoading && <div className="absolute flex items-center justify-center bg-black bg-opacity-40 top-0 left-0 right-0 w-full h-full z-[10]">
<LoadingIndicator/>
Expand Down
53 changes: 24 additions & 29 deletions apps/web-app/components/members/member-enrollment/addmember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ReactComponent as TextImage } from '/public/assets/images/create-member
import { LoadingIndicator } from '../../shared/loading-indicator/loading-indicator';
import { toast } from 'react-toastify';
import useAppAnalytics from '../../../hooks/shared/use-app-analytics';
import AddMemberExperience from './add-member-experience';
import ProjectContribution from '../../projects/contribution/project-contribution';
// import { useGoogleReCaptcha } from 'react-google-recaptcha-v3';

interface AddMemberModalProps {
Expand All @@ -40,7 +40,7 @@ interface AddMemberModalProps {
const steps = [
{ number: 1, name: 'BASIC' },
{ number: 2, name: 'SKILL' },
{ number: 3, name: 'EXPERIENCE' },
{ number: 3, name: 'CONTRIBUTIONS' },
{ number: 4, name: 'SOCIAL' },
];

Expand Down Expand Up @@ -75,15 +75,15 @@ function validateSkillForm(formValues) {
return errors;
}

function validateExperienceForm(fValues) {
function validateContributionForm(fValues) {
const formErrors = []
const exps = fValues.experience;
const exps = fValues.projectContributions;
exps.forEach((exp, expIndex) => {

if(exp.companyName.trim() === '') {
formErrors.push({id: expIndex, field: 'companyName', error: "Company Name is Mandatory"})
} if(exp.title.trim() === '') {
formErrors.push({id: expIndex, field: 'title', error: "Title is Mandatory"})
if(exp.projectName.trim() === '') {
formErrors.push({id: expIndex, field: 'projectName', error: "Project name is mandatory"})
} if(exp.role.trim() === '') {
formErrors.push({id: expIndex, field: 'role', error: "Role is Mandatory"})
} if(exp.endDate && exp.startDate.getTime() >= exp.endDate.getTime()) {
formErrors.push({id: expIndex, field: 'date', error: "To Date cannot be less than start date"})
}
Expand All @@ -102,7 +102,7 @@ function validateForm(formValues, formStep) {
errors = validateSkillForm(formValues);
return errors;
case 3:
errors = validateExperienceForm(formValues);
errors = validateContributionForm(formValues);
return errors;

}
Expand All @@ -113,7 +113,7 @@ function handleNextClick(
formStep,
setFormStep,
setErrors,
setExperienceErrors,
setContributionErrors,
emailExists,
divRef,
analytics
Expand All @@ -126,7 +126,7 @@ function handleNextClick(
}
if (errors?.length > 0 || emailExists) {
if(formStep === 3) {
setExperienceErrors(errors)
setContributionErrors(errors)
setErrors(["There are fields that require your attention. Please review the fields below."]);
return false;
} else {
Expand All @@ -135,7 +135,7 @@ function handleNextClick(
}

}
setExperienceErrors([])
setContributionErrors([])
analytics.captureEvent(APP_ANALYTICS_EVENTS.MEMBER_JOIN_NETWORK_FORM_STEPS, {
itemName: steps[formStep - 1].name,
});
Expand All @@ -150,7 +150,7 @@ function getSubmitOrNextButton(
setFormStep,
handleSubmit,
setErrors,
setExperienceErrors,
setContributionErrors,
isProcessing,
emailExists,
disableNext,
Expand Down Expand Up @@ -182,7 +182,7 @@ function getSubmitOrNextButton(
formStep,
setFormStep,
setErrors,
setExperienceErrors,
setContributionErrors,
emailExists,
divRef,
analytics
Expand Down Expand Up @@ -229,7 +229,7 @@ export function AddMemberModal({
}: AddMemberModalProps) {
const [formStep, setFormStep] = useState<number>(1);
const [errors, setErrors] = useState([]);
const [experienceErrors, setExperienceErrors] = useState([]);
const [contributionErrors, setContributionErrors] = useState([]);
const [dropDownValues, setDropDownValues] = useState({});
const [emailExists, setEmailExists] = useState<boolean>(false);
const [imageUrl, setImageUrl] = useState<string>();
Expand All @@ -254,7 +254,7 @@ export function AddMemberModal({
comments: '',
teamAndRoles: [{ teamUid: '', teamTitle: '', role: '', rowId: 1 }],
skills: [],
experience: [],
projectContributions: [],
openToWork: false,
});

Expand Down Expand Up @@ -301,7 +301,7 @@ export function AddMemberModal({
comments: '',
teamAndRoles: [{ teamUid: '', teamTitle: '', role: '', rowId: 1 }],
skills: [],
experience: [],
projectContributions: [],
openToWork: false,
});
}
Expand Down Expand Up @@ -387,14 +387,9 @@ export function AddMemberModal({
}
);
const values = formatData();
values.experience = [...values.experience].map(v => {
delete v.logoUrl;
if (v.logoUid === 0) {
delete v.logoUid
}
if(v.endDate === null) {
delete v.endDate
}
values.projectContributions = [...values.projectContributions].map(v => {
delete v.projectName;
delete v.projectLogo;
return v
})
try {
Expand Down Expand Up @@ -539,11 +534,11 @@ export function AddMemberModal({
);
case 3:
return (
<AddMemberExperience
<ProjectContribution
formValues={formValues}
onChange={handleInputChange}
experienceErrors={experienceErrors}
setExperienceErrors={setExperienceErrors}
contributionErrors={contributionErrors}
setContributionErrors={setContributionErrors}
/>
);
case 4:
Expand Down Expand Up @@ -626,7 +621,7 @@ export function AddMemberModal({
setFormStep,
handleSubmit,
setErrors,
setExperienceErrors,
setContributionErrors,
isProcessing,
emailExists,
disableNext,
Expand Down
Loading