Skip to content

Commit

Permalink
map feature requests
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanBonsignori committed Feb 19, 2024
1 parent 5efaa24 commit fff23f6
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/routes/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ import { Box, LinearProgress } from "@mui/material";
import Grid from "@mui/material/Grid";
import { useQuery } from "@tanstack/react-query";
import { FC } from "react";
import { FeatureRequestGetResponse } from "../api/generated";
import FeatureRequest from "../components/FeatureRequest";
import Layout from "../components/Layout";

const Root: FC = () => {
const featureRequestsQuery = (): Promise<FeatureRequestGetResponse[]> =>
fetch(`${import.meta.env.VITE_API_ROOT}/api/v1/feature-request`).then(
(res) => res.json()
);

const { isLoading, error, data } = useQuery({
queryKey: ["feature-requests"],
queryFn: () =>
fetch(`${import.meta.env.VITE_API_ROOT}/api/v1/feature-request`).then(
(res) => res.json()
),
queryFn: featureRequestsQuery,
});

if (isLoading)
Expand All @@ -24,12 +28,19 @@ const Root: FC = () => {

if (error) return <Layout>Error: {error.message}</Layout>;

if (!data)
return <Layout>No data yet, try creating a feature request</Layout>;

return (
<Layout>
<Grid container spacing={2}>
<Grid item xs={12} key={1}>
<h2>{"test"}</h2>
<p>{"testste"}</p>
{data.map((featureRequest) => (
<FeatureRequest
key={featureRequest.id}
featureRequest={featureRequest}
/>
))}
</Grid>
</Grid>
</Layout>
Expand Down

0 comments on commit fff23f6

Please sign in to comment.