import { useState, useEffect, useRef } from "react"; import { checkBox } from "../public/checkbox"; import { useTheme } from "next-themes"; const Home = () => { const { theme, setTheme } = useTheme(); const programRef = useRef(null); const iconRef = useRef(null); const [loadedProgram, setLoadedProgram] = useState(false); const [loadedIcon, setLoadedIcon] = useState(false); const [customExec, setCustomExec] = useState(false); const [terminal, setTerminal] = useState(false); const [error, setError] = useState(false); const [darkMode, setDarkMode] = useState(false); const [version, setVersion] = useState(""); const [input, setInput] = useState({ name: "", comment: "", exec: "", icon: "", terminal: false, }); console.log(darkMode); // Fetch app version useEffect(() => { setVersion(navigator.userAgent.match(/DeskCut\/([\d\.]+\d+)/)[1]); }, []); // Fetching update useEffect(async () => { const updateJson = await fetch( "https://nayamamarshe.github.io/api/deskcut.json", { method: "GET", } ).then((res) => res.json()); if (updateJson) { if ( updateJson.version > navigator.userAgent.match(/DeskCut\/([\d\.]+\d+)/)[1] ) { const confirmText = "Update available! Download now?"; if (confirm(confirmText) == true) { window.open( "https://github.com/NayamAmarshe/DeskCut/releases/", "_blank" ); } } } }, []); const handleSubmit = (e) => { e.preventDefault(); const { name, exec, icon } = input; const isValid = Object.values({ name, exec, icon }).every(Boolean); if (!isValid) { alert("Please enter the values correctly"); } else { window.electron.message(input); alert("Shortcut Successfully Created!"); } }; return (
Shortcut Creator
v{version}