Skip to content

Commit

Permalink
Merge pull request #684 from NIUANULP/revert-664-category
Browse files Browse the repository at this point in the history
Revert "TASK : #0000 Event crtificate functionality"
  • Loading branch information
paritshivani authored Oct 10, 2024
2 parents 925e6b3 + d994fef commit 3ece1f7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 88 deletions.
3 changes: 1 addition & 2 deletions packages/nulp_elite/src/configs/urlConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@
"ADD_CERTIFICATE": "v1/add/template",
"ATTACH_CERTIFICATE": "v1/template/add",
"CREATE_CERT_TEMPLATE": "asset/v1/create",
"UPLOAD_CERT_TEMPLATE": "asset/v1/upload",
"CUSTOM_CERTIFICATE_CREATE": "/custom_event/certificate/create"
"UPLOAD_CERT_TEMPLATE": "asset/v1/upload"
},
"COMPOSITE": {
"SEARCH": "composite/v1/search",
Expand Down
86 changes: 0 additions & 86 deletions packages/nulp_elite/src/pages/events/eventDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ const EventDetails = () => {
const [isChecked, setIsChecked] = useState(false);
const [open, setOpen] = React.useState(false);
const [recording, setRecording] = useState();
const [batchCertData,setBatchCertData] = useState();
const [isCertificateIssued , setIsCertificateIssued] = useState(true)
const [isAllreadyFilledRegistation,setIsAlreadyFilledRegistration] = useState(true)
const [isExpired , setIsExpired] = useState(false)
const handleClickOpen = () => {
Expand Down Expand Up @@ -288,8 +286,6 @@ const formatTimeWithTimezone = (date) => {
getUserData(_userId, "loggedIn");
fetchMyEvents();
getEventRecording();
fetchData();
checkCertificateAlreadyIssued();
// checkEnrolledCourse();
}, [_userId, eventId]);

Expand All @@ -312,7 +308,6 @@ const formatTimeWithTimezone = (date) => {

const { result } = response.data;
const { response: batchResponse } = result;
setBatchCertData(response.data.result)

if (batchResponse && batchResponse.count === 0) {
showErrorMessage(t("This course has no active Batches"));
Expand Down Expand Up @@ -460,83 +455,6 @@ const formatTimeWithTimezone = (date) => {
});
};

const fetchData = async () => {
try {
const url = `${urlConfig.URLS.LEARNER_PREFIX}${urlConfig.URLS.USER.GET_PROFILE}${_userId}?fields=${urlConfig.params.userReadParam.fields}`;

const header = "application/json";
const response = await fetch(url, {
// headers: {
// "Content-Type": "application/json",
// },
});
const data = await response.json();
setUserData(data);
} catch (error) {
console.error("Error fetching user data:", error);
showErrorMessage(t("FAILED_TO_FETCH_DATA"));
}
};

const checkCertificateAlreadyIssued = async () => {
try{
const url = `${urlConfig.URLS.LEARNER_PREFIX}${urlConfig.URLS.CERTIFICATE.CERTIF_SEARCH}`;
const requestBody = {
filters: {
recipient: {
id: {
eq: _userId
}
}
}
}
const resopnse = await axios.post(url, requestBody);
setIsCertificateIssued(resopnse.data.some((item) => item.training?.id === eventId));

}catch(error){
console.log("error While calling API ");
}

}

const generateCertificate = async () => {
const templateId = Object.keys(batchCertData?.response?.content[0]["certTemplates"])[0];
const certificateDetails = batchCertData?.response?.content[0]["certTemplates"][templateId];
try {
const url = `${urlConfig.URLS.CERTIFICATE.CUSTOM_CERTIFICATE_CREATE}`;
const requestBody = {
recipient: {
id: _userId,
name: userData?.result?.response?.firstName + " " + userData?.result?.response?.lastName,
type: "user",
},
issuer: certificateDetails?.issuer,
training: {
id: detailData?.identifier,
name: detailData?.name,
type: "Event",
batchId: batchData?.batchId,
},
templateUrl:
certificateDetails?.url,
status: "ACTIVE",
signatoryList:
certificateDetails?.signatoryList,
certificateLabel: "test",
issuedOn: new Date().toISOString(),
};
if(!isCertificateIssued){
const response = await axios.post(url, requestBody);
if(response.data.responseCode === "OK"){
setIsCertificateIssued(true)
}
}
} catch (error) {
console.error("Error creating certificate:", error);
}
};


const managePublicPrivateEvent = (button) => {
if (eventVisibility && eventVisibility === "Public" && button === "reg") {
handleOpenConsentModal();
Expand Down Expand Up @@ -947,10 +865,6 @@ const formatTimeWithTimezone = (date) => {
type="button"
onClick={() => {
managePublicPrivateEvent("join");
// generateCertificate();
if(detailData.issueCerificate === "Yes"){
generateCertificate();
}
}}
// onClick={attendWebinar}
style={{
Expand Down

0 comments on commit 3ece1f7

Please sign in to comment.