From 60eb8d20a1a4f0b1d6f7191089be63faf1a86d40 Mon Sep 17 00:00:00 2001 From: Taeho Choi <48103834+Taehoya@users.noreply.github.com> Date: Thu, 7 Mar 2024 13:58:52 -0600 Subject: [PATCH] Client data connect (#65) * fix add travel note * Fix additional warnings * trip by id stuff --------- Co-authored-by: leonw00 --- .../(components)/(object-types)/TripByID.tsx | 42 +++++++++++++++++++ .../src/app/[locale]/(routes)/[trip]/page.tsx | 22 +++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 client/src/app/[locale]/(components)/(object-types)/TripByID.tsx diff --git a/client/src/app/[locale]/(components)/(object-types)/TripByID.tsx b/client/src/app/[locale]/(components)/(object-types)/TripByID.tsx new file mode 100644 index 0000000..0f8070a --- /dev/null +++ b/client/src/app/[locale]/(components)/(object-types)/TripByID.tsx @@ -0,0 +1,42 @@ +type TripByID = { + id: number; + budget: number; + countryProperty: { + id: number; + code: string; + name: string; + currency: string; + }; + description: string; + startDateTime: string; + endDateTime: string; + name: string; + noteProperty: { + boundColor: string; + noteColor: string; + noteType: string; + }; + top5Transactions?: Array<{ + amount: number; + category: { + id: number; + name: string; + }; + description: string; + name: string; + transactionDateTime: string; + }>; + totalExpense?: number; + transactions?: Array<{ + amount: number; + category: { + id: number; + name: string; + }; + description: string; + name: string; + transactionDateTime: string; + }>; +}; + +export default TripByID; diff --git a/client/src/app/[locale]/(routes)/[trip]/page.tsx b/client/src/app/[locale]/(routes)/[trip]/page.tsx index a6d1a87..63634c1 100644 --- a/client/src/app/[locale]/(routes)/[trip]/page.tsx +++ b/client/src/app/[locale]/(routes)/[trip]/page.tsx @@ -1,7 +1,8 @@ "use client"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { Typography, IconButton, Grid } from "@mui/material"; +import axios from "axios"; // Icons import ArrowBackIosNewRoundedIcon from "@mui/icons-material/ArrowBackIosNewRounded"; @@ -14,9 +15,26 @@ import TransactionTemplate from "../../(components)/(transaction)/transaction-pa import TripGraph from "../../(components)/(trip)/TripGraph"; import WebWrapper from "../../(wrapper)/WebWrapper"; import TripDrawer from "../../(components)/(trip)/TripDrawer"; +import TripByID from "../../(components)/(object-types)/TripByID"; -const TripPage = ({ params }: { params: { trip: string } }) => { +const TripPage = () => { const [activeComponent, setActiveComponent] = useState(2); + // const [tripData, setTripData] = useState(null); + + // useEffect(() => { + // const accessToken = sessionStorage.getItem("access_token"); + // if (!accessToken) window.location.href = "/login"; + // else { + // fetchTripData(1, accessToken); + // } + // }, []); + + // const fetchTripData = async (id:number, token: String) => { + // const trip = await axios.get(`/api/v1/trips/${id}`, { + // headers: { Authorization: `Bearer ${token}` }, + // }); + // setTripData(trip.data); + // }; const handleSelect = (componentNumber: number) => { setActiveComponent(componentNumber);