diff --git a/src/routes.js b/src/routes.js index e0a5224..6d7d0e9 100644 --- a/src/routes.js +++ b/src/routes.js @@ -8,6 +8,7 @@ const EditCourier = React.lazy(() => import('./views/Courier/EditCourier')) const AddCourier = React.lazy(() => import('./views/Courier/AddCourier')) const Register = React.lazy(() => import('./views/pages/register/Register')) const Vendor = React.lazy(() => import('./views/Vendor/Vendor')) +const VendorDetail = React.lazy(() => import('./views/Vendor/VendorDetail')) const EditVendor = React.lazy(() => import('./views/Vendor/EditVendor')) const AddVendor = React.lazy(() => import('./views/Vendor/AddVendor')) @@ -71,6 +72,7 @@ const routes = [ { path: '/addairwaysbill', name: 'Airways Bill / Add New Entry', component: AddAirwaysBill }, { path: '/vendors', name: 'Vendors', component: Vendor }, { path: '/editvendor/:id', name: 'Edit Vendor', component: EditVendor }, + { path: '/viewvendor/:id', name: 'View Vendor', component: VendorDetail }, { path: '/addvendor', name: 'Vendors / Add New Vendor', component: AddVendor }, { path: '/dashboard', name: 'Dashboard', component: Dashboard }, { path: '/theme', name: 'Theme', component: Colors, exact: true }, diff --git a/src/views/AirwaysBill/AddAirwaysBill.js b/src/views/AirwaysBill/AddAirwaysBill.js index 94f54f4..5250522 100644 --- a/src/views/AirwaysBill/AddAirwaysBill.js +++ b/src/views/AirwaysBill/AddAirwaysBill.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { CButton, CCard, @@ -15,9 +15,51 @@ import { } from '@coreui/react' import CIcon from '@coreui/icons-react' import { cil3d, cilAirplaneMode, cilGlobeAlt, cilLocationPin, cilLockLocked, cilPeople, cilUser } from '@coreui/icons' +import { useState } from 'react'; +import axios from 'axios'; +import { isAutheticated } from 'src/auth'; const AddAirwaysBill = () => { + const { token } = isAutheticated() + const [bill, setBill] = useState({ + vendor_name: '', + city: '', + state: 'Andhra Pradesh', + country: 'India', + address_1: '', + address_2: '', + + }) + const [code, setCode] = useState() + useEffect(() => { + const generateCode = () => { + setCode(Math.round(Math.random() * 1000000000)) + } + const getData = async () => { + const res = await axios.get('/api/vendor/view', + { + headers: { + "Access-Control-Allow-Origin": "*", + "Content-type": "Application/json", + "Authorization": `Bearer ${token}` + } + }) + console.log(res.data.Stores); + } + getData(); + generateCode() + }, []) + const formatDate = () => { + let today = new Date(); + let dd = String(today.getDate()).padStart(2, '0'); + let mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0! + let yyyy = today.getFullYear(); + + today = dd + '/' + mm + '/' + yyyy; + return today + } + return
@@ -28,12 +70,12 @@ const AddAirwaysBill = () => {

ID:

5324756898
-

(auto-generated)

+ {/*

(auto-generated)

*/}

Date:

-
11/11/11
-

(auto-generated)

+
{formatDate()}
+ {/*

(auto-generated)

*/}
diff --git a/src/views/Courier/Courier.js b/src/views/Courier/Courier.js index 5483988..d0871fe 100644 --- a/src/views/Courier/Courier.js +++ b/src/views/Courier/Courier.js @@ -55,7 +55,8 @@ const Courier = () => { confirmButtonColor: '#303c54', iconColor: '#303c54' }).then(() => { - history.push('/courier'); + // history.push('/courier'); + location.reload(); }); } else { Swal("Oops!", "Something went wrong!", "error"); diff --git a/src/views/Vendor/AddVendor.js b/src/views/Vendor/AddVendor.js index c20b7ed..a16ad57 100644 --- a/src/views/Vendor/AddVendor.js +++ b/src/views/Vendor/AddVendor.js @@ -99,7 +99,7 @@ const AddVendor = () => {

Code:

{code}
-

(auto-generated)

+ {/*

(auto-generated)

*/}
diff --git a/src/views/Vendor/Vendor.js b/src/views/Vendor/Vendor.js index 298d5ec..608b7f2 100644 --- a/src/views/Vendor/Vendor.js +++ b/src/views/Vendor/Vendor.js @@ -61,7 +61,8 @@ const Vendor = () => { confirmButtonColor: '#303c54', iconColor: '#303c54' }).then(() => { - history.push('/vendors'); + // history.('/vendors'); + location.reload(); }); } else { Swal("Oops!", "Something went wrong!", "error"); @@ -87,33 +88,12 @@ const Vendor = () => { {item.code} {item.city} - - Edit - - View + history.push(`/editvendor/${item._id}`)}>Edit + history.push(`/viewvendor/${item._id}`)}>View handleDelete(item._id)}>Delete - )} - {/* - {data?.map(item => { - - -

{item.city}

- {item.vendor_name} - {item.code} - {item.city} - - - Edit - View - Delete - - -
- })} - - -
*/} + )} +
; }; diff --git a/src/views/Vendor/VendorDetail.js b/src/views/Vendor/VendorDetail.js new file mode 100644 index 0000000..5225e0e --- /dev/null +++ b/src/views/Vendor/VendorDetail.js @@ -0,0 +1,80 @@ +import React, { useEffect, useState } from 'react'; +import { + CTable, + CTableBody, + CTableDataCell, + CTableHead, + CTableHeaderCell, + CTableRow, +} from '@coreui/react' +import { useParams } from 'react-router-dom'; +import axios from 'axios'; +import { isAutheticated } from '../../auth'; + + + +const VendorDetail = () => { + const [data, setData] = useState({}); + const { id } = useParams() + const { token } = isAutheticated(); + + useEffect(() => { + const getData = async () => { + const res = await axios.get(`/api/vendor/view/${id}`, { + headers: { + "Access-Control-Allow-Origin": "*", + "Content-type": "Application/json", + "Authorization": `Bearer ${token}` + } + }); + if (res) { + setData(res?.data?.Store) + } + + } + getData(); + }, []); + console.log(data); + const formatDate = (date) => { + let today = new Date(date); + let dd = String(today.getDate()).padStart(2, '0'); + let mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0! + let yyyy = today.getFullYear(); + + today = dd + '/' + mm + '/' + yyyy; + return today + } + + + return
+

Vendor Details

+ + + + Unique ID + {data._id} + + + + + Code + {data.code} + + + Vendor Name + {data.vendor_name} + + + Added On + {formatDate(data.createdAt)} + + + Address + {data.address_1},{data.address_2},{data.city},{data.state},{data.country} + + + +
; +}; + +export default VendorDetail;