Files
Jellystat/src/pages/components/item-info/item-not-found.jsx
c4lyp5o 3ffb21f8b8 feat: change webpack to vite
changed all extensions from js to jsx
added proxies in vite config
set up chunk for smaller distribution size
remove setupProxy
remove reportWebVitals
2023-11-07 16:44:45 +08:00

55 lines
1.1 KiB
JavaScript

import React, {useState} from "react";
import axios from "axios";
import "../../css/error.css";
import { Button } from "react-bootstrap";
import Loading from "../general/loading";
function ItemNotFound(props) {
const [itemId] = useState(props.itemId);
const [loading,setLoading] = useState(false);
const token = localStorage.getItem('token');
async function fetchItem() {
setLoading(true);
const result = await axios
.post("/sync/fetchItem", {
itemId:itemId
}, {
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
})
.catch((error) => {
setLoading(false);
console.log(error);
});
if(result)
{
await props.fetchdataMethod();
setLoading(false);
}
}
if(loading)
{
return <Loading/>;
}
return (
<div className="error">
<h1 className="error-title">{props.message}</h1>
<Button variant="primary" className="mt-3" onClick={()=> fetchItem()}>Fetch this item from Jellyfin</Button>
</div>
);
}
export default ItemNotFound;