diff --git a/src/routes.js b/src/routes.js index 4246596..b7ec420 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1,6 +1,7 @@ import React from 'react' const AirwaysBill = React.lazy(() => import('./views/AirwaysBill/AirwaysBill')) +const EditBill = React.lazy(() => import('./views/AirwaysBill/EditBill')) const AddAirwaysBill = React.lazy(() => import('./views/AirwaysBill/AddAirwaysBill')) const AirwayBillDetail = React.lazy(() => import('./views/AirwaysBill/AirwayBillDetail')) const Courier = React.lazy(() => import('./views/Courier/Courier')) @@ -70,7 +71,8 @@ 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: '/viewbill/:id', name: 'View Bill', component: AirwayBillDetail }, + { path: '/editbill/:id', name: 'View Bill', component: EditBill }, { path: '/vendors', name: 'Vendors', component: Vendor }, { path: '/editvendor/:id', name: 'Edit Vendor', component: EditVendor }, { path: '/viewvendor/:id', name: 'View Vendor', component: VendorDetail }, diff --git a/src/scss/_custom.scss b/src/scss/_custom.scss index 88e1bd4..4ad4f56 100644 --- a/src/scss/_custom.scss +++ b/src/scss/_custom.scss @@ -3,4 +3,7 @@ $a-tags: 'a, a:active, a:hover, a:visited'; #{$a-tags} { text-decoration: none; } - .overflow-table { display: block; max-width: -moz-fit-content; max-width: fit-content; overflow-x: auto; white-space: nowrap; } \ No newline at end of file + .overflow-table { display: block; max-width: -moz-fit-content; max-width: fit-content; overflow-x: auto; white-space: nowrap; } + .edit_text{ + width: 22%; + } \ No newline at end of file diff --git a/src/views/AirwaysBill/AddAirwaysBill.js b/src/views/AirwaysBill/AddAirwaysBill.js index c4e8290..d05f97d 100644 --- a/src/views/AirwaysBill/AddAirwaysBill.js +++ b/src/views/AirwaysBill/AddAirwaysBill.js @@ -6,6 +6,7 @@ import { CCardGroup, CCol, CContainer, + CForm, CFormInput, CFormSelect, @@ -83,8 +84,8 @@ const AddAirwaysBill = () => { } }) - console.log(couriers.data.Pincode); - console.log(vendors.data.Stores); + // console.log(couriers.data.Pincode); + // console.log(vendors.data.Stores); setShowVendors(vendors.data.Stores) setShowCouriers(couriers.data.Pincode) } @@ -247,6 +248,21 @@ const AddAirwaysBill = () => { /> + + + + + { + showVendors.map((item) => + + ) + } + + + {/* @@ -256,7 +272,7 @@ const AddAirwaysBill = () => { autoComplete="AWB" onChange={handleChange(' Client_Name')} /> - + */} @@ -325,13 +341,30 @@ const AddAirwaysBill = () => { type="text" placeholder="Shipped From" autoComplete="AWB" + value='India' onChange={handleChange('Shipped_From')} /> + + + + + { + showCouriers.map((item) => + + ) + } + + + {/* + - + */} + DOD { placeholder="Total Weight " autoComplete="AWB" - onChange={handleChange('AWB')} + onChange={handleChange('Total_weight')} /> @@ -495,7 +529,8 @@ const AddAirwaysBill = () => { - + + RD { const { token } = isAutheticated(); const [data, setData] = useState([]) const [file, setFile] = useState(null) + const history = useHistory() let formData = new FormData(); useEffect(() => { @@ -63,7 +67,7 @@ const AirwaysBill = () => { formData.append('file', file, file.name) - console.log(...formData) + // console.log(...formData) const res = await axios.post('/api/airways/upload', { file: formData }, { headers: { @@ -97,17 +101,18 @@ const AirwaysBill = () => { Order No - Client Name + Vendor - Shipped From - - Logistic Name + {/* Shipped From + */} + + Courier AWB No - + Status Action @@ -117,12 +122,14 @@ const AirwaysBill = () => { {item.Order_No} {item.Client_Name} - {item.Shipped_From} + {/* {item.Shipped_From} */} {item.Logistic_Name} {item.AWB_No} + Delivered - View + history.push(`/viewbill/${item._id}`)}>View + history.push(`/editbill/${item._id}`)}>Edit diff --git a/src/views/AirwaysBill/EditBill.js b/src/views/AirwaysBill/EditBill.js new file mode 100644 index 0000000..c382504 --- /dev/null +++ b/src/views/AirwaysBill/EditBill.js @@ -0,0 +1,589 @@ +import React, { useEffect } from 'react'; +import { + CButton, + CCard, + CCardBody, + CCardGroup, + CCol, + CContainer, + CForm, + CFormInput, + CFormSelect, + CInputGroup, + CInputGroupText, + CRow, +} from '@coreui/react' +import CIcon from '@coreui/icons-react' +import { cil3d, cilAirplaneMode, cilBadge, cilBalanceScale, cilBoatAlt, cilBriefcase, cilBuilding, cilCalendar, cilGlobeAlt, cilListNumbered, cilLocationPin, cilLockLocked, cilMoney, cilNoteAdd, cilNotes, cilPeople, cilPhone, cilShareBoxed, cilUser, cilUserPlus } from '@coreui/icons' +import { useState } from 'react'; +import axios from 'axios'; +import { isAutheticated } from 'src/auth'; +import { useHistory } from 'react-router-dom'; +import Swal from 'sweetalert2'; +import { Country } from 'country-state-city'; +import { useParams } from 'react-router-dom'; + + +const AddAirwaysBill = () => { + const { token } = isAutheticated() + const countries = Country.getAllCountries(); + const { id } = useParams() + const [bill, setBill] = useState({ + AWB_No: '', + Actual_Billing: '', + Actual_Margin: 'Andhra Pradesh', + country: 'India', + Actual_Weight: '', + Client_Name: '', + Customer_Address: "", + Customer_Billing: "", + Customer_Name: "", + Customer_Phone: "", + Date_Of_Dispatch: "", + Dimension_Weight: "", + Dimensions: "", + Invoice_No: "", + Item_Name: "" + , Logistic_Name: "", + Order_No: "", + Projected_Margin: "", + Recieved_Amount: "", + Recieved_Date: "", + Shipment_Charges: "", + Shipments: "", + Shipped_From: "", + Sr_No: "", + Total_Weight: "", + }) + 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 couriers = await axios.get('/api/courier', + { + headers: { + "Access-Control-Allow-Origin": "*", + "Content-type": "Application/json", + "Authorization": `Bearer ${token}` + } + }) + 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() + }, []) + 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) { + // setBill() + setBill(res.data.Store); + // setData(res?.data?.Store) + // setVendor(res?.data?.Store) + } + + + console.log(res.data); + } + getData(); + + + }, []); + + + 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 + } + + const handleChange = (e) => (event) => { + setBill({ ...bill, [e]: event.target.value }); + }; + const handleClick = async () => { + let res = await axios.put(`/api/airways/${id}`, { ...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"); + } + } + console.log(bill); + + return
+ + + + +

Edit Bill

+

Fill the fields and submit to add a new bill

+ {/* */} + {/*

ID:

*/} + {/*
{code}
*/} + {/*

(auto-generated)

*/} + {/*
*/} + {/* */} + {/*

Date:

*/} + {/*
{formatDate()}
*/} + {/*

(auto-generated)

*/} + {/*
*/} + {/* + + + + + { + showVendors.map((item) => + + ) + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + showCouriers.map((item) => + + ) + } + + */} + + + AWB + + + + + + Order_No + + + + + + Vendor + + + { + showVendors.map((item) => + + ) + } + + + {/* + + + + + */} + + + Item_Name + + + + + + Customer_Name + + + + + + Customer_Phone + + + + + + Customer_Address + + + + + + country + + + { + countries.map((item) => + + ) + } + + + + + + Shipped_From + + + + + + Courier + + + { + showCouriers.map((item) => + + ) + } + + + {/* + + + + + + */} + + + + Date_Of_Dispatch + + + + + + Shipments + + + + + + Dimensions + + + + + + Dimension_Weight + + + + + + Actual_Weight + + + + + + Total_weight + + + + + + Shipment_Charges + + + + + + Actual_Billing + + + + + + Customer_Billing + + + + + + Projected_Margin + + + + + + Actual_Margin + + + + + + Invoice_No + + + + + + Recieved_Amount + + + + + + Recieved_Date + RD + + + + + + handleClick()}> + Submit + + +
+ +
+
+
+
;; +}; + +export default AddAirwaysBill;