refactor(frontend): Remove '/api' prefix from all API calls to align with backend URL convention
- Updated all API endpoint strings in 'frontend/src' (via sed and manual fixes) to remove the '/api/' prefix. - Manually fixed 'Timeline.tsx' absolute URLs to use the 'api' subdomain and correct path. - Manually fixed 'useAuth.ts' logout fetch URLs. - Updated 'HelpApiDocs.tsx' sandbox URL. - This change, combined with the backend URL update, fully transitions the application to use subdomain-based routing (e.g., 'http://api.lvh.me:8000/resource/') instead of path-prefix routing (e.g., 'http://api.lvh.me:8000/api/resource/').
This commit is contained in:
@@ -123,7 +123,7 @@ const CreateTaskModal: React.FC<CreateTaskModalProps> = ({ isOpen, onClose, onSu
|
||||
const { data: plugins = [], isLoading: pluginsLoading } = useQuery<PluginInstallation[]>({
|
||||
queryKey: ['plugin-installations'],
|
||||
queryFn: async () => {
|
||||
const { data } = await axios.get('/api/plugin-installations/');
|
||||
const { data } = await axios.get('/plugin-installations/');
|
||||
// Filter out plugins that already have scheduled tasks
|
||||
return data.filter((p: PluginInstallation) => !p.scheduled_task);
|
||||
},
|
||||
@@ -209,7 +209,7 @@ const CreateTaskModal: React.FC<CreateTaskModalProps> = ({ isOpen, onClose, onSu
|
||||
apply_to_existing: applyToExisting,
|
||||
};
|
||||
|
||||
await axios.post('/api/global-event-plugins/', payload);
|
||||
await axios.post('/global-event-plugins/', payload);
|
||||
queryClient.invalidateQueries({ queryKey: ['global-event-plugins'] });
|
||||
toast.success(applyToExisting ? 'Plugin attached to all events' : 'Plugin will apply to future events');
|
||||
} else {
|
||||
@@ -240,7 +240,7 @@ const CreateTaskModal: React.FC<CreateTaskModalProps> = ({ isOpen, onClose, onSu
|
||||
}
|
||||
}
|
||||
|
||||
await axios.post('/api/scheduled-tasks/', payload);
|
||||
await axios.post('/scheduled-tasks/', payload);
|
||||
toast.success('Scheduled task created');
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ export function DevQuickLogin({ embedded = false }: DevQuickLoginProps) {
|
||||
setLoading(user.username);
|
||||
try {
|
||||
// Call token auth API
|
||||
const response = await apiClient.post('/api/auth-token/', {
|
||||
const response = await apiClient.post('/auth-token/', {
|
||||
username: user.username,
|
||||
password: user.password,
|
||||
});
|
||||
@@ -98,7 +98,7 @@ export function DevQuickLogin({ embedded = false }: DevQuickLoginProps) {
|
||||
setCookie('access_token', response.data.token, 7);
|
||||
|
||||
// Fetch user data to determine redirect
|
||||
const userResponse = await apiClient.get('/api/auth/me/');
|
||||
const userResponse = await apiClient.get('/auth/me/');
|
||||
const userData = userResponse.data;
|
||||
|
||||
// Determine the correct subdomain based on user role
|
||||
|
||||
@@ -167,7 +167,7 @@ const EditTaskModal: React.FC<EditTaskModalProps> = ({ task, isOpen, onClose, on
|
||||
}
|
||||
}
|
||||
|
||||
await axios.patch(`/api/scheduled-tasks/${task.id}/`, payload);
|
||||
await axios.patch(`/scheduled-tasks/${task.id}/`, payload);
|
||||
onSuccess();
|
||||
handleClose();
|
||||
} catch (err: any) {
|
||||
|
||||
@@ -49,7 +49,7 @@ const EmailTemplateForm: React.FC<EmailTemplateFormProps> = ({
|
||||
const { data: variablesData } = useQuery<{ variables: EmailTemplateVariableGroup[] }>({
|
||||
queryKey: ['email-template-variables'],
|
||||
queryFn: async () => {
|
||||
const { data } = await api.get('/api/email-templates/variables/');
|
||||
const { data } = await api.get('/email-templates/variables/');
|
||||
return data;
|
||||
},
|
||||
});
|
||||
@@ -57,7 +57,7 @@ const EmailTemplateForm: React.FC<EmailTemplateFormProps> = ({
|
||||
// Preview mutation
|
||||
const previewMutation = useMutation({
|
||||
mutationFn: async () => {
|
||||
const { data } = await api.post('/api/email-templates/preview/', {
|
||||
const { data } = await api.post('/email-templates/preview/', {
|
||||
subject,
|
||||
html_content: htmlContent,
|
||||
text_content: textContent,
|
||||
@@ -80,10 +80,10 @@ const EmailTemplateForm: React.FC<EmailTemplateFormProps> = ({
|
||||
};
|
||||
|
||||
if (isEditing && template) {
|
||||
const { data } = await api.patch(`/api/email-templates/${template.id}/`, payload);
|
||||
const { data } = await api.patch(`/email-templates/${template.id}/`, payload);
|
||||
return data;
|
||||
} else {
|
||||
const { data } = await api.post('/api/email-templates/', payload);
|
||||
const { data } = await api.post('/email-templates/', payload);
|
||||
return data;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -32,7 +32,7 @@ const EmailTemplateSelector: React.FC<EmailTemplateSelectorProps> = ({
|
||||
queryFn: async () => {
|
||||
const params = new URLSearchParams();
|
||||
if (category) params.append('category', category);
|
||||
const { data } = await api.get(`/api/email-templates/?${params.toString()}`);
|
||||
const { data } = await api.get(`/email-templates/?${params.toString()}`);
|
||||
return data.map((t: any) => ({
|
||||
id: String(t.id),
|
||||
name: t.name,
|
||||
|
||||
@@ -72,7 +72,7 @@ const EventAutomations: React.FC<EventAutomationsProps> = ({ eventId, compact =
|
||||
const { data: plugins = [] } = useQuery<PluginInstallation[]>({
|
||||
queryKey: ['plugin-installations'],
|
||||
queryFn: async () => {
|
||||
const { data } = await axios.get('/api/plugin-installations/');
|
||||
const { data } = await axios.get('/plugin-installations/');
|
||||
return data;
|
||||
},
|
||||
});
|
||||
@@ -81,7 +81,7 @@ const EventAutomations: React.FC<EventAutomationsProps> = ({ eventId, compact =
|
||||
const { data: eventPlugins = [], isLoading } = useQuery<EventPlugin[]>({
|
||||
queryKey: ['event-plugins', eventId],
|
||||
queryFn: async () => {
|
||||
const { data } = await axios.get(`/api/event-plugins/?event_id=${eventId}`);
|
||||
const { data } = await axios.get(`/event-plugins/?event_id=${eventId}`);
|
||||
return data;
|
||||
},
|
||||
enabled: !!eventId,
|
||||
@@ -90,7 +90,7 @@ const EventAutomations: React.FC<EventAutomationsProps> = ({ eventId, compact =
|
||||
// Add plugin mutation
|
||||
const addMutation = useMutation({
|
||||
mutationFn: async (data: { plugin_installation: string; trigger: string; offset_minutes: number }) => {
|
||||
return axios.post('/api/event-plugins/', {
|
||||
return axios.post('/event-plugins/', {
|
||||
event: eventId,
|
||||
...data,
|
||||
});
|
||||
@@ -111,7 +111,7 @@ const EventAutomations: React.FC<EventAutomationsProps> = ({ eventId, compact =
|
||||
// Toggle mutation
|
||||
const toggleMutation = useMutation({
|
||||
mutationFn: async (pluginId: string) => {
|
||||
return axios.post(`/api/event-plugins/${pluginId}/toggle/`);
|
||||
return axios.post(`/event-plugins/${pluginId}/toggle/`);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['event-plugins', eventId] });
|
||||
@@ -121,7 +121,7 @@ const EventAutomations: React.FC<EventAutomationsProps> = ({ eventId, compact =
|
||||
// Delete mutation
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: async (pluginId: string) => {
|
||||
return axios.delete(`/api/event-plugins/${pluginId}/`);
|
||||
return axios.delete(`/event-plugins/${pluginId}/`);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['event-plugins', eventId] });
|
||||
|
||||
@@ -39,7 +39,7 @@ export const Timeline: React.FC = () => {
|
||||
const { data: resources = [] } = useQuery({
|
||||
queryKey: ['resources'],
|
||||
queryFn: async () => {
|
||||
const response = await axios.get('http://lvh.me:8000/api/resources/');
|
||||
const response = await axios.get('http://api.lvh.me:8000/resources/');
|
||||
return adaptResources(response.data);
|
||||
}
|
||||
});
|
||||
@@ -47,7 +47,7 @@ export const Timeline: React.FC = () => {
|
||||
const { data: backendAppointments = [] } = useQuery({ // Renamed to backendAppointments to avoid conflict with localEvents
|
||||
queryKey: ['appointments'],
|
||||
queryFn: async () => {
|
||||
const response = await axios.get('http://lvh.me:8000/api/appointments/');
|
||||
const response = await axios.get('http://api.lvh.me:8000/appointments/');
|
||||
return response.data; // Still return raw data, adapt in useEffect
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user