Skip to content

Commit

Permalink
Merge pull request #40 from icssc/fixing-eslint
Browse files Browse the repository at this point in the history
fixed eslint as well as subscription
  • Loading branch information
stevem-zhou authored Feb 27, 2024
2 parents 018142a + c2fd6a0 commit 6442cac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/components/CreateModal/CreateModal.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as React from "react";
import { useState, useContext, useEffect, useCallback } from "react";
import { useState, useEffect, useCallback } from "react";
import {
Image,
Button,
Flex,
FormLabel,
Input,
useDisclosure,
Modal,
ModalOverlay,
ModalContent,
Expand All @@ -30,8 +29,6 @@ import {
// import logo from "../../assets/images/small_logo.png";
import { storage } from "../../firebase";
import { ref, uploadBytes, getDownloadURL } from "firebase/storage";
import { UserAuth } from "../../context/AuthContext";
import DataContext from "../../context/DataContext";
import { MdDriveFileRenameOutline, MdOutlineDescription } from "react-icons/md";
import { FaMagnifyingGlass } from "react-icons/fa6";
import { SlCalender } from "react-icons/sl";
Expand All @@ -58,7 +55,6 @@ export default function CreateModal({
uploadImg,
upload,
}) {
const { user } = UserAuth();
const [isLoading, setIsLoading] = useState(false);

const uploadFile = useCallback(() => {
Expand Down
29 changes: 14 additions & 15 deletions src/components/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ export default function Home() {
const subscribeToggle = async (e) => {
e.preventDefault();
try {
const result = await axios.patch(
await axios.patch(
`${process.env.REACT_APP_AWS_BACKEND_URL}/leaderboard/changeSubscription`,
{
email: user.email,
subscription: subscription,
subscription: !subscription,
},
{
headers: {
Expand All @@ -154,9 +154,11 @@ export default function Home() {
setSubscription(!subscription);
toast({
title: subscription
? "Succesfully Subscribed!"
: "Succesfully Unsubscribed!", // just switched subscription
description: "You have been unsubscribed from the ZotNFound Newsletter",
? "Succesfully Unsubscribed!"
: "Succesfully Subscribed!", // just switched subscription
description: subscription
? "You have been unsubscribed from the ZotNFound Newsletter"
: "You have been subscribed to the ZotNFound Newsletter",
status: "success",
duration: 5000,
isClosable: true,
Expand Down Expand Up @@ -239,10 +241,6 @@ export default function Home() {
const userEmailExists = leaderboardData.some(
(entry) => entry.email === user?.email
);
const userSubscription = leaderboardData.some(
(entry) => entry.subscription === true
);
setSubscription(userSubscription);
// If it does not exist, add the user to the leaderboard
if (!userEmailExists && user) {
// added user to prevent race condition (user is undefined before auth resolves)
Expand Down Expand Up @@ -275,6 +273,7 @@ export default function Home() {

if (user) {
getLeaderboard();
setSubscription(user.subscription);
}
}, [user, token]);

Expand Down Expand Up @@ -407,21 +406,21 @@ export default function Home() {
<>
<Image
boxSize="1.2rem"
src={subscribe}
alt="unsubscribe from newsletter button"
src={unsubscribe}
alt="Unsubscribe from newsletter button"
mr="12px"
/>
Subscribe
Unsubscribe
</>
) : (
<>
<Image
boxSize="1.2rem"
src={unsubscribe}
alt="unsubscribe from newsletter button"
src={subscribe}
alt="Subscribe from newsletter button"
mr="12px"
/>
Unsubscribe
Subscribe
</>
)}
</MenuItem>
Expand Down

0 comments on commit 6442cac

Please sign in to comment.