added
This commit is contained in:
parent
6db066687c
commit
6b4e09abe1
@ -1,8 +1,8 @@
|
||||
import React from 'react'
|
||||
|
||||
|
||||
const AirwaysBill = React.lazy(() => import('./views/AirwaysBill/AirwaysBill'))
|
||||
const AddAirwaysBill = React.lazy(() => import('./views/AirwaysBill/AddAirwaysBill'))
|
||||
const AirwayBillDetail = React.lazy(() => import('./views/AirwaysBill/AirwayBillDetail'))
|
||||
const Courier = React.lazy(() => import('./views/Courier/Courier'))
|
||||
const EditCourier = React.lazy(() => import('./views/Courier/EditCourier'))
|
||||
const AddCourier = React.lazy(() => import('./views/Courier/AddCourier'))
|
||||
@ -70,6 +70,7 @@ const routes = [
|
||||
{ path: '/addcourier', name: 'Courier / Add Courier', component: AddCourier },
|
||||
{ path: '/airwaysbill', name: 'Airways Bill', component: AirwaysBill },
|
||||
{ path: '/addairwaysbill', name: 'Airways Bill / Add New Entry', component: AddAirwaysBill },
|
||||
{ path: '/viewbill/:id', name: 'View Bill', component: AirwayBillDetail }, ,
|
||||
{ path: '/vendors', name: 'Vendors', component: Vendor },
|
||||
{ path: '/editvendor/:id', name: 'Edit Vendor', component: EditVendor },
|
||||
{ path: '/viewvendor/:id', name: 'View Vendor', component: VendorDetail },
|
||||
|
@ -18,6 +18,8 @@ import { cil3d, cilAirplaneMode, cilGlobeAlt, cilLocationPin, cilLockLocked, cil
|
||||
import { useState } from 'react';
|
||||
import axios from 'axios';
|
||||
import { isAutheticated } from 'src/auth';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import Swal from 'sweetalert2';
|
||||
|
||||
|
||||
const AddAirwaysBill = () => {
|
||||
@ -27,17 +29,28 @@ const AddAirwaysBill = () => {
|
||||
city: '',
|
||||
state: 'Andhra Pradesh',
|
||||
country: 'India',
|
||||
address_1: '',
|
||||
address_2: '',
|
||||
|
||||
from_address_1: '',
|
||||
from_address_2: '',
|
||||
to_address_1: '',
|
||||
to_name: '',
|
||||
to_address_2: '',
|
||||
AWB: '',
|
||||
courier: ''
|
||||
})
|
||||
const [showCouriers, setShowCouriers] = useState([])
|
||||
const [showVendors, setShowVendors] = useState([])
|
||||
const [code, setCode] = useState()
|
||||
const history = useHistory()
|
||||
|
||||
useEffect(() => {
|
||||
const generateCode = () => {
|
||||
setCode(Math.round(Math.random() * 1000000000))
|
||||
}
|
||||
|
||||
|
||||
const getData = async () => {
|
||||
const res = await axios.get('/api/vendor/view',
|
||||
|
||||
const couriers = await axios.get('/api/courier',
|
||||
{
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
@ -45,11 +58,25 @@ const AddAirwaysBill = () => {
|
||||
"Authorization": `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
console.log(res.data.Stores);
|
||||
const vendors = await axios.get('/api/vendor/view',
|
||||
{
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Content-type": "Application/json",
|
||||
"Authorization": `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
|
||||
console.log(couriers.data.Pincode);
|
||||
console.log(vendors.data.Stores);
|
||||
setShowVendors(vendors.data.Stores)
|
||||
setShowCouriers(couriers.data.Pincode)
|
||||
}
|
||||
getData();
|
||||
generateCode()
|
||||
}, [])
|
||||
|
||||
|
||||
const formatDate = () => {
|
||||
let today = new Date();
|
||||
let dd = String(today.getDate()).padStart(2, '0');
|
||||
@ -60,6 +87,32 @@ const AddAirwaysBill = () => {
|
||||
return today
|
||||
}
|
||||
|
||||
const handleChange = (e) => (event) => {
|
||||
setBill({ ...bill, [e]: event.target.value });
|
||||
};
|
||||
const handleClick = async () => {
|
||||
let res = await axios.post('/api/airways/add', { ...bill, code }, {
|
||||
headers: {
|
||||
"Authorization": `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
if ((res.data.message === "Success")) {
|
||||
console.log(res.data);
|
||||
Swal.fire({
|
||||
title: 'Done',
|
||||
text: 'Bill Added',
|
||||
icon: 'success',
|
||||
confirmButtonText: 'ok',
|
||||
confirmButtonColor: '#303c54',
|
||||
iconColor: '#303c54'
|
||||
}).then(() => {
|
||||
history.push('/airwaysbill')
|
||||
});
|
||||
} else {
|
||||
Swal("Oops!", "Something went wrong!", "error");
|
||||
}
|
||||
}
|
||||
|
||||
return <div className="bg-light min-vh-100 d-flex flex-row align-items-start">
|
||||
<CContainer>
|
||||
<CRow className="justify-content-start">
|
||||
@ -69,7 +122,7 @@ const AddAirwaysBill = () => {
|
||||
<p className="text-medium-emphasis">Fill the fields and submit to add a new bill</p>
|
||||
<CRow className='flex-row align-items-center'>
|
||||
<CCol md={2} ><h4>ID:</h4></CCol>
|
||||
<CCol><h6>5324756898</h6></CCol>
|
||||
<CCol><h6>{code}</h6></CCol>
|
||||
{/* <p className="text-medium-emphasis">(auto-generated)</p> */}
|
||||
</CRow>
|
||||
<CRow className='flex-row align-items-center'>
|
||||
@ -83,13 +136,14 @@ const AddAirwaysBill = () => {
|
||||
</CInputGroupText>
|
||||
<CFormSelect
|
||||
aria-label="Default select example"
|
||||
options={[
|
||||
'Select Vendor',
|
||||
{ label: 'One', value: '1' },
|
||||
{ label: 'Two', value: '2' },
|
||||
{ label: 'Three', value: '3', disabled: true }
|
||||
]}
|
||||
/>
|
||||
onChange={handleChange('vendor_name')}
|
||||
>
|
||||
<option value='India'>Select Vendor</option>{
|
||||
showVendors.map((item) =>
|
||||
<option value={item.vendor_name}>{item.vendor_name}</option>
|
||||
)
|
||||
}
|
||||
</CFormSelect>
|
||||
</CInputGroup>
|
||||
<CInputGroup className="mb-3">
|
||||
<CInputGroupText>
|
||||
@ -98,12 +152,14 @@ const AddAirwaysBill = () => {
|
||||
<CFormInput
|
||||
type="text"
|
||||
placeholder="Address Line 1"
|
||||
// autoComplete="address"
|
||||
// autoComplete="address"
|
||||
onChange={handleChange('from_address_1')}
|
||||
/>
|
||||
<CFormInput
|
||||
type="text"
|
||||
placeholder="Address Line 2(area)"
|
||||
autoComplete="address2"
|
||||
onChange={handleChange('from_address_2')}
|
||||
/>
|
||||
</CInputGroup>
|
||||
<CInputGroup className="mb-3">
|
||||
@ -114,6 +170,7 @@ const AddAirwaysBill = () => {
|
||||
type="text"
|
||||
placeholder="To (Name)"
|
||||
autoComplete="toname"
|
||||
onChange={handleChange('to_name')}
|
||||
/>
|
||||
|
||||
</CInputGroup>
|
||||
@ -124,12 +181,14 @@ const AddAirwaysBill = () => {
|
||||
<CFormInput
|
||||
type="text"
|
||||
placeholder="Address Line 1"
|
||||
// autoComplete="address"
|
||||
// autoComplete="address"
|
||||
onChange={handleChange('to_address_1')}
|
||||
/>
|
||||
<CFormInput
|
||||
type="text"
|
||||
placeholder="Address Line 2(area)"
|
||||
autoComplete="address2"
|
||||
onChange={handleChange('to_address_2')}
|
||||
/>
|
||||
</CInputGroup>
|
||||
<CInputGroup className="mb-3">
|
||||
@ -138,13 +197,15 @@ const AddAirwaysBill = () => {
|
||||
</CInputGroupText>
|
||||
<CFormSelect
|
||||
aria-label="Default select example"
|
||||
options={[
|
||||
'Select Courier',
|
||||
{ label: 'One', value: '1' },
|
||||
{ label: 'Two', value: '2' },
|
||||
{ label: 'Three', value: '3', disabled: true }
|
||||
]}
|
||||
/></CInputGroup>
|
||||
onChange={handleChange('courier')}
|
||||
>
|
||||
<option value='India'>Select Courier</option>{
|
||||
showCouriers.map((item) =>
|
||||
<option value={item._id}>{item.name}</option>
|
||||
)
|
||||
}
|
||||
</CFormSelect>
|
||||
</CInputGroup>
|
||||
<CInputGroup className="mb-3">
|
||||
<CInputGroupText>
|
||||
<CIcon icon={cilAirplaneMode} />
|
||||
@ -153,9 +214,10 @@ const AddAirwaysBill = () => {
|
||||
type="text"
|
||||
placeholder="AWB"
|
||||
autoComplete="AWB"
|
||||
onChange={handleChange('AWB')}
|
||||
/>
|
||||
</CInputGroup>
|
||||
<CButton color="dark" className="px-4">
|
||||
<CButton color="dark" className="px-4" onClick={() => handleClick()}>
|
||||
Submit
|
||||
</CButton>
|
||||
|
||||
|
88
src/views/AirwaysBill/AirwayBillDetail.js
Normal file
88
src/views/AirwaysBill/AirwayBillDetail.js
Normal file
@ -0,0 +1,88 @@
|
||||
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 AirwayBillDetail = () => {
|
||||
const [data, setData] = useState({});
|
||||
const { id } = useParams()
|
||||
const { token } = isAutheticated();
|
||||
|
||||
useEffect(() => {
|
||||
const getData = async () => {
|
||||
const res = await axios.get(`/api/airways/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 <div >
|
||||
<h1>Bill Details</h1>
|
||||
<CTable color="dark" striped>
|
||||
<CTableHead>
|
||||
<CTableRow>
|
||||
<CTableHeaderCell scope="col">Unique ID</CTableHeaderCell>
|
||||
<CTableDataCell scope="col">{data._id}</CTableDataCell>
|
||||
</CTableRow>
|
||||
</CTableHead>
|
||||
<CTableBody>
|
||||
<CTableRow>
|
||||
<CTableHeaderCell scope="col">Code</CTableHeaderCell>
|
||||
<CTableDataCell scope="col">{data.code}</CTableDataCell>
|
||||
</CTableRow>
|
||||
<CTableRow>
|
||||
<CTableHeaderCell scope="col">AWB</CTableHeaderCell>
|
||||
<CTableDataCell scope="col">{data.AWB}</CTableDataCell>
|
||||
</CTableRow>
|
||||
<CTableRow>
|
||||
<CTableHeaderCell scope="row">Vendor Name</CTableHeaderCell>
|
||||
<CTableDataCell>{data.vendor_name}</CTableDataCell>
|
||||
</CTableRow>
|
||||
<CTableRow>
|
||||
<CTableHeaderCell scope="row">Added On</CTableHeaderCell>
|
||||
<CTableDataCell>{formatDate(data.createdAt)}</CTableDataCell>
|
||||
</CTableRow>
|
||||
<CTableRow>
|
||||
<CTableHeaderCell scope="row">From Address</CTableHeaderCell>
|
||||
<CTableDataCell>{data.from_address_1},{data.from_address_2},{data.city},{data.state},{data.country}</CTableDataCell>
|
||||
</CTableRow>
|
||||
<CTableRow>
|
||||
<CTableHeaderCell scope="row">To Address</CTableHeaderCell>
|
||||
<CTableDataCell>{data.to_address_1},{data.to_address_2}</CTableDataCell>
|
||||
</CTableRow>
|
||||
</CTableBody>
|
||||
</CTable>
|
||||
</div>;
|
||||
};
|
||||
|
||||
export default AirwayBillDetail;
|
@ -24,11 +24,11 @@ import axios from 'axios';
|
||||
|
||||
const AirwaysBill = () => {
|
||||
const { token } = isAutheticated();
|
||||
console.log(token);
|
||||
const [data, setData] = useState([])
|
||||
|
||||
useEffect(() => {
|
||||
const getData = async () => {
|
||||
const res = await axios.get('/api/vendor/view', {
|
||||
const res = await axios.get('/api/airways/view', {
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Content-type": "Application/json",
|
||||
@ -36,10 +36,20 @@ const AirwaysBill = () => {
|
||||
}
|
||||
});
|
||||
console.log(res.data);
|
||||
setData(res.data.Stores)
|
||||
}
|
||||
getData();
|
||||
|
||||
}, []);
|
||||
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 <div>
|
||||
|
||||
@ -59,21 +69,25 @@ const AirwaysBill = () => {
|
||||
<CTableHeaderCell scope="col">Action</CTableHeaderCell>
|
||||
</CTableRow>
|
||||
</CTableHead>
|
||||
<CTableBody>
|
||||
<CTableRow>
|
||||
<CTableHeaderCell scope="row">Mark</CTableHeaderCell>
|
||||
<CTableDataCell>123</CTableDataCell>
|
||||
<CTableDataCell>Otto</CTableDataCell>
|
||||
<CTableDataCell>123</CTableDataCell>
|
||||
<CTableDataCell>Otto</CTableDataCell>
|
||||
<CTableDataCell>
|
||||
<CButtonGroup role="group" aria-label="Basic mixed styles example">
|
||||
<CButton color="success">View</CButton>
|
||||
<tbody>
|
||||
{data.map(item =>
|
||||
<tr>
|
||||
<td scope="row">{item.code}</td>
|
||||
<td>{item.vendor_name}</td>
|
||||
<td>{formatDate(item.createdAt)}</td>
|
||||
<td>{item.to_name}</td>
|
||||
<td>{item.AWB}</td>
|
||||
<td>
|
||||
<CButtonGroup role="group" aria-label="Basic mixed styles example">
|
||||
<Link to={`/viewbill/${item._id}`}><CButton color="success">View</CButton></Link>
|
||||
|
||||
</CButtonGroup>
|
||||
</CTableDataCell>
|
||||
</CTableRow>
|
||||
</CTableBody>
|
||||
</CButtonGroup>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
)}
|
||||
|
||||
</tbody>
|
||||
</CTable></div>;
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,7 @@ import { useHistory } from 'react-router-dom';
|
||||
const Courier = () => {
|
||||
const { token } = isAutheticated();
|
||||
const [data, setData] = useState([])
|
||||
const history = useHistory()
|
||||
const [reload, setReload] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const getData = async () => {
|
||||
@ -37,7 +37,7 @@ const Courier = () => {
|
||||
}
|
||||
getData();
|
||||
|
||||
}, []);
|
||||
}, [reload]);
|
||||
const handleDelete = async (id) => {
|
||||
const res = await axios.delete(`/api/courier/${id}`, {
|
||||
headers: {
|
||||
@ -56,7 +56,8 @@ const Courier = () => {
|
||||
iconColor: '#303c54'
|
||||
}).then(() => {
|
||||
// history.push('/courier');
|
||||
location.reload();
|
||||
// location.reload();
|
||||
setReload(!reload)
|
||||
});
|
||||
} else {
|
||||
Swal("Oops!", "Something went wrong!", "error");
|
||||
|
2
src/views/Vendor/AddVendor.js
vendored
2
src/views/Vendor/AddVendor.js
vendored
@ -82,7 +82,7 @@ const AddVendor = () => {
|
||||
confirmButtonColor: '#303c54',
|
||||
iconColor: '#303c54'
|
||||
}).then(() => {
|
||||
history.push('/courier');
|
||||
history.push('/vendors');
|
||||
});
|
||||
} else {
|
||||
Swal("Oops!", "Something went wrong!", "error");
|
||||
|
10
src/views/Vendor/Vendor.js
vendored
10
src/views/Vendor/Vendor.js
vendored
@ -21,6 +21,7 @@ const Vendor = () => {
|
||||
const { token } = isAutheticated();
|
||||
const history = useHistory();
|
||||
const [data, setData] = useState([]);
|
||||
const [reload, setReload] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const getData = async () => {
|
||||
@ -36,12 +37,12 @@ const Vendor = () => {
|
||||
}
|
||||
|
||||
|
||||
console.log(res.data);
|
||||
|
||||
}
|
||||
getData();
|
||||
data.map(item => console.log(item.city))
|
||||
|
||||
}, []);
|
||||
|
||||
}, [reload]);
|
||||
console.log(data);
|
||||
|
||||
const handleDelete = async (id) => {
|
||||
@ -62,7 +63,8 @@ const Vendor = () => {
|
||||
iconColor: '#303c54'
|
||||
}).then(() => {
|
||||
// history.('/vendors');
|
||||
location.reload();
|
||||
setReload(!reload)
|
||||
// location.reload();
|
||||
});
|
||||
} else {
|
||||
Swal("Oops!", "Something went wrong!", "error");
|
||||
|
Loading…
Reference in New Issue
Block a user