diff --git a/react-app/components/TripPlan/ViewTripPlan.js b/react-app/components/TripPlan/ViewTripPlan.js index ff63620..c8c6218 100644 --- a/react-app/components/TripPlan/ViewTripPlan.js +++ b/react-app/components/TripPlan/ViewTripPlan.js @@ -8,15 +8,7 @@ import { Close } from '../common/icons/Close' import { FaEye } from 'react-icons/fa' import TripPlanLayout from './TripPlanLayout' const TripPlanInfo = ({ - id, - vehicleEntryId, - vehicleEntry, - amount, - paid, - createdAt, - distance, - duration, - ...props + tripplan }) => { const [isOpen, setIsOpen] = useState(false) const handleClose = () => setIsOpen(false) @@ -25,7 +17,7 @@ const TripPlanInfo = ({ <>
@@ -64,16 +56,15 @@ const TripPlanInfo = ({ - + {/* */}
diff --git a/react-app/components/TripPlans/TripPlanItem.js b/react-app/components/TripPlans/TripPlanItem.js index f9c9f96..ea3e50f 100644 --- a/react-app/components/TripPlans/TripPlanItem.js +++ b/react-app/components/TripPlans/TripPlanItem.js @@ -6,78 +6,39 @@ import { BiBuildingHouse, BiDownload, BiLocationPlus, BiMoneyWithdraw } from 're import { FaMoneyTripPlan, FaTimesCircle } from 'react-icons/fa' import { RxClock } from 'react-icons/rx' -const TripPlanItem = ({ - id, - vehicleEntryId, - vehicleEntry, - amount, - paid, - createdAt, - distance, - duration -}) => { +const TripPlanItem = ({ id, vehicle, tripPlanStss, tripPlanLandfills }) => { return ( -
- Vehicle: {vehicleEntry?.vehicle?.registrationNumber} + Vehicle: {vehicle?.registrationNumber}
- STS: {vehicleEntry?.sts?.wardNumber} - {vehicleEntry?.sts?.name} + STS: {tripPlanStss.map(tripPlanSts => `${tripPlanSts.sts.wardNumber} - ${tripPlanSts.sts.name}`).join(', ')}
- Landfill: {vehicleEntry?.landfill?.name} -
-
-
-
- - {distance.toFixed(2)} km + Landfill: {tripPlanLandfills.map(tripPlanLandfill => tripPlanLandfill.landfill.name).join(', ')}
-
- - {duration.toFixed(2)} mins -
-
- -
- - {new Date(createdAt).toLocaleString()}
+
+ + Capacity: {vehicle?.capacity?.toFixed(2)} Ton +
-
- - {vehicleEntry.volumeOfWaste.toFixed(2)} Ton -
-
- - {amount.toFixed(2)} Tk -
- - - + {/* */}
) } export default TripPlanItem + diff --git a/react-app/components/TripPlans/TripPlanItems.js b/react-app/components/TripPlans/TripPlanItems.js index fc28240..b7d3443 100644 --- a/react-app/components/TripPlans/TripPlanItems.js +++ b/react-app/components/TripPlans/TripPlanItems.js @@ -1,12 +1,12 @@ import React from 'react' import TripPlanItem from './TripPlanItem' -const TripPlanItems = ({ tripplans }) => { +const TripPlanItems = ({ tripplan }) => { return (
- {tripplans?.length + {tripplan?.length ? ( - tripplans?.map((i) => ) + tripplan?.map((i) => ) ) : (
diff --git a/react-app/pages/bills.js b/react-app/pages/bills.js index b28de4b..5fdb44e 100644 --- a/react-app/pages/bills.js +++ b/react-app/pages/bills.js @@ -82,44 +82,44 @@ function Bills() { setValue(newValue) } - useEffect(() => { - const token = localStorage.getItem('token') + // useEffect(() => { + // const token = localStorage.getItem('token') - setLoadingBills(true) - if (token) { - const queryString = getQueryString({ - ...value, - ...filters, - }) + // setLoadingBills(true) + // if (token) { + // const queryString = getQueryString({ + // ...value, + // ...filters, + // }) - console.log('queryString:', queryString) + // console.log('queryString:', queryString) - axios - .get(getBaseUrl() + queryString, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - setBillData(res.data) - console.log(res.data) - setLoadingBills(false) - setErrorBills(null) - }) - .catch((err) => { - setErrorBills(err) - console.log(err) - setLoadingBills(false) - }) - } - }, [ - value, - filters.isPaid, - filters.isVerified, - filters.landfillId, - filters.stsId, - filters.vehicleId, - ]) + // axios + // .get(getBaseUrl() + queryString, { + // headers: { + // Authorization: `Bearer ${token}`, + // }, + // }) + // .then((res) => { + // setBillData(res.data) + // console.log(res.data) + // setLoadingBills(false) + // setErrorBills(null) + // }) + // .catch((err) => { + // setErrorBills(err) + // console.log(err) + // setLoadingBills(false) + // }) + // } + // }, [ + // value, + // filters.isPaid, + // filters.isVerified, + // filters.landfillId, + // filters.stsId, + // filters.vehicleId, + // ]) const colors = [ { b: 'bg-blue-100', c: 'text-blue-700' }, @@ -146,7 +146,7 @@ function Bills() { }, }) .then((res) => { - setValues(res.data) + setBillData(res.data) }) .catch((err) => { console.log(err) @@ -154,6 +154,25 @@ function Bills() { } }, []) + useEffect(() => { + const token = localStorage.getItem('token') + axios + .get(getBaseUrl() + '/bill', { + headers: { + Authorization: `Bearer ${token}`, + }, + }) + .then((res) => { + setBillData(res.data) + console.log(res.data) + setLoadingBills(false) + setErrorBills(null) + }) + .catch((err) => { + console.log(err) + }) + }, []); + return (
diff --git a/react-app/pages/tripplan.js b/react-app/pages/tripplan.js index b28de4b..043a128 100644 --- a/react-app/pages/tripplan.js +++ b/react-app/pages/tripplan.js @@ -6,7 +6,7 @@ import { useEffect, useState } from 'react' import Layout from '../components/layout' import { NoSSR } from '../components/common/NoSSR' import Datepicker from 'react-tailwindcss-datepicker' -import BillItems from '../components/Bills/BillItems' +import TripPlanItems from '../components/TripPlans/TripPlanItems' import { getBaseUrl } from '../utils/url' import axios from 'axios' import Select from '../components/common/Select' @@ -51,10 +51,11 @@ const getQueryString = (params) => { return queryString } -function Bills() { - const [billData, setBillData] = useState({}) +function Trips () { + // const [billData, setBillData] = useState({}) const [loadingBills, setLoadingBills] = useState(true) const [errorBills, setErrorBills] = useState(null) + const [tripplan, setTripplan] = useState({}) const [filters, setFilters] = useState({ isPaid: 's', @@ -82,44 +83,44 @@ function Bills() { setValue(newValue) } - useEffect(() => { - const token = localStorage.getItem('token') + // useEffect(() => { + // const token = localStorage.getItem('token') - setLoadingBills(true) - if (token) { - const queryString = getQueryString({ - ...value, - ...filters, - }) + // setLoadingBills(true) + // if (token) { + // const queryString = getQueryString({ + // ...value, + // ...filters, + // }) - console.log('queryString:', queryString) + // console.log('queryString:', queryString) - axios - .get(getBaseUrl() + queryString, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - setBillData(res.data) - console.log(res.data) - setLoadingBills(false) - setErrorBills(null) - }) - .catch((err) => { - setErrorBills(err) - console.log(err) - setLoadingBills(false) - }) - } - }, [ - value, - filters.isPaid, - filters.isVerified, - filters.landfillId, - filters.stsId, - filters.vehicleId, - ]) + // axios + // .get(getBaseUrl() + queryString, { + // headers: { + // Authorization: `Bearer ${token}`, + // }, + // }) + // .then((res) => { + // setBillData(res.data) + // console.log(res.data) + // setLoadingBills(false) + // setErrorBills(null) + // }) + // .catch((err) => { + // setErrorBills(err) + // console.log(err) + // setLoadingBills(false) + // }) + // } + // }, [ + // value, + // filters.isPaid, + // filters.isVerified, + // filters.landfillId, + // filters.stsId, + // filters.vehicleId, + // ]) const colors = [ { b: 'bg-blue-100', c: 'text-blue-700' }, @@ -140,19 +141,22 @@ function Bills() { const token = localStorage.getItem('token') if (token) { axios - .get(getBaseUrl() + '/dashboard-bills-filter', { + .get(getBaseUrl() + '/tripplan', { headers: { Authorization: `Bearer ${token}`, }, }) .then((res) => { - setValues(res.data) + setTripplan(res.data) + console.log(res.data) + setLoadingBills(false) + setErrorBills(null) }) .catch((err) => { console.log(err) }) } - }, []) + }, [tripplan.length]) return ( @@ -261,8 +265,8 @@ function Bills() { ) : (
- {billData?.additionalData && - billData?.additionalData.map((item, i) => { + {tripplan?.additionalData && + tripplan?.additionalData.map((item, i) => { return (
Error loading data
) : ( - + )}
) } -export default Bills +export default Trips -Bills.getLayout = function getLayout(page) { +Trips.getLayout = function getLayout(page) { // eslint-disable-next-line react/react-in-jsx-scope return {page} }