From 407ba2868ae39bdde744cc9e4d3c0d156a8c31b1 Mon Sep 17 00:00:00 2001
From: pawan-dot <71133473+pawan-dot@users.noreply.github.com>
Date: Thu, 23 Feb 2023 21:48:40 +0530
Subject: [PATCH] compalian
---
src/_nav.js | 148 ++++----
src/index.js | 4 +-
src/routes.js | 20 ++
src/views/Complaints/AddComplaint.js | 9 +
src/views/Complaints/Complaints.js | 332 ++++++++++++++++++
src/views/Complaints/ViewComplaint.js | 9 +
src/views/Departures/AddDeparture.js | 340 +++++++++++++++++++
src/views/Departures/Departures.js | 389 ++++++++++++++++++++++
src/views/Informations/AddInformations.js | 217 ++++++++++++
src/views/Informations/Informations.js | 311 +++++++++++++++++
src/views/Profile/EditProfile.js | 4 +-
11 files changed, 1716 insertions(+), 67 deletions(-)
create mode 100644 src/views/Complaints/AddComplaint.js
create mode 100644 src/views/Complaints/Complaints.js
create mode 100644 src/views/Complaints/ViewComplaint.js
create mode 100644 src/views/Departures/AddDeparture.js
create mode 100644 src/views/Departures/Departures.js
create mode 100644 src/views/Informations/AddInformations.js
create mode 100644 src/views/Informations/Informations.js
diff --git a/src/_nav.js b/src/_nav.js
index 22aec88..1c3eb0a 100644
--- a/src/_nav.js
+++ b/src/_nav.js
@@ -2,6 +2,7 @@ import React from 'react'
import CIcon from '@coreui/icons-react'
import {
cilAddressBook,
+ cilAirplaneMode,
cilAppsSettings,
cilBell,
cilCalculator,
@@ -9,10 +10,12 @@ import {
cilChartPie,
cilClipboard,
cilCommand,
+ cilCompress,
cilCursor,
cilDrop,
cilFace,
cilFilterSquare,
+ cilInfo,
cilLoopCircular,
cilMedicalCross,
cilMoney,
@@ -50,54 +53,73 @@ const _nav = [
},
{
component: CNavItem,
- name: 'Franchisee',
- icon: ,
- to: '/franchisees',
+ name: 'Departures',
+ icon: ,
+ to: '/departures',
},
{
- component: CNavGroup,
- name: 'Franchisee Orders',
- icon: ,
- items: [
- {
- component: CNavItem,
- name: 'New',
- icon: ,
- to: '/orders/new',
- },
- {
- component: CNavItem,
- name: 'Paid',
- icon: ,
- to: '/orders/returned',
- },
- {
- component: CNavItem,
- name: 'Processing',
- icon: ,
- to: '/orders/processing',
- },
- {
- component: CNavItem,
- name: 'Dispatched',
- icon: ,
- to: '/orders/dispatched',
- },
- {
- component: CNavItem,
- name: 'Delivered',
- icon: ,
- to: '/orders/delivered',
- },
- {
- component: CNavItem,
- name: 'Cancelled',
- icon: ,
- to: '/orders/cancelled',
- },
-
- ],
+ component: CNavItem,
+ name: 'Complaints',
+ icon: ,
+ to: '/complaints',
},
+ {
+ component: CNavItem,
+ name: 'Information',
+ icon: ,
+ to: '/informations',
+ },
+
+ // {
+ // component: CNavItem,
+ // name: 'Franchisee',
+ // icon: ,
+ // to: '/franchisees',
+ // },
+ // {
+ // component: CNavGroup,
+ // name: 'Franchisee Orders',
+ // icon: ,
+ // items: [
+ // {
+ // component: CNavItem,
+ // name: 'New',
+ // icon: ,
+ // to: '/orders/new',
+ // },
+ // {
+ // component: CNavItem,
+ // name: 'Paid',
+ // icon: ,
+ // to: '/orders/returned',
+ // },
+ // {
+ // component: CNavItem,
+ // name: 'Processing',
+ // icon: ,
+ // to: '/orders/processing',
+ // },
+ // {
+ // component: CNavItem,
+ // name: 'Dispatched',
+ // icon: ,
+ // to: '/orders/dispatched',
+ // },
+ // {
+ // component: CNavItem,
+ // name: 'Delivered',
+ // icon: ,
+ // to: '/orders/delivered',
+ // },
+ // {
+ // component: CNavItem,
+ // name: 'Cancelled',
+ // icon: ,
+ // to: '/orders/cancelled',
+ // },
+
+ // ],
+ // },
{
@@ -111,18 +133,18 @@ const _nav = [
name: 'Configuration',
icon: ,
items: [
- {
- component: CNavItem,
- name: 'Cities',
- icon: ,
- to: '/cities',
- },
- {
- component: CNavItem,
- name: 'States',
- icon: ,
- to: '/states',
- },
+ // {
+ // component: CNavItem,
+ // name: 'Cities',
+ // icon: ,
+ // to: '/cities',
+ // },
+ // {
+ // component: CNavItem,
+ // name: 'States',
+ // icon: ,
+ // to: '/states',
+ // },
// {
// component: CNavItem,
// name: 'Standard Shipping',
@@ -141,12 +163,12 @@ const _nav = [
// icon: ,
// to: '/pincode',
// },
- {
- component: CNavItem,
- name: 'Tax Rates',
- icon: ,
- to: '/tax',
- },
+ // {
+ // component: CNavItem,
+ // name: 'Tax Rates',
+ // icon: ,
+ // to: '/tax',
+ // },
// {
// component: CNavItem,
// name: 'Pages',
diff --git a/src/index.js b/src/index.js
index 1e256bf..c7cc467 100644
--- a/src/index.js
+++ b/src/index.js
@@ -11,8 +11,8 @@ import axios from 'axios'
import { store } from './redux/store';
const setupAxios = () => {
- // axios.defaults.baseURL = 'https://atpapi.checkapp.one'
- axios.defaults.baseURL = 'http://localhost:5000'
+ axios.defaults.baseURL = 'https://atpapi.checkapp.one'
+ //axios.defaults.baseURL = 'http://localhost:5000'
axios.defaults.headers = {
'Cache-Control': 'no-cache,no-store',
'Pragma': 'no-cache',
diff --git a/src/routes.js b/src/routes.js
index e243285..c0d8f27 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -47,6 +47,13 @@ import Addtax from './views/configuration/tax/Addtax'
import Edittax from './views/configuration/tax/Edittax'
import EditOrder from './views/orders/EditOrder'
import ViewOrders from './views/orders/ViewOrders'
+import Departures from './views/Departures/Departures'
+import AddDeparture from './views/Departures/AddDeparture'
+import Informations from './views/Informations/Informations'
+import AddInformations from './views/Informations/AddInformations'
+import Complaints from './views/Complaints/Complaints'
+import AddComplaint from './views/Complaints/AddComplaint'
+import ViewComplaint from './views/Complaints/ViewComplaint'
const routes = [
@@ -61,6 +68,19 @@ const routes = [
{ path: '/product/add', name: 'Add products', element: AddProduct },
{ path: '/product/edit/:id', name: 'Edit products', element: EditProduct },
{ path: '/product/view/:id', name: 'view products', element: ViewProduct },
+ //Departure
+ { path: '/departures', name: 'Departures', element: Departures },
+ { path: '/departure/add', name: 'Add Departure', element: AddDeparture },
+ { path: '/product/edit/:id', name: 'Edit products', element: EditProduct },
+ { path: '/product/view/:id', name: 'view products', element: ViewProduct },
+ //Complaints
+ { path: '/complaints', name: 'Complaints', element: Complaints },
+ { path: '/complaint/new', name: 'Add Complaint', element: AddComplaint },
+ { path: '/complaint/view/:id', name: 'view Complain', element: ViewComplaint },
+ //informations
+ { path: '/informations', name: 'Informations', element: Informations },
+ { path: '/information/new', name: 'Add Informations', element: AddInformations },
+
//Order Management
diff --git a/src/views/Complaints/AddComplaint.js b/src/views/Complaints/AddComplaint.js
new file mode 100644
index 0000000..b968f84
--- /dev/null
+++ b/src/views/Complaints/AddComplaint.js
@@ -0,0 +1,9 @@
+import React from 'react'
+
+const AddComplaint = () => {
+ return (
+
AddComplaint
+ )
+}
+
+export default AddComplaint
\ No newline at end of file
diff --git a/src/views/Complaints/Complaints.js b/src/views/Complaints/Complaints.js
new file mode 100644
index 0000000..f1191fe
--- /dev/null
+++ b/src/views/Complaints/Complaints.js
@@ -0,0 +1,332 @@
+
+
+import React, { useState, useEffect } from 'react'
+import { Link } from 'react-router-dom'
+import Button from '@material-ui/core/Button'
+import { useNavigate } from 'react-router-dom'
+import axios from 'axios'
+import { isAutheticated } from 'src/auth'
+
+const Complaints = () => {
+ const token = isAutheticated()
+ const navigate = useNavigate()
+ const [loading, setLoading] = useState(true)
+ const [success, setSuccess] = useState(true)
+ const [ComplaintsData, setComplaintsData] = useState([])
+
+ const [currentPage, setCurrentPage] = useState(1)
+ const [itemPerPage, setItemPerPage] = useState(10)
+ const [showData, setShowData] = useState(ComplaintsData)
+
+ const handleShowEntries = (e) => {
+ setCurrentPage(1)
+ setItemPerPage(e.target.value)
+ }
+
+
+
+ const getComplaintsData = async () => {
+ axios
+ .get(`/api/information/getAll/`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ })
+ .then((res) => {
+ setComplaintsData(res.data?.information)
+ setLoading(false)
+ })
+ .catch((err) => {
+ setLoading(false)
+ })
+ }
+
+ useEffect(() => {
+ getComplaintsData()
+ }, [success])
+
+ useEffect(() => {
+ const loadData = () => {
+ const indexOfLastPost = currentPage * itemPerPage
+ const indexOfFirstPost = indexOfLastPost - itemPerPage
+ setShowData(ComplaintsData.slice(indexOfFirstPost, indexOfLastPost))
+ }
+ loadData()
+ }, [currentPage, itemPerPage, ComplaintsData])
+
+ 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/product/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,
+ })
+ })
+ }
+ })
+ }
+
+ return (
+
+
+
+
+
+
+
+ Complaints
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID |
+ Mobile or EMail |
+ Date & Time |
+
+
+ Action |
+
+
+
+ {!loading && showData.length === 0 && (
+
+
+ No Data Available
+ |
+
+ )}
+ {loading ? (
+
+
+ Loading...
+ |
+
+ ) : (
+ showData.map((product, i) => {
+ return (
+
+ {product.title} |
+
+ {product.description} |
+
+ {new Date(product.createdAt).toLocaleString('en-IN', {
+ weekday: 'short',
+ month: 'short',
+ day: 'numeric',
+ year: 'numeric',
+ hour: 'numeric',
+ minute: 'numeric',
+ hour12: true,
+ })}
+ |
+
+
+
+
+
+ |
+
+
+ )
+ })
+ )}
+
+
+
+
+
+
+
+ Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
+ {Math.min(currentPage * itemPerPage, ComplaintsData.length)} of{' '}
+ {ComplaintsData.length} entries
+
+
+
+
+
+
+ -
+ setCurrentPage((prev) => prev - 1)}
+ >
+ Previous
+
+
+
+ {!(currentPage - 1 < 1) && (
+ -
+ setCurrentPage((prev) => prev - 1)}
+ >
+ {currentPage - 1}
+
+
+ )}
+
+ -
+
+ {currentPage}
+
+
+
+ {!(
+ (currentPage + 1) * itemPerPage - itemPerPage >
+ ComplaintsData.length - 1
+ ) && (
+ -
+ {
+ setCurrentPage((prev) => prev + 1)
+ }}
+ >
+ {currentPage + 1}
+
+
+ )}
+
+ -
+ ComplaintsData.length - 1
+ )
+ ? 'paginate_button page-item next'
+ : 'paginate_button page-item next disabled'
+ }
+ >
+ setCurrentPage((prev) => prev + 1)}
+ >
+ Next
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default Complaints
diff --git a/src/views/Complaints/ViewComplaint.js b/src/views/Complaints/ViewComplaint.js
new file mode 100644
index 0000000..40fc5f9
--- /dev/null
+++ b/src/views/Complaints/ViewComplaint.js
@@ -0,0 +1,9 @@
+import React from 'react'
+
+const ViewComplaint = () => {
+ return (
+ ViewComplaint
+ )
+}
+
+export default ViewComplaint
\ No newline at end of file
diff --git a/src/views/Departures/AddDeparture.js b/src/views/Departures/AddDeparture.js
new file mode 100644
index 0000000..22eab87
--- /dev/null
+++ b/src/views/Departures/AddDeparture.js
@@ -0,0 +1,340 @@
+
+import React, { useEffect, useState } from 'react'
+import Button from '@material-ui/core/Button'
+import { Link, useNavigate } from 'react-router-dom'
+import swal from 'sweetalert'
+import axios from 'axios'
+import { isAutheticated } from 'src/auth'
+// import { WebsiteURL } from '../WebsiteURL'
+
+const AddDeparture = () => {
+ const token = isAutheticated()
+ const navigate = useNavigate()
+ const [data, setData] = useState({
+ FlightNumber: '',
+ Airline: '',
+ Destination: '',
+ GateNumber: '',
+
+ ActualTimeofDeparture: '',
+ EstimatedTimeofDeparture: '',
+ ScheduledTimeofDeparture: '',
+ Status: '',
+
+
+
+
+ })
+
+
+ const [loading, setLoading] = useState(false)
+
+
+
+
+
+
+
+ const handleChange = (e) => {
+ setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
+ }
+ const handleClick = (e) => {
+ setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
+ }
+
+
+
+
+ const handleSubmit = () => {
+ if (
+
+ data.FlightNumber.trim() === '' ||
+
+ data.Airline.trim() === '' ||
+ data.Destination === '' ||
+ data.GateNumber === '' ||
+ data.ActualTimeofDeparture === '' ||
+ data.EstimatedTimeofDeparture === '' ||
+ data.ScheduledTimeofDeparture === ''
+ // data.Status === ''
+
+ ) {
+ swal({
+ title: 'Warning',
+ text: 'Fill all mandatory fields',
+ icon: 'error',
+ button: 'Close',
+ dangerMode: true,
+ })
+ return
+ }
+ setLoading(true)
+ const formData = new FormData()
+ formData.set('FlightNumber', data.FlightNumber)
+
+ formData.set('Airline', data.Airline)
+ formData.set('Destination', data.Destination)
+ formData.set('GateNumber', data.GateNumber)
+
+ formData.set('ActualTimeofDeparture', data.ActualTimeofDeparture)
+ formData.set('EstimatedTimeofDeparture', data.EstimatedTimeofDeparture)
+
+ formData.set('ScheduledTimeofDeparture', data.ScheduledTimeofDeparture)
+ formData.set('Status', data.Status)
+
+
+
+ axios
+ .post(`/api/departure/flight/new/`, formData, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ 'Content-Type': 'multipart/formdata',
+ 'Access-Control-Allow-Origin': '*',
+ },
+ })
+ .then((res) => {
+ swal({
+ title: 'Added',
+ text: 'New Flight added successfully!',
+ icon: 'success',
+ button: 'ok',
+ })
+ setLoading(false)
+ navigate('/departures', { 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,
+ })
+ })
+ }
+
+ return (
+
+
+
+
+
+ Add New Flight
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default AddDeparture
diff --git a/src/views/Departures/Departures.js b/src/views/Departures/Departures.js
new file mode 100644
index 0000000..6e78cd8
--- /dev/null
+++ b/src/views/Departures/Departures.js
@@ -0,0 +1,389 @@
+
+
+import React, { useState, useEffect } from 'react'
+import { Link } from 'react-router-dom'
+import Button from '@material-ui/core/Button'
+import { useNavigate } from 'react-router-dom'
+import axios from 'axios'
+import { isAutheticated } from 'src/auth'
+
+const Departures = () => {
+ const token = isAutheticated()
+ const navigate = useNavigate()
+ const [loading, setLoading] = useState(true)
+ const [success, setSuccess] = useState(true)
+ const [DeparturesData, setDeparturesData] = useState([])
+
+ const [currentPage, setCurrentPage] = useState(1)
+ const [itemPerPage, setItemPerPage] = useState(10)
+ const [showData, setShowData] = useState(DeparturesData)
+
+ const handleShowEntries = (e) => {
+ setCurrentPage(1)
+ setItemPerPage(e.target.value)
+ }
+
+
+
+ const getDeparturesData = async () => {
+ axios
+ .get(`/api/departure/flight/getAll/`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ })
+ .then((res) => {
+ console.log(res.data.departure)
+ setDeparturesData(res.data?.departure)
+ setLoading(false)
+ })
+ .catch((err) => {
+ setLoading(false)
+ })
+ }
+
+ useEffect(() => {
+ getDeparturesData()
+ }, [success])
+
+ useEffect(() => {
+ const loadData = () => {
+ const indexOfLastPost = currentPage * itemPerPage
+ const indexOfFirstPost = indexOfLastPost - itemPerPage
+ setShowData(DeparturesData.slice(indexOfFirstPost, indexOfLastPost))
+ }
+ loadData()
+ }, [currentPage, itemPerPage, DeparturesData])
+
+ 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/product/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,
+ })
+ })
+ }
+ })
+ }
+
+ return (
+
+
+
+
+
+
+
+ Departures
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Flight Number |
+ Airline |
+ Destination |
+ Gate Number |
+
+ Actual Time of Departure |
+ Scheduled Time of Departure |
+
+ Estimated Time of Departure |
+ Status |
+
+
+ Added On |
+ {/* Actions | */}
+
+
+
+ {!loading && showData.length === 0 && (
+
+
+ No Data Available
+ |
+
+ )}
+ {loading ? (
+
+
+ Loading...
+ |
+
+ ) : (
+ showData.map((product, i) => {
+ return (
+
+ {product.FlightNumber} |
+
+ {product.Airline} |
+ {product.Destination} |
+
+ {product.GateNumber} |
+
+ {product.ActualTimeofDeparture} |
+ {product.ScheduledTimeofDeparture} |
+
+ {product.EstimatedTimeofDeparture} |
+
+ |
+
+
+
+ {new Date(product.createdAt).toLocaleString('en-IN', {
+ weekday: 'short',
+ month: 'short',
+ day: 'numeric',
+ year: 'numeric',
+ hour: 'numeric',
+ minute: 'numeric',
+ hour12: true,
+ })}
+ |
+ {/*
+
+
+
+
+
+
+
+
+
+
+ | */}
+
+ )
+ })
+ )}
+
+
+
+
+
+
+
+ Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
+ {Math.min(currentPage * itemPerPage, DeparturesData.length)} of{' '}
+ {DeparturesData.length} entries
+
+
+
+
+
+
+ -
+ setCurrentPage((prev) => prev - 1)}
+ >
+ Previous
+
+
+
+ {!(currentPage - 1 < 1) && (
+ -
+ setCurrentPage((prev) => prev - 1)}
+ >
+ {currentPage - 1}
+
+
+ )}
+
+ -
+
+ {currentPage}
+
+
+
+ {!(
+ (currentPage + 1) * itemPerPage - itemPerPage >
+ DeparturesData.length - 1
+ ) && (
+ -
+ {
+ setCurrentPage((prev) => prev + 1)
+ }}
+ >
+ {currentPage + 1}
+
+
+ )}
+
+ -
+ DeparturesData.length - 1
+ )
+ ? 'paginate_button page-item next'
+ : 'paginate_button page-item next disabled'
+ }
+ >
+ setCurrentPage((prev) => prev + 1)}
+ >
+ Next
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default Departures
diff --git a/src/views/Informations/AddInformations.js b/src/views/Informations/AddInformations.js
new file mode 100644
index 0000000..9df6002
--- /dev/null
+++ b/src/views/Informations/AddInformations.js
@@ -0,0 +1,217 @@
+
+
+
+
+
+
+
+
+import React, { useEffect, useState } from 'react'
+import Button from '@material-ui/core/Button'
+import { Link, useNavigate } from 'react-router-dom'
+import swal from 'sweetalert'
+import axios from 'axios'
+import { isAutheticated } from 'src/auth'
+// import { WebsiteURL } from '../WebsiteURL'
+
+const AddInformations = () => {
+ const token = isAutheticated()
+ const navigate = useNavigate()
+ const [data, setData] = useState({
+
+ title: '',
+ description: '',
+
+
+
+ })
+
+
+ const [loading, setLoading] = useState(false)
+
+
+
+
+
+
+
+ const handleChange = (e) => {
+
+
+ setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
+ }
+
+
+
+
+ const handleSubmit = () => {
+ if (
+ data.title.trim() === '' ||
+
+ data.description.trim() === ''
+
+ ) {
+ swal({
+ title: 'Warning',
+ text: 'Fill all mandatory fields',
+ icon: 'error',
+ button: 'Close',
+ dangerMode: true,
+ })
+ return
+ }
+ setLoading(true)
+ const formData = new FormData()
+ formData.set('title', data.title)
+
+ formData.set('description', data.description)
+
+
+
+ axios
+ .post(`/api/information/new/`, formData, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ 'Content-Type': 'multipart/formdata',
+ 'Access-Control-Allow-Origin': '*',
+ },
+ })
+ .then((res) => {
+ swal({
+ title: 'Added',
+ text: 'information added successfully!',
+ icon: 'success',
+ button: 'ok',
+ })
+ setLoading(false)
+ navigate('/informations', { 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,
+ })
+ })
+ }
+
+ return (
+
+
+
+
+
+ Add Information
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ handleChange(e)}
+ />
+ {data.title ? <>
+ {150 - data.title.length} characters left
+ > : <>>
+
+ }
+
+
+
+
+
+ {data.description ? <>
+ {500 - data.description.length} characters left
+ > : <>>
+ }
+
+
+
+ {/*
+
+
+
+
*/}
+
+
+
+
+
+
+ )
+}
+
+export default AddInformations
diff --git a/src/views/Informations/Informations.js b/src/views/Informations/Informations.js
new file mode 100644
index 0000000..dc324f7
--- /dev/null
+++ b/src/views/Informations/Informations.js
@@ -0,0 +1,311 @@
+
+
+import React, { useState, useEffect } from 'react'
+import { Link } from 'react-router-dom'
+import Button from '@material-ui/core/Button'
+import { useNavigate } from 'react-router-dom'
+import axios from 'axios'
+import { isAutheticated } from 'src/auth'
+
+const Informations = () => {
+ const token = isAutheticated()
+ const navigate = useNavigate()
+ const [loading, setLoading] = useState(true)
+ const [success, setSuccess] = useState(true)
+ const [InformationsData, setInformationsData] = useState([])
+
+ const [currentPage, setCurrentPage] = useState(1)
+ const [itemPerPage, setItemPerPage] = useState(10)
+ const [showData, setShowData] = useState(InformationsData)
+
+ const handleShowEntries = (e) => {
+ setCurrentPage(1)
+ setItemPerPage(e.target.value)
+ }
+
+
+
+ const getInformationsData = async () => {
+ axios
+ .get(`/api/information/getAll/`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ })
+ .then((res) => {
+ setInformationsData(res.data?.information)
+ setLoading(false)
+ })
+ .catch((err) => {
+ setLoading(false)
+ })
+ }
+
+ useEffect(() => {
+ getInformationsData()
+ }, [success])
+
+ useEffect(() => {
+ const loadData = () => {
+ const indexOfLastPost = currentPage * itemPerPage
+ const indexOfFirstPost = indexOfLastPost - itemPerPage
+ setShowData(InformationsData.slice(indexOfFirstPost, indexOfLastPost))
+ }
+ loadData()
+ }, [currentPage, itemPerPage, InformationsData])
+
+ 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/product/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,
+ })
+ })
+ }
+ })
+ }
+
+ return (
+
+
+
+
+
+
+
+ Informations
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Title |
+ Description |
+ {/* Base Price | */}
+ Added On |
+ {/* Actions | */}
+
+
+
+ {!loading && showData.length === 0 && (
+
+
+ No Data Available
+ |
+
+ )}
+ {loading ? (
+
+
+ Loading...
+ |
+
+ ) : (
+ showData.map((product, i) => {
+ return (
+
+ {product.title} |
+
+ {product.description} |
+
+ {new Date(product.createdAt).toLocaleString('en-IN', {
+ weekday: 'short',
+ month: 'short',
+ day: 'numeric',
+ year: 'numeric',
+ hour: 'numeric',
+ minute: 'numeric',
+ hour12: true,
+ })}
+ |
+
+
+ )
+ })
+ )}
+
+
+
+
+
+
+
+ Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
+ {Math.min(currentPage * itemPerPage, InformationsData.length)} of{' '}
+ {InformationsData.length} entries
+
+
+
+
+
+
+ -
+ setCurrentPage((prev) => prev - 1)}
+ >
+ Previous
+
+
+
+ {!(currentPage - 1 < 1) && (
+ -
+ setCurrentPage((prev) => prev - 1)}
+ >
+ {currentPage - 1}
+
+
+ )}
+
+ -
+
+ {currentPage}
+
+
+
+ {!(
+ (currentPage + 1) * itemPerPage - itemPerPage >
+ InformationsData.length - 1
+ ) && (
+ -
+ {
+ setCurrentPage((prev) => prev + 1)
+ }}
+ >
+ {currentPage + 1}
+
+
+ )}
+
+ -
+ InformationsData.length - 1
+ )
+ ? 'paginate_button page-item next'
+ : 'paginate_button page-item next disabled'
+ }
+ >
+ setCurrentPage((prev) => prev + 1)}
+ >
+ Next
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default Informations
diff --git a/src/views/Profile/EditProfile.js b/src/views/Profile/EditProfile.js
index d794c61..b1dc77d 100644
--- a/src/views/Profile/EditProfile.js
+++ b/src/views/Profile/EditProfile.js
@@ -151,7 +151,7 @@ const EditProfile = () => {
- {
{imagesPreview &&
}
-
+ */}
{loading ? 'Loading...' : 'Submit'}
Cancel