import React, { useEffect, useState } from 'react' import axios from 'axios' import { Box, Grid, CircularProgress, Card, CardHeader, Divider, CardContent, TextField, CardActions, Button, Typography } from '@mui/material' import { toast } from 'react-toastify' const AuthConfig = () => { const [isLoading, setIsLoading] = useState(false) const [authDetail, setAuthDetail] = useState({}) useEffect(() => { setIsLoading(true) axios .get(`/SASjsApi/authConfig`) .then((res: any) => { setAuthDetail(res.data) }) .catch((err) => { toast.error('Failed: ' + err.response?.data || err.text, { theme: 'dark', position: toast.POSITION.BOTTOM_RIGHT }) }) .finally(() => setIsLoading(false)) }, []) const synchroniseWithLDAP = () => { setIsLoading(true) axios .post(`/SASjsApi/authConfig/synchroniseWithLDAP`) .then((res: any) => { const { userCount, groupCount } = res.data toast.success( `Imported ${userCount} ${ userCount > 1 ? 'users' : 'user' } and ${groupCount} ${groupCount > 1 ? 'groups' : 'group'}`, { theme: 'dark', position: toast.POSITION.BOTTOM_RIGHT } ) }) .catch((err) => { toast.error('Failed: ' + err.response?.data || err.text, { theme: 'dark', position: toast.POSITION.BOTTOM_RIGHT }) }) .finally(() => setIsLoading(false)) } return isLoading ? ( ) : ( {Object.entries(authDetail).length === 0 && ( No external Auth Provider is used )} {authDetail.ldap && ( )} ) } export default AuthConfig