Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Gather307/Gather
Browse files Browse the repository at this point in the history
  • Loading branch information
SilveerDusk committed Jun 4, 2024
2 parents acd2182 + a5d0e80 commit 562a5dd
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 151 deletions.
2 changes: 1 addition & 1 deletion frontend/lib/edits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type updatedItem = {
name: string;
notes: string;
toShare: string;
isPrivate: string;
isPrivate: boolean;
price: string;
quantity: string;
};
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/components/AddFriendToBasket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,19 @@ const AddFriendToBasket: React.FC<Props> = ({

return (
<div>
<Popover>
<Popover
placement="auto"
modifiers={[
{
name: "preventOverflow",
options: {
boundary: "viewport",
altBoundary: true,
padding: 8,
},
},
]}
>
<PopoverTrigger>
<Button
bgColor="var(--col-secondary)"
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/components/EditBasket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,19 @@ const EditBasket: React.FC<Props> = ({ basketId, groupId }) => {
};

return (
<Popover>
<Popover
placement="auto"
modifiers={[
{
name: "preventOverflow",
options: {
boundary: "viewport",
altBoundary: true,
padding: 8,
},
},
]}
>
<PopoverTrigger>
<Button onClick={() => setIsEditing(true)}>Edit</Button>
</PopoverTrigger>
Expand Down
65 changes: 14 additions & 51 deletions frontend/src/components/EditGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import {
Input,
Box,
HStack,
Stack,
Radio,
RadioGroup,
Text,
} from "@chakra-ui/react";
import React, { useState, useEffect } from "react";
Expand Down Expand Up @@ -132,7 +129,19 @@ const Editgroup: React.FC<Props> = ({
};

return (
<Popover>
<Popover
placement="auto"
modifiers={[
{
name: "preventOverflow",
options: {
boundary: "viewport",
altBoundary: true,
padding: 8,
},
},
]}
>
<PopoverTrigger>
<Button onClick={() => setIsEditing(true)}>Edit Group</Button>
</PopoverTrigger>
Expand Down Expand Up @@ -178,53 +187,7 @@ const Editgroup: React.FC<Props> = ({
_hover={{ bg: "var(--col-tertiary)" }}
/>
</FormControl>
<FormControl>
<FormLabel fontWeight="bold">Visible to Others?</FormLabel>
<RadioGroup onChange={setEditedPub} value={editedPub}>
<Stack direction="row">
<Radio
value="false"
borderColor="var(--col-dark)"
_checked={{
borderColor: "var(--col-bright)",
bg: "var(--col-bright)",
color: "var(--col-dark)",
_before: {
content: '""',
display: "inline-block",
width: "100%",
height: "100%",
borderRadius: "50%",
bg: "var(--col-dark)",
},
}}
_hover={{ bg: "var(--col-tertiary)" }}
>
Public
</Radio>
<Radio
value="true"
borderColor="var(--col-dark)"
_checked={{
borderColor: "var(--col-bright)",
bg: "var(--col-bright)",
color: "var(--col-dark)",
_before: {
content: '""',
display: "inline-block",
width: "100%",
height: "100%",
borderRadius: "50%",
bg: "var(--col-dark)",
},
}}
_hover={{ bg: "var(--col-tertiary)" }}
>
Private
</Radio>
</Stack>
</RadioGroup>
</FormControl>

<HStack width="100%" spacing={4}>
<Button
bgColor="var(--col-secondary)"
Expand Down
85 changes: 22 additions & 63 deletions frontend/src/components/EditItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ const EditItem: React.FC<Props> = ({ itemId, editable = true }) => {
const [editedDesc, setEditedDesc] = useState("");
const [editedQuant, setEditedQuant] = useState("");
const [editedPrice, setEditedPrice] = useState("");
const [editedPub, setEditedPub] = useState("");
const [editedPub, setEditedPub] = useState(false);
const [editedSharable, setEditedSharable] = useState("");
const [ItemData, setItemData] = useState({
itemId: "",
itemName: "",
itemDesc: "",
itemQuant: "",
itemPrice: "",
itemPub: "",
itemPub: false,
itemSharable: "",
});

Expand All @@ -69,14 +69,14 @@ const EditItem: React.FC<Props> = ({ itemId, editable = true }) => {
itemDesc: data.notes,
itemQuant: data.quantity,
itemPrice: data.price,
itemPub: data.isPrivate,
itemPub: data.isPrivate === "true" || data.isPrivate === true,
itemSharable: data.toShare,
});
setEditedName(data.name);
setEditedDesc(data.notes);
setEditedQuant(data.quantity);
setEditedPrice(data.price);
setEditedPub(data.isPrivate);
setEditedPub(data.isPrivate === "true" || data.isPrivate === true);
setEditedSharable(data.toShare);
} else {
console.error("Failed to fetch user data");
Expand Down Expand Up @@ -126,7 +126,19 @@ const EditItem: React.FC<Props> = ({ itemId, editable = true }) => {
};

return (
<Popover>
<Popover
placement="auto"
modifiers={[
{
name: "preventOverflow",
options: {
boundary: "viewport",
altBoundary: true,
padding: 8,
},
},
]}
>
<PopoverTrigger>
<IconButton aria-label="More" icon={<SearchIcon />} />
</PopoverTrigger>
Expand Down Expand Up @@ -204,7 +216,10 @@ const EditItem: React.FC<Props> = ({ itemId, editable = true }) => {
</FormControl>
<FormControl>
<FormLabel fontWeight="bold">Visible to Others?</FormLabel>
<RadioGroup onChange={setEditedPub} value={editedPub}>
<RadioGroup
onChange={(val) => setEditedPub(val === "true")}
value={editedPub ? "true" : "false"}
>
<Stack direction="row">
<Radio
value="false"
Expand Down Expand Up @@ -249,56 +264,6 @@ const EditItem: React.FC<Props> = ({ itemId, editable = true }) => {
</Stack>
</RadioGroup>
</FormControl>
<FormControl>
<FormLabel fontWeight="bold">Sharable?</FormLabel>
<RadioGroup
onChange={setEditedSharable}
value={editedSharable}
>
<Stack direction="row">
<Radio
value="true"
borderColor="var(--col-dark)"
_checked={{
borderColor: "var(--col-bright)",
bg: "var(--col-bright)",
color: "var(--col-dark)",
_before: {
content: '""',
display: "inline-block",
width: "100%",
height: "100%",
borderRadius: "50%",
bg: "var(--col-dark)",
},
}}
_hover={{ bg: "var(--col-tertiary)" }}
>
Yes
</Radio>
<Radio
value="false"
borderColor="var(--col-dark)"
_checked={{
borderColor: "var(--col-bright)",
bg: "var(--col-bright)",
color: "var(--col-dark)",
_before: {
content: '""',
display: "inline-block",
width: "100%",
height: "100%",
borderRadius: "50%",
bg: "var(--col-dark)",
},
}}
_hover={{ bg: "var(--col-tertiary)" }}
>
No
</Radio>
</Stack>
</RadioGroup>
</FormControl>
<HStack
display={"flex"}
width="100%"
Expand Down Expand Up @@ -356,13 +321,7 @@ const EditItem: React.FC<Props> = ({ itemId, editable = true }) => {
<Text as="span" fontWeight="bold">
Viewability:
</Text>{" "}
{ItemData.itemPub === "true" ? "Private" : "Public"}
</Box>
<Box>
<Text as="span" fontWeight="bold">
Sharable:
</Text>{" "}
{ItemData.itemSharable === "true" ? "Yes" : "No"}
{ItemData.itemPub ? "Private" : "Public"}
</Box>
<HStack width="100%">
<Button
Expand Down
34 changes: 5 additions & 29 deletions frontend/src/components/NewItemOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ interface CreateProps {
const CreateItem = ({ postItem }: CreateProps) => {
const [item, setItem] = useState({
name: "",
toShare: false,
toShare: true,
isPrivate: false,
type: "",
notes: "",
Expand All @@ -123,18 +123,18 @@ const CreateItem = ({ postItem }: CreateProps) => {
console.log(item);
postItem(
item.name,
item.toShare,
(item.toShare = true),
item.isPrivate,
item.type,
(item.type = "No type"),
item.notes === "" ? "No description given" : item.notes,
item.price,
item.quantity,
);
setItem({
name: "",
toShare: false,
toShare: true,
isPrivate: false,
type: "",
type: "No type given",
notes: "",
price: 0,
quantity: 0,
Expand Down Expand Up @@ -221,17 +221,6 @@ const CreateItem = ({ postItem }: CreateProps) => {
onChange={handleChange}
className="i-b text-container multiline"
/>
<label htmlFor="desc" className="i-b">
Type
</label>
<input
type="text"
name="type"
id="type"
value={item.type}
onChange={handleChange}
className="i-b text-container multiline"
/>
<PopoverFooter
display="flex"
flexDirection="column"
Expand Down Expand Up @@ -293,19 +282,6 @@ const CreateItem = ({ postItem }: CreateProps) => {
justifyContent="space-between"
mb="10px"
>
<Box>
<input
type="checkbox"
name="toShare"
id="toShare"
checked={item.toShare === true}
onChange={handleChange}
className="checkbox"
/>
<label htmlFor="toShare" className="sidenote">
Sharable
</label>
</Box>
<Box>
<input
type="checkbox"
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/components/RemoveFromGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,19 @@ const RemoveFromGroup = ({ LoggedInUser, group }: Props) => {

return (
<div>
<Popover>
<Popover
placement="auto"
modifiers={[
{
name: "preventOverflow",
options: {
boundary: "viewport",
altBoundary: true,
padding: 8,
},
},
]}
>
<PopoverTrigger>
<Button colorScheme="red" marginRight="10px">
<VStack spacing="1">
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/pages/ItemsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ const ItemsPage: React.FC<Props> = ({
}, [stateVariable.user]);

return (
<Box w="100vw" p="0px 20px" bg="var(--col-bright)" overflow="auto" height="100%">
<Box
w="100vw"
p="0px 20px"
bg="var(--col-bright)"
overflow="auto"
height="100%"
>
<Flex direction="column" minH="100%" width="full">
{/* Header flex */}
<HStack
Expand Down
Loading

0 comments on commit 562a5dd

Please sign in to comment.