refactor: use apiUrl

This commit is contained in:
karishmas6
2024-11-01 08:25:33 +05:30
parent ba9e046576
commit a0eb6d427e
4 changed files with 14 additions and 10 deletions

View File

@@ -18,6 +18,7 @@ import { ContentCopy, Visibility, Delete } from '@mui/icons-material';
import styled from 'styled-components';
import axios from 'axios';
import { useGlobalInfoStore } from '../../context/globalInfo';
import { apiUrl } from '../../apiConfig';
const Container = styled(Box)`
display: flex;
@@ -38,7 +39,7 @@ const ApiKeyManager = () => {
useEffect(() => {
const fetchApiKey = async () => {
try {
const { data } = await axios.get('http://localhost:8080/auth/api-key');
const { data } = await axios.get(`${apiUrl}/auth/api-key`);
setApiKey(data.api_key);
} catch (error: any) {
notify('error', `Failed to fetch API Key - ${error.message}`);
@@ -53,7 +54,7 @@ const ApiKeyManager = () => {
const generateApiKey = async () => {
setLoading(true);
try {
const { data } = await axios.post('http://localhost:8080/auth/generate-api-key');
const { data } = await axios.post(`${apiUrl}/auth/generate-api-key`);
setApiKey(data.api_key);
notify('success', `Generated API Key successfully`);
} catch (error: any) {
@@ -66,7 +67,7 @@ const ApiKeyManager = () => {
const deleteApiKey = async () => {
setLoading(true);
try {
await axios.delete('http://localhost:8080/auth/delete-api-key');
await axios.delete(`${apiUrl}/auth/delete-api-key`);
setApiKey(null);
notify('success', 'API Key deleted successfully');
} catch (error: any) {

View File

@@ -4,6 +4,7 @@ import Tab from '@mui/material/Tab';
import Box from '@mui/material/Box';
import { Paper, Button } from "@mui/material";
import { AutoAwesome, FormatListBulleted, VpnKey, Usb, Article, Link, CloudQueue } from "@mui/icons-material";
import { apiUrl } from "../../apiConfig";
interface MainMenuProps {
value: string;
@@ -86,7 +87,7 @@ export const MainMenu = ({ value = 'recordings', handleChangeContent }: MainMenu
</Tabs>
<hr />
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '1rem', textAlign: 'left' }}>
<Button href="http://localhost:8080/api-docs/" target="_blank" rel="noopener noreferrer" sx={buttonStyles} startIcon={<Article />}>
<Button href={`${apiUrl}/api-docs/`} target="_blank" rel="noopener noreferrer" sx={buttonStyles} startIcon={<Article />}>
API Docs
</Button>
<Button href="https://forms.gle/hXjgqDvkEhPcaBW76" target="_blank" rel="noopener noreferrer" sx={buttonStyles} startIcon={<CloudQueue />}>