Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
feat: Update bazaar page
Browse files Browse the repository at this point in the history
  • Loading branch information
re-taro committed Oct 26, 2022
1 parent 66e925e commit 292a0b6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/pages/bazaar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import type { FC } from "react";
import useSWR from "swr";
import { Redirect } from "wouter";
import { Bazaar } from "../components/templates/bazaar";
import { fetcher } from "../libs/axios";
import type { BazaarWithId } from "../api/bazaar";

// TODO: Fetch with swr
const BazaarPage: FC = () => <Bazaar bazaars={[]} />;
const BazaarPage: FC = () => {
const query = new URLSearchParams(window.location.search);
const isRecreation = query.get("select") === "recreation";
const { data, error } = useSWR<ReadonlyArray<BazaarWithId>>(
isRecreation ? "/bazaar/data/recreation" : "/bazaar/data/eating",
fetcher,
);
if (!data) return <p>Loading...</p>;
if (error) return <Redirect to="/error" />;
return <Bazaar bazaars={data} />;
};

export { BazaarPage };

0 comments on commit 292a0b6

Please sign in to comment.