diff --git a/src/.index.tsx.swp b/src/.index.tsx.swp index 4747b7cc..2fc0c461 100644 Binary files a/src/.index.tsx.swp and b/src/.index.tsx.swp differ diff --git a/src/GarageApp/.App.tsx.swp b/src/GarageApp/.App.tsx.swp index ec17a0a7..cb723411 100644 Binary files a/src/GarageApp/.App.tsx.swp and b/src/GarageApp/.App.tsx.swp differ diff --git a/src/GarageApp/App.tsx b/src/GarageApp/App.tsx index f6464ef9..516f178c 100644 --- a/src/GarageApp/App.tsx +++ b/src/GarageApp/App.tsx @@ -21,7 +21,9 @@ export function App() {
- + + +
); diff --git a/src/GarageApp/i18n.js b/src/GarageApp/i18n.js index d0ca8cbd..512a85cb 100644 --- a/src/GarageApp/i18n.js +++ b/src/GarageApp/i18n.js @@ -11,7 +11,7 @@ i18n .use(initReactI18next) .init({ fallbackLng: 'en', - debug: true, + debug: false, backend: { loadPath: '/GarageApp/locales/{{lng}}/{{ns}}.json' }, diff --git a/src/GarageApp/modules/.MenuBar.tsx.swp b/src/GarageApp/modules/.MenuBar.tsx.swp index 70ca4ca8..1309b6c4 100644 Binary files a/src/GarageApp/modules/.MenuBar.tsx.swp and b/src/GarageApp/modules/.MenuBar.tsx.swp differ diff --git a/src/GarageApp/modules/.MenuLanguages.tsx.swp b/src/GarageApp/modules/.MenuLanguages.tsx.swp new file mode 100644 index 00000000..2673ec83 Binary files /dev/null and b/src/GarageApp/modules/.MenuLanguages.tsx.swp differ diff --git a/src/GarageApp/modules/.StatisticsView.tsx.swp b/src/GarageApp/modules/.StatisticsView.tsx.swp index 3b15b2b1..a6fe565c 100644 Binary files a/src/GarageApp/modules/.StatisticsView.tsx.swp and b/src/GarageApp/modules/.StatisticsView.tsx.swp differ diff --git a/src/GarageApp/modules/.VehicleCardSummary.tsx.swp b/src/GarageApp/modules/.VehicleCardSummary.tsx.swp new file mode 100644 index 00000000..c962d789 Binary files /dev/null and b/src/GarageApp/modules/.VehicleCardSummary.tsx.swp differ diff --git a/src/GarageApp/modules/.VehicleCards.tsx.swp b/src/GarageApp/modules/.VehicleCards.tsx.swp new file mode 100644 index 00000000..a6b2755b Binary files /dev/null and b/src/GarageApp/modules/.VehicleCards.tsx.swp differ diff --git a/src/GarageApp/modules/.YourVehicles.tsx.swp b/src/GarageApp/modules/.YourVehicles.tsx.swp index f92f3638..25b446b9 100644 Binary files a/src/GarageApp/modules/.YourVehicles.tsx.swp and b/src/GarageApp/modules/.YourVehicles.tsx.swp differ diff --git a/src/GarageApp/modules/MenuBar.tsx b/src/GarageApp/modules/MenuBar.tsx index e5f3aaae..657df543 100644 --- a/src/GarageApp/modules/MenuBar.tsx +++ b/src/GarageApp/modules/MenuBar.tsx @@ -43,8 +43,35 @@ function GarageAppLogo() { ) } -const pages = ['Home', 'Quick Entries', 'Import']; +const pages = [ + {name: 'menu.home',key: "home",href: "/"}, + {name: 'menu.quickentries',key: 'quickentries',href: "/"}, + {name: 'menu.import',key: 'import',href: "/"} +] const settings = ['Profile', 'Admin', 'Logout']; + +//const settings = [ +// {name: 'menu.settings',key: "profile",href: "/"}, +// {name: 'menu.admin',key: 'admin',href: "/"}, +// {name: 'menu.logout',key: 'logout',href: "/"} +//] + +function MenuButtons({ key,onClick,href,name }) { + const { t, i18n } = useTranslation(); + + return( + + {t (name)} + + ) + +} + function ResponsiveAppBar() { //translation const { t, i18n } = useTranslation(); @@ -101,21 +128,13 @@ function ResponsiveAppBar() { sx={{ display: { xs: 'block', md: 'none' } }} > {pages.map((page) => ( - - {page} - + ))} {pages.map((page) => ( - + ))} @@ -145,9 +164,7 @@ function ResponsiveAppBar() { {setting} ))} - - diff --git a/src/GarageApp/modules/MenuLanguages.tsx b/src/GarageApp/modules/MenuLanguages.tsx index 4dbd32f0..32c5e239 100644 --- a/src/GarageApp/modules/MenuLanguages.tsx +++ b/src/GarageApp/modules/MenuLanguages.tsx @@ -49,7 +49,7 @@ export default function LanguageMenu( {closeAction} ) { return ( - + - @@ -161,7 +160,6 @@ export default function StatisticsView() { - ); } diff --git a/src/GarageApp/modules/VehicleCardSummary.tsx b/src/GarageApp/modules/VehicleCardSummary.tsx new file mode 100644 index 00000000..9343cbb7 --- /dev/null +++ b/src/GarageApp/modules/VehicleCardSummary.tsx @@ -0,0 +1,86 @@ +import * as React from 'react'; +import Grid from '@mui/material/Grid'; +import Paper from '@mui/material/Paper'; +import Container from '@mui/material/Container'; +import { useTranslation, withTranslation, Trans } from 'react-i18next'; + +const uid = "39e9009e-50e1-4277-bbf7-69e5e0f6c6dc" + +async function DataFetch(url) { + const response = await fetch(url); + const data = await response.json(); + return data; +} + +function VehicleCardSummary({ vehicleid }) { + const { t, i18n } = useTranslation(); + + const [data, setData] = React.useState(null); + const [loading, setLoading] = React.useState(true); + const [error, setError] = React.useState(null); + + React.useEffect(() => { + async function fetchData() { + try { + const data = await DataFetch(`/GarageApp/api/fillups/${uid}/${vehicleid}/lastfillup`); + setData(data); + setLoading(false); + } catch (error) { + setError(error); + setLoading(false); + } + } + + + fetchData(); + }, []); + console.log("blablambpmgpoa") + console.log(data) + if (loading) { + return
Loading...
; + } + + if (error) { + return
Error: {error.message}
; + } + if (!data.toString()) { + return

Nothing Registered

+ } + return ( +
+ + + +

{t ('lastfillup')}:

+
+
+ + + {data.map((f) => ( +
+

{f.date.split(" ",1)}

+

{f.total_amount.toFixed(2) + " " + f.currency}

+

{f.fuel_quantity.toFixed(2) + " @ " + f.per_unit_price.toFixed(2)}"

+
+ ))} +
+
+
+ + + +

{t ('odometer')}:

+
+
+ + +

{data.map((fillup) => ( +

{fillup.odo_reading + " km"}

+ ))}

+
+
+
+
+ ); +} +export default VehicleCardSummary; diff --git a/src/GarageApp/modules/VehicleCards.tsx b/src/GarageApp/modules/VehicleCards.tsx index 20f4ddcf..5c6a8d5d 100644 --- a/src/GarageApp/modules/VehicleCards.tsx +++ b/src/GarageApp/modules/VehicleCards.tsx @@ -17,10 +17,12 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import MoreVertIcon from '@mui/icons-material/MoreVert'; import GasStation from './icons/gasFillup' import Expense from './icons/Expense' +import VehicleCardSummary from "./VehicleCardSummary"; import { useTranslation, withTranslation, Trans } from 'react-i18next'; + interface ExpandMoreProps extends IconButtonProps { expand: boolean; } @@ -50,7 +52,7 @@ const ExpandMore = styled((props: ExpandMoreProps) => { ], })); -export default function VehicleCard({ nickname, makemodel, registration}) { +export default function VehicleCard({ nickname, makemodel, registration, vehicleID}) { const { t, i18n } = useTranslation(); const [expanded, setExpanded] = React.useState(false); @@ -93,9 +95,7 @@ export default function VehicleCard({ nickname, makemodel, registration}) { - - Expanded area… - + diff --git a/src/GarageApp/modules/YourVehicles.tsx b/src/GarageApp/modules/YourVehicles.tsx index ffccddb8..b7cee96a 100644 --- a/src/GarageApp/modules/YourVehicles.tsx +++ b/src/GarageApp/modules/YourVehicles.tsx @@ -5,9 +5,16 @@ import VehicleCard from "./VehicleCards"; import Button from '@mui/material/Button'; import { useTranslation, withTranslation, Trans } from 'react-i18next'; + + const uid = "39e9009e-50e1-4277-bbf7-69e5e0f6c6dc" const response = await fetch(`/GarageApp/api/vehicles/${uid}`); const vehicles = await response.json(); + + + + + export default function YourVehicleList() { const { t, i18n } = useTranslation(); return ( @@ -29,7 +36,7 @@ export default function YourVehicleList() { }}> {vehicles.map((vehicle, index) => ( - + ))} diff --git a/src/index.tsx b/src/index.tsx index 0e89c00f..1df02fc2 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -26,7 +26,6 @@ const server = serve({ return new Response(Bun.file(path)) }, "/GarageApp/api/vehicles/:uid": async req => { - //const uid = "39e9009e-50e1-4277-bbf7-69e5e0f6c6dc" const uid = req.params.uid; const query = db.query( `SELECT * FROM vehicles WHERE id IN (SELECT vehicle_id FROM user_vehicles WHERE user_id='${uid}');` @@ -53,6 +52,16 @@ const server = serve({ return Response.json(fillups) }, + "/GarageApp/api/fillups/:uid/:vid/lastfillup": async req => { + const uid = req.params.uid; + const vid = req.params.vid; + const query = db.query( + `SELECT * FROM fillups WHERE user_id='${uid}' AND vehicle_id='${vid}' ORDER BY odo_reading DESC LIMIT 1;` + ); + const lastfillup = query.all(); + return Response.json(lastfillup) + }, + "/api/hello": { async GET(req) {