diff --git a/dashboard/src/states/Dashboard/pages/Info/components/Defaults/components/LicenseKey/LicenseKey.jsx b/dashboard/src/states/Dashboard/pages/Info/components/Defaults/components/LicenseKey/LicenseKey.jsx new file mode 100644 index 0000000..b86ec3a --- /dev/null +++ b/dashboard/src/states/Dashboard/pages/Info/components/Defaults/components/LicenseKey/LicenseKey.jsx @@ -0,0 +1,44 @@ +import {IconButton, Stack, TextField, Typography} from "@mui/material"; +import { + replaceLicenseDefaults +} from "@/states/Dashboard/pages/Licenses/components/LicenseDialog/pages/LicenseKey/util.js"; +import {ProjectContext} from "@/states/Dashboard/contexts/Project"; +import {useContext, useState} from "react"; +import {patchRequest} from "@/common/utils/RequestUtil.js"; +import {Save} from "@mui/icons-material"; + +export const LicenseKey = () => { + + const {currentProject, updateProjects} = useContext(ProjectContext); + + const [keyChanged, setKeyChanged] = useState(false); + const [licenseKey, setLicenseKey] = useState(currentProject.defaults.licenseKey); + + const saveLicenseKey = async () => { + try { + await patchRequest(`/project/${currentProject.id}`, {defaults: {licenseKey}}); + await updateProjects(); + setKeyChanged(false); + } catch (e) { + console.error(e.message); + } + } + + return ( + + + License key + + Example: {replaceLicenseDefaults(licenseKey)} + + + { + setLicenseKey(event.target.value); + setKeyChanged(true); + }} + InputProps={keyChanged ? {endAdornment: } : {}}/> + + ) +} \ No newline at end of file diff --git a/dashboard/src/states/Dashboard/pages/Info/components/Defaults/components/LicenseKey/index.js b/dashboard/src/states/Dashboard/pages/Info/components/Defaults/components/LicenseKey/index.js new file mode 100644 index 0000000..4bda861 --- /dev/null +++ b/dashboard/src/states/Dashboard/pages/Info/components/Defaults/components/LicenseKey/index.js @@ -0,0 +1 @@ +export {LicenseKey as default} from "./LicenseKey.jsx"; \ No newline at end of file