Skip to content

Commit

Permalink
Merge pull request #276 from Abhimanyu-dev/forms
Browse files Browse the repository at this point in the history
Proforma View Update
  • Loading branch information
bmerchant22 authored Jun 12, 2024
2 parents 03d02dc + 8a59d8d commit 2bf7f89
Show file tree
Hide file tree
Showing 8 changed files with 1,666 additions and 802 deletions.
27 changes: 26 additions & 1 deletion callbacks/admin/rc/adminproforma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,32 @@ export interface AdminProformaType {
additional_eligibility: string;
message_for_cordinator: string;
company_name: string;
cpi_cutoff: number;
postal_address: string;
establishment_date: string;
total_employees: string;
social_media: string;
website: string;
turnover: string;
type_of_org: string;
head_office: string;
min_hires: string;
total_hires: string;
skill_set: string;
pwd: string;
cpi_criteria: string;
backlog_eligibility: string;
ctc_inr: string;
ctc_fr: string;
gross: string;
take_home: string;
base: string;
joining_bonus: string;
relocation_bonus: string;
first_ctc: string;
medical_allowance: string;
retention_bonus: string;
deductions: string;
perks: string;
}

export interface ProformaResponse {
Expand Down
231 changes: 180 additions & 51 deletions pages/admin/rc/[rcid]/proforma/[proformaid]/step1.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { Button, Card, FormControl, Stack, TextField } from "@mui/material";
import {
Button,
Card,
Checkbox,
FormControl,
InputLabel,
ListItemText,
MenuItem,
Select,
SelectChangeEvent,
Stack,
TextField,
} from "@mui/material";
import React, { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { useRouter } from "next/router";

import Meta from "@components/Meta";
import RichTextEditor from "@components/Editor/RichText";
import useStore from "@store/store";
import requestProforma, {
AdminProformaType,
Expand All @@ -13,14 +24,34 @@ import requestCompany, { CompanyRc } from "@callbacks/admin/rc/company";

const ROUTE = "/admin/rc/[rcId]/proforma/[proformaid]/step2";
function ProformaNew() {
const [value, onChange] = useState("");
const [industrySectors, setIndustrySectors] = useState<string[]>([]);
const [type, setType] = useState<string>("");
const [industrySectorsString, setIndustrySectorsString] =
useState<string>("");
const { token, name } = useStore();
const router = useRouter();
const { rcid, proformaid } = router.query;
const rid = (rcid || "").toString();
const pid = (proformaid || "").toString();
const [companies, setCompanies] = useState<CompanyRc[]>([]);
const [company, setCompany] = useState("");

const handleIndustrySectorChange = (event: SelectChangeEvent<string[]>) => {
const {
target: { value },
} = event;
const selectedValues = typeof value === "string" ? value.split(",") : value;
setIndustrySectors(selectedValues);
setIndustrySectorsString(selectedValues.join(", ")); // Store the comma-separated string
};
const handleTypeChange = (event: SelectChangeEvent<string>) => {
const {
target: { value },
} = event;
const selectedValue = value;
setType(selectedValue);
};

const [fetchData, setFetch] = useState<AdminProformaType>({
ID: 0,
} as AdminProformaType);
Expand Down Expand Up @@ -52,8 +83,9 @@ function ProformaNew() {
getCompanydata();
const getStep1 = async () => {
data = await requestProforma.get(token, rid, pid);
onChange(data.job_description);
setFetch(data);
setIndustrySectors(data.role.split(","));
setType(data.type_of_org);
reset(data);
};
getStep1();
Expand All @@ -63,8 +95,9 @@ function ProformaNew() {
const info: AdminProformaType = {
...data,
ID: parseInt(pid, 10),
job_description: value,
recruitment_cycle_id: parseInt(rid, 10),
role: industrySectorsString,
type_of_org: type,
};
const res = await requestProforma.put(token, rid, info);
if (res) {
Expand All @@ -73,7 +106,6 @@ function ProformaNew() {
role: "",
tentative_job_location: "",
});
onChange("");
router.push({
pathname: ROUTE,
query: { rcId: rid, proformaid: pid },
Expand All @@ -82,7 +114,7 @@ function ProformaNew() {
};
return (
<div>
<Meta title="Step 1 - Basic Details" />
<Meta title="Step 1 - Company Details" />
<Card
elevation={5}
sx={{
Expand All @@ -97,80 +129,178 @@ function ProformaNew() {
<TextField
id="Cname"
disabled
value={company}
required
value={company}
sx={{ marginLeft: "5 rem" }}
fullWidth
multiline
variant="standard"
{...register("company_name")}
/>
</FormControl>
<FormControl sx={{ m: 1 }}>
<p style={{ fontWeight: 300 }}>Nature of Business</p>
<p style={{ fontWeight: 300 }}>Postal Address</p>
<TextField
id="NatureOfBusiness"
id="postalAddress"
required
sx={{ marginLeft: "5 rem" }}
fullWidth
multiline
helperText={errors.company_name && "This field is required"}
variant="standard"
error={!!errors.role}
helperText={errors.role?.message}
{...register("role", {
required: "Role is required",
maxLength: {
value: 100,
message: "Role length should be less than 100",
},
{...register("postal_address", {
required: "Postal Address is required",
})}
/>
</FormControl>

<FormControl sx={{ m: 1 }}>
<p style={{ fontWeight: 300 }}>Profile</p>
<p style={{ fontWeight: 300 }}>Date of Establishment</p>
<TextField
id="Profile"
id="dateOfEstablishment"
type="date"
required
sx={{ marginLeft: "5 rem" }}
fullWidth
multiline
variant="standard"
error={!!errors.profile}
helperText={errors.profile?.message}
{...register("profile", {
required: "Profile is required",
maxLength: {
value: 100,
message: "Profile length should be less than 100",
},
InputLabelProps={{
shrink: true,
}}
{...register("establishment_date", {
required: "Date of Establishment is required",
})}
/>
</FormControl>

<FormControl sx={{ m: 1 }}>
<p style={{ fontWeight: 300 }}>Tentative Job Location</p>
<p style={{ fontWeight: 300 }}>Number of Employees</p>
<TextField
id="TentativeJobDescription"
id="numberOfEmployees"
required
fullWidth
variant="standard"
{...register("total_employees", {
required: "Number of Employees is required",
})}
/>
</FormControl>

<FormControl sx={{ m: 1 }}>
<p style={{ fontWeight: 300 }}>Social Media Page Link (optional)</p>
<TextField
id="socialMediaPageLink"
fullWidth
variant="standard"
{...register("social_media")}
/>
</FormControl>

<FormControl sx={{ m: 1 }}>
<p style={{ fontWeight: 300 }}>Website</p>
<TextField
id="website"
required
sx={{ marginLeft: "5 rem" }}
fullWidth
multiline
variant="standard"
error={!!errors.tentative_job_location}
helperText={
errors.tentative_job_location && "This field is required"
}
{...register("tentative_job_location", { required: true })}
{...register("website", {
required: "Website is required",
})}
/>
</FormControl>

<FormControl sx={{ m: 1 }}>
<p style={{ fontWeight: 300 }}>Company Turnover for NIRF Purpose</p>
<TextField
id="companyTurnover"
required
fullWidth
variant="standard"
{...register("turnover", {
required: "Company Turnover is required",
})}
/>
</FormControl>
{fetchData.ID !== 0 && (
<FormControl sx={{ m: 1 }}>
<p style={{ fontWeight: 300 }}>Job Description</p>
<RichTextEditor
value={fetchData.job_description}
onChange={onChange}
style={{ minHeight: 200 }}
/>
</FormControl>
)}

<FormControl sx={{ m: 1 }}>
<InputLabel>Type of Organization</InputLabel>
<Select
id="typeOfOrganization"
required
fullWidth
variant="standard"
value={type}
onChange={handleTypeChange}
renderValue={(selected) => selected}
>
<MenuItem value="Private (Indian/Foreign)">
Private (Indian/Foreign)
</MenuItem>
<MenuItem value="Multi National Company (Indian Origin)">
Multi National Company (Indian Origin)
</MenuItem>
<MenuItem value="Multi National Company (Foreign Origin)">
Multi National Company (Foreign Origin)
</MenuItem>
<MenuItem value="Government">Government</MenuItem>
<MenuItem value="Public Sector Undertakings (Indian)">
Public Sector Undertakings (Indian)
</MenuItem>
<MenuItem value="Non-Government Organisation">
Non-Government Organisation
</MenuItem>
<MenuItem value="STARTUP">STARTUP</MenuItem>
<MenuItem value="Others">Others</MenuItem>
</Select>
</FormControl>

<FormControl sx={{ m: 1 }}>
<p style={{ fontWeight: 300 }}>
Location and Head office of the parent company (if MnC)
</p>
<TextField
id="mncDetails"
fullWidth
variant="standard"
{...register("head_office")}
/>
</FormControl>

<FormControl sx={{ m: 1 }}>
<InputLabel>Nature of Business / Industry Sector</InputLabel>
<Select
id="NatureOfBusiness"
multiple
fullWidth
variant="standard"
value={industrySectors}
onChange={handleIndustrySectorChange}
renderValue={(selected) => selected.join(", ")}
>
{[
"Core Engineering & Technology",
"Analytics",
"IT / Software",
"Oil & Gas / Energy",
"Data Science/ AI/ ML",
"Cyber Security",
"Finance & Consulting",
"Management",
"Academics/Research",
"Media",
"E-Commerce",
"Construction",
"Design",
"Manufacturing",
"Infrastructure",
"HealthCare/ Biomedical",
"Edutech",
"Policy",
].map((sector) => (
<MenuItem key={sector} value={sector}>
<Checkbox checked={industrySectors.indexOf(sector) > -1} />
<ListItemText primary={sector} />
</MenuItem>
))}
</Select>
</FormControl>

<Stack
spacing={3}
Expand All @@ -195,7 +325,6 @@ function ProformaNew() {
role: "",
tentative_job_location: "",
});
onChange("");
}}
>
Reset
Expand Down
2 changes: 1 addition & 1 deletion pages/admin/rc/[rcid]/proforma/[proformaid]/step2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function Step2() {
<div>
<Meta title="Step 2 - New Opening" />
<Card sx={{ padding: 3 }}>
<h2>Step 2/5 (Eligibility Matrix)</h2>
<h2>Step 2 (Eligibility Matrix)</h2>
<Stack spacing={4} alignItems="center">
<Stack spacing={1}>
<Stack spacing={4} direction="row" alignItems="center">
Expand Down
Loading

0 comments on commit 2bf7f89

Please sign in to comment.