From 302d7299c7b75d52dc1032df8d219b885e075eae Mon Sep 17 00:00:00 2001 From: Pallavi Das Date: Sun, 2 Jun 2024 16:54:17 -0700 Subject: [PATCH] Revert "static routing + prettier" This reverts commit a5b08459ef91f210946284c6d9f878c3e6be015e. --- backend/tsconfig.json | 32 ++++++++-------- frontend/lib/deletes.tsx | 6 ++- frontend/lib/edits.tsx | 7 +--- frontend/lib/fetches.tsx | 43 ++++++++++++++-------- frontend/src/App.tsx | 4 +- frontend/src/pages/IndividualGroupPage.tsx | 1 + frontend/src/pages/MyGroupsPage.tsx | 7 ++-- frontend/src/pages/ProfilePage.tsx | 3 +- frontend/staticwebapp.config.json | 8 ---- frontend/vite.config.ts | 20 +--------- 10 files changed, 61 insertions(+), 70 deletions(-) delete mode 100644 frontend/staticwebapp.config.json diff --git a/backend/tsconfig.json b/backend/tsconfig.json index eeebc72..0557b5b 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -1,16 +1,18 @@ { - "compilerOptions": { - "lib": ["es6"], - "target": "es6", - "module": "ESNext", - "moduleResolution": "node", - "outDir": "dist", - "resolveJsonModule": true, - "emitDecoratorMetadata": true, - "esModuleInterop": true, - "experimentalDecorators": true, - "sourceMap": true - }, - "include": ["**/*.ts"], - "exclude": ["node_modules", "**/*.spec.ts"] -} + "compilerOptions": { + "lib": [ + "es6" + ], + "target": "es6", + "module": "ESNext", + "moduleResolution": "node", + "outDir": "dist", + "resolveJsonModule": true, + "emitDecoratorMetadata": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "sourceMap": true + }, + "include": ["**/*.ts"], + "exclude": ["node_modules", "**/*.spec.ts"] + } \ No newline at end of file diff --git a/frontend/lib/deletes.tsx b/frontend/lib/deletes.tsx index f8217bd..201800b 100644 --- a/frontend/lib/deletes.tsx +++ b/frontend/lib/deletes.tsx @@ -90,7 +90,8 @@ export const handleDeleteGroupFromUsers = async ( headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); if (response.ok) { const user = await response.json(); const userGroups = user.groups; @@ -137,7 +138,8 @@ export const handleDeleteBasketFromGroup = async ( headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); if (response.ok) { const group = await response.json(); const groupBaskets = group.baskets; diff --git a/frontend/lib/edits.tsx b/frontend/lib/edits.tsx index e76c6a9..0d02450 100644 --- a/frontend/lib/edits.tsx +++ b/frontend/lib/edits.tsx @@ -187,10 +187,7 @@ export const addUserToGroup = async (group: IGroup, users: ObjectId[]) => { }); }; -export const addFriendToUser = async ( - user: IUser, - updatedFriends: ObjectId[], -) => { +export const addFriendToUser = async (user: IUser, updatedFriends: ObjectId[]) => { return fetch(`${vite_backend_url}/users/${user._id}`, { method: "PATCH", headers: { @@ -199,4 +196,4 @@ export const addFriendToUser = async ( }, body: JSON.stringify({ friends: updatedFriends }), }); -}; +} diff --git a/frontend/lib/fetches.tsx b/frontend/lib/fetches.tsx index 74596b6..b07fddf 100644 --- a/frontend/lib/fetches.tsx +++ b/frontend/lib/fetches.tsx @@ -12,7 +12,8 @@ export const fetchBasket = async (basketId: string) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); }; export const fetchItem = async (itemId: string) => { @@ -20,16 +21,18 @@ export const fetchItem = async (itemId: string) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); }; export const fetchGroupById = async (groupId: string) => { try { - const res = await fetch(`${vite_backend_url}/groups/${groupId}`, { + const res = await fetch(`${vite_backend_url}/groups/${groupId}`, { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); if (res.ok) { return res.json(); } else { @@ -45,7 +48,8 @@ export const fetchGroup = async (groupId: string) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); }; export const fetchUser = async (userId: ObjectId) => { @@ -53,7 +57,8 @@ export const fetchUser = async (userId: ObjectId) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); }; export const fetchUserWithString = async (userId: string) => { @@ -61,7 +66,8 @@ export const fetchUserWithString = async (userId: string) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); }; export const fetchUserGroupsByUser = async (user: IUser) => { @@ -70,7 +76,8 @@ export const fetchUserGroupsByUser = async (user: IUser) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); if (res.status === 200) { const data = await res.json(); return data; @@ -87,7 +94,8 @@ export const fetchUserFriendsByUser = async (user: IUser) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); if (res.status === 200) { const data = await res.json(); return data; @@ -144,7 +152,8 @@ export const fetchGroupBaskets = async (group: IGroup) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); if (res.status === 200) { const data = await res.json(); return data; @@ -166,7 +175,8 @@ export const fetchBasketItems = async (basket: IBasket) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); if (res.status === 200) { const data = await res.json(); return data; @@ -182,7 +192,8 @@ export const fetchUserBaskets = async (userId: string) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); if (res.status === 200) { const allBaskets = await res.json(); const userBaskets = [] as IBasket[]; @@ -197,11 +208,12 @@ export const fetchUserBaskets = async (userId: string) => { export const fetchGroups = async (userGroups: ObjectId[]) => { const groupPromises = userGroups.map(async (group) => { - const res = await fetch(`${vite_backend_url}/groups/${group}`, { + const res = await fetch(`${vite_backend_url}/groups/${group}`, { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); if (res.status === 200) { const data = await res.json(); return data; @@ -220,7 +232,8 @@ export const fetchMembers = async (memberIds: ObjectId[]) => { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, - }); + } + ); if (res.ok) { return res.json(); } else { diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1b86849..d031547 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -85,7 +85,7 @@ function App() { updateState={{ setUser, setToken }} /> ) : ( - + )} } /> @@ -129,7 +129,7 @@ function App() { element={ } - /> + /> diff --git a/frontend/src/pages/IndividualGroupPage.tsx b/frontend/src/pages/IndividualGroupPage.tsx index dfa429b..06bdc39 100644 --- a/frontend/src/pages/IndividualGroupPage.tsx +++ b/frontend/src/pages/IndividualGroupPage.tsx @@ -33,6 +33,7 @@ import { fetchUserWithString } from "../../lib/fetches"; // const vite_backend_url = import.meta.env.VITE_BACKEND_URL as string; const vite_backend_url = "https://gather-app-307.azurewebsites.net"; + type Props = { LoggedInUser: IUser | null; setUser: any; diff --git a/frontend/src/pages/MyGroupsPage.tsx b/frontend/src/pages/MyGroupsPage.tsx index bb6414f..90ba945 100644 --- a/frontend/src/pages/MyGroupsPage.tsx +++ b/frontend/src/pages/MyGroupsPage.tsx @@ -158,8 +158,7 @@ const GroupPage: React.FC = ({ justifyContent="center" alignItems="center" > - {stateVariable.user?.groups.length !== 0 && - filteredGroups.length === 0 ? ( + {stateVariable.user?.groups.length !== 0 && filteredGroups.length === 0 ? ( skelIds.map((id) => { return ( @@ -195,7 +194,9 @@ const GroupPage: React.FC = ({ }) ) : ( - No groups found! Do you want to add one? + + No groups found! Do you want to add one? + )} diff --git a/frontend/src/pages/ProfilePage.tsx b/frontend/src/pages/ProfilePage.tsx index ceec857..6b9a8c7 100644 --- a/frontend/src/pages/ProfilePage.tsx +++ b/frontend/src/pages/ProfilePage.tsx @@ -18,7 +18,8 @@ const ProfilePage: React.FC = ({ if (!LoggedInUser) { navigate("/login"); } - }); + } + ); return ( diff --git a/frontend/staticwebapp.config.json b/frontend/staticwebapp.config.json deleted file mode 100644 index 0418213..0000000 --- a/frontend/staticwebapp.config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "routes": [ - { - "route": "/*", - "rewrite": "/index.html" - } - ] -} diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 0ce9c2b..9cc50ea 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,25 +1,7 @@ -// import { defineConfig } from "vite"; -// import react from "@vitejs/plugin-react"; - -// // https://vitejs.dev/config/ -// export default defineConfig({ -// plugins: [react()], -// }); - import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; -import { resolve } from "path"; +// https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], - build: { - outDir: "dist", // Ensure this matches your deployment directory - rollupOptions: { - input: { - main: resolve(__dirname, "index.html"), - }, - }, - }, - // Ensure the public directory is included in the build - publicDir: "public", });