Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 7x 7x 7x | import { useParams } from "react-router-dom"; import { useQuery } from "react-query"; import { Strip } from "@canonical/react-components"; import PageHeader from "../../../shared/PageHeader"; import ListingForm from "../ListingForm"; function App(): JSX.Element { const { snapName } = useParams(); const { data, isLoading, refetch } = useQuery({ queryKey: ["listing"], queryFn: async () => { const response = await fetch(`/api/${snapName}/listing`); if (!response.ok) { throw new Error("There was a problem fetching listing data"); } const data = await response.json(); if (!data.success) { throw new Error(data.message); } return data.data; }, }); return ( <> <PageHeader snapName={snapName} snapTitle={snapName} activeTab="listing" /> {isLoading && ( <Strip shallow> <p> <i className="p-icon--spinner u-animation--spin"></i> Loading{" "} {snapName} listing data </p> </Strip> )} {data && <ListingForm data={data} refetch={refetch} />} </> ); } export default App; |