Skip to content

Commit

Permalink
Revert "static routing + prettier"
Browse files Browse the repository at this point in the history
This reverts commit a5b0845.
  • Loading branch information
palldas committed Jun 2, 2024
1 parent 878bdbe commit 302d729
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 70 deletions.
32 changes: 17 additions & 15 deletions backend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
6 changes: 4 additions & 2 deletions frontend/lib/deletes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions frontend/lib/edits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -199,4 +196,4 @@ export const addFriendToUser = async (
},
body: JSON.stringify({ friends: updatedFriends }),
});
};
}
43 changes: 28 additions & 15 deletions frontend/lib/fetches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@ export const fetchBasket = async (basketId: string) => {
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});
}
);
};

export const fetchItem = async (itemId: string) => {
return fetch(`${vite_backend_url}/items/${itemId}`, {
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 {
Expand All @@ -45,23 +48,26 @@ export const fetchGroup = async (groupId: string) => {
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});
}
);
};

export const fetchUser = async (userId: ObjectId) => {
return fetch(`${vite_backend_url}/users/${userId}`, {
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});
}
);
};

export const fetchUserWithString = async (userId: string) => {
return fetch(`${vite_backend_url}/users/${userId}`, {
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});
}
);
};

export const fetchUserGroupsByUser = async (user: IUser) => {
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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[];
Expand All @@ -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;
Expand All @@ -220,7 +232,8 @@ export const fetchMembers = async (memberIds: ObjectId[]) => {
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});
}
);
if (res.ok) {
return res.json();
} else {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function App() {
updateState={{ setUser, setToken }}
/>
) : (
<NavbarSignedOut />
<NavbarSignedOut/>
)}
<Routes>
<Route path="/" element={<MoveLetters />} />
Expand Down Expand Up @@ -129,7 +129,7 @@ function App() {
element={
<IndividualGroupPage LoggedInUser={user} setUser={setUser} />
}
/>
/>
</Routes>
</Box>
</Router>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/IndividualGroupPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/pages/MyGroupsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ const GroupPage: React.FC<Props> = ({
justifyContent="center"
alignItems="center"
>
{stateVariable.user?.groups.length !== 0 &&
filteredGroups.length === 0 ? (
{stateVariable.user?.groups.length !== 0 && filteredGroups.length === 0 ? (
skelIds.map((id) => {
return (
<GridItem w="100%" h="100%" key={`skelly${id}`}>
Expand Down Expand Up @@ -195,7 +194,9 @@ const GroupPage: React.FC<Props> = ({
})
) : (
<GridItem key="default">
<Box>No groups found! Do you want to add one?</Box>
<Box>
No groups found! Do you want to add one?
</Box>
</GridItem>
)}
</Grid>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const ProfilePage: React.FC<ProfilePageProps> = ({
if (!LoggedInUser) {
navigate("/login");
}
});
}
);

return (
<Box bg="gray.100" color="gray.800" minH="93vh" p={4} overflowY={"auto"}>
Expand Down
8 changes: 0 additions & 8 deletions frontend/staticwebapp.config.json

This file was deleted.

20 changes: 1 addition & 19 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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",
});

0 comments on commit 302d729

Please sign in to comment.