diff --git a/src/views/Directory/View_Bisuness.js b/src/views/Directory/View_Bisuness.js
index 1dc08c1..1538321 100644
--- a/src/views/Directory/View_Bisuness.js
+++ b/src/views/Directory/View_Bisuness.js
@@ -25,7 +25,7 @@ const View_Bisuness = () => {
},
}
);
- console.log(res.data.directory.name)
+ console.log(res.data.directory)
setBisuness(res.data.directory)
// changeState({
// ...res.data,
@@ -66,52 +66,37 @@ const View_Bisuness = () => {
-
- Name |
- Category |
- email |
- phone |
- Building_Name |
- Street_Name |
- city |
- description |
- Status |
- Google Location |
- LinkedinUrl |
- FacebookUrl |
- intagramUrl |
-
+
+ Name | {bisuness?.name} |
+ Bisuness image |
+
+ |
+ Category | {bisuness?.category} |
+ email | {bisuness?.email} |
+ phone | {bisuness?.phone} |
+ Building_Name | {bisuness?.Building_Name} |
+ Street_Name | {bisuness?.Street_Name} |
+ city | {bisuness?.city} |
+ description | {bisuness?.description} |
+ Status |
+
+ {bisuness?.status ? "Live" : "Suspended"}
+
+ |
+ Google Location | {bisuness?.Glocation} |
+ LinkedinUrl | {bisuness?.LinkedinUrl} |
+ FacebookUrl | {bisuness?.FacebookUrl} |
+ intagramUrl | {bisuness?.InstagramUrl} |
+
+
-
- {bisuness?.name} |
- {bisuness?.category} |
- {bisuness?.email} |
- {bisuness?.phone} |
- {bisuness?.Building_Name} |
- {bisuness?.Street_Name} |
- {bisuness?.city} |
- {bisuness?.description} |
-
-
-
- {bisuness?.status ? "Live" : "Suspended"}
-
- |
- {bisuness?.Glocation} |
- {bisuness?.LinkedinUrl} |
- {bisuness?.FacebookUrl} |
- {bisuness?.InstagramUrl} |
-
-
- |
-
diff --git a/src/views/Events/AddEvent.js b/src/views/Events/AddEvent.js
new file mode 100644
index 0000000..8a3f908
--- /dev/null
+++ b/src/views/Events/AddEvent.js
@@ -0,0 +1,164 @@
+
+import axios from "axios";
+import React, { useCallback, useEffect, useState } from "react";
+import { API } from "../../data";
+import { isAutheticated } from "../../auth";
+import ClipLoader from "react-spinners/ClipLoader";
+import { useHistory } from "react-router-dom";
+import swal from 'sweetalert';
+
+import {
+ CButton,
+ CCard,
+ CCardBody,
+ CCol,
+ CContainer,
+ CForm,
+ CFormInput,
+ CInputGroup,
+ CInputGroupText,
+ CRow,
+} from '@coreui/react'
+import CIcon from '@coreui/icons-react'
+import { cilPencil, cilSettings, cilLockLocked, cilUser, cilBell, cilLocationPin, cilAudioDescription } from '@coreui/icons'
+const AddEvent = () => {
+ const { token } = isAutheticated();
+ let history = useHistory();
+ const [image, setImage] = useState("");
+ const [title, setTitle] = useState("");
+ const [description, setDescription] = useState("");
+ const [location, setLocation] = useState("");
+
+ const [loading, setLoading] = useState(false);
+
+
+ const handleSubmit = async () => {
+ const myForm = new FormData();
+
+ myForm.set("title", title);
+ myForm.set("description", description);
+ myForm.set("location", location);
+ myForm.set("image", image);
+ setLoading({ loading: true });
+ // console.log(image)
+ let res = await axios.post(
+ `/api/event/create`, myForm,
+ {
+ headers: {
+ "Content-Type": 'multipart/form-data',
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ // console.log(res.data)
+ if (res.data) {
+ swal("success!", "Event Added Successfully!", "success");
+ history.goBack();
+ }
+
+ setLoading(false);
+ };
+ const handleImage = (e) => {
+ const files = e.target.files[0];
+ // console.log(files)
+ setImage(files);
+
+ };
+ //
+ const onCancel = () => {
+ // window.location = "/comproducts";
+ history.goBack()
+
+ };
+
+ return (
+ <>
+
+
+
+
+
+
+
+ Add Event
+
+
+
+
+
+
+ setTitle(e.target.value)}
+ value={title}
+ placeholder="Title" />
+
+
+
+
+
+
+ setDescription(e.target.value)}
+ value={description}
+ placeholder="Description" />
+
+
+
+
+
+ setLocation(e.target.value)}
+ value={location}
+ placeholder="Location" />
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )
+}
+
+export default AddEvent
\ No newline at end of file
diff --git a/src/views/Events/EditEvent.js b/src/views/Events/EditEvent.js
new file mode 100644
index 0000000..0c15dbb
--- /dev/null
+++ b/src/views/Events/EditEvent.js
@@ -0,0 +1,178 @@
+
+import axios from "axios";
+import React, { useCallback, useEffect, useState } from "react";
+import { API } from "../../data";
+import { isAutheticated } from "../../auth";
+import ClipLoader from "react-spinners/ClipLoader";
+import { useHistory } from "react-router-dom";
+import { Link, useParams } from "react-router-dom";
+import swal from 'sweetalert';
+
+import {
+ CButton,
+ CCard,
+ CCardBody,
+ CCol,
+ CContainer,
+ CForm,
+ CFormInput,
+ CInputGroup,
+ CInputGroupText,
+ CRow,
+} from '@coreui/react'
+import CIcon from '@coreui/icons-react'
+import { cilPencil, cilSettings, cilLockLocked, cilUser, cilBell, cilLocationPin, cilAudioDescription } from '@coreui/icons'
+const EditEvent = () => {
+ const { id } = useParams();
+ // console.log(id)
+ const { token } = isAutheticated();
+ let history = useHistory();
+ const [image, setImage] = useState("");
+ const [title, setTitle] = useState("");
+ const [description, setDescription] = useState("");
+ const [location, setLocation] = useState("");
+ const [loading, setLoading] = useState(false);
+
+ //fetch one image
+ useEffect(async () => {
+ const res = await axios.get(`/api/event/getOne/${id}`, {
+ // headers: {
+ // Authorization: `Bearer ${token}`,
+ // },
+ });
+ // console.log(res.data)
+ setTitle(res.data.Event.title)
+ setDescription(res.data.Event.description)
+ setLocation(res.data.Event.location)
+
+ }, [id]);
+
+ const handleSubmit = async () => {
+ const myForm = new FormData();
+
+ myForm.set("title", title);
+ myForm.set("description", description);
+ myForm.set("location", location);
+ myForm.set("image", image);
+ setLoading({ loading: true });
+ // console.log(image)
+ let res = await axios.put(
+ `/api/event/update/${id}`, myForm,
+ {
+ headers: {
+ "Content-Type": 'multipart/form-data',
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ // console.log(res.data)
+ if (res.data) {
+ swal("success!", "Event Edit Successfully!", "success");
+ history.goBack();
+ }
+
+ setLoading(false);
+ };
+ const handleImage = (e) => {
+ const files = e.target.files[0];
+ // console.log(files)
+ setImage(files);
+
+ };
+ //
+ const onCancel = () => {
+ // window.location = "/comproducts";
+ history.goBack()
+
+ };
+
+ return (
+ <>
+
+
+
+
+
+
+
+ Edit Event
+
+
+
+
+
+
+ setTitle(e.target.value)}
+ value={title}
+ placeholder="Title" />
+
+
+
+
+
+ setDescription(e.target.value)}
+ value={description}
+ placeholder="Description" />
+
+
+
+
+
+ setLocation(e.target.value)}
+ value={location}
+ placeholder="Location" />
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )
+}
+
+export default EditEvent
\ No newline at end of file
diff --git a/src/views/Events/Event.js b/src/views/Events/Event.js
new file mode 100644
index 0000000..cf7cab8
--- /dev/null
+++ b/src/views/Events/Event.js
@@ -0,0 +1,166 @@
+
+import axios from "axios";
+import React, { useEffect, useState, useCallback, useMemo } from "react";
+import { Link } from "react-router-dom";
+import swal from 'sweetalert';
+// import { API } from "../../data";
+import { isAutheticated } from "../../auth";
+
+function Event() {
+ const [event, setEvent] = useState([])
+
+ const { token } = isAutheticated();
+
+ const getEvent = useCallback(async () => {
+ let res = await axios.get(
+ `/api/event/getAll`,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ // console.log(res.data)
+ setEvent(res.data.Event)
+
+
+ }, [token]);
+
+ useEffect(() => {
+ getEvent();
+ }, [getEvent]);
+
+
+ const handleDelete = async (id) => {
+ let status = window.confirm("Do you want to delete");
+ if (!status) return;
+
+ let res = await axios.delete(`/api/event/delete/${id}`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ });
+ console.log(res)
+ if (res.data.success == true) {
+ swal("success!", "Event Deleted Successfully!", "success");
+ window.location.reload();
+ }
+ };
+
+
+ //change time formate
+ function formatAMPM(date) {
+ var hours = new Date(date).getHours();
+ var minutes = new Date(date).getMinutes();
+ var ampm = hours >= 12 ? 'PM' : 'AM';
+ hours = hours % 12;
+ hours = hours ? hours : 12; // the hour '0' should be '12'
+ minutes = minutes < 10 ? '0' + minutes : minutes;
+ var strTime = hours + ':' + minutes + ' ' + ampm;
+ return strTime;
+ }
+
+
+ return (
+
+
+
+ {/* */}
+
+
+
+
CMP-Event
+
+ {/*
+
+ -
+ CMD-App
+
+ - CMD-Category
+
+
*/}
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+ Title |
+ Image |
+ Location |
+ Added On |
+ Action |
+
+
+
+ {event && event.map((item, index) =>
+
+ {item?.title} |
+
+  |
+ {item?.location} |
+
+ {/* {item?.addedOn} */}
+ {new Date(`${item?.addedOn}`).toDateString()} , {`${formatAMPM(item?.addedOn)}`}
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ )}
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+ {/* */}
+
+
+ );
+}
+
+export default Event;
diff --git a/src/views/Events/ViewEvent.js b/src/views/Events/ViewEvent.js
new file mode 100644
index 0000000..4f89caa
--- /dev/null
+++ b/src/views/Events/ViewEvent.js
@@ -0,0 +1,122 @@
+
+import axios from "axios";
+import React, { useEffect, useState, useCallback, useMemo } from "react";
+import swal from 'sweetalert';
+// import { API } from "../../data";
+import { Link, useParams } from "react-router-dom";
+import { isAutheticated } from "../../auth";
+
+function ViewEvent() {
+ const [event, setEvent] = useState([])
+ const { id } = useParams();
+ console.log(id)
+ const token = isAutheticated();
+
+ const getEvent = useCallback(async () => {
+ let res = await axios.get(
+ `/api/event/getOne/${id}`,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ // console.log(res.data.Event)
+ setEvent(res.data.Event)
+
+
+ }, [token]);
+
+ useEffect(() => {
+ getEvent();
+ }, [getEvent]);
+
+
+
+
+
+ //change time formate
+ function formatAMPM(date) {
+ var hours = new Date(date).getHours();
+ var minutes = new Date(date).getMinutes();
+ var ampm = hours >= 12 ? 'PM' : 'AM';
+ hours = hours % 12;
+ hours = hours ? hours : 12; // the hour '0' should be '12'
+ minutes = minutes < 10 ? '0' + minutes : minutes;
+ var strTime = hours + ':' + minutes + ' ' + ampm;
+ return strTime;
+ }
+
+
+ return (
+
+
+
+ {/* */}
+
+
+
+
CMP-Event
+
+ {/*
+
+ -
+ CMD-App
+
+ - CMD-Category
+
+
*/}
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+ Id | {event?._id} |
+ Title | {event?.title} |
+
+ Image |
+
+ |
+ Description | {event?.description} |
+ Location | {event?.location} |
+ Added On |
+ {new Date(`${event?.addedOn}`).toDateString()} , {`${formatAMPM(event?.addedOn)}`}
+ |
+ Updated At |
+
+ {new Date(`${event?.updatedAt}`).toDateString()} , {`${formatAMPM(event?.updatedAt)}`}
+ |
+
+
+
+
+
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+ {/* */}
+
+
+ );
+}
+
+export default ViewEvent;
diff --git a/src/views/Feedback/Pagination.js b/src/views/Feedback/Pagination.js
new file mode 100644
index 0000000..92a8292
--- /dev/null
+++ b/src/views/Feedback/Pagination.js
@@ -0,0 +1,25 @@
+import React from 'react';
+import { Link } from "react-router-dom";
+const Pagination = ({ postsPerPage, totalPosts, paginate }) => {
+ const pageNumbers = [];
+
+ for (let i = 1; i <= Math.ceil(totalPosts / postsPerPage); i++) {
+ pageNumbers.push(i);
+ }
+
+ return (
+
+ );
+};
+
+export default Pagination;
\ No newline at end of file
diff --git a/src/views/Feedback/ViewFeedback.js b/src/views/Feedback/ViewFeedback.js
new file mode 100644
index 0000000..7cd90bd
--- /dev/null
+++ b/src/views/Feedback/ViewFeedback.js
@@ -0,0 +1,123 @@
+
+import axios from "axios";
+import React, { useEffect, useState, useCallback, useMemo } from "react";
+import swal from 'sweetalert';
+// import { API } from "../../data";
+import { Link, useParams } from "react-router-dom";
+import { isAutheticated } from "../../auth";
+
+function ViewFeedback() {
+ const [user, setUser] = useState([])
+
+
+ const [feedback, setFeedback] = useState([])
+ const { id } = useParams();
+ // console.log(id)
+ const token = isAutheticated();
+
+ const getFeedback = useCallback(async () => {
+ let res = await axios.get(
+ `/api/feedback/getOne/${id}`,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ setFeedback(res.data.feedback)
+
+ let resp = await axios.get(
+ `/api/v1/admin/user/${feedback.user}`,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ setUser(resp.data.user)
+
+
+ }, [token, feedback.user]);
+
+ useEffect(() => {
+ getFeedback();
+ }, [getFeedback]);
+
+
+
+
+
+ //change time formate
+ function formatAMPM(date) {
+ var hours = new Date(date).getHours();
+ var minutes = new Date(date).getMinutes();
+ var ampm = hours >= 12 ? 'PM' : 'AM';
+ hours = hours % 12;
+ hours = hours ? hours : 12; // the hour '0' should be '12'
+ minutes = minutes < 10 ? '0' + minutes : minutes;
+ var strTime = hours + ':' + minutes + ' ' + ampm;
+ return strTime;
+ }
+
+
+ return (
+
+
+
+ {/* */}
+
+
+
+
CMP-Customer feedback
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+ User_Id | {user?._id} |
+ Name | {feedback?.name} |
+ email | {user?.email} |
+
+ Image |
+
+ |
+ Description | {feedback?.description} |
+
+ Pnone No. | {user?.phone} |
+ Feedback Given At |
+ {new Date(`${feedback?.createdAt}`).toDateString()} , {`${formatAMPM(feedback?.createdAt)}`}
+ |
+
+
+
+
+
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+ {/* */}
+
+
+ );
+}
+
+export default ViewFeedback;
diff --git a/src/views/Feedback/feedback.js b/src/views/Feedback/feedback.js
new file mode 100644
index 0000000..9f305df
--- /dev/null
+++ b/src/views/Feedback/feedback.js
@@ -0,0 +1,146 @@
+
+import axios from "axios";
+import React, { useEffect, useState, useCallback, useMemo } from "react";
+import Pagination from "./Pagination";
+import { Link } from "react-router-dom";
+import swal from 'sweetalert';
+// import { API } from "../../data";
+import { isAutheticated } from "../../auth";
+
+function feedback() {
+ const [feedback, setFeedback] = useState([])
+
+
+ const [currentPage, setCurrentPage] = useState(1);
+ const [postsPerPage] = useState(10);
+ const token = isAutheticated();
+
+ const getRestriction = useCallback(async () => {
+ let res = await axios.get(
+ `/api/feedback/getAll`,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ // console.log(res.data.feedback)
+ setFeedback(res.data.feedback)
+
+
+ }, [token]);
+
+ useEffect(() => {
+ getRestriction();
+ }, [getRestriction]);
+
+
+ // console.log(cmsRes)
+
+ // Get current posts
+ //pagination
+ const indexOfLastPost = currentPage * postsPerPage;
+ const indexOfFirstPost = indexOfLastPost - postsPerPage;
+ const currentPosts = feedback.slice(indexOfFirstPost, indexOfLastPost);
+
+ // Change page
+ const paginate = pageNumber => setCurrentPage(pageNumber);
+
+ //change time formate
+ function formatAMPM(date) {
+ var hours = new Date(date).getHours();
+ var minutes = new Date(date).getMinutes();
+ var ampm = hours >= 12 ? 'PM' : 'AM';
+ hours = hours % 12;
+ hours = hours ? hours : 12; // the hour '0' should be '12'
+ minutes = minutes < 10 ? '0' + minutes : minutes;
+ var strTime = hours + ':' + minutes + ' ' + ampm;
+ return strTime;
+ }
+
+
+
+ return (
+ <>
+
+
+
+ {/* */}
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name |
+ Description |
+ Given At |
+ Action |
+
+
+
+ {currentPosts && currentPosts.map((item, index) =>
+
+
+ {item?.name} |
+ {item?.description} |
+
+
+
+ {new Date(`${item?.createdAt}`).toDateString()} , {`${formatAMPM(item?.createdAt)}`}
+
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+
+ )}
+
+
+
+ {/* */}
+
+
+
+
+
+ {/* */}
+
+
+
+ >
+ );
+}
+
+export default feedback;
diff --git a/src/views/News/EditNews.js b/src/views/News/EditNews.js
index a494cd4..9379dd0 100644
--- a/src/views/News/EditNews.js
+++ b/src/views/News/EditNews.js
@@ -39,7 +39,6 @@ const EditNews = () => {
// Authorization: `Bearer ${token}`,
// },
});
- // console.log(res.data.news.title)
setTitle(res.data.news.title)
setDescription(res.data.news.description)
diff --git a/src/views/News/News.js b/src/views/News/News.js
index 1fcaf72..d0553cb 100644
--- a/src/views/News/News.js
+++ b/src/views/News/News.js
@@ -119,7 +119,7 @@ function News() {
@@ -128,7 +128,7 @@ function News() {
@@ -136,7 +136,7 @@ function News() {
diff --git a/src/views/Offers/AddOffer.js b/src/views/Offers/AddOffer.js
new file mode 100644
index 0000000..f42e137
--- /dev/null
+++ b/src/views/Offers/AddOffer.js
@@ -0,0 +1,215 @@
+
+import axios from "axios";
+import React, { useCallback, useEffect, useState } from "react";
+import { API } from "../../data";
+import { isAutheticated } from "../../auth";
+import ClipLoader from "react-spinners/ClipLoader";
+import { useHistory } from "react-router-dom";
+import swal from 'sweetalert';
+
+import {
+ CButton,
+ CCard,
+ CCardBody,
+ CCol,
+ CContainer,
+ CForm,
+ CFormInput,
+ CInputGroup,
+ CInputGroupText,
+ CRow,
+} from '@coreui/react'
+import CIcon from '@coreui/icons-react'
+import { cilPencil, cilSettings, cilLockLocked, cilUser, cilBell, cilLocationPin, cilAudioDescription } from '@coreui/icons'
+const AddOffer = () => {
+ const token = isAutheticated();
+ let history = useHistory();
+ //console.log(token)
+ const [image, setImage] = useState("");
+ const [title, setTitle] = useState("");
+ const [bisunessName, setBisunessName] = useState([]);
+ const [sendBisunessName, setSendBisunessName] = useState('');
+
+ const [description, setDescription] = useState("");
+ const [location, setLocation] = useState("");
+
+ const [loading, setLoading] = useState(false);
+
+ const changeState = (newState) =>
+ setBisunessName((prevState) => ({ ...prevState, ...newState }));
+
+ const handleChange = (e) => {
+ changeState({ ...bisunessName, [e.target.name]: e.target.value })
+
+ };
+ const fetchBusuness = useCallback(async () => {
+ const res = await axios.get(`/api/directory/getAll`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ // console.log(res.data.directory);
+ setBisunessName(res.data.directory)
+
+ }, [token]);
+
+ useEffect(async () => {
+ fetchBusuness();
+
+ }, [fetchBusuness]);
+
+
+
+ const handleSubmit = async () => {
+ const myForm = new FormData();
+
+ myForm.set("title", title);
+ myForm.set("description", description);
+ myForm.set("bisunessName", sendBisunessName);
+ myForm.set("location", location);
+ myForm.set("image", image);
+ setLoading({ loading: true });
+ // console.log(image)
+ let res = await axios.post(
+ `/api/offer/create`, myForm,
+ {
+ headers: {
+ "Content-Type": 'multipart/form-data',
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ // console.log(res.data)
+ if (res.data) {
+ swal("success!", "Event Added Successfully!", "success");
+ history.goBack();
+ }
+
+ setLoading(false);
+ };
+ const handleImage = (e) => {
+ const files = e.target.files[0];
+ // console.log(files)
+ setImage(files);
+
+ };
+ //
+ const onCancel = () => {
+ // window.location = "/comproducts";
+ history.goBack()
+
+ };
+ // console.log(bisunessName)
+ return (
+ <>
+
+
+
+
+
+
+
+ Add New Offer
+
+
+
+
+
+
+ setTitle(e.target.value)}
+ value={title}
+ placeholder="Title" />
+
+
+
+
+
+
+ setDescription(e.target.value)}
+ value={description}
+ placeholder="Description" />
+
+
+
+
+
+
+
+
+
+
+
+
+ setLocation(e.target.value)}
+ value={location}
+ placeholder="Location" />
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )
+}
+
+export default AddOffer
\ No newline at end of file
diff --git a/src/views/Offers/EditOffer.js b/src/views/Offers/EditOffer.js
new file mode 100644
index 0000000..3a74d85
--- /dev/null
+++ b/src/views/Offers/EditOffer.js
@@ -0,0 +1,224 @@
+
+import axios from "axios";
+import React, { useCallback, useEffect, useState } from "react";
+import { API } from "../../data";
+import { isAutheticated } from "../../auth";
+import ClipLoader from "react-spinners/ClipLoader";
+import { useHistory } from "react-router-dom";
+import swal from 'sweetalert';
+import { Link, useParams } from "react-router-dom";
+import {
+ CButton,
+ CCard,
+ CCardBody,
+ CCol,
+ CContainer,
+ CForm,
+ CFormInput,
+ CInputGroup,
+ CInputGroupText,
+ CRow,
+} from '@coreui/react'
+import CIcon from '@coreui/icons-react'
+import { cilPencil, cilSettings, cilLockLocked, cilUser, cilBell, cilLocationPin, cilAudioDescription } from '@coreui/icons'
+const EditOffer = () => {
+ const { id } = useParams();
+ const token = isAutheticated();
+ // console.log(token)
+ let history = useHistory();
+ const [image, setImage] = useState("");
+ const [title, setTitle] = useState("");
+ const [bisunessName, setBisunessName] = useState([]);
+ const [sendBisunessName, setSendBisunessName] = useState('');
+
+ const [description, setDescription] = useState("");
+ const [location, setLocation] = useState("");
+
+ const [loading, setLoading] = useState(false);
+
+
+ //fetch one Offer
+ useEffect(async () => {
+ const res = await axios.get(`/api/offer/getOne/${id}`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ });
+ // console.log(res.data)
+ setTitle(res.data.offer.title)
+ setDescription(res.data.offer.description)
+ setLocation(res.data.offer.location)
+ setSendBisunessName(res.data.offer.bisunessName)
+
+ }, [id]);
+ const fetchBusuness = useCallback(async () => {
+ const res = await axios.get(`/api/directory/getAll`, {
+ // headers: {
+ // Authorization: `Bearer ${token}`,
+ // },
+ });
+
+ // console.log(res.data.directory);
+ setBisunessName(res.data.directory)
+
+ }, [token]);
+
+ useEffect(async () => {
+ fetchBusuness();
+
+ }, [fetchBusuness]);
+
+
+
+ const handleSubmit = async () => {
+ const myForm = new FormData();
+
+ myForm.set("title", title);
+ myForm.set("description", description);
+ myForm.set("bisunessName", sendBisunessName);
+ myForm.set("location", location);
+ myForm.set("image", image);
+ setLoading({ loading: true });
+ // console.log(image)
+ let res = await axios.put(
+ `/api/offer/update/${id}`, myForm,
+ {
+ headers: {
+ "Content-Type": 'multipart/form-data',
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ // console.log(res.data)
+ if (res.data) {
+ swal("success!", "Event Added Successfully!", "success");
+ history.goBack();
+ }
+
+ setLoading(false);
+ };
+ const handleImage = (e) => {
+ const files = e.target.files[0];
+ // console.log(files)
+ setImage(files);
+
+ };
+ //
+ const onCancel = () => {
+ // window.location = "/comproducts";
+ history.goBack()
+
+ };
+ // console.log(bisunessName)
+ return (
+ <>
+
+
+
+
+
+
+
+ Edit Offer
+
+
+
+
+
+
+ setTitle(e.target.value)}
+ value={title}
+ placeholder="Title" />
+
+
+
+
+
+
+ setDescription(e.target.value)}
+ value={description}
+ placeholder="Description" />
+
+
+
+
+
+
+
+
+
+
+
+
+ setLocation(e.target.value)}
+ value={location}
+ placeholder="Location" />
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )
+}
+
+export default EditOffer
\ No newline at end of file
diff --git a/src/views/Offers/Offer.js b/src/views/Offers/Offer.js
new file mode 100644
index 0000000..a85902d
--- /dev/null
+++ b/src/views/Offers/Offer.js
@@ -0,0 +1,162 @@
+
+import axios from "axios";
+import React, { useEffect, useState, useCallback, useMemo } from "react";
+import { Link } from "react-router-dom";
+import swal from 'sweetalert';
+// import { API } from "../../data";
+import { isAutheticated } from "../../auth";
+
+function Offer() {
+ const [offer, setOffer] = useState([])
+
+ const token = isAutheticated();
+
+ const getOffer = useCallback(async () => {
+ let res = await axios.get(
+ `/api/offer/getAll`,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ // console.log(res.data)
+ setOffer(res.data.offer)
+
+
+ }, [token]);
+
+ useEffect(() => {
+ getOffer();
+ }, [getOffer]);
+
+
+ const handleDelete = async (id) => {
+ let status = window.confirm("Do you want to delete");
+ if (!status) return;
+
+ let res = await axios.delete(`/api/offer/delete/${id}`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ });
+ console.log(res)
+ if (res.data.success == true) {
+ swal("success!", "Offer Deleted Successfully!", "success");
+ window.location.reload();
+ }
+ };
+
+
+ //change time formate
+ function formatAMPM(date) {
+ var hours = new Date(date).getHours();
+ var minutes = new Date(date).getMinutes();
+ var ampm = hours >= 12 ? 'PM' : 'AM';
+ hours = hours % 12;
+ hours = hours ? hours : 12; // the hour '0' should be '12'
+ minutes = minutes < 10 ? '0' + minutes : minutes;
+ var strTime = hours + ':' + minutes + ' ' + ampm;
+ return strTime;
+ }
+
+
+ return (
+
+
+
+ {/* */}
+
+
+
+
CMP-Offers
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+ Title |
+ Image |
+ Business Name |
+ Location |
+ Added On |
+ Action |
+
+
+
+ {offer && offer.map((item, index) =>
+
+ {item?.title} |
+
+
+  |
+ {item?.bisunessName} |
+ {item?.location} |
+
+ {/* {item?.addedOn} */}
+ {new Date(`${item?.addedOn}`).toDateString()} , {`${formatAMPM(item?.addedOn)}`}
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ )}
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+ {/* */}
+
+
+ );
+}
+
+export default Offer;
diff --git a/src/views/Offers/ViewOffer.js b/src/views/Offers/ViewOffer.js
new file mode 100644
index 0000000..c57f42b
--- /dev/null
+++ b/src/views/Offers/ViewOffer.js
@@ -0,0 +1,137 @@
+
+import axios from "axios";
+import React, { useEffect, useState, useCallback, useMemo } from "react";
+import swal from 'sweetalert';
+// import { API } from "../../data";
+import { Link, useParams } from "react-router-dom";
+import { isAutheticated } from "../../auth";
+
+function ViewOffer() {
+ const [offer, setOffer] = useState([])
+ const { id } = useParams();
+ console.log(id)
+ const token = isAutheticated();
+
+ const getOffer = useCallback(async () => {
+ let res = await axios.get(
+ `/api/offer/getOne/${id}`,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+
+ setOffer(res.data.offer)
+
+
+ }, [token]);
+
+ useEffect(() => {
+ getOffer();
+ }, [getOffer]);
+
+
+
+
+
+ //change time formate
+ function formatAMPM(date) {
+ var hours = new Date(date).getHours();
+ var minutes = new Date(date).getMinutes();
+ var ampm = hours >= 12 ? 'PM' : 'AM';
+ hours = hours % 12;
+ hours = hours ? hours : 12; // the hour '0' should be '12'
+ minutes = minutes < 10 ? '0' + minutes : minutes;
+ var strTime = hours + ':' + minutes + ' ' + ampm;
+ return strTime;
+ }
+
+
+ return (
+
+
+
+ {/* */}
+
+
+
+
CMP-Offers
+
+ {/*
+
+ -
+ CMD-App
+
+ - CMD-Category
+
+
*/}
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+ Id |
+ {offer?._id} |
+
+ Title |
+ {offer?.title} |
+
+
+ Image |
+
+
+ |
+
+ Bisuness Name |
+ {offer?.bisunessName} |
+
+ Description |
+ {offer?.description} |
+
+ Location |
+ {offer?.location} |
+
+ Added On |
+
+ {new Date(`${offer?.addedOn}`).toDateString()} , {`${formatAMPM(offer?.addedOn)}`}
+ |
+
+ Updated At |
+
+ {new Date(`${offer?.updatedAt}`).toDateString()} , {`${formatAMPM(offer?.updatedAt)}`}
+ |
+
+
+
+
+
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+ {/* */}
+
+
+ );
+}
+
+export default ViewOffer;
diff --git a/src/views/Users/Pagination.js b/src/views/Users/Pagination.js
new file mode 100644
index 0000000..55b2c76
--- /dev/null
+++ b/src/views/Users/Pagination.js
@@ -0,0 +1,25 @@
+import React from 'react';
+import { Link } from "react-router-dom";
+const Pagination = ({ userPerPage, totalUsers, paginate }) => {
+ const pageNumbers = [];
+
+ for (let i = 1; i <= Math.ceil(totalUsers / userPerPage); i++) {
+ pageNumbers.push(i);
+ }
+
+ return (
+
+ );
+};
+
+export default Pagination;
\ No newline at end of file
diff --git a/src/views/Users/ViewUsers.js b/src/views/Users/ViewUsers.js
new file mode 100644
index 0000000..7fd6ba8
--- /dev/null
+++ b/src/views/Users/ViewUsers.js
@@ -0,0 +1,131 @@
+
+import axios from "axios";
+import React, { useEffect, useState, useCallback, useMemo } from "react";
+import swal from 'sweetalert';
+// import { API } from "../../data";
+import { Link, useParams } from "react-router-dom";
+import { isAutheticated } from "../../auth";
+
+function ViewUsers() {
+ const [user, setUser] = useState([])
+ const { id } = useParams();
+ // console.log(id)
+ const token = isAutheticated();
+
+ const getUserDetails = useCallback(async () => {
+
+
+ let resp = await axios.get(
+ `/api/v1/admin/user/${id}`,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ setUser(resp.data.user)
+
+
+ }, [token]);
+
+ useEffect(() => {
+ getUserDetails();
+ }, [getUserDetails]);
+
+
+
+
+
+ //change time formate
+ function formatAMPM(date) {
+ var hours = new Date(date).getHours();
+ var minutes = new Date(date).getMinutes();
+ var ampm = hours >= 12 ? 'PM' : 'AM';
+ hours = hours % 12;
+ hours = hours ? hours : 12; // the hour '0' should be '12'
+ minutes = minutes < 10 ? '0' + minutes : minutes;
+ var strTime = hours + ':' + minutes + ' ' + ampm;
+ return strTime;
+ }
+
+
+ return (
+
+
+
+ {/* */}
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ User_Id |
+
+ {user?._id} |
+
+
+
+ Name |
+ {user?.name} |
+
+ email |
+ {user?.email} |
+
+ Image |
+
+
+ |
+
+ {/* Description | */}
+ Pnone No. |
+ {user?.phone} |
+ Role |
+ {user?.role} |
+ Register At |
+
+
+ {new Date(`${user?.createdAt}`).toDateString()} , {`${formatAMPM(user?.createdAt)}`}
+ |
+ Profile Updated At |
+
+ {new Date(`${user?.updatedAt}`).toDateString()} , {`${formatAMPM(user?.updatedAt)}`}
+ |
+
+
+
+
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+ {/* */}
+
+
+ );
+}
+
+export default ViewUsers;
+
diff --git a/src/views/Users/users.js b/src/views/Users/users.js
new file mode 100644
index 0000000..57c1bd9
--- /dev/null
+++ b/src/views/Users/users.js
@@ -0,0 +1,153 @@
+
+import axios from "axios";
+import React, { useEffect, useState, useCallback, useMemo } from "react";
+import Pagination from "./Pagination";
+import { Link } from "react-router-dom";
+import swal from 'sweetalert';
+// import { API } from "../../data";
+import { isAutheticated } from "../../auth";
+
+function users() {
+ const [users, setUsers] = useState([])
+
+
+ const [currentPage, setCurrentPage] = useState(1);
+ const [userPerPage] = useState(10);
+ const token = isAutheticated();
+
+ const getAllUsers = useCallback(async () => {
+ let res = await axios.get(
+ `/api/v1/admin/users`,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ // console.log(res.data)
+ setUsers(res.data.users)
+
+
+ }, [token]);
+
+ useEffect(() => {
+ getAllUsers();
+ }, [getAllUsers]);
+
+
+ // console.log(cmsRes)
+
+ // Get current posts
+ //pagination
+ const indexOfLastUser = currentPage * userPerPage;
+ const indexOfFirstUser = indexOfLastUser - userPerPage;
+ const currentUser = users.slice(indexOfFirstUser, indexOfLastUser);
+
+ // Change page
+ const paginate = pageNumber => setCurrentPage(pageNumber);
+
+ //change time formate
+ function formatAMPM(date) {
+ var hours = new Date(date).getHours();
+ var minutes = new Date(date).getMinutes();
+ var ampm = hours >= 12 ? 'PM' : 'AM';
+ hours = hours % 12;
+ hours = hours ? hours : 12; // the hour '0' should be '12'
+ minutes = minutes < 10 ? '0' + minutes : minutes;
+ var strTime = hours + ':' + minutes + ' ' + ampm;
+ return strTime;
+ }
+
+
+
+ return (
+ <>
+
+
+
+ {/* */}
+
+
+
+
CMP - All Users
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name |
+ email |
+ Profile Image |
+ Phone No. |
+ Register At |
+ Action |
+
+
+
+ {currentUser && currentUser.map((item, index) =>
+
+
+ {item?.name} |
+ {item?.email} |
+
+
+ |
+ {item?.phone} |
+
+
+
+
+ {new Date(`${item?.createdAt}`).toDateString()} , {`${formatAMPM(item?.createdAt)}`}
+
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+
+ )}
+
+
+
+ {/* */}
+
+
+
+
+
+ {/* */}
+
+
+
+ >
+ );
+}
+
+export default users;
diff --git a/src/views/pages/login/Login.js b/src/views/pages/login/Login.js
index ca5ddaf..1973ebd 100644
--- a/src/views/pages/login/Login.js
+++ b/src/views/pages/login/Login.js
@@ -15,11 +15,13 @@ import {
} from '@coreui/react'
import CIcon from '@coreui/icons-react'
import { cilLockLocked, cilUser } from '@coreui/icons'
+import ClipLoader from "react-spinners/ClipLoader";
import { useState } from 'react'
import axios from 'axios'
import { useHistory } from 'react-router-dom'
const Login = () => {
+ const [loading, setLoading] = useState(false);
const [auth, setAuth] = useState({
email: "",
password: ""
@@ -31,24 +33,19 @@ const Login = () => {
};
const Login = async () => {
- const res = await axios.post("/api/user/login/", auth);
+ setLoading({ loading: true })
+ const res = await axios.post("/api/v1/user/login/", auth);
if (res.data.success == true) {
localStorage.setItem("authToken", res.data.token)
- console.log(res.data)
- localStorage.setItem("auth", JSON.stringify({
- user: res.data.user,
- token: res.data.token,
-
-
- }));
history.push('/dashboard')
+ setLoading(false);
+ window.location.reload()
+
}
else {
- if (res.data.status === "blocked")
- alert(res.data.message)
- else
- alert("Invalid Credentials");
+ alert("Invalid Credentials");
+ setLoading(false);
}
}
return (
@@ -82,7 +79,9 @@ const Login = () => {
- Login
+
+ {!loading && "Login"}
+
diff --git a/src/views/pages/register/Change_password.js b/src/views/pages/register/Change_password.js
index a386109..d505333 100644
--- a/src/views/pages/register/Change_password.js
+++ b/src/views/pages/register/Change_password.js
@@ -13,6 +13,7 @@ import {
} from '@coreui/react'
import CIcon from '@coreui/icons-react'
import { cilLockLocked, cilUser } from '@coreui/icons'
+import ClipLoader from "react-spinners/ClipLoader";
import axios from 'axios'
import { isAutheticated } from 'src/auth'
import Swal from 'sweetalert2'
@@ -22,15 +23,16 @@ const Register = () => {
const [oldPassword, setOldPassword] = useState();
const [newPassword, setNewPassword] = useState();
const [confirmPassword, setConfirmPassword] = useState();
+ const [loading, setLoading] = useState(false);
const history = useHistory();
const handleSubmit = async () => {
const token = localStorage.getItem("authToken")
- //console.log(token)
+ setLoading({ loading: true })
if (newPassword == confirmPassword) {
- let res = await axios.put('/api/user/update/password',
+ let res = await axios.put('/api/v1/user/password/update',
{
oldPassword
, newPassword,
@@ -40,8 +42,9 @@ const Register = () => {
Authorization: `Bearer ${token}`,
}
})
- console.log(res)
- if (res) {
+
+ // console.log(res.data.success)
+ if (res.data.success == true) {
Swal.fire({
title: 'Done',
text: 'Password Changed',
@@ -52,10 +55,12 @@ const Register = () => {
}).then(() => {
history.push('/dashboard')
});
- }
+ }
+ setLoading(false);
} else {
alert('new password and confirm password are not matched')
+ setLoading(false);
}
}
@@ -98,7 +103,10 @@ const Register = () => {
/>
- Submit
+
+
+ {!loading && "Submit"}
+