Skip to content

Commit

Permalink
Merge branch 'main' into 104-edititempage
Browse files Browse the repository at this point in the history
  • Loading branch information
jhagendoornCP authored Jun 3, 2024
2 parents d5da4aa + 88e43ce commit 8438385
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 83 deletions.
32 changes: 15 additions & 17 deletions backend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
{
"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"]
}
2 changes: 1 addition & 1 deletion frontend/lib/edits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const moveItem = async (
body: JSON.stringify({
items: newBasketsItems,
}),
}
},
);
if (removeItemFromBasket.ok) {
console.log("Item removed from basket successfully");
Expand Down
8 changes: 0 additions & 8 deletions frontend/lib/fetches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const fetchGroupById = async (groupId: string) => {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});

if (res.ok) {
return res.json();
} else {
Expand Down Expand Up @@ -72,7 +71,6 @@ export const fetchUserGroupsByUser = async (user: IUser) => {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});

if (res.status === 200) {
const data = await res.json();
return data;
Expand All @@ -90,7 +88,6 @@ export const fetchUserFriendsByUser = async (user: IUser) => {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});

if (res.status === 200) {
const data = await res.json();
return data;
Expand Down Expand Up @@ -148,7 +145,6 @@ export const fetchGroupBaskets = async (group: IGroup) => {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});

if (res.status === 200) {
const data = await res.json();
return data;
Expand All @@ -171,7 +167,6 @@ export const fetchBasketItems = async (basket: IBasket) => {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});

if (res.status === 200) {
const data = await res.json();
return data;
Expand All @@ -188,7 +183,6 @@ export const fetchUserBaskets = async (userId: string) => {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});

if (res.status === 200) {
const allBaskets = await res.json();
const userBaskets = [] as IBasket[];
Expand All @@ -209,7 +203,6 @@ export const fetchGroups = async (userGroups: ObjectId[]) => {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});

if (res.status === 200) {
const data = await res.json();
return data;
Expand All @@ -229,7 +222,6 @@ export const fetchMembers = async (memberIds: ObjectId[]) => {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});

if (res.ok) {
return res.json();
} else {
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function App() {
updateState={{ setUser, setToken }}
/>
) : (
<NavbarSignedOut/>
<NavbarSignedOut />
)}
<Routes>
<Route path="/" element={<MoveLetters />} />
Expand All @@ -92,9 +92,7 @@ function App() {
<Route
path="/profile"
element={
<ProfilePage
LoggedInUser={user ? user._id.toString() : ""}
/>
<ProfilePage LoggedInUser={user ? user._id.toString() : ""} />
}
/>
<Route
Expand All @@ -116,7 +114,6 @@ function App() {
<IndividualGroupPage LoggedInUser={user} setUser={setUser} />
}
/>

</Routes>
</Box>
</Router>
Expand Down
86 changes: 45 additions & 41 deletions frontend/src/components/ItemGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,47 +144,51 @@ const ItemGroup: React.FC<Props> = ({
</Thead>
<Tbody>
{!loading && items.length > 0 ? (
items.map((item, index) => (
console.log(item),
<Tr key={index}>
<Td width="25%">{item.name}</Td>
<Td width="50%">{item.notes}</Td>
<Td width="8%">
<EditItem itemId={item._id.toString()} />
</Td>
<Td width="8%">
<Menu>
<MenuButton as={Button} rightIcon={<FaChevronDown />}>
Select Basket
</MenuButton>
<MenuList>
{userBaskets.length > 0 ? (
(console.log(userBaskets),
userBaskets.map((basket) => (
<MenuItem
key={basket._id.toString()}
onClick={() => handleMove(basket, item)}
_hover={{ textColor: "black" }}
>
{basket.basketName}
</MenuItem>
)))
) : (
<MenuItem disabled>No baskets available</MenuItem>
)}
</MenuList>
</Menu>
</Td>
<Td width="9%">
<IconButton
aria-label="Delete"
icon={<DeleteIcon />}
colorScheme="red"
onClick={() => removeItem(item)}
/>
</Td>
</Tr>
))
items.map(
(item, index) => (
console.log(item),
(
<Tr key={index}>
<Td width="25%">{item.name}</Td>
<Td width="50%">{item.notes}</Td>
<Td width="8%">
<EditItem itemId={item._id.toString()} />
</Td>
<Td width="8%">
<Menu>
<MenuButton as={Button} rightIcon={<FaChevronDown />}>
Select Basket
</MenuButton>
<MenuList>
{userBaskets.length > 0 ? (
(console.log(userBaskets),
userBaskets.map((basket) => (
<MenuItem
key={basket._id.toString()}
onClick={() => handleMove(basket, item)}
_hover={{ textColor: "black" }}
>
{basket.basketName}
</MenuItem>
)))
) : (
<MenuItem disabled>No baskets available</MenuItem>
)}
</MenuList>
</Menu>
</Td>
<Td width="9%">
<IconButton
aria-label="Delete"
icon={<DeleteIcon />}
colorScheme="red"
onClick={() => removeItem(item)}
/>
</Td>
</Tr>
)
),
)
) : (
<Tr>
<Td colSpan={5}>No items found.</Td>
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/pages/MyGroupsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ 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 @@ -198,9 +199,7 @@ 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
9 changes: 3 additions & 6 deletions frontend/src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ interface ProfilePageProps {
LoggedInUser: string;
}

const ProfilePage: React.FC<ProfilePageProps> = ({
LoggedInUser,
}) => {
const ProfilePage: React.FC<ProfilePageProps> = ({ LoggedInUser }) => {
const navigate = useNavigate();
useEffect(() => {
if (!localStorage.getItem("token")) {
navigate("/login");
}
}
);
});

return (
<Box bg="gray.100" color="gray.800" minH="93vh" p={4} overflowY={"auto"}>
Expand All @@ -27,7 +24,7 @@ const ProfilePage: React.FC<ProfilePageProps> = ({
justifyContent={"space-between"}
>
<GridItem p={4} height="auto" width={{ base: "90vw", md: "45vw" }}>
<UserProfile userId={LoggedInUser}/>
<UserProfile userId={LoggedInUser} />
</GridItem>
<GridItem p={4} width={{ base: "90vw", md: "52vw" }}>
<Box
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/styles/moveLetters.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Resetting margins, padding, and overflow behavior on the entire document */
html, body {
html,
body {
margin: 0;
padding: 0px;
height: 100%; /* or 100vh */
Expand Down
5 changes: 5 additions & 0 deletions frontend/staticwebapp.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"navigationFallback": {
"rewrite": "/index.html"
}
}

0 comments on commit 8438385

Please sign in to comment.