Skip to content

Commit

Permalink
Fix eslint errors in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
haoyangw committed Sep 26, 2024
1 parent e67c5bd commit 8899402
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions frontend/app/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { ChevronDown } from "lucide-react";
import { getEventsEventsGet, MiniEventDTO } from "@/client";
import ArticleLoading from "@/components/news/article-loading";
import NewsArticle from "@/components/news/news-article";
import { useUserStore } from "@/store/user/user-store-provider";
import { useUpdateTopEventsPeriod } from "@/queries/user";
import { useUserStore } from "@/store/user/user-store-provider";

const enum Period {
Day = 1,
Week = 7,
Month = 30,
};
}

const getDisplayValueFor = (period: Period) => {
switch (period) {
Expand All @@ -24,7 +24,7 @@ const getDisplayValueFor = (period: Period) => {
default:
return "week";
}
}
};

const NUM_TOP_EVENTS = 10;
const DEFAULT_EVENT_PERIOD = Period.Week;
Expand All @@ -34,11 +34,12 @@ const Home = () => {
const [topEvents, setTopEvents] = useState<MiniEventDTO[]>([]);
const [isLoaded, setIsLoaded] = useState<boolean>(false);
const [showDropdown, setShowDropdown] = useState<boolean>(false);
const [selectedPeriod, setSelectedPeriod] = useState<Period>(DEFAULT_EVENT_PERIOD);
const [selectedPeriod, setSelectedPeriod] =
useState<Period>(DEFAULT_EVENT_PERIOD);
const user = useUserStore((state) => state.user);
const updateTopEventsMutation = useUpdateTopEventsPeriod();
const router = useRouter();

if (!user!.categories.length) {
router.push("/onboarding");
}
Expand All @@ -48,7 +49,9 @@ const Home = () => {
setIsLoaded(false);
const dateNow = new Date();
const eventStartDate = new Date(dateNow);
const eventPeriod = user?.top_events_period ? user.top_events_period : DEFAULT_EVENT_PERIOD;
const eventPeriod = user?.top_events_period
? user.top_events_period
: DEFAULT_EVENT_PERIOD;
setSelectedPeriod(eventPeriod);
eventStartDate.setDate(dateNow.getDate() - eventPeriod);
const formattedEventStartDate = eventStartDate
Expand Down

0 comments on commit 8899402

Please sign in to comment.