diff --git a/apps/frontend/src/app/accounts/page.tsx b/apps/frontend/src/app/accounts/page.tsx index 16e6ab87..1c5cd0f4 100644 --- a/apps/frontend/src/app/accounts/page.tsx +++ b/apps/frontend/src/app/accounts/page.tsx @@ -2,14 +2,7 @@ import React from 'react'; import StaffCard from '../components/StaffCard'; - -interface User { - user_id: number; - name: string; - email: string; - is_admin: boolean; - created_at?: string; -} +import { User } from '@/types'; const mockUsers: User[] = [ { user_id: 1, name: 'Mehana Nagarur', email: 'nagarur.m@northeastern.edu', is_admin: true }, diff --git a/apps/frontend/src/app/components/AddExpenseModal.tsx b/apps/frontend/src/app/components/AddExpenseModal.tsx index 883d97f6..15dc707b 100644 --- a/apps/frontend/src/app/components/AddExpenseModal.tsx +++ b/apps/frontend/src/app/components/AddExpenseModal.tsx @@ -6,18 +6,13 @@ import DropdownSelector from './DropdownSelector'; import { useApi } from '@/hooks/useApi'; import FileUpload from './FileUpload'; import { FiDollarSign } from 'react-icons/fi'; - -interface Project { - project_id: number; - name: string; -} - +import { Project } from '@/types'; interface AddExpenseModalProps { open: boolean; onClose: () => void; onSuccess: () => void; categories: string[]; - projects: Project[]; + projects: Pick[]; } export default function AddExpenseModal({ diff --git a/apps/frontend/src/app/components/ExpensesTable.tsx b/apps/frontend/src/app/components/ExpensesTable.tsx index 90c090c7..eaf134e7 100644 --- a/apps/frontend/src/app/components/ExpensesTable.tsx +++ b/apps/frontend/src/app/components/ExpensesTable.tsx @@ -1,17 +1,7 @@ import { Table, } from '@chakra-ui/react'; - - export type Expenditure = { - expenditure_id: number; - project_id: number; - entered_by: number | null; - amount: string; - category: string | null; - description: string | null; - spent_on: string; - created_at: string | null; - }; +import { Expenditure } from '@/types'; interface ExpensesTableProps { expenditures: Expenditure[]; diff --git a/apps/frontend/src/app/expenses/page.tsx b/apps/frontend/src/app/expenses/page.tsx index 7c7e884d..e6432961 100644 --- a/apps/frontend/src/app/expenses/page.tsx +++ b/apps/frontend/src/app/expenses/page.tsx @@ -16,22 +16,7 @@ import { CiFilter } from 'react-icons/ci'; import { LuArrowDownUp } from 'react-icons/lu'; import { FaPlus } from 'react-icons/fa'; import ExpensesTable from '../components/ExpensesTable'; - -type Expenditure = { - expenditure_id: number; - project_id: number; - entered_by: number | null; - amount: string; - category: string | null; - description: string | null; - spent_on: string; - created_at: string | null; -}; - -type Project = { - project_id: number; - name: string; -}; +import { Expenditure, Project } from '@/types'; const MONTHS = [ 'January', 'February', 'March', 'April', 'May', 'June', @@ -61,7 +46,7 @@ function ExpensePageContent() { // Data const [expenditures, setExpenditures] = useState([]); - const [projects, setProjects] = useState([]); + const [projects, setProjects] = useState[]>([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); diff --git a/apps/frontend/src/app/projects/[id]/ProjectDetailClient.tsx b/apps/frontend/src/app/projects/[id]/ProjectDetailClient.tsx index cdb86b6d..96cf4d7d 100644 --- a/apps/frontend/src/app/projects/[id]/ProjectDetailClient.tsx +++ b/apps/frontend/src/app/projects/[id]/ProjectDetailClient.tsx @@ -6,26 +6,8 @@ import { RxCaretRight } from 'react-icons/rx'; import NavBar from '../../components/Navbar'; import ExpensesTable from '../../components/ExpensesTable'; import StaffCard from '../../components/StaffCard'; -import type { Expenditure } from '../../components/ExpensesTable'; import { useApi } from '@/hooks/useApi'; - -type Project = { - project_id: number; - name: string; - description: string; - total_budget: string | null; - start_date: string | null; - end_date: string | null; - currency: string | null; - created_at: string | null; -}; - -type Member = { - user_id: number; - name: string; - email: string; - role: string; -}; +import { Project, Expenditure, Member } from '@/types'; const PREVIEW_EXPENSES = 8; const PREVIEW_STAFF = 4; diff --git a/apps/frontend/src/types/auth.ts b/apps/frontend/src/types/auth.ts new file mode 100644 index 00000000..312d7a24 --- /dev/null +++ b/apps/frontend/src/types/auth.ts @@ -0,0 +1,5 @@ +export interface AuthUser { + sub: string; + email: string; + name?: string; +} \ No newline at end of file diff --git a/apps/frontend/src/types/expenditure.ts b/apps/frontend/src/types/expenditure.ts new file mode 100644 index 00000000..c0560780 --- /dev/null +++ b/apps/frontend/src/types/expenditure.ts @@ -0,0 +1,10 @@ +export interface Expenditure { + expenditure_id: number; + project_id: number; + entered_by: number | null; + amount: string; + category: string | null; + description: string | null; + spent_on: string; + created_at: string | null; + }; \ No newline at end of file diff --git a/apps/frontend/src/types/index.ts b/apps/frontend/src/types/index.ts new file mode 100644 index 00000000..231818ef --- /dev/null +++ b/apps/frontend/src/types/index.ts @@ -0,0 +1,4 @@ +export * from './project'; +export * from './expenditure'; +export * from './user'; +export * from './auth'; \ No newline at end of file diff --git a/apps/frontend/src/types/project.ts b/apps/frontend/src/types/project.ts new file mode 100644 index 00000000..f1af6a27 --- /dev/null +++ b/apps/frontend/src/types/project.ts @@ -0,0 +1,19 @@ +export interface Project { + project_id: number; + name: string; + description: string; + total_budget: string | null; + start_date: string | null; + end_date: string | null; + currency: string | null; + created_at: string | null; +}; + +export type ProjectRole = 'PI' | 'Accountant' | 'Staff' | 'Admin'; + +export interface Member { + user_id: number; + name: string; + email: string; + role: ProjectRole; +} \ No newline at end of file diff --git a/apps/frontend/src/types/user.ts b/apps/frontend/src/types/user.ts new file mode 100644 index 00000000..d3f23ad4 --- /dev/null +++ b/apps/frontend/src/types/user.ts @@ -0,0 +1,8 @@ +export interface User { + user_id: number; + name: string; + email: string; + is_admin: boolean; + created_at?: string; + profile_image?: string | null; +} \ No newline at end of file