Skip to content

Commit

Permalink
test hook 4
Browse files Browse the repository at this point in the history
  • Loading branch information
kami2016 committed May 23, 2024
1 parent 6dfae08 commit be34785
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
File renamed without changes

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500&family=Karla&display=swap"
rel="stylesheet"
/>
<script type="module" crossorigin src="/bv2024_frontend/assets/index.b78f674f.js"></script>
<script type="module" crossorigin src="/bv2024_frontend/assets/index.03504ce4.js"></script>
<link rel="stylesheet" href="/bv2024_frontend/assets/index.800bf6e7.css">
</head>
<body>
Expand Down
37 changes: 22 additions & 15 deletions js/ServicePicComp.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import { useFetchMedia } from "./useFetchMedia";
import { useQuery } from "@tanstack/react-query";
import { useNavigate } from "react-router-dom";
import Spinner from "./Spinner";
import fetchData from "./fetchData";
const ServicePicComp = ({ imgid, picName }) => {
console.log(imgid);
console.log({ imgid });
const media = useFetchMedia(imgid, "imgs/category/forschung.png");
// const navigate = useNavigate();
// const pic = useQuery(["pic", `media`, `${imgid}`], fetchData);
// if (pic.isLoading) {
// return <Spinner></Spinner>;
// }
// if (pic.isError) {
// navigate("/NotMatch404");
// }
// let servicePic = "imgs/category/forschung.png";
// let image = pic.data.source_url;
// console.log(pic);
// if (image) {
// servicePic = image;
// }
console.log(media);
const navigate = useNavigate();
const pic = useQuery(["pic", `media`, `${imgid}`], fetchData);
if (pic.isLoading) {
return <Spinner></Spinner>;
}
if (pic.isError) {
navigate("/NotMatch404");
}
let servicePic = "imgs/category/forschung.png";
let image = pic.data.source_url;
console.log(pic);
if (image) {
servicePic = image;
}

return (
<div className="picContainer">
<div className="service_pic">
<img src={media} alt={picName} />
<img src={servicePic} alt={picName} />
<div className="service_pic_caption">
<div className="service_pic_text">{picName}</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions js/useFetchMedia.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useNavigate } from "react-router-dom";
import Spinner from "./Spinner";
import fetchData from "./fetchData";
export function useFetchMedia(imgid, default_media) {
console.log(imgid);
const navigate = useNavigate();
const pic = useQuery(["pic", `media`, `${imgid}`], fetchData);
if (pic.isLoading) {
Expand Down

0 comments on commit be34785

Please sign in to comment.