@ -7,6 +7,7 @@ import { Form, Formik, Field } from 'formik';
import axios from 'axios' ;
import axios from 'axios' ;
import Button from '../Common/Button' ;
import Button from '../Common/Button' ;
import { defineMessages , useIntl } from 'react-intl' ;
import { defineMessages , useIntl } from 'react-intl' ;
import { useUser , Permission } from '../../hooks/useUser' ;
const messages = defineMessages ( {
const messages = defineMessages ( {
generalsettings : 'General Settings' ,
generalsettings : 'General Settings' ,
@ -19,6 +20,7 @@ const messages = defineMessages({
} ) ;
} ) ;
const SettingsMain : React.FC = ( ) = > {
const SettingsMain : React.FC = ( ) = > {
const { hasPermission } = useUser ( ) ;
const intl = useIntl ( ) ;
const intl = useIntl ( ) ;
const { data , error , revalidate } = useSWR < MainSettings > (
const { data , error , revalidate } = useSWR < MainSettings > (
'/api/v1/settings/main'
'/api/v1/settings/main'
@ -41,7 +43,6 @@ const SettingsMain: React.FC = () => {
< div className = "mt-6 sm:mt-5" >
< div className = "mt-6 sm:mt-5" >
< Formik
< Formik
initialValues = { {
initialValues = { {
apiKey : data?.apiKey ,
applicationUrl : data?.applicationUrl ,
applicationUrl : data?.applicationUrl ,
} }
} }
onSubmit = { async ( values ) = > {
onSubmit = { async ( values ) = > {
@ -59,6 +60,7 @@ const SettingsMain: React.FC = () => {
{ ( { isSubmitting } ) = > {
{ ( { isSubmitting } ) = > {
return (
return (
< Form >
< 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" >
< 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
< label
htmlFor = "username"
htmlFor = "username"
@ -70,7 +72,7 @@ const SettingsMain: React.FC = () => {
< div className = "max-w-lg flex rounded-md shadow-sm" >
< div className = "max-w-lg flex rounded-md shadow-sm" >
< input
< input
type = "text"
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"
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 }
value = { data ? . apiKey }
readOnly
readOnly
@ -93,6 +95,7 @@ const SettingsMain: React.FC = () => {
< / div >
< / div >
< / div >
< / 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" >
< 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
< label
htmlFor = "name"
htmlFor = "name"