admin demo deploy
This commit is contained in:
parent
205552d559
commit
645a89aa43
10
src/_nav.js
10
src/_nav.js
@ -36,7 +36,8 @@ import {
|
|||||||
cilTags,
|
cilTags,
|
||||||
cilTennisBall,
|
cilTennisBall,
|
||||||
cilText,
|
cilText,
|
||||||
cilUser,
|
cilUser
|
||||||
|
,
|
||||||
} from "@coreui/icons";
|
} from "@coreui/icons";
|
||||||
import { CNavGroup, CNavItem, CNavTitle } from "@coreui/react";
|
import { CNavGroup, CNavItem, CNavTitle } from "@coreui/react";
|
||||||
|
|
||||||
@ -143,6 +144,13 @@ const _nav = [
|
|||||||
icon: <CIcon icon={cilUser} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilUser} customClassName="nav-icon" />,
|
||||||
to: "/recipents",
|
to: "/recipents",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
component: CNavItem,
|
||||||
|
name: "Campaigns",
|
||||||
|
icon: <CIcon icon={cilUser
|
||||||
|
} customClassName="nav-icon" />,
|
||||||
|
to: "/campaigns",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
component: CNavGroup,
|
component: CNavGroup,
|
||||||
name: "Configuration",
|
name: "Configuration",
|
||||||
|
@ -14,8 +14,8 @@ import { createRoot } from "react-dom/client";
|
|||||||
|
|
||||||
const setupAxios = () => {
|
const setupAxios = () => {
|
||||||
//axios.defaults.baseURL = 'https://bolo-api.checkapp.one/'
|
//axios.defaults.baseURL = 'https://bolo-api.checkapp.one/'
|
||||||
//axios.defaults.baseURL = "http://localhost:5000";
|
axios.defaults.baseURL = "http://localhost:8000";
|
||||||
axios.defaults.baseURL = "https://boloai-api.onrender.com"; //->USE THIS
|
// axios.defaults.baseURL = "https://boloai-api.onrender.com"; //->USE THIS
|
||||||
|
|
||||||
axios.defaults.headers = {
|
axios.defaults.headers = {
|
||||||
"Cache-Control": "no-cache,no-store",
|
"Cache-Control": "no-cache,no-store",
|
||||||
|
@ -80,6 +80,8 @@ import ViewAppointment from "./views/Appointments/ViewAppointment";
|
|||||||
import EditAppointment from "./views/Appointments/EditAppointment";
|
import EditAppointment from "./views/Appointments/EditAppointment";
|
||||||
import AddNewAppointment from "./views/Appointments/AddNewAppointment";
|
import AddNewAppointment from "./views/Appointments/AddNewAppointment";
|
||||||
import ViewHealthCareProvider from "./views/Business/ViewHealthCareProvider";
|
import ViewHealthCareProvider from "./views/Business/ViewHealthCareProvider";
|
||||||
|
import Campaign from "./views/Campaigns/Campaign.js";
|
||||||
|
import AddCampaign from "./views/Campaigns/AddCampaign.js";
|
||||||
const routes = [
|
const routes = [
|
||||||
{ path: "/", exact: true, name: "Home" },
|
{ path: "/", exact: true, name: "Home" },
|
||||||
{
|
{
|
||||||
@ -141,8 +143,37 @@ const routes = [
|
|||||||
element: ViewHealthCareProvider,
|
element: ViewHealthCareProvider,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
path: "//campaigns",
|
||||||
|
name: "campaigns",
|
||||||
|
element: Campaign,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "//campaign/add",
|
||||||
|
name: "Add Campaigns",
|
||||||
|
element: AddCampaign,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/campaigns/edit/:id",
|
||||||
|
name: "Edit healthcare providers",
|
||||||
|
element: EditBusiness,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/campaigns/view/:id",
|
||||||
|
name: "view healthcare providers",
|
||||||
|
element: ViewHealthCareProvider,
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// { path: '/franchisee/view/:id', name: 'view franchisee', element: ViewFra },
|
// { path: '/franchisee/view/:id', name: 'view franchisee', element: ViewFra },
|
||||||
//Contact Requests
|
//Contact Requests
|
||||||
|
|
||||||
{
|
{
|
||||||
path: "/contact/request",
|
path: "/contact/request",
|
||||||
name: "Contact Requests",
|
name: "Contact Requests",
|
||||||
|
323
src/views/Campaigns/AddCampaign.js
Normal file
323
src/views/Campaigns/AddCampaign.js
Normal file
@ -0,0 +1,323 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
// import { Button } from '@mui/material'
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
import { Link, useNavigate } from "react-router-dom";
|
||||||
|
import {
|
||||||
|
CCard,
|
||||||
|
CCardBody,
|
||||||
|
CCardGroup,
|
||||||
|
CCol,
|
||||||
|
CContainer,
|
||||||
|
CRow,
|
||||||
|
} from "@coreui/react";
|
||||||
|
// import SelectPurpose from "../Business/multiform/SelectPurpose.js";
|
||||||
|
// import SelectBusiness from "../Business/multiform/SelectBusiness.js";
|
||||||
|
// import Contacts from "../Business/multiform/Contacts.js";
|
||||||
|
// import BAddress from "../Business/multiform/BAddress.js";
|
||||||
|
import Button from "@material-ui/core/Button";
|
||||||
|
|
||||||
|
import { isAutheticated } from "src/auth";
|
||||||
|
// import DoctorInfo from "../Business/multiform/DoctorInfo.js";
|
||||||
|
import BasicDetaiils from "./BasicDetaiils.js";
|
||||||
|
import ContactDetails from "./ContactDetails.js";
|
||||||
|
import Preview from "./Preview.js";
|
||||||
|
|
||||||
|
const AddCampaign = () => {
|
||||||
|
const token = isAutheticated();
|
||||||
|
const [productId, setProductId] = useState("");
|
||||||
|
const [viewState, setViewState] = useState(1);
|
||||||
|
// const [WebsiteURL, setWebsiteURL] = useState('https://bolo.ai.in/')
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const [data, setData] = useState({
|
||||||
|
WebsiteURL: "https://bolo.ai.in/",
|
||||||
|
campaignName: "",
|
||||||
|
language: "",
|
||||||
|
campaignType: "",
|
||||||
|
video: null,
|
||||||
|
recipients: [{ name: "", phoneNumber: "" }],
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log(data)
|
||||||
|
|
||||||
|
const handleView = (n) => {
|
||||||
|
if (viewState === n) return;
|
||||||
|
setViewState(n);
|
||||||
|
};
|
||||||
|
// const handleSubmit = () => {
|
||||||
|
|
||||||
|
// if (
|
||||||
|
// data.address_Line_1.trim() === "" ||
|
||||||
|
// data.address_Line_2.trim() === "" ||
|
||||||
|
// data.userType === "" ||
|
||||||
|
// data.language === "" ||
|
||||||
|
// data.country === "" ||
|
||||||
|
// data.state === "" ||
|
||||||
|
// data.city === "" ||
|
||||||
|
// data.pincode.trim() === "" ||
|
||||||
|
// //Contacts
|
||||||
|
// // data.image === '' ||
|
||||||
|
// // data.imageURL.trim() === '' ||
|
||||||
|
// (data.userName.trim() === ""
|
||||||
|
// // &&
|
||||||
|
// // (data.contact_Person_Name.trim() === "" ||
|
||||||
|
// // data.specialization === "")
|
||||||
|
// ) ||
|
||||||
|
// data.email.trim() === "" ||
|
||||||
|
// // data.short_url.trim() === "" ||
|
||||||
|
// data.contact_Number === ""
|
||||||
|
// // || data.contact_Person_Name.trim() === ""
|
||||||
|
// ) {
|
||||||
|
// swal({
|
||||||
|
// title: "Warning",
|
||||||
|
// text: "Fill all mandatory fields",
|
||||||
|
// icon: "error",
|
||||||
|
// button: "Close",
|
||||||
|
// dangerMode: true,
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// setLoading(true);
|
||||||
|
// const formData = new FormData();
|
||||||
|
// formData.set("address_Line_1", data.address_Line_1);
|
||||||
|
// formData.set("address_Line_2", data.address_Line_2);
|
||||||
|
|
||||||
|
// formData.set("purpose", data.purpose);
|
||||||
|
// formData.set("userType", data.userType);
|
||||||
|
// // formData.set("language", data.language);
|
||||||
|
|
||||||
|
// formData.set("country", data.country);
|
||||||
|
// formData.set("city", data.city);
|
||||||
|
// formData.set("state", data.state);
|
||||||
|
|
||||||
|
// formData.set("pincode", data.pincode);
|
||||||
|
// //contacts
|
||||||
|
// formData.set("userName", data.userName);
|
||||||
|
// formData.set("email", data.email);
|
||||||
|
|
||||||
|
// formData.set("contact_Number", data.contact_Number);
|
||||||
|
// formData.set("contact_Person_Name", data.contact_Person_Name);
|
||||||
|
|
||||||
|
// formData.set("specialization", data.specialization);
|
||||||
|
|
||||||
|
// formData.set("url", data.WebsiteURL);
|
||||||
|
// formData.set("short_url", data.short_url);
|
||||||
|
|
||||||
|
// axios
|
||||||
|
// .post(`/api/businesses/add`, formData, {
|
||||||
|
// headers: {
|
||||||
|
// Authorization: `Bearer ${token}`,
|
||||||
|
// "Content-Type": "multipart/formdata",
|
||||||
|
// "Access-Control-Allow-Origin": "*",
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// swal({
|
||||||
|
// title: "Added",
|
||||||
|
// text: res?.data?.message
|
||||||
|
// ? res?.data?.message
|
||||||
|
// : "Business added successfully!",
|
||||||
|
// icon: "success",
|
||||||
|
// button: "Return",
|
||||||
|
// });
|
||||||
|
// setLoading(false);
|
||||||
|
// navigate("/users", { replace: true });
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// setLoading(false);
|
||||||
|
// const message = err.response?.data?.message || "Something went wrong!";
|
||||||
|
// swal({
|
||||||
|
// title: "Warning",
|
||||||
|
// text: message,
|
||||||
|
// icon: "error",
|
||||||
|
// button: "Retry",
|
||||||
|
// dangerMode: true,
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<CContainer>
|
||||||
|
<CRow className="mt-3">
|
||||||
|
<CCol md={12}>
|
||||||
|
<div
|
||||||
|
className="
|
||||||
|
page-title-box
|
||||||
|
d-flex
|
||||||
|
align-items-center
|
||||||
|
justify-content-between
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
Add Campaign
|
||||||
|
</div>
|
||||||
|
<div className="page-title-right">
|
||||||
|
<div className="page-title-right">
|
||||||
|
{/* <Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
handleSubmit();
|
||||||
|
}}
|
||||||
|
disabled={
|
||||||
|
data.address_Line_1.trim() === "" ||
|
||||||
|
data.address_Line_2.trim() === "" ||
|
||||||
|
data.userType === "" ||
|
||||||
|
data.language === "" ||
|
||||||
|
data.country === "" ||
|
||||||
|
data.state === "" ||
|
||||||
|
data.city === "" ||
|
||||||
|
data.pincode.trim() === "" ||
|
||||||
|
data.userName.trim() === "" ||
|
||||||
|
// &&
|
||||||
|
// (data.contact_Person_Name.trim() === "" ||
|
||||||
|
// data.specialization === "")
|
||||||
|
data.email.trim() === "" ||
|
||||||
|
// data.short_url.trim() === "" ||
|
||||||
|
data.contact_Number === ""
|
||||||
|
// ||
|
||||||
|
// data.contact_Person_Name.trim() === ""
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{loading ? "Loading" : "Add Now"}
|
||||||
|
</Button> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CCol>
|
||||||
|
</CRow>
|
||||||
|
<CRow>
|
||||||
|
<CCol md={9} className="mt-1">
|
||||||
|
<CCardGroup>
|
||||||
|
<CCard className="p-4 mb-3">
|
||||||
|
<CCardBody>
|
||||||
|
{viewState === 1 && (
|
||||||
|
<BasicDetaiils
|
||||||
|
props={{ data, setData, handleView }}
|
||||||
|
setData={setData}
|
||||||
|
handleView={handleView}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{viewState === 2 && (
|
||||||
|
<ContactDetails props={{ data, setData, handleView }} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{viewState === 3 && (
|
||||||
|
<Preview props={{ data, setData, handleView }} />
|
||||||
|
)}
|
||||||
|
{viewState === 4 && (
|
||||||
|
<BAddress
|
||||||
|
data={{ data, setData }}
|
||||||
|
handleView={handleView}
|
||||||
|
// productId={productId}
|
||||||
|
// data={{ images, setImages }}
|
||||||
|
loading={{ loading, setLoading }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</CCardBody>
|
||||||
|
</CCard>
|
||||||
|
</CCardGroup>
|
||||||
|
</CCol>
|
||||||
|
<CCol md={3} className="mt-1">
|
||||||
|
<CCardGroup>
|
||||||
|
<CCard>
|
||||||
|
<CCardBody>
|
||||||
|
<div className="d-grid gap-2">
|
||||||
|
<button
|
||||||
|
className={
|
||||||
|
viewState === 1
|
||||||
|
? "btn btn-light"
|
||||||
|
: "btn btn-info text-white"
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleView(1)}
|
||||||
|
>
|
||||||
|
Basic Details
|
||||||
|
</button>
|
||||||
|
{/*<button
|
||||||
|
className={
|
||||||
|
viewState === 2
|
||||||
|
? "btn btn-light"
|
||||||
|
: "btn btn-info text-white"
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleView(2)}
|
||||||
|
>
|
||||||
|
Select Purpose
|
||||||
|
</button>*/}
|
||||||
|
<button
|
||||||
|
className={
|
||||||
|
viewState === 2
|
||||||
|
? "btn btn-light"
|
||||||
|
: "btn btn-info text-white"
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleView(3)}
|
||||||
|
>
|
||||||
|
Contact Details
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={
|
||||||
|
viewState === 3
|
||||||
|
? "btn btn-light"
|
||||||
|
: "btn btn-info text-white"
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleView(5)}
|
||||||
|
>
|
||||||
|
Preview
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={
|
||||||
|
viewState === 4
|
||||||
|
? "btn btn-light"
|
||||||
|
: "btn btn-info text-white"
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleView(5)}
|
||||||
|
>
|
||||||
|
Videos
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={
|
||||||
|
viewState === 5
|
||||||
|
? "btn btn-light"
|
||||||
|
: "btn btn-info text-white"
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleView(5)}
|
||||||
|
>
|
||||||
|
Test & Launch
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={
|
||||||
|
viewState === 6
|
||||||
|
? "btn btn-light"
|
||||||
|
: "btn btn-info text-white"
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleView(5)}
|
||||||
|
>
|
||||||
|
Status
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</CCardBody>
|
||||||
|
</CCard>
|
||||||
|
</CCardGroup>
|
||||||
|
</CCol>
|
||||||
|
</CRow>
|
||||||
|
</CContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddCampaign;
|
163
src/views/Campaigns/BasicDetaiils.js
Normal file
163
src/views/Campaigns/BasicDetaiils.js
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import Button from "@material-ui/core/Button";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
const BasicDetaiils = ({ props }) => {
|
||||||
|
const { data, setData, handleView } = props;
|
||||||
|
|
||||||
|
const handleChange = (e) => {
|
||||||
|
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleVideoUpload = (e) => {
|
||||||
|
const file = e.target.files[0];
|
||||||
|
setData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
[e.target.id]: URL.createObjectURL(file),
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
const handleCampaignTypeClick = (campaignType) => {
|
||||||
|
setData((prevData) => ({
|
||||||
|
...prevData,
|
||||||
|
campaignType: campaignType,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div className="container">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12">
|
||||||
|
<div
|
||||||
|
className="
|
||||||
|
page-title-box
|
||||||
|
d-flex
|
||||||
|
align-items-center
|
||||||
|
justify-content-between
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
Basic Details
|
||||||
|
</div>
|
||||||
|
<div style={{ display: "flex", gap: "1rem" }}>
|
||||||
|
<h4 className="mb-0"></h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="page-title-right">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="secondary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
data?.campaignName === "" ||
|
||||||
|
data?.campaignType === "" ||
|
||||||
|
data?.selectedLanguage === null ||
|
||||||
|
data?.video === null
|
||||||
|
) {
|
||||||
|
toast.error("Fill all details");
|
||||||
|
} else {
|
||||||
|
handleView(2);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-sm-12 col-md-12 col-lg-12 my-1">
|
||||||
|
<div className="card h-100">
|
||||||
|
<div className="card-body px-5">
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="title" className="form-label">
|
||||||
|
Campaign Name
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="campaignName"
|
||||||
|
value={data?.campaignName}
|
||||||
|
maxLength="50"
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="title" className="form-label">
|
||||||
|
Select Language
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
onChange={(e) => handleChange(e)}
|
||||||
|
value={data?.language}
|
||||||
|
className="form-control"
|
||||||
|
id="language"
|
||||||
|
>
|
||||||
|
<option value="">---English/Hindi---</option>
|
||||||
|
<option value="english">English</option>
|
||||||
|
<option value="hindi">Hindi</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="title" className="form-label">
|
||||||
|
Select Campaign Type
|
||||||
|
</label>
|
||||||
|
<button
|
||||||
|
onClick={() => handleCampaignTypeClick("whatsapp")}
|
||||||
|
type="button"
|
||||||
|
className={`btn ${
|
||||||
|
data?.campaignType === "whatsapp"
|
||||||
|
? "btn-primary"
|
||||||
|
: "btn-outline-primary"
|
||||||
|
} mx-4`}
|
||||||
|
>
|
||||||
|
WHATSAPP
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => handleCampaignTypeClick("rcs")}
|
||||||
|
type="button"
|
||||||
|
className={`btn ${
|
||||||
|
data?.campaignType === "rcs"
|
||||||
|
? "btn-primary"
|
||||||
|
: "btn-outline-primary"
|
||||||
|
} mx-4`}
|
||||||
|
>
|
||||||
|
RCS
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => handleCampaignTypeClick("email")}
|
||||||
|
type="button"
|
||||||
|
className={`btn ${
|
||||||
|
data?.campaignType === "email"
|
||||||
|
? "btn-primary"
|
||||||
|
: "btn-outline-primary"
|
||||||
|
} mx-4`}
|
||||||
|
>
|
||||||
|
EMAIL
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="title" className="form-label">
|
||||||
|
Upload Video
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
className="form-control"
|
||||||
|
id="video"
|
||||||
|
onChange={(e) => handleVideoUpload(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BasicDetaiils;
|
434
src/views/Campaigns/Campaign.js
Normal file
434
src/views/Campaigns/Campaign.js
Normal file
@ -0,0 +1,434 @@
|
|||||||
|
import React, { useEffect } from "react";
|
||||||
|
import Button from "@material-ui/core/Button";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import axios from "axios";
|
||||||
|
import swal from "sweetalert";
|
||||||
|
import { isAutheticated } from "src/auth.js";
|
||||||
|
|
||||||
|
const Campaign = () => {
|
||||||
|
const token = isAutheticated();
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [success, setSuccess] = useState(true);
|
||||||
|
const [BusinessesData, setBusinessesData] = useState([]);
|
||||||
|
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
const [itemPerPage, setItemPerPage] = useState(10);
|
||||||
|
const [showData, setShowData] = useState(BusinessesData);
|
||||||
|
|
||||||
|
const handleShowEntries = (e) => {
|
||||||
|
setCurrentPage(1);
|
||||||
|
setItemPerPage(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getbusinesses = () => {
|
||||||
|
axios
|
||||||
|
.get(`/api/businesses/getall`, {
|
||||||
|
headers: {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setBusinessesData(res.data?.businesses);
|
||||||
|
setLoading(false);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getbusinesses();
|
||||||
|
}, [success]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadData = () => {
|
||||||
|
const indexOfLastPost = currentPage * itemPerPage;
|
||||||
|
const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
||||||
|
setShowData(BusinessesData.slice(indexOfFirstPost, indexOfLastPost));
|
||||||
|
};
|
||||||
|
loadData();
|
||||||
|
}, [currentPage, itemPerPage, BusinessesData]);
|
||||||
|
|
||||||
|
// const handleVarification = (id) => {
|
||||||
|
// swal({
|
||||||
|
// title: 'Are you sure?',
|
||||||
|
// icon: 'warning',
|
||||||
|
// buttons: { Yes: { text: 'Yes', value: true }, Cancel: { text: 'Cancel', value: 'cancel' } },
|
||||||
|
// }).then((value) => {
|
||||||
|
// if (value === true) {
|
||||||
|
// axios
|
||||||
|
// .get(`/api/i/admin/verify/${id}`, {
|
||||||
|
// headers: {
|
||||||
|
// 'Access-Control-Allow-Origin': '*',
|
||||||
|
// Authorization: `Bearer ${token}`,
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// swal({
|
||||||
|
// title: 'success',
|
||||||
|
// text: res.data.message ? res.data.message : 'Verified Successfully!',
|
||||||
|
// icon: 'success',
|
||||||
|
// button: 'ok',
|
||||||
|
// dangerMode: true,
|
||||||
|
// })
|
||||||
|
// setSuccess((prev) => !prev)
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// swal({
|
||||||
|
// title: 'Failled',
|
||||||
|
// text: 'Something went wrong!',
|
||||||
|
// icon: 'error',
|
||||||
|
// button: 'Retry',
|
||||||
|
// dangerMode: true,
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
const handleDelete = (id) => {
|
||||||
|
swal({
|
||||||
|
title: "Are you sure?",
|
||||||
|
icon: "error",
|
||||||
|
buttons: {
|
||||||
|
Yes: { text: "Yes", value: true },
|
||||||
|
Cancel: { text: "Cancel", value: "cancel" },
|
||||||
|
},
|
||||||
|
}).then((value) => {
|
||||||
|
if (value === true) {
|
||||||
|
axios
|
||||||
|
.delete(`/api/businesses/delete/${id}`, {
|
||||||
|
headers: {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setSuccess((prev) => !prev);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
swal({
|
||||||
|
title: "Warning",
|
||||||
|
text: "Something went wrong!",
|
||||||
|
icon: "error",
|
||||||
|
button: "Retry",
|
||||||
|
dangerMode: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatDate = (inputDate) => {
|
||||||
|
const options = { year: "numeric", month: "short", day: "numeric" };
|
||||||
|
const date = new Date(inputDate);
|
||||||
|
return date.toLocaleDateString("en-US", options);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="main-content">
|
||||||
|
<div className="page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12">
|
||||||
|
<div
|
||||||
|
className="
|
||||||
|
page-title-box
|
||||||
|
d-flex
|
||||||
|
align-items-center
|
||||||
|
justify-content-between
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
Campaigns
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="page-title-right">
|
||||||
|
<Link to="/campaign/add">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Add new campaign
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row ml-0 mr-0 mb-10">
|
||||||
|
<div className="col-sm-12 col-md-12">
|
||||||
|
<div className="dataTables_length">
|
||||||
|
<label className="w-100">
|
||||||
|
Show
|
||||||
|
<select
|
||||||
|
style={{ width: "10%" }}
|
||||||
|
name=""
|
||||||
|
onChange={(e) => handleShowEntries(e)}
|
||||||
|
className="
|
||||||
|
select-w
|
||||||
|
custom-select custom-select-sm
|
||||||
|
form-control form-control-sm
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="25">25</option>
|
||||||
|
<option value="50">50</option>
|
||||||
|
<option value="100">100</option>
|
||||||
|
</select>
|
||||||
|
entries
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="table-responsive table-shoot mt-3">
|
||||||
|
<table
|
||||||
|
className="table table-centered table-nowrap"
|
||||||
|
style={{ border: "1px solid" }}
|
||||||
|
>
|
||||||
|
<thead
|
||||||
|
className="thead-info"
|
||||||
|
style={{ background: "rgb(140, 213, 213)" }}
|
||||||
|
>
|
||||||
|
<tr>
|
||||||
|
<th className="text-start">User Name </th>
|
||||||
|
{/* <th className="text-start">Logo</th> */}
|
||||||
|
<th className="text-start"> Type</th>
|
||||||
|
<th className="text-start">Recipients</th>
|
||||||
|
{/* <th className="text-start">Status</th> */}
|
||||||
|
<th className="text-center">Action</th>
|
||||||
|
<th className="text-center">Launch Date</th>
|
||||||
|
<th className="text-center">Status</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{!loading && showData.length === 0 && (
|
||||||
|
<tr className="text-center">
|
||||||
|
<td colSpan="6">
|
||||||
|
<h5>No Data Available</h5>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
{loading ? (
|
||||||
|
<tr>
|
||||||
|
<td className="text-center" colSpan="6">
|
||||||
|
Loading...
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
) : (
|
||||||
|
showData.map((i, idx) => {
|
||||||
|
return (
|
||||||
|
<tr key={idx}>
|
||||||
|
<td className="text-start">
|
||||||
|
{i.userName ? i.userName : i.business}
|
||||||
|
</td>
|
||||||
|
{/* {i.banner && i.banner ?
|
||||||
|
<td className="text-start">
|
||||||
|
<img src={i.banner.url} alt="No Image" height="50" />
|
||||||
|
</td> :
|
||||||
|
<p>No image!</p>
|
||||||
|
} */}
|
||||||
|
|
||||||
|
<td className="text-start">
|
||||||
|
{i.userType ? i.userType : i.short_url}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td className="text-start">
|
||||||
|
{formatDate(i.createdAt)}
|
||||||
|
</td>
|
||||||
|
{/* <td className="text-start">
|
||||||
|
<button
|
||||||
|
style={{ color: 'white' }}
|
||||||
|
type="button"
|
||||||
|
className={`
|
||||||
|
|
||||||
|
btn ${i?.verify === true ? 'btn-success' : 'btn-danger'} btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
ms-2
|
||||||
|
|
||||||
|
`}
|
||||||
|
disabled={i?.verify === true}
|
||||||
|
onClick={() => {
|
||||||
|
handleVarification(i._id)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{i?.verify ? 'verified' : 'Not Verify'}
|
||||||
|
</button>
|
||||||
|
</td> */}
|
||||||
|
<td className=" text-center">
|
||||||
|
{/* <OverLayButton data={{ url: i?.url }} /> */}
|
||||||
|
|
||||||
|
<Link to={`/users/view/${i._id}`}>
|
||||||
|
<button
|
||||||
|
style={{ color: "white" }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-primary btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
ms-2
|
||||||
|
"
|
||||||
|
>
|
||||||
|
View
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<Link to={`/users/edit/${i._id}`}>
|
||||||
|
<button
|
||||||
|
style={{ color: "white" }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-success btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
ms-2
|
||||||
|
"
|
||||||
|
>
|
||||||
|
Edit
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
|
<button
|
||||||
|
style={{ color: "white" }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-danger btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
ms-2
|
||||||
|
|
||||||
|
"
|
||||||
|
onClick={() => {
|
||||||
|
handleDelete(i._id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
<td className="text-center">0</td>
|
||||||
|
<td className="text-center">active</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row mt-20">
|
||||||
|
<div className="col-sm-12 col-md-6 mb-20">
|
||||||
|
<div
|
||||||
|
className="dataTables_info"
|
||||||
|
id="datatable_info"
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
>
|
||||||
|
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
||||||
|
{Math.min(
|
||||||
|
currentPage * itemPerPage,
|
||||||
|
BusinessesData.length
|
||||||
|
)}{" "}
|
||||||
|
of {BusinessesData.length} entries
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-sm-12 col-md-6">
|
||||||
|
<div className="d-flex">
|
||||||
|
<ul className="pagination ms-auto">
|
||||||
|
<li
|
||||||
|
className={
|
||||||
|
currentPage === 1
|
||||||
|
? "paginate_button page-item previous disabled"
|
||||||
|
: "paginate_button page-item previous"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => setCurrentPage((prev) => prev - 1)}
|
||||||
|
>
|
||||||
|
Previous
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{!(currentPage - 1 < 1) && (
|
||||||
|
<li className="paginate_button page-item">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={(e) =>
|
||||||
|
setCurrentPage((prev) => prev - 1)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{currentPage - 1}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<li className="paginate_button page-item active">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
{currentPage}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{!(
|
||||||
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
BusinessesData.length - 1
|
||||||
|
) && (
|
||||||
|
<li className="paginate_button page-item ">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentPage((prev) => prev + 1);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{currentPage + 1}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<li
|
||||||
|
className={
|
||||||
|
!(
|
||||||
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
BusinessesData.length - 1
|
||||||
|
)
|
||||||
|
? "paginate_button page-item next"
|
||||||
|
: "paginate_button page-item next disabled"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => setCurrentPage((prev) => prev + 1)}
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Campaign;
|
179
src/views/Campaigns/ContactDetails.js
Normal file
179
src/views/Campaigns/ContactDetails.js
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
import React from "react";
|
||||||
|
import Button from "@material-ui/core/Button";
|
||||||
|
import { useState } from "react";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
const ContactDetails = ({ props }) => {
|
||||||
|
const { data, setData, handleView } = props;
|
||||||
|
// const [recipients, setRecipients] = useState([{ name: "", phoneNumber: "" }]);
|
||||||
|
|
||||||
|
const addRecord = () => {
|
||||||
|
setData((prevData) => ({
|
||||||
|
...prevData,
|
||||||
|
recipients: [...prevData.recipients, { name: "", phoneNumber: "" }],
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteRecipient = (index) => {
|
||||||
|
const updatedRecipients = [...data.recipients];
|
||||||
|
updatedRecipients.splice(index, 1);
|
||||||
|
setData((prevData) => ({
|
||||||
|
...prevData,
|
||||||
|
recipients: updatedRecipients,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const recipientNameChange = (e, index) => {
|
||||||
|
const updatedRecipients = [...data.recipients];
|
||||||
|
updatedRecipients[index] = {
|
||||||
|
...updatedRecipients[index],
|
||||||
|
name: e.target.value,
|
||||||
|
};
|
||||||
|
setData((prevData) => ({
|
||||||
|
...prevData,
|
||||||
|
recipients: updatedRecipients,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const recipientNumberChange = (e, index) => {
|
||||||
|
const updatedRecipients = [...data.recipients];
|
||||||
|
updatedRecipients[index] = {
|
||||||
|
...updatedRecipients[index],
|
||||||
|
phoneNumber: e.target.value,
|
||||||
|
};
|
||||||
|
setData((prevData) => ({
|
||||||
|
...prevData,
|
||||||
|
recipients: updatedRecipients,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12">
|
||||||
|
<div
|
||||||
|
className="
|
||||||
|
page-title-box
|
||||||
|
d-flex
|
||||||
|
align-items-center
|
||||||
|
justify-content-between
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
Contact Details
|
||||||
|
</div>
|
||||||
|
<div style={{ display: "flex", gap: "1rem" }}>
|
||||||
|
<h4 className="mb-0"></h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="page-title-right">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="secondary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
marginRight: "5px",
|
||||||
|
}}
|
||||||
|
onClick={() => handleView(1)}
|
||||||
|
>
|
||||||
|
Prev
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="secondary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
data?.recipients.every(
|
||||||
|
(recipient) =>
|
||||||
|
recipient.name !== "" && recipient.phoneNumber !== ""
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
handleView(3);
|
||||||
|
} else {
|
||||||
|
toast.error("Fill all contact details");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-sm-12 col-md-12 col-lg-12 my-1">
|
||||||
|
<div className="card h-100">
|
||||||
|
<div className="card-body px-5">
|
||||||
|
{data?.recipients.map((recipient, index) => {
|
||||||
|
return (
|
||||||
|
<div className="mb-3 border p-3 rounded">
|
||||||
|
<label
|
||||||
|
htmlFor="title"
|
||||||
|
className="form-label d-flex justify-content-between"
|
||||||
|
>
|
||||||
|
<p>Name</p>
|
||||||
|
|
||||||
|
{index === 0 ? null : (
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
deleteRecipient(index);
|
||||||
|
}}
|
||||||
|
className="btn btn-danger btn-smn rounded-5 fw-bold"
|
||||||
|
>
|
||||||
|
delete
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
name={`name-${index}`}
|
||||||
|
value={recipient?.name}
|
||||||
|
onChange={(e) => recipientNameChange(e, index)}
|
||||||
|
maxLength="50"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<label htmlFor="title" className="form-label mt-2">
|
||||||
|
{data?.campaignType === "rcs" ||
|
||||||
|
data?.campaignType === "whatsapp" ? (
|
||||||
|
<p>Phone Number</p>
|
||||||
|
) : (
|
||||||
|
<p>Email</p>
|
||||||
|
)}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
className="form-control"
|
||||||
|
id="recipients-phone-number"
|
||||||
|
maxLength="50"
|
||||||
|
name={`toPhoneNumber-${index}`}
|
||||||
|
value={recipient?.phoneNumber}
|
||||||
|
onChange={(e) => recipientNumberChange(e, index)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
addRecord();
|
||||||
|
}}
|
||||||
|
className="btn btn-secondary"
|
||||||
|
>
|
||||||
|
Add another record
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ContactDetails;
|
94
src/views/Campaigns/Preview.js
Normal file
94
src/views/Campaigns/Preview.js
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
import React from "react";
|
||||||
|
import Button from "@material-ui/core/Button";
|
||||||
|
const Preview = ({ props }) => {
|
||||||
|
const { data, handleView, setData } = props;
|
||||||
|
console.log(data);
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="col-12">
|
||||||
|
<div
|
||||||
|
className="
|
||||||
|
page-title-box
|
||||||
|
d-flex
|
||||||
|
align-items-center
|
||||||
|
justify-content-between
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
Campaign Details
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="page-title-right">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="secondary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
marginRight: "5px",
|
||||||
|
}}
|
||||||
|
onClick={() => props.handleView(3)}
|
||||||
|
>
|
||||||
|
Prev
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="secondary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
handleView(4);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{data && (
|
||||||
|
<div>
|
||||||
|
<table className="table table-striped">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Campaign Name</th>
|
||||||
|
<td>{data?.campaignName}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Language</th>
|
||||||
|
<td>{data?.language}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Campaign Type</th>
|
||||||
|
<td>{data?.campaignType}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="col"> Video</th>
|
||||||
|
<td>
|
||||||
|
<video
|
||||||
|
className="rounded"
|
||||||
|
autoPlay={true}
|
||||||
|
height={300}
|
||||||
|
width={250}
|
||||||
|
src={data?.video}
|
||||||
|
></video>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Recipients</th>
|
||||||
|
<td>{data?.recipients?.length}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Preview;
|
@ -1,293 +1,293 @@
|
|||||||
import axios from 'axios'
|
import axios from "axios";
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
import ClipLoader from 'react-spinners/ClipLoader'
|
|
||||||
import { Link } from 'react-router-dom'
|
|
||||||
import swal from 'sweetalert'
|
|
||||||
import { isAutheticated } from 'src/auth'
|
|
||||||
|
|
||||||
|
import ClipLoader from "react-spinners/ClipLoader";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import swal from "sweetalert";
|
||||||
|
import { isAutheticated } from "src/auth";
|
||||||
|
|
||||||
function Address() {
|
function Address() {
|
||||||
const token = isAutheticated()
|
const token = isAutheticated();
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false);
|
||||||
const [company, setCompany] = useState('')
|
const [company, setCompany] = useState("");
|
||||||
const [address, setAddress] = useState('')
|
const [address, setAddress] = useState("");
|
||||||
const [city, setCity] = useState('')
|
const [city, setCity] = useState("");
|
||||||
const [state, setState] = useState('')
|
const [state, setState] = useState("");
|
||||||
const [country, setCountry] = useState('')
|
const [country, setCountry] = useState("");
|
||||||
const [pincode, setPincode] = useState('')
|
const [pincode, setPincode] = useState("");
|
||||||
const [website, setWebsite] = useState('')
|
const [website, setWebsite] = useState("");
|
||||||
const [contact, setContact] = useState('')
|
const [contact, setContact] = useState("");
|
||||||
const [email, setEmail] = useState('')
|
const [email, setEmail] = useState("");
|
||||||
const [gstin, setGSTIN] = useState('')
|
const [gstin, setGSTIN] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getConfiguration() {
|
async function getConfiguration() {
|
||||||
const configDetails = await axios.get(`/api/config`, {
|
const configDetails = await axios.get(`/api/config`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
configDetails.data.result.map((item) => {
|
configDetails.data.result.map((item) => {
|
||||||
item.address.map((el) => {
|
item.address.map((el) => {
|
||||||
setCompany(el.company)
|
setCompany(el.company);
|
||||||
setAddress(el.address)
|
setAddress(el.address);
|
||||||
setCity(el.city)
|
setCity(el.city);
|
||||||
setState(el.state)
|
setState(el.state);
|
||||||
setCountry(el.country)
|
setCountry(el.country);
|
||||||
setPincode(el.pincode)
|
setPincode(el.pincode);
|
||||||
setWebsite(el.website)
|
setWebsite(el.website);
|
||||||
setContact(el.contact)
|
setContact(el.contact);
|
||||||
setEmail(el.email)
|
setEmail(el.email);
|
||||||
setGSTIN(el?.gstin)
|
setGSTIN(el?.gstin);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
}
|
|
||||||
getConfiguration()
|
|
||||||
}, [])
|
|
||||||
async function handelChange(e) {
|
|
||||||
if (e.target.name.toLowerCase() === 'address') {
|
|
||||||
setAddress(e.target.value)
|
|
||||||
} else if (e.target.name.toLowerCase() === 'company name') {
|
|
||||||
setCompany(e.target.value)
|
|
||||||
} else if (e.target.name.toLowerCase() === 'city') {
|
|
||||||
setCity(e.target.value)
|
|
||||||
} else if (e.target.name.toLowerCase() === 'state') {
|
|
||||||
setState(e.target.value)
|
|
||||||
} else if (e.target.name.toLowerCase() === 'country') {
|
|
||||||
setCountry(e.target.value)
|
|
||||||
} else if (e.target.name.toLowerCase() === 'pincode') {
|
|
||||||
setPincode(e.target.value)
|
|
||||||
} else if (e.target.name.toLowerCase() === 'website') {
|
|
||||||
setWebsite(e.target.value)
|
|
||||||
} else if (e.target.name.toLowerCase() === 'contact number') {
|
|
||||||
setContact(e.target.value)
|
|
||||||
} else if (e.target.name.toLowerCase() === 'email') {
|
|
||||||
setEmail(e.target.value)
|
|
||||||
} else if (e.target.name.toLowerCase() === 'gstin') {
|
|
||||||
setGSTIN(e.target.value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
async function handelSubmit() {
|
getConfiguration();
|
||||||
if (!/^[0-9A-Za-z]{15}$/.test(gstin)) return swal('Warning!', 'Enter valid GSTIN')
|
}, []);
|
||||||
setLoading(true)
|
async function handelChange(e) {
|
||||||
let data = {
|
if (e.target.name.toLowerCase() === "address") {
|
||||||
company,
|
setAddress(e.target.value);
|
||||||
address,
|
} else if (e.target.name.toLowerCase() === "company name") {
|
||||||
city,
|
setCompany(e.target.value);
|
||||||
state,
|
} else if (e.target.name.toLowerCase() === "city") {
|
||||||
country,
|
setCity(e.target.value);
|
||||||
pincode,
|
} else if (e.target.name.toLowerCase() === "state") {
|
||||||
website,
|
setState(e.target.value);
|
||||||
contact,
|
} else if (e.target.name.toLowerCase() === "country") {
|
||||||
email,
|
setCountry(e.target.value);
|
||||||
gstin,
|
} else if (e.target.name.toLowerCase() === "pincode") {
|
||||||
}
|
setPincode(e.target.value);
|
||||||
let res = await axios.post(`/api/config/address`, data, {
|
} else if (e.target.name.toLowerCase() === "website") {
|
||||||
headers: {
|
setWebsite(e.target.value);
|
||||||
Authorization: `Bearer ${token}`,
|
} else if (e.target.name.toLowerCase() === "contact number") {
|
||||||
},
|
setContact(e.target.value);
|
||||||
})
|
} else if (e.target.name.toLowerCase() === "email") {
|
||||||
|
setEmail(e.target.value);
|
||||||
if (res) {
|
} else if (e.target.name.toLowerCase() === "gstin") {
|
||||||
setLoading(false)
|
setGSTIN(e.target.value);
|
||||||
console.log(res)
|
|
||||||
swal('Success!', res.data.message, res.data.status)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
async function handelSubmit() {
|
||||||
|
if (!/^[0-9A-Za-z]{15}$/.test(gstin))
|
||||||
|
return swal("Warning!", "Enter valid GSTIN");
|
||||||
|
setLoading(true);
|
||||||
|
let data = {
|
||||||
|
company,
|
||||||
|
address,
|
||||||
|
city,
|
||||||
|
state,
|
||||||
|
country,
|
||||||
|
pincode,
|
||||||
|
website,
|
||||||
|
contact,
|
||||||
|
email,
|
||||||
|
gstin,
|
||||||
|
};
|
||||||
|
let res = await axios.post(`/api/config/address`, data, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
if (res) {
|
||||||
<div>
|
setLoading(false);
|
||||||
<div className="main-content">
|
console.log(res);
|
||||||
<div className="page-content">
|
swal("Success!", res.data.message, res.data.status);
|
||||||
<div className="container-fluid">
|
}
|
||||||
<div className="row">
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="main-content">
|
||||||
|
<div className="page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-md-12 col-lg-6 col-xl-6">
|
||||||
|
<h1 className="text-left head-small">Address</h1>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<div className="row">
|
||||||
<div className="col-lg-12">
|
<div className="col-lg-12">
|
||||||
<div className="card">
|
<div className="form-group">
|
||||||
<div className="card-body">
|
<>
|
||||||
<div className="row">
|
<label
|
||||||
<div className="col-md-12 col-lg-6 col-xl-6">
|
htmlFor="basicpill-phoneno-input"
|
||||||
<h1 className="text-left head-small">Address</h1>
|
className="label-100 mt-3"
|
||||||
|
>
|
||||||
<form>
|
Company Name
|
||||||
<div className="row">
|
</label>
|
||||||
<div className="col-lg-12">
|
<input
|
||||||
<div className="form-group">
|
type="text"
|
||||||
<>
|
name="company name"
|
||||||
<label
|
value={company}
|
||||||
htmlFor="basicpill-phoneno-input"
|
onChange={(e) => handelChange(e)}
|
||||||
className="label-100 mt-3"
|
className="form-control input-field "
|
||||||
>
|
id="basicpill-phoneno-input"
|
||||||
Company Name
|
/>
|
||||||
</label>
|
<label
|
||||||
<input
|
htmlFor="basicpill-phoneno-input"
|
||||||
type="text"
|
className="label-100 mt-3"
|
||||||
name="company name"
|
>
|
||||||
value={company}
|
Address
|
||||||
onChange={(e) => handelChange(e)}
|
</label>
|
||||||
className="form-control input-field "
|
<input
|
||||||
id="basicpill-phoneno-input"
|
value={address}
|
||||||
/>
|
type="text"
|
||||||
<label
|
name="address"
|
||||||
htmlFor="basicpill-phoneno-input"
|
onChange={(e) => handelChange(e)}
|
||||||
className="label-100 mt-3"
|
className="form-control input-field "
|
||||||
>
|
id="basicpill-phoneno-input"
|
||||||
Address
|
/>{" "}
|
||||||
</label>
|
<label
|
||||||
<input
|
htmlFor="basicpill-phoneno-input"
|
||||||
value={address}
|
className="label-100 mt-3"
|
||||||
type="text"
|
>
|
||||||
name="address"
|
City
|
||||||
onChange={(e) => handelChange(e)}
|
</label>
|
||||||
className="form-control input-field "
|
<input
|
||||||
id="basicpill-phoneno-input"
|
value={city}
|
||||||
/>{' '}
|
type="text"
|
||||||
<label
|
name="city"
|
||||||
htmlFor="basicpill-phoneno-input"
|
onChange={(e) => handelChange(e)}
|
||||||
className="label-100 mt-3"
|
className="form-control input-field "
|
||||||
>
|
id="basicpill-phoneno-input"
|
||||||
City
|
/>
|
||||||
</label>
|
<label
|
||||||
<input
|
htmlFor="basicpill-phoneno-input"
|
||||||
value={city}
|
className="label-100 mt-3"
|
||||||
type="text"
|
>
|
||||||
name="city"
|
State
|
||||||
onChange={(e) => handelChange(e)}
|
</label>
|
||||||
className="form-control input-field "
|
<input
|
||||||
id="basicpill-phoneno-input"
|
value={state}
|
||||||
/>
|
type="text"
|
||||||
<label
|
name="state"
|
||||||
htmlFor="basicpill-phoneno-input"
|
onChange={(e) => handelChange(e)}
|
||||||
className="label-100 mt-3"
|
className="form-control input-field "
|
||||||
>
|
id="basicpill-phoneno-input"
|
||||||
State
|
/>
|
||||||
</label>
|
<label
|
||||||
<input
|
htmlFor="basicpill-phoneno-input"
|
||||||
value={state}
|
className="label-100 mt-3"
|
||||||
type="text"
|
>
|
||||||
name="state"
|
Country
|
||||||
onChange={(e) => handelChange(e)}
|
</label>
|
||||||
className="form-control input-field "
|
<input
|
||||||
id="basicpill-phoneno-input"
|
value={country}
|
||||||
/>
|
type="text"
|
||||||
<label
|
name="country"
|
||||||
htmlFor="basicpill-phoneno-input"
|
onChange={(e) => handelChange(e)}
|
||||||
className="label-100 mt-3"
|
className="form-control input-field "
|
||||||
>
|
id="basicpill-phoneno-input"
|
||||||
Country
|
/>
|
||||||
</label>
|
<label
|
||||||
<input
|
htmlFor="basicpill-phoneno-input"
|
||||||
value={country}
|
className="label-100 mt-3"
|
||||||
type="text"
|
>
|
||||||
name="country"
|
Pin Code
|
||||||
onChange={(e) => handelChange(e)}
|
</label>
|
||||||
className="form-control input-field "
|
<input
|
||||||
id="basicpill-phoneno-input"
|
value={pincode}
|
||||||
/>
|
type="text"
|
||||||
<label
|
name="pincode"
|
||||||
htmlFor="basicpill-phoneno-input"
|
onChange={(e) => handelChange(e)}
|
||||||
className="label-100 mt-3"
|
className="form-control input-field "
|
||||||
>
|
id="basicpill-phoneno-input"
|
||||||
Pin Code
|
/>
|
||||||
</label>
|
<label
|
||||||
<input
|
htmlFor="basicpill-phoneno-input"
|
||||||
value={pincode}
|
className="label-100 mt-3"
|
||||||
type="text"
|
>
|
||||||
name="pincode"
|
GSTIN
|
||||||
onChange={(e) => handelChange(e)}
|
</label>
|
||||||
className="form-control input-field "
|
<input
|
||||||
id="basicpill-phoneno-input"
|
value={gstin}
|
||||||
/>
|
type="text"
|
||||||
<label
|
name="gstin"
|
||||||
htmlFor="basicpill-phoneno-input"
|
onChange={(e) => handelChange(e)}
|
||||||
className="label-100 mt-3"
|
className="form-control input-field "
|
||||||
>
|
id="basicpill-phoneno-input"
|
||||||
GSTIN
|
/>
|
||||||
</label>
|
<label
|
||||||
<input
|
htmlFor="basicpill-phoneno-input"
|
||||||
value={gstin}
|
className="label-100 mt-3"
|
||||||
type="text"
|
>
|
||||||
name="gstin"
|
Website
|
||||||
onChange={(e) => handelChange(e)}
|
</label>
|
||||||
className="form-control input-field "
|
<input
|
||||||
id="basicpill-phoneno-input"
|
value={website}
|
||||||
/>
|
type="text"
|
||||||
<label
|
name="website"
|
||||||
htmlFor="basicpill-phoneno-input"
|
onChange={(e) => handelChange(e)}
|
||||||
className="label-100 mt-3"
|
className="form-control input-field "
|
||||||
>
|
id="basicpill-phoneno-input"
|
||||||
Website
|
/>
|
||||||
</label>
|
<label
|
||||||
<input
|
htmlFor="basicpill-phoneno-input"
|
||||||
value={website}
|
className="label-100 mt-3"
|
||||||
type="text"
|
>
|
||||||
name="website"
|
Contact Number
|
||||||
onChange={(e) => handelChange(e)}
|
</label>
|
||||||
className="form-control input-field "
|
<input
|
||||||
id="basicpill-phoneno-input"
|
value={contact}
|
||||||
/>
|
type="text"
|
||||||
<label
|
name="contact number"
|
||||||
htmlFor="basicpill-phoneno-input"
|
onChange={(e) => handelChange(e)}
|
||||||
className="label-100 mt-3"
|
className="form-control input-field "
|
||||||
>
|
id="basicpill-phoneno-input"
|
||||||
Contact Number
|
/>{" "}
|
||||||
</label>
|
<label
|
||||||
<input
|
htmlFor="basicpill-phoneno-input"
|
||||||
value={contact}
|
className="label-100 mt-3"
|
||||||
type="text"
|
>
|
||||||
name="contact number"
|
Email
|
||||||
onChange={(e) => handelChange(e)}
|
</label>
|
||||||
className="form-control input-field "
|
<input
|
||||||
id="basicpill-phoneno-input"
|
value={email}
|
||||||
/>{' '}
|
type="text"
|
||||||
<label
|
name="email"
|
||||||
htmlFor="basicpill-phoneno-input"
|
onChange={(e) => handelChange(e)}
|
||||||
className="label-100 mt-3"
|
className="form-control input-field "
|
||||||
>
|
id="basicpill-phoneno-input"
|
||||||
Email
|
/>
|
||||||
</label>
|
</>
|
||||||
<input
|
</div>
|
||||||
value={email}
|
|
||||||
type="text"
|
|
||||||
name="email"
|
|
||||||
onChange={(e) => handelChange(e)}
|
|
||||||
className="form-control input-field "
|
|
||||||
id="basicpill-phoneno-input"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="row mt-2">
|
|
||||||
<div className="col-lg-12">
|
|
||||||
<div className="form-group text-left">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={handelSubmit}
|
|
||||||
className="btn btn-success btn-login waves-effect waves-light mr-3 pt-2 pb-2 pr-4 pl-4"
|
|
||||||
>
|
|
||||||
<ClipLoader loading={loading} size={18} />
|
|
||||||
{!loading && 'Save'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* <!-- end table-responsive --> */}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="row mt-2">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="form-group text-left">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handelSubmit}
|
||||||
|
className="btn btn-success btn-login waves-effect waves-light mr-3 pt-2 pb-2 pr-4 pl-4"
|
||||||
|
>
|
||||||
|
<ClipLoader loading={loading} size={18} />
|
||||||
|
{!loading && "Save"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* <!-- container-fluid --> */}
|
|
||||||
|
{/* <!-- end table-responsive --> */}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* <!-- End Page-content --> */}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* <!-- container-fluid --> */}
|
||||||
</div>
|
</div>
|
||||||
)
|
{/* <!-- End Page-content --> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Address
|
export default Address;
|
||||||
|
Loading…
Reference in New Issue
Block a user