Skip to content

Commit

Permalink
Client data connect (#65)
Browse files Browse the repository at this point in the history
* fix add travel note

* Fix additional warnings

* trip by id stuff

---------

Co-authored-by: leonw00 <[email protected]>
  • Loading branch information
Taehoya and leonw00 authored Mar 7, 2024
1 parent 65c41ae commit 60eb8d2
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
42 changes: 42 additions & 0 deletions client/src/app/[locale]/(components)/(object-types)/TripByID.tsx
Original file line number Diff line number Diff line change
@@ -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;
22 changes: 20 additions & 2 deletions client/src/app/[locale]/(routes)/[trip]/page.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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<number>(2);
// const [tripData, setTripData] = useState<TripByID | null>(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);
Expand Down

0 comments on commit 60eb8d2

Please sign in to comment.