integrated api for tab 3 contact details
This commit is contained in:
parent
53305ccd60
commit
7794ada908
@ -180,7 +180,9 @@ const ContactDetails = ({ props }) => {
|
|||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type={
|
type={
|
||||||
data?.campaignType === "email" ? "email" : "tel"
|
data?.campaignType === "email"
|
||||||
|
? "email"
|
||||||
|
: "number"
|
||||||
}
|
}
|
||||||
className="form-control"
|
className="form-control"
|
||||||
id={`contact-${index}`}
|
id={`contact-${index}`}
|
||||||
|
@ -10,36 +10,37 @@ const Preview = ({ props }) => {
|
|||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// console.log(data);
|
|
||||||
|
|
||||||
// const campaignData = {
|
const hasEmptyRecipients = data.recipients.some((recipient) => {
|
||||||
// campaignType: data.campaignType,
|
return !recipient.name || !recipient.contact;
|
||||||
// campaignName: data.campaignName,
|
});
|
||||||
// language: data.language,
|
|
||||||
// videoTemplate: data.video,
|
if (hasEmptyRecipients) {
|
||||||
// recipients: data.recipients,
|
swal({
|
||||||
// };
|
title: "Validation Error",
|
||||||
|
text: "Please fill Conatct details",
|
||||||
|
icon: "error",
|
||||||
|
button: "Close",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const formattedRecipients = data.recipients.map((recipient) => ({
|
const formattedRecipients = data.recipients.map((recipient) => ({
|
||||||
name: recipient.name,
|
name: recipient.name,
|
||||||
contact: recipient.contact.email || recipient.contact.phoneNumber,
|
contact: recipient.contact,
|
||||||
}));
|
}));
|
||||||
// console.log(data.campaignType);
|
|
||||||
|
|
||||||
const formData = new FormData();
|
const campaignData = {
|
||||||
formData.append("campaignType", data.campaignType);
|
campaignType: data.campaignType,
|
||||||
formData.append("campaignName", data.campaignName);
|
campaignName: data.campaignName,
|
||||||
formData.append("language", data.language);
|
language: data.language,
|
||||||
formData.append("videoTemplate", data.video);
|
recipients: formattedRecipients,
|
||||||
// formData.set("recipients",JSON.stringify(formattedRecipients));
|
};
|
||||||
// console.log("campaignData", campaignData);
|
|
||||||
// console.log("formData", formData);
|
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.post(`/api/campaign/create`, formData, {
|
.post(`/api/campaign/create`, campaignData, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
"Content-Type": "multipart/form-data",
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
"Access-Control-Allow-Origin": "*",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -51,10 +52,10 @@ const Preview = ({ props }) => {
|
|||||||
? res?.data?.message
|
? res?.data?.message
|
||||||
: "Campaign added successfully!",
|
: "Campaign added successfully!",
|
||||||
icon: "success",
|
icon: "success",
|
||||||
button: "Return",
|
button: "Close",
|
||||||
});
|
});
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
// handleView(5);
|
handleView(5);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@ -64,7 +65,7 @@ const Preview = ({ props }) => {
|
|||||||
title: "Warning",
|
title: "Warning",
|
||||||
text: message,
|
text: message,
|
||||||
icon: "error",
|
icon: "error",
|
||||||
button: "Retry",
|
button: "Close",
|
||||||
dangerMode: true,
|
dangerMode: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -100,9 +101,7 @@ const Preview = ({ props }) => {
|
|||||||
marginBottom: "1rem",
|
marginBottom: "1rem",
|
||||||
textTransform: "capitalize",
|
textTransform: "capitalize",
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={handleSubmit}
|
||||||
handleView(5);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Next
|
Next
|
||||||
</Button>
|
</Button>
|
||||||
@ -147,20 +146,6 @@ const Preview = ({ props }) => {
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="page-title-right d-flex justify-content-end">
|
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
color="primary"
|
|
||||||
style={{
|
|
||||||
fontWeight: "bold",
|
|
||||||
marginBottom: "1rem",
|
|
||||||
textTransform: "capitalize",
|
|
||||||
}}
|
|
||||||
onClick={handleSubmit}
|
|
||||||
>
|
|
||||||
{loading ? "Loading" : "Add Now"}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user