Skip to content

Commit c5658fc

Browse files
committed
did auth, email, fixed leaderboard
1 parent 56ada22 commit c5658fc

File tree

7 files changed

+105
-60
lines changed

7 files changed

+105
-60
lines changed

src/components/FeedbackModal/FeedbackModal.jsx

+29-10
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,26 @@ export default function FeedbackModal({
2323
email,
2424
}) {
2525
const [feedbackHelped, setFeedbackHelped] = useState(null);
26-
const { setLoading } = useContext(DataContext);
26+
const { setLoading, token } = useContext(DataContext);
2727
async function handleFeedback() {
28+
if (!token) {
29+
return;
30+
}
2831
setLoading(false);
2932
axios
30-
.put(`${process.env.REACT_APP_AWS_BACKEND_URL}/items/${props.id}`, {
31-
...props,
32-
isresolved: true,
33-
ishelped: feedbackHelped,
34-
})
33+
.put(
34+
`${process.env.REACT_APP_AWS_BACKEND_URL}/items/${props.id}`,
35+
{
36+
...props,
37+
isresolved: true,
38+
ishelped: feedbackHelped,
39+
},
40+
{
41+
headers: {
42+
Authorization: `Bearer ${token}`, // verify auth
43+
},
44+
}
45+
)
3546
.then(() => console.log("Success"))
3647
.catch((err) => console.log(err));
3748

@@ -51,10 +62,18 @@ export default function FeedbackModal({
5162
// Update the leaderboard
5263
const pointsToAdd = props.islost ? 2 : 5;
5364

54-
axios.put(`${process.env.REACT_APP_AWS_BACKEND_URL}/leaderboard`, {
55-
email: email,
56-
pointsToAdd: pointsToAdd,
57-
});
65+
axios.put(
66+
`${process.env.REACT_APP_AWS_BACKEND_URL}/leaderboard`,
67+
{
68+
email: email,
69+
pointsToAdd: pointsToAdd,
70+
},
71+
{
72+
headers: {
73+
Authorization: `Bearer ${token}`, // verify auth
74+
},
75+
}
76+
);
5877

5978
setLeaderboard((prev) =>
6079
prev.map((u) =>

src/components/Home/Home.jsx

+15-4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export default function Home() {
8888
);
8989
}
9090

91+
console.log(token);
92+
9193
const [loading, setLoading] = useState(false);
9294

9395
const [newAddedItem, setNewAddedItem] = useState({
@@ -169,6 +171,11 @@ export default function Home() {
169171
{
170172
email: user.email,
171173
points: 5, // You can modify this as per your requirements
174+
},
175+
{
176+
headers: {
177+
Authorization: `Bearer ${token}`, // verify auth
178+
},
172179
}
173180
);
174181
// Fetch the leaderboard again after insertion
@@ -309,7 +316,7 @@ export default function Home() {
309316
gap={{ base: 1, md: 1.5 }}
310317
justifyContent={"center"}
311318
background={"#74a2fa"}
312-
padding={{ base: "6px", md: 1.5 }}
319+
padding={{ base: "5px", md: 1.5 }}
313320
borderRadius={"xl"}
314321
_hover={{
315322
background: "#365fad",
@@ -323,10 +330,14 @@ export default function Home() {
323330
<Image
324331
ref={btnRef}
325332
src={cookie}
326-
h={{ base: "20px", md: "20px" }}
327-
w={{ base: "25px", md: "25px" }}
333+
h={{ base: "15px", md: "20px" }}
334+
w={{ base: "15px", md: "25px" }}
328335
/>
329-
<Text as={"b"} fontSize={"lg"} color={"white"}>
336+
<Text
337+
as={"b"}
338+
fontSize={{ base: "sm", md: "lg" }}
339+
color={"white"}
340+
>
330341
{user
331342
? leaderboard.find((u) => u.email === user.email)?.points
332343
: 0}

src/components/Home/Leaderboard.jsx

+16-16
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default function Leaderboard({
6969
<Flex
7070
w={{ base: "100%", md: "500px" }}
7171
padding={5}
72-
px={5}
72+
px={{ base: 3, md: 5 }}
7373
background={"#5c5be5"}
7474
color={"white"}
7575
alignItems={"center"}
@@ -81,26 +81,27 @@ export default function Leaderboard({
8181
<Text as={"b"} fontSize={"4xl"}>
8282
1
8383
</Text>
84-
<Text as={"b"} fontSize={"lg"}>
84+
<Text as={"b"} fontSize={{ base: "sm", md: "lg" }}>
8585
{leaderboard[0]?.email}
8686
</Text>
8787
</Flex>
8888

89-
<Flex>
90-
<Text as={"b"} fontSize={"4xl"}>
89+
<Flex alignItems={"center"}>
90+
<Text as={"b"} fontSize={{ base: "3xl", md: "4xl" }}>
9191
{leaderboard[0]?.points}
9292
</Text>
9393
<Image
9494
class="gold-medal"
9595
src={goldmedal}
9696
alt="gold medal"
97+
w={"5vh"}
98+
h={"5vh"}
9799
/>
98100
</Flex>
99101
</Flex>
100102
<Flex
101103
w={{ base: "100%", md: "500px" }}
102-
padding={5}
103-
px={5}
104+
p={{ base: 3, md: 5 }}
104105
background={"white"}
105106
color={"black"}
106107
alignItems={"center"}
@@ -112,21 +113,20 @@ export default function Leaderboard({
112113
<Text as={"b"} fontSize={"4xl"}>
113114
2
114115
</Text>
115-
<Text as={"b"} fontSize={"lg"}>
116-
{leaderboard[0]?.email}
116+
<Text as={"b"} fontSize={{ base: "sm", md: "lg" }}>
117+
{leaderboard[1]?.email}
117118
</Text>
118119
</Flex>
119120

120121
<Flex>
121-
<Text as={"b"} fontSize={"4xl"}>
122-
{leaderboard[0]?.points} 🍪
122+
<Text as={"b"} fontSize={{ base: "3xl", md: "4xl" }}>
123+
{leaderboard[1]?.points} 🍪
123124
</Text>
124125
</Flex>
125126
</Flex>
126127
<Flex
127128
w={{ base: "100%", md: "500px" }}
128-
padding={5}
129-
px={5}
129+
p={{ base: 3, md: 5 }}
130130
background={"white"}
131131
color={"black"}
132132
alignItems={"center"}
@@ -138,14 +138,14 @@ export default function Leaderboard({
138138
<Text as={"b"} fontSize={"4xl"}>
139139
3
140140
</Text>
141-
<Text as={"b"} fontSize={"lg"}>
142-
{leaderboard[0]?.email}
141+
<Text as={"b"} fontSize={{ base: "sm", md: "lg" }}>
142+
{leaderboard[2]?.email}
143143
</Text>
144144
</Flex>
145145

146146
<Flex>
147-
<Text as={"b"} fontSize={"4xl"}>
148-
{leaderboard[0]?.points} 🍪
147+
<Text as={"b"} fontSize={{ base: "3xl", md: "4xl" }}>
148+
{leaderboard[2]?.points} 🍪
149149
</Text>
150150
</Flex>
151151
</Flex>

src/components/ImageContainer/ImageContainer.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function ImageContainer({ image, isresolved }) {
1616
alignItems={"center"}
1717
marginTop={30}
1818
flexDir={"column"}
19-
w={450}
19+
w={{ base: "100vw", md: 450 }}
2020
>
2121
<Text fontSize={18} as="b" color={"white"}>
2222
RETURNED

src/components/InfoModal/InfoModal.jsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default function InfoModal({
2727
setLeaderboard,
2828
}) {
2929
const [showEmail, setShowEmail] = useState(false);
30+
const [isShared, setIsShared] = useState(false);
3031
const { onLoginModalOpen } = useContext(DataContext);
3132
const { user } = UserAuth();
3233
const navigate = useNavigate();
@@ -170,8 +171,14 @@ export default function InfoModal({
170171
size={"lg"}
171172
variant={"outline"}
172173
gap={2}
174+
onClick={() => {
175+
setIsShared(true);
176+
navigator.clipboard.writeText(
177+
`https://zotnfound.com/${props.id}`
178+
);
179+
}}
173180
>
174-
<LinkIcon /> Share
181+
<LinkIcon /> {!isShared ? "Share" : "Copied"}
175182
</Button>
176183
</Flex>
177184
</Flex>

src/components/Map/Map.jsx

+12-4
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,18 @@ export default function Map({
197197
// Update the leaderboard
198198
const pointsToAdd = newAddedItem.islost ? 1 : 3;
199199

200-
axios.put(`${process.env.REACT_APP_AWS_BACKEND_URL}/leaderboard`, {
201-
email: user.email,
202-
pointsToAdd: pointsToAdd,
203-
});
200+
axios.put(
201+
`${process.env.REACT_APP_AWS_BACKEND_URL}/leaderboard`,
202+
{
203+
email: user.email,
204+
pointsToAdd: pointsToAdd,
205+
},
206+
{
207+
headers: {
208+
Authorization: `Bearer ${token}`, // verify auth
209+
},
210+
}
211+
);
204212

205213
setLeaderboard((prev) =>
206214
prev.map((u) =>

src/components/Map/MapIcons.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -20,74 +20,74 @@ import fly_img from "../../assets/images/fly_img.png";
2020

2121
const resolvedIcon = L.icon({
2222
iconUrl: resolved,
23-
iconSize: [50, 50],
24-
iconAnchor: [25, 40],
23+
iconSize: [40, 40],
24+
iconAnchor: [20, 30],
2525
});
2626

2727
const headphoneLost = L.icon({
2828
iconUrl: headphone_lost,
29-
iconSize: [60, 60],
30-
iconAnchor: [30, 50],
29+
iconSize: [50, 50],
30+
iconAnchor: [25, 40],
3131
});
3232

3333
const headphoneFound = L.icon({
3434
iconUrl: headphone_found,
35-
iconSize: [60, 60],
36-
iconAnchor: [30, 50],
35+
iconSize: [50, 50],
36+
iconAnchor: [25, 40],
3737
});
3838

3939
const phoneLost = L.icon({
4040
iconUrl: phone_lost,
41-
iconSize: [60, 60],
42-
iconAnchor: [30, 50],
41+
iconSize: [50, 50],
42+
iconAnchor: [25, 40],
4343
});
4444

4545
const phoneFound = L.icon({
4646
iconUrl: phone_found,
47-
iconSize: [60, 60],
48-
iconAnchor: [30, 50],
47+
iconSize: [50, 50],
48+
iconAnchor: [25, 40],
4949
});
5050

5151
const keyLost = L.icon({
5252
iconUrl: key_lost,
53-
iconSize: [60, 60],
54-
iconAnchor: [30, 50],
53+
iconSize: [50, 50],
54+
iconAnchor: [25, 40],
5555
});
5656

5757
const keyFound = L.icon({
5858
iconUrl: key_found,
59-
iconSize: [60, 60],
60-
iconAnchor: [30, 50],
59+
iconSize: [50, 50],
60+
iconAnchor: [25, 40],
6161
});
6262

6363
const walletLost = L.icon({
6464
iconUrl: wallet_lost,
65-
iconSize: [60, 60],
66-
iconAnchor: [30, 50],
65+
iconSize: [50, 50],
66+
iconAnchor: [25, 40],
6767
});
6868

6969
const walletFound = L.icon({
7070
iconUrl: wallet_found,
71-
iconSize: [60, 60],
72-
iconAnchor: [30, 50],
71+
iconSize: [50, 50],
72+
iconAnchor: [25, 40],
7373
});
7474

7575
const othersLost = L.icon({
7676
iconUrl: others_lost,
77-
iconSize: [60, 60],
78-
iconAnchor: [30, 50],
77+
iconSize: [50, 50],
78+
iconAnchor: [25, 40],
7979
});
8080

8181
const othersFound = L.icon({
8282
iconUrl: others_found,
83-
iconSize: [60, 60],
84-
iconAnchor: [30, 50],
83+
iconSize: [50, 50],
84+
iconAnchor: [25, 40],
8585
});
8686

8787
export const othersDrag = L.icon({
8888
iconUrl: others_black,
89-
iconSize: [50, 50],
90-
iconAnchor: [25, 30],
89+
iconSize: [40, 40],
90+
iconAnchor: [25, 25],
9191
});
9292

9393
export const flyImg = L.icon({

0 commit comments

Comments
 (0)