forked from reorproject/reor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6d41e2
commit a44af8c
Showing
7 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { Button } from "@material-tailwind/react"; | ||
import Switch from "@mui/material/Switch"; | ||
|
||
interface AnalyticsSettingsProps {} | ||
const AnalyticsSettings: React.FC<AnalyticsSettingsProps> = () => { | ||
const [isAnalyticsEnabled, setIsAnalyticsEnabled] = useState<boolean>(false); | ||
|
||
const [userHasMadeUpdate, setUserHasMadeUpdate] = useState(false); | ||
|
||
useEffect(() => { | ||
const fetchParams = async () => { | ||
const isAnalyticsEnabled = await window.electronStore.getAnalyticsMode(); | ||
|
||
if (isAnalyticsEnabled !== undefined) { | ||
setIsAnalyticsEnabled(isAnalyticsEnabled); | ||
} | ||
}; | ||
|
||
fetchParams(); | ||
}, []); | ||
|
||
const handleSave = () => { | ||
// Execute the save function here | ||
if (isAnalyticsEnabled !== undefined) { | ||
window.electronStore.setAnalyticsMode(isAnalyticsEnabled); | ||
setUserHasMadeUpdate(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="w-full bg-neutral-800 rounded pb-7 "> | ||
<h2 className="text-2xl font-semibold mb-0 text-white">Analytics mode</h2>{" "} | ||
<Switch | ||
checked={isAnalyticsEnabled} | ||
onChange={() => { | ||
setUserHasMadeUpdate(true); | ||
setIsAnalyticsEnabled(!isAnalyticsEnabled); | ||
}} | ||
// inputProps={{ "aria-label": "controlled" }} | ||
/> | ||
{userHasMadeUpdate && ( | ||
<div className="flex"> | ||
<Button | ||
// variant="contained" | ||
placeholder={""} | ||
onClick={handleSave} | ||
className="bg-orange-700 w-[150px] border-none h-8 hover:bg-orange-900 cursor-pointer text-center pt-0 pb-0 pr-2 pl-2 mb-0 mr-4 mt-2" | ||
> | ||
Save | ||
</Button> | ||
</div> | ||
)} | ||
{!isAnalyticsEnabled && ( | ||
<p className="text-yellow-500 text-xs"> | ||
Quit and restart the app for it to take effect | ||
</p> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default AnalyticsSettings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters