Skip to content
Open
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
12 changes: 8 additions & 4 deletions src/validations/Opportunity.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ export const OpportunityValidations = Yup.object({
(value) => value && !value.endsWith(' ') && !value.startsWith(' ')
),
pin_code,
earning_type: Yup.string().when('type', {
is: 'Freelance',
then: (schema) => schema.required('Earning type is required when type is Freelance.'),
otherwise: (schema) => schema.optional(),
earning_type: Yup.string()
.nullable()
.when("type", {
is: "Freelance",
then: (schema) =>
schema.required("Earning type is required when type is Freelance."),
otherwise: (schema) => schema.notRequired(),
}),


});

export const EmployerOpportunityValidations = Yup.object({
Expand Down
1 change: 0 additions & 1 deletion src/validations/Student.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export const EmploymentConnectionValidations = Yup.object({
work_engagement,
assigned_to,
earning_type: Yup.string().required("Earning type is required."),

});

export const OpportunityEmploymentConnectionValidations = Yup.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getStateDistricts,
} from "../../Address/addressActions";
import { searchBatches, searchInstitutions } from "./operationsActions";
import {getOrgsPicklist,searchEmployers} from "./operationsActions"
import { connect } from "react-redux";
import { RowsData } from "./RowsData";

Expand All @@ -29,6 +30,8 @@ const OperationCreateform = (props) => {
const { setAlert } = props;
let iconStyles = { color: "#257b69", fontSize: "1.5em" };
const [classValue, setclassValue] = useState({});
const [organizationOptions, setOrganizationOptions] = useState([]);


const userId = localStorage.getItem("user_id");

Expand Down Expand Up @@ -212,7 +215,11 @@ const OperationCreateform = (props) => {
);
});
}
updateRow(rowid, key, options.value);



updateRow(rowid, key, options ? options.value : null);

};
const updateRow = (id, field, value) => {
const updatedRows = rows.map((row) => {
Expand All @@ -233,6 +240,10 @@ const OperationCreateform = (props) => {
};

useEffect(() => {
getOrgsPicklist("name", "employers").then((data) => {
setOrganizationOptions(data);
})

getAddressOptions().then((data) => {
setStateOptions(
data?.data?.data?.geographiesConnection.groupBy.state
Expand All @@ -246,6 +257,24 @@ const OperationCreateform = (props) => {
});
}, []);



const filterOrganization = async (filterValue) => {
try {
const { data } = await searchEmployers(filterValue);
let filterData = data.employersConnection.values.map((org) => {
return {
...org,
label: org.name,
value: Number(org.id),
};
});
return filterData;
} catch (error) {
console.error(error);
}
}

const handleInputChange = (e, index, field) => {
const { value } = e;
setData((prevRows) =>
Expand Down Expand Up @@ -450,6 +479,9 @@ const OperationCreateform = (props) => {
{rows.map((row, id) => (
<tr key={id} className="mt-4">
<RowsData
organizationOptions={organizationOptions}
filterOrganization={filterOrganization}
setOrganizationOptions={setOrganizationOptions}
key={id}
handleInputChange={handleInputChange}
handleChange={handleChange}
Expand Down
57 changes: 31 additions & 26 deletions src/views/OperationsModule/OperationComponents/operationsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,40 @@ import {
SEARCH_BY_STUDENTS,
SEARCH_BY_PROGRAMS,
UPDATE_MENTORSHIP,
SEARCH_EMPLOYERS,
GET_COLLEGES_BY_PROJECT_NAME
} from "../../../graphql/operations";



export const getOrgsPicklist = async (field, table)=>{
try {
const response = await api.get(`/users-ops-activities/custom-picklist/${table}/${field}`);
return response.data;
} catch (error) {
console.error("Error fetching organization picklist:", error);
throw error;

}
}

export const searchEmployers = async function (searchValue) {
try {
const { data } = await api.post("/graphql", {
query: SEARCH_EMPLOYERS,
variables: {
limit: 20,
sort: "name:asc",
query: searchValue,
},
});

return data;
} catch (error) {
console.error(error.message);
}
};

export const searchPrograms = async function (searchValue) {
try {
const { data } = await api.post("/graphql", {
Expand Down Expand Up @@ -974,30 +1005,4 @@ export const getCurriculumInterventionFieldValues = async (field) => {
}
};

export const getOrgsPicklist = async (field, table) => {
try {
const response = await api.get(`/users-ops-activities/custom-picklist/${table}/${field}`);
return response.data;
} catch (error) {
console.error("Error fetching organization picklist:", error);
throw error;

}
}

export const searchEmployers = async function (searchValue) {
// try {
// const { data } = await api.post("/graphql", {
// query: SEARCH_EMPLOYERS,
// variables: {
// limit: 20,
// sort: "name:asc",
// query: searchValue,
// },
// });

// return data;
// } catch (error) {
// console.error(error.message);
// }
};
3 changes: 3 additions & 0 deletions src/views/Opportunities/OpportunityComponents/Details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ const Details = (props) => {
<div className="row latto-regular">
<div className="col-6 col-md-4">
<DetailField label="Role/Designation" className="capitalize" value={role_or_designation} />
{type === "Freelance" && (
<DetailField label="Earning Type" value={earning_type} />
)}
<DetailField label="Employer" value={<Anchor text={employer ? employer.name : ''} href={`/employer/${employer?.id}`} />} />
{/* <DetailField label="Location" value={employer ? employer.address : ''} /> */}
<DetailField label="No. of openings" value={number_of_opportunities} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const EmploymentConnection = (props) => {
<DetailField label="Student" value={student.full_name} />
<DetailField label="Employer" value={(isSRM() || isAdmin()) ? <Anchor text={employerName} href={`/employer/${ employmentConnection?.opportunity?.employer?.id }`} /> : employerName} />
<DetailField label="Opportunity" value={employmentConnection.opportunity ? employmentConnection.opportunity.role_or_designation : ''} />
{employmentConnection?.opportunity?.type && employmentConnection.opportunity.type === "Freelance" ? <DetailField label="Earning Type" value={employmentConnection.earning_type ? employmentConnection.earning_type :''} /> : ''}
<DetailField label="Opportunity Type" value={employmentConnection.opportunity ? <Badge value={employmentConnection.opportunity.type} pickList={opportunitiesPickList.type} /> : ''} />
{employmentConnection?.opportunity?.type && employmentConnection.opportunity.type === "Freelance" ? <DetailField label="Earning Type" value={employmentConnection.earning_type ? employmentConnection.earning_type :''} /> : ''}

Expand Down