Skip to content

Commit

Permalink
fixed backend variables inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
NwinNwin committed Sep 22, 2023
1 parent 1c8f98e commit cc0f76b
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 81 deletions.
Binary file added src/assets/logos/resolved.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions src/components/CreateModal/CreateModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ export default function CreateModal({
islost: true,
name: "",
description: "",
itemDate: "",
isResolved: false,
isHelped: null,
itemdate: "",
isresolved: false,
ishelped: null,
});
setUploadImg("");
setActiveStep(0);
Expand All @@ -173,9 +173,9 @@ export default function CreateModal({
islost: true,
name: "",
description: "",
itemDate: "",
isResolved: false,
isHelped: null,
itemdate: "",
isresolved: false,
ishelped: null,
});
setUploadImg("");
setActiveStep(0);
Expand Down Expand Up @@ -344,7 +344,7 @@ export default function CreateModal({
setDate(e);
setNewAddedItem((prev) => ({
...prev,
itemDate: e.toISOString().split("T")[0],
itemdate: e.toISOString().split("T")[0],
}));
}}
value={date}
Expand Down Expand Up @@ -515,7 +515,7 @@ export default function CreateModal({
>
<SlCalender size={"1.3em"} />
<Text ml="2%" fontSize={15} w={"100%"}>
{newAddedItem.itemDate}
{newAddedItem.itemdate}
</Text>
</Flex>
</Flex>
Expand Down Expand Up @@ -548,9 +548,9 @@ export default function CreateModal({
islost: true,
name: "",
description: "",
itemDate: "",
isResolved: false,
isHelped: null,
itemdate: "",
isresolved: false,
ishelped: null,
});
setUploadImg("");
onClose();
Expand All @@ -565,7 +565,7 @@ export default function CreateModal({
(activeStep === 0 && newAddedItem.name === "") ||
newAddedItem.description === "" ||
(activeStep === 1 && newAddedItem.type === "") ||
(activeStep === 2 && newAddedItem.itemDate === "") ||
(activeStep === 2 && newAddedItem.itemdate === "") ||
(activeStep === 3 && uploadImg === "")
}
variant={"solid"}
Expand Down
6 changes: 4 additions & 2 deletions src/components/FeedbackModal/FeedbackModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export default function FeedbackModal({
setLoading(false);
axios
.put(`${process.env.REACT_APP_AWS_BACKEND_URL}/items/${props.id}`, {
isHelped: feedbackHelped,
...props,
isresolved: true,
ishelped: feedbackHelped,
})
.then(() => console.log("Success"))
.catch((err) => console.log(err));
Expand All @@ -37,7 +39,7 @@ export default function FeedbackModal({
return prevItems.map((item) => {
if (item.id === props.id) {
item.isresolved = true;
item.isHelped = feedbackHelped;
item.ishelped = feedbackHelped;
}
return item;
});
Expand Down
106 changes: 55 additions & 51 deletions src/components/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ export default function Home() {
islost: true,
name: "",
description: "",
itemDate: "",
isResolved: false,
isHelped: null
itemdate: "",
isresolved: false,
ishelped: null,
});

const [isEdit, setIsEdit] = useState(false);
Expand All @@ -97,7 +97,7 @@ export default function Home() {
const [screenWidth, setScreenWidth] = useState(window.screen.width);
const [uploadImg, setUploadImg] = useState("");

console.log(data)
console.log(data);

// LOGIN MODAL
const {
Expand Down Expand Up @@ -137,10 +137,11 @@ export default function Home() {
};
getData();
}, []);

window.onresize = () => {
setScreenWidth(window.screen.width);
};
console.log(data);

return (
<DataContext.Provider
Expand Down Expand Up @@ -239,55 +240,58 @@ export default function Home() {

<Flex alignItems="center" justifyContent="space-between" mr={7} gap={5}>
{user ? (
<Menu>
<MenuButton>
<Image
src={user?.photoURL}
h={{ base: "50px", md: "80px" }}
w={{ base: "50px", md: "80px" }}
borderRadius="100%"
/>
</MenuButton>

<MenuList zIndex={10000}>
<MenuItem _focus={{ bg: "white" }}>
<Image
boxSize="1.2rem"
src={userlogo}
alt="logoutbutton"
mr="12px"
/>
{user?.email}
</MenuItem>
<MenuItem
onClick={() => {
setFindFilter((prev) => ({
...prev,
isYourPosts: !prev.isYourPosts,
}));
onOpen();
}}
>
<>
<Text>Leaderboard</Text>
<Menu>
<MenuButton>
<Image
boxSize="1.2rem"
src={yourposts}
alt="logoutbutton"
mr="12px"
src={user?.photoURL}
h={{ base: "50px", md: "80px" }}
w={{ base: "50px", md: "80px" }}
borderRadius="100%"
/>
Your Posts
</MenuItem>
</MenuButton>

<MenuItem onClick={handleLogout}>
<Image
boxSize="1.2rem"
src={logout}
alt="logoutbutton"
mr="12px"
/>
Logout
</MenuItem>
</MenuList>
</Menu>
<MenuList zIndex={10000}>
<MenuItem _focus={{ bg: "white" }}>
<Image
boxSize="1.2rem"
src={userlogo}
alt="logoutbutton"
mr="12px"
/>
{user?.email}
</MenuItem>
<MenuItem
onClick={() => {
setFindFilter((prev) => ({
...prev,
isYourPosts: !prev.isYourPosts,
}));
onOpen();
}}
>
<Image
boxSize="1.2rem"
src={yourposts}
alt="logoutbutton"
mr="12px"
/>
Your Posts
</MenuItem>

<MenuItem onClick={handleLogout}>
<Image
boxSize="1.2rem"
src={logout}
alt="logoutbutton"
mr="12px"
/>
Logout
</MenuItem>
</MenuList>
</Menu>
</>
) : (
<Button
h={{ base: "6vh", md: "7vh" }}
Expand Down
29 changes: 17 additions & 12 deletions src/components/Map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default function Map({
}
}, [focusLocation, setFocusLocation]);

console.log(findFilter);
const allMarkers = data
.filter((item) => {
return (
Expand All @@ -85,7 +86,7 @@ export default function Map({
findFilter.isFound === !item.islost) &&
(findFilter.type === "everything" || findFilter.type === item.type) &&
(findFilter.uploadDate === "" ||
item.itemDate.includes(findFilter.uploadDate)) &&
(item.itemdate && item.itemdate.includes(findFilter.uploadDate))) &&
(!findFilter.isYourPosts ||
(findFilter.isYourPosts && item.email === user.email))
);
Expand All @@ -102,7 +103,11 @@ export default function Map({
setFocusLocation(item.location);
},
}}
icon={(iconsMap[item.type] || iconsMap["others"])[item.islost]}
icon={
item.isresolved
? iconsMap["resolved"][item.islost]
: (iconsMap[item.type] || iconsMap["others"])[item.islost]
}
></Marker>
);
});
Expand Down Expand Up @@ -133,7 +138,7 @@ export default function Map({
);

async function handleSubmit() {
console.log("submitted")
console.log("submitted");
const date = new Date();

axios
Expand All @@ -145,10 +150,10 @@ export default function Map({
description: newAddedItem.description,
email: user.email,
location: [position.lat, position.lng],
itemDate: newAddedItem.itemDate,
itemdate: newAddedItem.itemdate,
date: date.toISOString(),
isResolved: newAddedItem.isResolved,
isHelped: newAddedItem.isHelped,
isresolved: newAddedItem.isresolved,
ishelped: newAddedItem.ishelped,
})
.then((item) => {
const newItem = {
Expand All @@ -160,10 +165,10 @@ export default function Map({
email: user.email,
location: [position.lat, position.lng],
date: date.toISOString(),
itemDate: newAddedItem.itemDate,
itemdate: newAddedItem.itemdate,
id: item.data.id,
isResolved: newAddedItem.isResolved,
isHelped: newAddedItem.isHelped,
isresolved: newAddedItem.isresolved,
ishelped: newAddedItem.ishelped,
};
setData((prev) => [...prev, newItem]);
setPosition(centerPosition);
Expand All @@ -174,9 +179,9 @@ export default function Map({
islost: true,
name: "",
description: "",
itemDate: "",
isResolved: false,
isHelped: null,
itemdate: "",
isresolved: false,
ishelped: null,
});
setIsCreate(!isCreate);
setUploadImg("");
Expand Down
11 changes: 11 additions & 0 deletions src/components/Map/MapIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ import wallet_lost from "../../assets/logos/Wallet_lost.png";

import key_found from "../../assets/logos/Key_found.png";
import key_lost from "../../assets/logos/Key_lost.png";
import resolved from "../../assets/logos/resolved.png";

import others_lost from "../../assets/logos/Others_lost.png";
import others_found from "../../assets/logos/Others_found.png";
import others_black from "../../assets/logos/others_black.svg";

import fly_img from "../../assets/images/fly_img.png";

const resolvedIcon = L.icon({
iconUrl: resolved,
iconSize: [50, 50],
iconAnchor: [25, 40],
});

const headphoneLost = L.icon({
iconUrl: headphone_lost,
iconSize: [60, 60],
Expand Down Expand Up @@ -109,4 +116,8 @@ export const iconsMap = {
true: othersLost,
false: othersFound,
},
resolved: {
true: resolvedIcon,
false: resolvedIcon,
},
};
28 changes: 25 additions & 3 deletions src/components/ResultCard/ResultCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,34 @@ import locate from "../../assets/logos/locate.svg";

export default function ResultCard({ props, setData, onResultsBarClose }) {
const infoModalDisclosure = useDisclosure();
const {id} = useParams();
const { id } = useParams();

const formattedDate = formatDate(new Date(props.date));
return (
<>
<Card maxW="lg" align={"center"} mb="10px">
<CardBody>
<Image src={props.image} alt="Car key" borderRadius="lg" />
<Flex justifyContent={"center"} alignItems={"center"}>
{props.isresolved && (
<Flex
backgroundColor={"rgba(255, 123, 0, 0.9)"}
position={"absolute"}
justifyContent={"center"}
alignItems={"center"}
marginTop={30}
flexDir={"column"}
w={450}
>
<Text fontSize={18} as="b" color={"white"}>
RETURNED
</Text>
<Text fontSize={15} color={"white"}>
This item has been returned.
</Text>
</Flex>
)}
<Image rounded={"lg"} src={props.image} />
</Flex>
<Stack mt="6" spacing="3">
<Flex justifyContent={"space-between"}>
<Text color="blue.600" fontSize="md" fontWeight="bold">
Expand Down Expand Up @@ -83,7 +103,9 @@ export default function ResultCard({ props, setData, onResultsBarClose }) {
<InfoModal
props={props}
onClose={infoModalDisclosure.onClose}
isOpen={id === props.id.toString() ? true: infoModalDisclosure.isOpen}
isOpen={
id === props.id.toString() ? true : infoModalDisclosure.isOpen
}
setData={setData}
/>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ResultsBar/ResultsBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default function ResultsBar({
findFilter.isFound === !item.islost) &&
(findFilter.type === "everything" || findFilter.type === item.type) &&
(findFilter.uploadDate === "" ||
item.itemDate.includes(findFilter.uploadDate)) &&
!item.itemdate ||
(item.itemdate && item.itemdate.includes(findFilter.uploadDate))) &&
(!findFilter.isYourPosts ||
(findFilter.isYourPosts && item.email === user.email))
);
Expand Down

0 comments on commit cc0f76b

Please sign in to comment.