Skip to content

Commit

Permalink
Merge pull request #30 from NwinNwin/dang_leaderboard
Browse files Browse the repository at this point in the history
Dang fixed bugs in code
  • Loading branch information
NwinNwin authored Sep 22, 2023
2 parents 1c8f98e + 8eb0289 commit 478f244
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 88 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.
32 changes: 17 additions & 15 deletions src/components/CreateModal/CreateModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,17 @@ export default function CreateModal({
<>
{isCreate ? (
<Button
h={{ base: "10vh", md: "7vh" }}
w={{ base: "40vw", md: "8vw" }}
// h={{ base: "10vh", md: "7vh" }}
// w={{ base: "40vw", md: "" }}
boxShadow="xl"
_hover={{ bg: "#b4dbd9" }}
backgroundColor="#33b249"
color="white"
fontSize="xl"
fontWeight="bold"
borderRadius={20}
borderRadius={30}
size={"lg"}
paddingY={{ base: 10, md: 8 }}
onClick={() => {
if (user) {
onOpen();
Expand Down Expand Up @@ -150,9 +152,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 +175,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 +346,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 +517,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 +550,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 +567,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
120 changes: 65 additions & 55 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 Expand Up @@ -373,13 +377,16 @@ export default function Home() {
) : (
<>
<Button
backgroundColor="#a881af"
boxShadow="2xl"
color="white"
backgroundColor="white"
variant="outline"
boxShadow="7px 7px 14px #666666,
-7px -7px 14px #ffffff;"
color="#74a2fa"
onClick={onOpen}
fontSize={{ base: "xl", md: "2xl" }}
size="lg"
gap={2}
borderRadius={"lg"}
>
<SettingsIcon />
Filter
Expand All @@ -396,9 +403,12 @@ export default function Home() {
colorScheme="blue"
onClick={onResultsBarOpen}
fontSize="2xl"
boxShadow="2xl"
boxShadow="12px 12px 24px #a8a8a8,
-12px -12px 24px #ffffff;"
size="lg"
gap={2}
justifyContent={"center"}
alignItems={"center"}
>
<StarIcon />
</Button>
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,
},
};
Loading

0 comments on commit 478f244

Please sign in to comment.