Skip to content

Commit

Permalink
Added the latest repo version in about section of Settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
navishmonga committed Oct 15, 2024
1 parent 814cce3 commit cbb4dc7
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions Client/src/Pages/Settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import PropTypes from "prop-types";
import LoadingButton from "@mui/lab/LoadingButton";
import { setTimezone, setMode } from "../../Features/UI/uiSlice";
import timezones from "../../Utils/timezones.json";
import { useState } from "react";
import { useState,useEffect } from "react";
import { ConfigBox } from "./styled";
import { networkService } from "../../main";
import { settingsValidation } from "../../Validation/validation";
Expand All @@ -37,10 +37,30 @@ const Settings = ({ isAdmin }) => {
const [form, setForm] = useState({
ttl: checkTTL ? (checkTTL / SECONDS_PER_DAY).toString() : 0,
});
const [version,setVersion]=useState("");
const [errors, setErrors] = useState({});
const dispatch = useDispatch();
const navigate = useNavigate();

//Fetching latest release version from github
useEffect(() => {
const fetchLatestVersion = async () => {
try {
const response = await fetch(
"https://api.github.com/repos/bluewave-labs/bluewave-uptime/releases/latest"
);
if (!response.ok) {
throw new Error("Failed to fetch latest version");
}
const data = await response.json();
setVersion(data.tag_name); // Set the latest version number
} catch (error) {
createToast({ body: error.message || "Error fetching latest version" }); // Set error message
}
};
fetchLatestVersion();
});

const handleChange = (event) => {
const { value, id } = event.target;
const { error } = settingsValidation.validate(
Expand Down Expand Up @@ -300,15 +320,16 @@ const Settings = ({ isAdmin }) => {
</Box>
<Box>
<Typography component="h2">BlueWave Uptime v1.0.0</Typography>
<Typography component="h2">Latest Version: {version}</Typography>
<Typography
sx={{ mt: theme.spacing(2), mb: theme.spacing(6), opacity: 0.6 }}
>
Developed by Bluewave Labs.
</Typography>
<Link
level="secondary"
url="https://github.com/bluewave-labs"
label="https://github.com/bluewave-labs"
url="https://github.com/bluewave-labs/bluewave-uptime"
label="https://github.com/bluewave-labs/bluewave-uptime"
/>
</Box>
</ConfigBox>
Expand Down

0 comments on commit cbb4dc7

Please sign in to comment.