@ -7,6 +7,7 @@ import { Form, Formik, Field } from 'formik';
import axios from 'axios' ;
import Button from '../Common/Button' ;
import { defineMessages , useIntl } from 'react-intl' ;
import { useUser , Permission } from '../../hooks/useUser' ;
const messages = defineMessages ( {
generalsettings : 'General Settings' ,
@ -19,6 +20,7 @@ const messages = defineMessages({
} ) ;
const SettingsMain : React.FC = ( ) = > {
const { hasPermission } = useUser ( ) ;
const intl = useIntl ( ) ;
const { data , error , revalidate } = useSWR < MainSettings > (
'/api/v1/settings/main'
@ -41,7 +43,6 @@ const SettingsMain: React.FC = () => {
< div className = "mt-6 sm:mt-5" >
< Formik
initialValues = { {
apiKey : data?.apiKey ,
applicationUrl : data?.applicationUrl ,
} }
onSubmit = { async ( values ) = > {
@ -59,6 +60,7 @@ const SettingsMain: React.FC = () => {
{ ( { isSubmitting } ) = > {
return (
< Form >
{ hasPermission ( Permission . ADMIN ) && (
< div className = "sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5" >
< label
htmlFor = "username"
@ -70,7 +72,7 @@ const SettingsMain: React.FC = () => {
< div className = "max-w-lg flex rounded-md shadow-sm" >
< input
type = "text"
id = "username "
id = "apiKey "
className = "flex-1 form-input block w-full min-w-0 rounded-none rounded-l-md transition duration-150 ease-in-out sm:text-sm sm:leading-5 bg-gray-700 border border-gray-500"
value = { data ? . apiKey }
readOnly
@ -93,6 +95,7 @@ const SettingsMain: React.FC = () => {
< / div >
< / div >
< / div >
) }
< div className = "mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5" >
< label
htmlFor = "name"