Skip to content

Commit

Permalink
Merge pull request #1043 from gitmedha/uploadExcel
Browse files Browse the repository at this point in the history
Mentorship excel uplaod
  • Loading branch information
naresh0101 authored Dec 10, 2024
2 parents a6644c1 + ae1c63d commit 1d7489b
Show file tree
Hide file tree
Showing 10 changed files with 1,191 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,6 @@ const statusOption = [
{ value: "Dropped out", label: "Dropped out" },
];

const Activityoptions = [
{ value: "Industry talk/Expert talk", label: "Industry talk/Expert talk" },
{
value: "Industry visit/Exposure visit",
label: "Industry visit/Exposure visit",
},
{
value: "Workshop/Training Session/Activity (In/Off campus)",
label: "Workshop/Training Session/Activity (In/Off campus)",
},
{ value: "Alumni Engagement", label: "Alumni Engagement" },
{ value: "Placement Drive", label: "Placement Drive" },
];

const UpdateMentorship = (props) => {
let { onHide, show, closeopsedit, refreshTableOnDataSaving } = props;
Expand Down
115 changes: 96 additions & 19 deletions src/views/OperationsModule/Operations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ import {
// import UploadFile from "./OperationComponents/UploadFile";
import { FaDownload, FaFileUpload, FaPlus } from "react-icons/fa";
import UploadFile from "./OperationComponents/UploadFile";
import TotUpload from "./UploadFiles/TotUpload";
import TotUpload from "./UploadFiles/TOT/TotUpload";
import MentorshipdataField from "./OperationComponents/Mentorship/MentorshipdataField";
import MentorBulkAdd from "./OperationComponents/Mentorship/MentorBulkAdd";
import MentorshipSearchbar from "./OperationComponents/Mentorship/MentorshipSearchbar";
import { createLatestAcivity } from "src/utils/LatestChange/Api";
import MentorshipUpload from "./UploadFiles/MentorShip/MentorshipUpload";
import UpskillUpdate from "./OperationComponents/UpskillUpdate";
import UpskillingUpload from "./UploadFiles/Upskilling/UpskillingUpload";

const tabPickerOptionsMain = [
{ title: "Core Programs", key: "coreProgramme" },
Expand Down Expand Up @@ -92,6 +95,8 @@ const Styled = styled.div`

const totfile=`https://medhasisstg.s3.ap-south-1.amazonaws.com/ToT-Template.xlsx`;
const feildActivityFIle='https://medhasisstg.s3.ap-south-1.amazonaws.com/Field-Activities-Template.xlsx'
const mentorshipFile='https://medhasisstg.s3.ap-south-1.amazonaws.com/Field-Activities-Template.xlsx'


const Operations = ({
opsData,
Expand Down Expand Up @@ -136,6 +141,9 @@ const Operations = ({
const [uploadModal, setUploadModal] = useState({
myData: false,
tot: false,
mentorship:false,
upskill:false,
pitching:false
});
const userId = localStorage.getItem("user_id");

Expand Down Expand Up @@ -536,7 +544,6 @@ const Operations = ({
variables,
})
.then((data) => {
console.log(data.data.data);
setOpts(data.data.data.activeMentoshipData.values);
setoptsAggregate(data.data.data.activeMentoshipData.aggregate);
})
Expand Down Expand Up @@ -1033,20 +1040,31 @@ const Operations = ({
let datavaluesforlatestcreate={};
try {
if (key === "my_data") {
datavaluesforlatestcreate={module_name:"Operations",activity:"Field Activities Upload File",event_id:"",updatedby:userId ,changes_in:{changes_in:"N/A"}};
datavaluesforlatestcreate={module_name:"Operations",activity:"Field Activities Upload File",event_id:"",updatedby:userId ,changes_in:{changes_in:{name:"N/A"}}};
await createLatestAcivity(datavaluesforlatestcreate);
await api.post("/users-ops-activities/createBulkOperations", data);
setAlert("Data created successfully.", "success");
}
if (key === "tot") {
datavaluesforlatestcreate={module_name:"Operations",activity:"User-Tot Upload File",event_id:"",updatedby:userId ,changes_in:{changes_in:"N/A"}};
datavaluesforlatestcreate={module_name:"Operations",activity:"User-Tot Upload File",event_id:"",updatedby:userId ,changes_in:{changes_in:{name:"N/A"}}};
await createLatestAcivity(datavaluesforlatestcreate);
await bulkCreateUsersTots(data)
.then(() => {
setAlert("data created successfully.", "success");
})
.catch((err) => {
setAlert("Unable to create upskilling data.", "error");
setAlert("Unable to create TOT data.", "error");
})
}
if (key === "mentorship") {
datavaluesforlatestcreate={module_name:"Operations",activity:"Mentorship Upload File",event_id:"",updatedby:userId ,changes_in:{changes_in:{name:"N/A"}}};
await createLatestAcivity(datavaluesforlatestcreate);
await bulkCreateMentorship(data)
.then(() => {
setAlert("data created successfully.", "success");
})
.catch((err) => {
setAlert("Unable to create Mentorship data.", "error");
})
}
getoperations()
Expand Down Expand Up @@ -1075,6 +1093,53 @@ const Operations = ({
setUploadModal(false);
};

const openclosepopup=()=>{
if (activeTab.key == "my_data") {
setUploadModal({
myData: true,
tot: false,
mentorship:false,
upskill:false,
pitching:true
});
} if(activeTab.key == "useTot") {
setUploadModal({
tot: true,
myData: false,
mentorship:false,
upskill:false,
pitching:true
});
}
if(activeTab.key == "mentorship"){
setUploadModal({
tot: false,
myData: false,
mentorship:true,
upskill:false,
pitching:true
});
}
if(activeTab.key == "upskilling"){
setUploadModal({
tot: false,
myData: false,
mentorship:false,
pitching:true,
upskill:true
});
}
if(activeTab.key == "collegePitches"){
setUploadModal({
tot: false,
myData: false,
mentorship:false,
upskill:false,
pitching:true
});
}
}

return (
<Collapse title="OPERATIONS" type="plain" opened={true}>
<Styled>
Expand Down Expand Up @@ -1115,21 +1180,11 @@ const Operations = ({
</span>
</button>

{activeTab.key == "my_data" || activeTab.key == "useTot" ? (
{activeTab.key == "my_data" || activeTab.key == "useTot" || activeTab.key =="mentorship" || activeTab.key == "upskilling" || activeTab.key == "collegePitches" ? (
<button
className="btn btn-primary ops_action_button"
onClick={() => {
if (activeTab.key == "my_data") {
setUploadModal({
myData: true,
tot: false,
});
} else {
setUploadModal({
tot: true,
myData: false,
});
}
openclosepopup()
}}
>
Upload &nbsp;
Expand All @@ -1140,14 +1195,14 @@ const Operations = ({
) : (
""
)}
{activeTab.key == "my_data" || activeTab.key == "useTot" ? (
{activeTab.key == "my_data" || activeTab.key == "useTot" || activeTab.key =="mentorship" || activeTab.key == "upskilling" || activeTab.key == "collegePitches"? (
<button className="btn btn-primary ops_action_button">
<div>
<a
href={
activeTab.key == "my_data"?
feildActivityFIle
:totfile}
: activeTab.key == "useTot" ? totfile: activeTab.key == "mentorship" ? mentorshipFile :""}
target="_blank"
className="c-pointer mb-1 d-block text-light text-decoration-none downloadLink"
download={
Expand Down Expand Up @@ -1419,6 +1474,28 @@ const Operations = ({
/>
</>
)}

{uploadModal.mentorship && (
<>
<MentorshipUpload
uploadExcel={uploadExcel}
// alertForNotuploadedData={alertForNotuploadedData}
closeThepopus={()=>closeUpload()}
mentorship="yes"
/>
</>
)}

{uploadModal.upskill && (
<>
<UpskillingUpload
// uploadExcel={uploadExcel}
// alertForNotuploadedData={alertForNotuploadedData}
closeThepopus={()=>closeUpload()}
mentorship="yes"
/>
</>
)}
</div>
</Styled>
</Collapse>
Expand Down
11 changes: 11 additions & 0 deletions src/views/OperationsModule/UploadFiles/CheckMentorship.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

function CheckMentorship() {
return (
<>

</>
)
}

export default CheckMentorship
163 changes: 163 additions & 0 deletions src/views/OperationsModule/UploadFiles/MentorShip/Check.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import React from "react";
import { Modal } from "react-bootstrap";
import { isAdmin, isSRM } from "../../../../common/commonFunctions";
import { useState, useEffect } from "react";
import Table from "react-bootstrap/Table";
import styled from "styled-components";

const Check = (props) => {
let { onHide } = props;

const isValidContact=(contact) =>{
const pattern = /^[0-9]{10}$/; // Regex for 10-digit number
return contact && pattern.test(contact);
}
return (
<>
<Modal
centered
size="xl"
show={props.show}
onHide={onHide}
animation={false}
aria-labelledby="contained-modal-title-vcenter"
className="form-modal"
id="custom-modal"
>
<Modal.Header className="bg-white">
<Modal.Title
id="contained-modal-title-vcenter"
className="d-flex align-items-center"
>
<h1 className="text--primary bebas-thick mb-0">
<p>Data Validation Failures</p>
</h1>
</Modal.Title>
</Modal.Header>
<Modal.Body className="bg-white hide-scrollbar">
<div style={{ width: "100%", height: "450px", overflow: "scroll" }}>
{props.notUploadedData.length > 0 ? (
<>
<Table striped bordered hover responsive size="sm">
<thead>
<tr>
<th>#</th>
<th>Assigned To</th>
<th>Mentor Name</th>
<th>Email</th>
<th>Mentor Domain</th>
<th>Mentor Company Name</th>
<th>Designation</th>
<th>Mentor Area</th>
<th>Mentor State</th>
<th>Outreach</th>
<th>Onboarding Date</th>
<th>Social Media Profile</th>
<th>Medha Area</th>
<th>Status</th>
<th>Program Name</th>
<th>Contact</th>
</tr>
</thead>
<tbody>
{props.notUploadedData.map((obj, i) => (
<tr key={i}>
<td>{obj.index}</td>
<td className={!obj.assigned_to ? "text-danger" : ""}>
{obj.assigned_to || "No data"}
</td>
<td className={!obj.mentor_name ? "text-danger" : ""}>
{obj.mentor_name || "No data"}
</td>
<td className={!obj.email ? "text-danger" : ""}>
{obj.email || "No data"}
</td>
<td className={!obj.mentor_domain ? "text-danger" : ""}>
{obj.mentor_domain || "No data"}
</td>
<td
className={
!obj.mentor_company_name ? "text-danger" : ""
}
>
{obj.mentor_company_name || "No data"}
</td>
<td className={!obj.designation ? "text-danger" : ""}>
{obj.designation || "No data"}
</td>
<td className={!obj.mentor_area ? "text-danger" : ""}>
{obj.mentor_area || "No data"}
</td>
<td className={!obj.mentor_state ? "text-danger" : ""}>
{obj.mentor_state || "No data"}
</td>
<td className={!obj.outreach ? "text-danger" : ""}>
{obj.outreach || "No data"}
</td>
<td
className={!obj.onboarding_date ? "text-danger" : ""}
>
{obj.onboarding_date || "No data"}
</td>
<td>
{obj.social_media_profile_link || "No data"}
</td>
<td className={!obj.medha_area ? "text-danger" : ""}>
{obj.medha_area || "No data"}
</td>
<td className={!obj.status ? "text-danger" : ""}>
{obj.status || "No data"}
</td>
<td className={!obj.program_name ? "text-danger" : ""}>
{obj.program_name || "No data"}
</td>
<td className={!isValidContact(obj.contact) ? "text-danger" : ""}>
{obj.contact || "No data"}
</td>
</tr>
))}
</tbody>
</Table>
</>
) : (
<div className="d-flex justify-content-center align-content-center">
<h2 className="text--primary bebas-thick mb-0"></h2>
</div>
)}
</div>
<div className="">
<h6 className="text-danger text-center">
There are 1 or more incorrect data in the Excel. Please correct
the ones shown in red and reupload the file.
</h6>
{(isSRM() || isAdmin()) && (
<div className="row mb-4">
<div className="col-md-12 d-flex justify-content-center">
{props.notUploadedData.length === 0 ? (
<button
type="button"
onClick={() => props.uploadExcel(props.excelData)}
className="btn btn-primary px-4"
>
Upload
</button>
) : (
<button
type="button"
className="btn btn-primary px-4"
onClick={() => onHide()}
>
ReUpload
</button>
)}
</div>
</div>
)}
</div>
</Modal.Body>
</Modal>
</>
);
};

export default Check;
Loading

0 comments on commit 1d7489b

Please sign in to comment.