diff --git a/src/_nav.js b/src/_nav.js index e47f95b..f9c5d44 100644 --- a/src/_nav.js +++ b/src/_nav.js @@ -36,7 +36,8 @@ import { cilTags, cilTennisBall, cilText, - cilUser, + cilUser + , } from "@coreui/icons"; import { CNavGroup, CNavItem, CNavTitle } from "@coreui/react"; @@ -143,6 +144,13 @@ const _nav = [ icon: , to: "/recipents", }, + { + component: CNavItem, + name: "Campaigns", + icon: , + to: "/campaigns", + }, { component: CNavGroup, name: "Configuration", diff --git a/src/index.js b/src/index.js index f261c47..4a80d7f 100644 --- a/src/index.js +++ b/src/index.js @@ -14,8 +14,8 @@ import { createRoot } from "react-dom/client"; const setupAxios = () => { //axios.defaults.baseURL = 'https://bolo-api.checkapp.one/' - //axios.defaults.baseURL = "http://localhost:5000"; - axios.defaults.baseURL = "https://boloai-api.onrender.com"; //->USE THIS + axios.defaults.baseURL = "http://localhost:8000"; + // axios.defaults.baseURL = "https://boloai-api.onrender.com"; //->USE THIS axios.defaults.headers = { "Cache-Control": "no-cache,no-store", diff --git a/src/routes.js b/src/routes.js index a08fc48..483dbe2 100644 --- a/src/routes.js +++ b/src/routes.js @@ -80,6 +80,8 @@ import ViewAppointment from "./views/Appointments/ViewAppointment"; import EditAppointment from "./views/Appointments/EditAppointment"; import AddNewAppointment from "./views/Appointments/AddNewAppointment"; import ViewHealthCareProvider from "./views/Business/ViewHealthCareProvider"; +import Campaign from "./views/Campaigns/Campaign.js"; +import AddCampaign from "./views/Campaigns/AddCampaign.js"; const routes = [ { path: "/", exact: true, name: "Home" }, { @@ -141,8 +143,37 @@ const routes = [ 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 }, //Contact Requests + { path: "/contact/request", name: "Contact Requests", diff --git a/src/views/Campaigns/AddCampaign.js b/src/views/Campaigns/AddCampaign.js new file mode 100644 index 0000000..a0f224b --- /dev/null +++ b/src/views/Campaigns/AddCampaign.js @@ -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 ( + + + +
+
+ Add Campaign +
+
+
+ {/* */} +
+
+
+
+
+ + + + + + {viewState === 1 && ( + + )} + + {viewState === 2 && ( + + )} + + {viewState === 3 && ( + + )} + {viewState === 4 && ( + + )} + + + + + + + + +
+ + {/**/} + + + + + +
+
+
+
+
+
+
+ ); +}; + +export default AddCampaign; diff --git a/src/views/Campaigns/BasicDetaiils.js b/src/views/Campaigns/BasicDetaiils.js new file mode 100644 index 0000000..50d0981 --- /dev/null +++ b/src/views/Campaigns/BasicDetaiils.js @@ -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 ( +
+
+
+
+
+ Basic Details +
+
+

+
+ +
+ +
+
+
+
+ +
+
+
+
+
+ + handleChange(e)} + /> +
+
+ + +
+
+ + + + +
+ +
+ + handleVideoUpload(e)} + /> +
+
+
+
+
+
+ ); +}; + +export default BasicDetaiils; diff --git a/src/views/Campaigns/Campaign.js b/src/views/Campaigns/Campaign.js new file mode 100644 index 0000000..99d6222 --- /dev/null +++ b/src/views/Campaigns/Campaign.js @@ -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 ( +
+
+
+
+
+
+
+ Campaigns +
+ +
+ + + +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+ +
+ + + + + {/* */} + + + {/* */} + + + + + + + {!loading && showData.length === 0 && ( + + + + )} + {loading ? ( + + + + ) : ( + showData.map((i, idx) => { + return ( + + + {/* {i.banner && i.banner ? + : +

No image!

+ } */} + + + + + {/* */} + + + + + ); + }) + )} + +
User Name Logo TypeRecipientsStatusActionLaunch DateStatus
+
No Data Available
+
+ Loading... +
+ {i.userName ? i.userName : i.business} + + No Image + + {i.userType ? i.userType : i.short_url} + + {formatDate(i.createdAt)} + + + + {/* */} + + + + + + + + + + 0active
+
+ +
+
+
+ Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "} + {Math.min( + currentPage * itemPerPage, + BusinessesData.length + )}{" "} + of {BusinessesData.length} entries +
+
+ +
+
+
    +
  • + setCurrentPage((prev) => prev - 1)} + > + Previous + +
  • + + {!(currentPage - 1 < 1) && ( +
  • + + setCurrentPage((prev) => prev - 1) + } + > + {currentPage - 1} + +
  • + )} + +
  • + + {currentPage} + +
  • + + {!( + (currentPage + 1) * itemPerPage - itemPerPage > + BusinessesData.length - 1 + ) && ( +
  • + { + setCurrentPage((prev) => prev + 1); + }} + > + {currentPage + 1} + +
  • + )} + +
  • + BusinessesData.length - 1 + ) + ? "paginate_button page-item next" + : "paginate_button page-item next disabled" + } + > + setCurrentPage((prev) => prev + 1)} + > + Next + +
  • +
+
+
+
+
+
+
+
+
+
+
+ ); +}; + +export default Campaign; diff --git a/src/views/Campaigns/ContactDetails.js b/src/views/Campaigns/ContactDetails.js new file mode 100644 index 0000000..bd899bc --- /dev/null +++ b/src/views/Campaigns/ContactDetails.js @@ -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 ( +
+
+
+
+
+ Contact Details +
+
+

+
+ +
+ + +
+
+
+
+ +
+
+
+
+ {data?.recipients.map((recipient, index) => { + return ( +
+ + recipientNameChange(e, index)} + maxLength="50" + /> + + + recipientNumberChange(e, index)} + /> +
+ ); + })} + +
+
+
+
+
+ ); +}; + +export default ContactDetails; diff --git a/src/views/Campaigns/Preview.js b/src/views/Campaigns/Preview.js new file mode 100644 index 0000000..fe33526 --- /dev/null +++ b/src/views/Campaigns/Preview.js @@ -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 ( +
+
+
+
+ Campaign Details +
+ +
+ + +
+
+
+ + {data && ( +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Campaign Name{data?.campaignName}
Language{data?.language}
Campaign Type{data?.campaignType}
Video + +
Recipients{data?.recipients?.length}
+
+ )} +
+ ); +}; + +export default Preview; diff --git a/src/views/configuration/Address.js b/src/views/configuration/Address.js index e06dcb5..c6429de 100644 --- a/src/views/configuration/Address.js +++ b/src/views/configuration/Address.js @@ -1,293 +1,293 @@ -import axios from 'axios' -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 axios from "axios"; +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"; function Address() { - const token = isAutheticated() - const [loading, setLoading] = useState(false) - const [company, setCompany] = useState('') - const [address, setAddress] = useState('') - const [city, setCity] = useState('') - const [state, setState] = useState('') - const [country, setCountry] = useState('') - const [pincode, setPincode] = useState('') - const [website, setWebsite] = useState('') - const [contact, setContact] = useState('') - const [email, setEmail] = useState('') - const [gstin, setGSTIN] = useState('') + const token = isAutheticated(); + const [loading, setLoading] = useState(false); + const [company, setCompany] = useState(""); + const [address, setAddress] = useState(""); + const [city, setCity] = useState(""); + const [state, setState] = useState(""); + const [country, setCountry] = useState(""); + const [pincode, setPincode] = useState(""); + const [website, setWebsite] = useState(""); + const [contact, setContact] = useState(""); + const [email, setEmail] = useState(""); + const [gstin, setGSTIN] = useState(""); - useEffect(() => { - async function getConfiguration() { - const configDetails = await axios.get(`/api/config`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - configDetails.data.result.map((item) => { - item.address.map((el) => { - setCompany(el.company) - setAddress(el.address) - setCity(el.city) - setState(el.state) - setCountry(el.country) - setPincode(el.pincode) - setWebsite(el.website) - setContact(el.contact) - setEmail(el.email) - 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) - } + useEffect(() => { + async function getConfiguration() { + const configDetails = await axios.get(`/api/config`, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + configDetails.data.result.map((item) => { + item.address.map((el) => { + setCompany(el.company); + setAddress(el.address); + setCity(el.city); + setState(el.state); + setCountry(el.country); + setPincode(el.pincode); + setWebsite(el.website); + setContact(el.contact); + setEmail(el.email); + setGSTIN(el?.gstin); + }); + }); } - 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}`, - }, - }) - - if (res) { - setLoading(false) - console.log(res) - swal('Success!', res.data.message, res.data.status) - } + 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() { + 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) { + setLoading(false); + console.log(res); + swal("Success!", res.data.message, res.data.status); + } + } + + return ( +
+
+
+
+
+
+
+
+
+
+

Address

+ +
+
-
-
-
-
-

Address

- - -
-
-
- <> - - handelChange(e)} - className="form-control input-field " - id="basicpill-phoneno-input" - /> - - handelChange(e)} - className="form-control input-field " - id="basicpill-phoneno-input" - />{' '} - - handelChange(e)} - className="form-control input-field " - id="basicpill-phoneno-input" - /> - - handelChange(e)} - className="form-control input-field " - id="basicpill-phoneno-input" - /> - - handelChange(e)} - className="form-control input-field " - id="basicpill-phoneno-input" - /> - - handelChange(e)} - className="form-control input-field " - id="basicpill-phoneno-input" - /> - - handelChange(e)} - className="form-control input-field " - id="basicpill-phoneno-input" - /> - - handelChange(e)} - className="form-control input-field " - id="basicpill-phoneno-input" - /> - - handelChange(e)} - className="form-control input-field " - id="basicpill-phoneno-input" - />{' '} - - handelChange(e)} - className="form-control input-field " - id="basicpill-phoneno-input" - /> - -
-
-
-
-
-
- -
-
-
- -
-
- - {/* */} -
-
+
+ <> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + />{" "} + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + />{" "} + + handelChange(e)} + className="form-control input-field " + id="basicpill-phoneno-input" + /> + +
-
+
+
+
+
+ +
+
+
+ +
- {/* */} + + {/* */} +
- {/* */} +
+
+ {/* */}
- ) + {/* */} +
+
+ ); } -export default Address +export default Address;