({
+ border: 4,
+ borderColor: "#F7F8E9",
+ fontSize: "small",
+ color: "#F7F8E9",
+ backgroundColor: "#B0B09A",
+ "&:hover": {
+ color: "black",
+ },
+}));
+
function Header() {
const token = localStorage.getItem("access_token");
@@ -31,18 +79,29 @@ function Header() {
}
}, []);
- const [mouseOn, setMouseOn] = useState(false);
+ function deleteToken() {
+ localStorage.clear();
+ }
- const handlePopoverOpen = () => {
- setMouseOn(true);
+ //============Mypage List============
+ const navigate = useNavigate();
+
+ const [anchorEl, setAnchorEl] = useState(null);
+ const [selectedIndex, setSelectedIndex] = useState(0);
+ const open = Boolean(anchorEl);
+ const handleClickListItem = (event: any) => {
+ setAnchorEl(event.currentTarget);
};
- const handlePopoverClose = () => {
- setMouseOn(false);
+
+ const handleMenuItemClick = (event: any, index: any, option: any) => {
+ setSelectedIndex(index);
+ setAnchorEl(null);
+ navigate(option.to);
};
- function deleteToken() {
- localStorage.clear();
- }
+ const handleClose = () => {
+ setAnchorEl(null);
+ };
return (
@@ -76,23 +135,74 @@ function Header() {
{token ? (
// if IsLogin is true
-
-
diff --git a/frontend/src/components/mainpage/PopularTrash.tsx b/frontend/src/components/mainpage/PopularTrash.tsx
index ea33892..a44e9ed 100644
--- a/frontend/src/components/mainpage/PopularTrash.tsx
+++ b/frontend/src/components/mainpage/PopularTrash.tsx
@@ -1,38 +1,20 @@
-import {Typography, Box} from "@mui/material";
-import FirstImg from '../../images/firstImg'
-import SecondImg from '../../images/secondImg';
-import ThirdImg from '../../images/thirdImg';
+import { Typography, Box } from "@mui/material";
import TrashCardView from "./TrashCardView";
import AutoGraphIcon from '@mui/icons-material/AutoGraph';
-function PopularTrash(){
- return(
+function PopularTrash() {
+ return (
-
-
-
- 인기 쓰레기
+
+ This Week's Ranking
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
);
};
diff --git a/frontend/src/components/mainpage/TrashCardView.tsx b/frontend/src/components/mainpage/TrashCardView.tsx
index 100b8b7..a9b94ab 100644
--- a/frontend/src/components/mainpage/TrashCardView.tsx
+++ b/frontend/src/components/mainpage/TrashCardView.tsx
@@ -1,41 +1,240 @@
import * as React from "react";
+import { useState, useEffect } from "react";
+import { useNavigate } from "react-router-dom";
import {
+ Grid,
Button,
CardActionArea,
CardActions,
Card,
+ Box,
CardContent,
CardMedia,
Typography,
} from "@mui/material";
+import { decodeToken } from "src/Auth/tokenGetter";
+import axios from "axios";
+import { response } from "express";
+
+interface BaseContent {
+ kind: string;
+ images: any;
+}
+
+const trashlist: BaseContent[] = [
+ {
+ kind: "",
+ images: ``,
+ },
+ {
+ kind: "",
+ images: ``,
+ },
+ {
+ kind: "",
+ images: ``,
+ },
+];
+
+const ranklist: BaseContent[] = [
+ {
+ kind: "GLASS",
+ images: `https://i.ibb.co/g9rSyFX/31-OEv-Rve-V3-L-SY450.jpg`,
+ },
+ {
+ kind: "BIODEGRADABLE",
+ images: `https://i.ibb.co/0MHvQZr/2022-07-30-11-23-56.png`,
+ },
+ {
+ kind: "CARDBOARD",
+ images: `https://i.ibb.co/jHTxfbS/17457488-1837243389875287-7962009710514097503-n.jpg`,
+ },
+ {
+ kind: "PAPER",
+ images: `https://i.ibb.co/7XPdFc5/2558-B64255-CF58-B833.jpg`,
+ },
+ {
+ kind: "METAL",
+ images: `https://i.ibb.co/tsjSswc/2022-07-30-11-26-27.png`,
+ },
+ {
+ kind: "PLASTIC",
+ images: `https://i.ibb.co/xLm0vv2/2022-07-30-11-20-36.png`,
+ },
+];
+
+function MultiActionAreaCard() {
+ let navigate = useNavigate();
+
+ const [firstData, setFirstData] = useState(null);
+ const [secondData, setSecondData] = useState(null);
+ const [thridData, setThirdData] = useState(null);
+
+ axios
+ .get("http://localhost:8080/api/trash/statistics/ranking")
+ .then((response) => {
+ for (let i = 0; i < 3; i++) {
+ trashlist[i].kind = response.data[i].kind;
+ for (let j = 0; j < 6; j++) {
+ if (ranklist[j].kind === trashlist[i].kind) {
+ trashlist[i].images = ranklist[j].images;
+ }
+ }
+ }
+ /*
+ trashlist.forEach(kindlist => {
+ kindlist.kind = response.data.kind
+ ranklist.forEach(imagelist => {
+ if (imagelist.kind === kindlist.kind)
+ kindlist.images = imagelist.images;
+ })})
+ */
+ setFirstData(trashlist[0]);
+ setSecondData(trashlist[1]);
+ setThirdData(trashlist[2]);
+ })
+ .catch((error) => {
+ console.log("error", error.response);
+ });
-export default function MultiActionAreaCard() {
return (
-
-
-
+
+
- 물병
+ sx={{ fontSize: 40, mt: 10, fontFamily: "Itim", color: "#737458" }}
+ >1st
-
-
+
+
+
+
+ {firstData?.kind}
+
+
+
{
+ navigate(`/defaulthowpage`, {
+ state: {
+ needKind: firstData?.kind,
+ needImages: firstData?.images,
+ },
+ });
+ }}
+ sx={{ mt:3, margin: "auto", fontFamily: "Itim", color: "#737458", fontSize: 20 }}
>
- 더보기
+ How to Recycle this {firstData?.kind}??
-
-
+
+
+
+ 2nd
+
+
+
+
+
+ {secondData?.kind}
+
+
+
+
+ {
+ navigate(`/defaulthowpage`, {
+ state: {
+ needKind: secondData?.kind,
+ needImages: secondData?.images,
+ },
+ });
+ }}
+ sx={{ mt:3, margin: "auto", fontFamily: "Itim", color: "#737458", fontSize: 20 }}
+ >
+ How to Recycle this {secondData?.kind}??
+
+
+
+
+ 3rd
+
+
+
+
+
+ {thridData?.kind}
+
+
+
+ {
+ navigate(`/defaulthowpage`, {
+ state: {
+ needKind: thridData?.kind,
+ needImages: thridData?.images,
+ },
+ });
+ }}
+ sx={{ mt:3, margin: "auto", fontFamily: "Itim", color: "#737458", fontSize: 20 }}
+ >
+ How to Recycle this {thridData?.kind}??
+
+
+
);
}
+
+export default MultiActionAreaCard;
diff --git a/frontend/src/images/moreIcon.tsx b/frontend/src/images/moreIcon.tsx
index 7049aed..2aaba56 100644
--- a/frontend/src/images/moreIcon.tsx
+++ b/frontend/src/images/moreIcon.tsx
@@ -11,7 +11,7 @@ function IconExpand() {
);
diff --git a/frontend/src/utils/autoSaveToggle.tsx b/frontend/src/utils/autoSaveToggle.tsx
new file mode 100644
index 0000000..74cd89a
--- /dev/null
+++ b/frontend/src/utils/autoSaveToggle.tsx
@@ -0,0 +1,34 @@
+import Api from "./customApi";
+import { getAccess } from "src/Auth/tokenManager";
+import { rs } from "../utils/types";
+
+const what: any = getAccess();
+let user_autosave: rs.AutoSave;
+
+const isAutoSave = async () => {
+ await Api.get(`/users/autosave`, {
+ headers: {
+ Authorization: `${what.value}`,
+ },
+ }).then((res) => {
+ user_autosave = res.data;
+
+ return user_autosave;
+ });
+ return user_autosave;
+};
+
+const changeAutoSave = async (isBoolean: boolean) => {
+ await Api.patch(`/users/autosave`, isBoolean, {
+ headers: {
+ Authorization: `${what.value}`,
+ },
+ }).then((res) => {
+ user_autosave = res.data;
+
+ return user_autosave;
+ });
+ return user_autosave;
+};
+
+export { isAutoSave, changeAutoSave };
diff --git a/frontend/src/utils/types.tsx b/frontend/src/utils/types.tsx
index 23dd6f2..173788e 100644
--- a/frontend/src/utils/types.tsx
+++ b/frontend/src/utils/types.tsx
@@ -16,7 +16,7 @@ export namespace rs {
}
export interface Trash {
- uploaded_trash_image_id: number;
+ id?: any;
image: string;
}
@@ -34,7 +34,7 @@ export namespace rs {
}
//❌
export interface Challenge {
- challenge_number: number;
+ challenge_id: number;
type: boolean;
}
export interface ChallengeInfo {
@@ -43,4 +43,8 @@ export namespace rs {
imgF: string;
test: string;
}
+
+ export interface AutoSave {
+ user_autosave: boolean;
+ }
}