refactor: use apiUrl
This commit is contained in:
@@ -6,6 +6,7 @@ import TextField from "@mui/material/TextField";
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useGlobalInfoStore } from '../../context/globalInfo';
|
import { useGlobalInfoStore } from '../../context/globalInfo';
|
||||||
import { getStoredRecording } from '../../api/storage';
|
import { getStoredRecording } from '../../api/storage';
|
||||||
|
import { apiUrl } from '../../apiConfig.js';
|
||||||
interface IntegrationProps {
|
interface IntegrationProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
handleStart: (data: IntegrationSettings) => void;
|
handleStart: (data: IntegrationSettings) => void;
|
||||||
@@ -32,12 +33,12 @@ export const IntegrationSettingsModal = ({ isOpen, handleStart, handleClose }: I
|
|||||||
const [recording, setRecording] = useState<any>(null);
|
const [recording, setRecording] = useState<any>(null);
|
||||||
|
|
||||||
const authenticateWithGoogle = () => {
|
const authenticateWithGoogle = () => {
|
||||||
window.location.href = `http://localhost:8080/auth/google?robotId=${recordingId}`;
|
window.location.href = `${apiUrl}/auth/google?robotId=${recordingId}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOAuthCallback = async () => {
|
const handleOAuthCallback = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`http://localhost:8080/auth/google/callback`);
|
const response = await axios.get(`${apiUrl}/auth/google/callback`);
|
||||||
const { google_sheet_email, files } = response.data;
|
const { google_sheet_email, files } = response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError('Error authenticating with Google');
|
setError('Error authenticating with Google');
|
||||||
@@ -46,7 +47,7 @@ export const IntegrationSettingsModal = ({ isOpen, handleStart, handleClose }: I
|
|||||||
|
|
||||||
const fetchSpreadsheetFiles = async () => {
|
const fetchSpreadsheetFiles = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`http://localhost:8080/auth/gsheets/files?robotId=${recordingId}`, {
|
const response = await axios.get(`${apiUrl}/auth/gsheets/files?robotId=${recordingId}`, {
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
setSpreadsheets(response.data);
|
setSpreadsheets(response.data);
|
||||||
@@ -66,7 +67,7 @@ export const IntegrationSettingsModal = ({ isOpen, handleStart, handleClose }: I
|
|||||||
const updateGoogleSheetId = async () => {
|
const updateGoogleSheetId = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`http://localhost:8080/auth/gsheets/update`,
|
`${apiUrl}/auth/gsheets/update`,
|
||||||
{ spreadsheetId: settings.spreadsheetId, spreadsheetName: settings.spreadsheetName, robotId: recordingId },
|
{ spreadsheetId: settings.spreadsheetId, spreadsheetName: settings.spreadsheetName, robotId: recordingId },
|
||||||
{ withCredentials: true }
|
{ withCredentials: true }
|
||||||
);
|
);
|
||||||
@@ -79,7 +80,7 @@ export const IntegrationSettingsModal = ({ isOpen, handleStart, handleClose }: I
|
|||||||
const removeIntegration = async () => {
|
const removeIntegration = async () => {
|
||||||
try {
|
try {
|
||||||
await axios.post(
|
await axios.post(
|
||||||
`http://localhost:8080/auth/gsheets/remove`,
|
`${apiUrl}/auth/gsheets/remove`,
|
||||||
{ robotId: recordingId },
|
{ robotId: recordingId },
|
||||||
{ withCredentials: true }
|
{ withCredentials: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { AuthContext } from '../../context/auth';
|
import { AuthContext } from '../../context/auth';
|
||||||
import { SaveRecording } from '../molecules/SaveRecording';
|
import { SaveRecording } from '../molecules/SaveRecording';
|
||||||
import DiscordIcon from '../atoms/DiscordIcon';
|
import DiscordIcon from '../atoms/DiscordIcon';
|
||||||
|
import { apiUrl } from '../../apiConfig';
|
||||||
|
|
||||||
interface NavBarProps {
|
interface NavBarProps {
|
||||||
recordingName: string;
|
recordingName: string;
|
||||||
@@ -34,7 +35,7 @@ export const NavBar: React.FC<NavBarProps> = ({ recordingName, isRecording }) =>
|
|||||||
const logout = async () => {
|
const logout = async () => {
|
||||||
dispatch({ type: 'LOGOUT' });
|
dispatch({ type: 'LOGOUT' });
|
||||||
window.localStorage.removeItem('user');
|
window.localStorage.removeItem('user');
|
||||||
const { data } = await axios.get('http://localhost:8080/auth/logout');
|
const { data } = await axios.get(`${apiUrl}/auth/logout`);
|
||||||
notify('success', data.message);
|
notify('success', data.message);
|
||||||
navigate('/login');
|
navigate('/login');
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { ContentCopy, Visibility, Delete } from '@mui/icons-material';
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useGlobalInfoStore } from '../../context/globalInfo';
|
import { useGlobalInfoStore } from '../../context/globalInfo';
|
||||||
|
import { apiUrl } from '../../apiConfig';
|
||||||
|
|
||||||
const Container = styled(Box)`
|
const Container = styled(Box)`
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -38,7 +39,7 @@ const ApiKeyManager = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchApiKey = async () => {
|
const fetchApiKey = async () => {
|
||||||
try {
|
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);
|
setApiKey(data.api_key);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
notify('error', `Failed to fetch API Key - ${error.message}`);
|
notify('error', `Failed to fetch API Key - ${error.message}`);
|
||||||
@@ -53,7 +54,7 @@ const ApiKeyManager = () => {
|
|||||||
const generateApiKey = async () => {
|
const generateApiKey = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
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);
|
setApiKey(data.api_key);
|
||||||
notify('success', `Generated API Key successfully`);
|
notify('success', `Generated API Key successfully`);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@@ -66,7 +67,7 @@ const ApiKeyManager = () => {
|
|||||||
const deleteApiKey = async () => {
|
const deleteApiKey = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
await axios.delete('http://localhost:8080/auth/delete-api-key');
|
await axios.delete(`${apiUrl}/auth/delete-api-key`);
|
||||||
setApiKey(null);
|
setApiKey(null);
|
||||||
notify('success', 'API Key deleted successfully');
|
notify('success', 'API Key deleted successfully');
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Tab from '@mui/material/Tab';
|
|||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import { Paper, Button } from "@mui/material";
|
import { Paper, Button } from "@mui/material";
|
||||||
import { AutoAwesome, FormatListBulleted, VpnKey, Usb, Article, Link, CloudQueue } from "@mui/icons-material";
|
import { AutoAwesome, FormatListBulleted, VpnKey, Usb, Article, Link, CloudQueue } from "@mui/icons-material";
|
||||||
|
import { apiUrl } from "../../apiConfig";
|
||||||
|
|
||||||
interface MainMenuProps {
|
interface MainMenuProps {
|
||||||
value: string;
|
value: string;
|
||||||
@@ -86,7 +87,7 @@ export const MainMenu = ({ value = 'recordings', handleChangeContent }: MainMenu
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
<hr />
|
<hr />
|
||||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '1rem', textAlign: 'left' }}>
|
<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
|
API Docs
|
||||||
</Button>
|
</Button>
|
||||||
<Button href="https://forms.gle/hXjgqDvkEhPcaBW76" target="_blank" rel="noopener noreferrer" sx={buttonStyles} startIcon={<CloudQueue />}>
|
<Button href="https://forms.gle/hXjgqDvkEhPcaBW76" target="_blank" rel="noopener noreferrer" sx={buttonStyles} startIcon={<CloudQueue />}>
|
||||||
|
|||||||
Reference in New Issue
Block a user