mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 18:52:56 +00:00
dev day #75
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL as API_BASE_URL } from './api';
|
||||
import api, { API_URL as API_BASE_URL } from './api';
|
||||
|
||||
export interface NavigationItem {
|
||||
id?: number;
|
||||
@@ -30,86 +29,64 @@ export interface SocialLink {
|
||||
|
||||
// Public endpoints
|
||||
export const getNavigationItems = async (): Promise<NavigationItem[]> => {
|
||||
const response = await axios.get(`${API_BASE_URL}/navigation`);
|
||||
const response = await api.get(`/navigation`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const getSocialLinks = async (): Promise<SocialLink[]> => {
|
||||
const response = await axios.get(`${API_BASE_URL}/social-links`);
|
||||
const response = await api.get(`/social-links`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
// Admin endpoints
|
||||
export const getAllNavigationItems = async (): Promise<NavigationItem[]> => {
|
||||
const response = await axios.get(`${API_BASE_URL}/admin/navigation`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
const response = await api.get(`/admin/navigation`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const createNavigationItem = async (item: Partial<NavigationItem>): Promise<NavigationItem> => {
|
||||
const response = await axios.post(`${API_BASE_URL}/admin/navigation`, item, {
|
||||
withCredentials: true,
|
||||
});
|
||||
const response = await api.post(`/admin/navigation`, item);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const updateNavigationItem = async (id: number, item: Partial<NavigationItem>): Promise<NavigationItem> => {
|
||||
const response = await axios.put(`${API_BASE_URL}/admin/navigation/${id}`, item, {
|
||||
withCredentials: true,
|
||||
});
|
||||
const response = await api.put(`/admin/navigation/${id}`, item);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const deleteNavigationItem = async (id: number): Promise<void> => {
|
||||
await axios.delete(`${API_BASE_URL}/admin/navigation/${id}`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
await api.delete(`/admin/navigation/${id}`);
|
||||
};
|
||||
|
||||
export const reorderNavigationItems = async (orders: { id: number; display_order: number }[]): Promise<void> => {
|
||||
await axios.post(`${API_BASE_URL}/admin/navigation/reorder`, orders, {
|
||||
withCredentials: true,
|
||||
});
|
||||
await api.post(`/admin/navigation/reorder`, orders);
|
||||
};
|
||||
|
||||
// Social links admin endpoints
|
||||
export const getAllSocialLinks = async (): Promise<SocialLink[]> => {
|
||||
const response = await axios.get(`${API_BASE_URL}/admin/social-links`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
const response = await api.get(`/admin/social-links`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const createSocialLink = async (link: Partial<SocialLink>): Promise<SocialLink> => {
|
||||
const response = await axios.post(`${API_BASE_URL}/admin/social-links`, link, {
|
||||
withCredentials: true,
|
||||
});
|
||||
const response = await api.post(`/admin/social-links`, link);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const updateSocialLink = async (id: number, link: Partial<SocialLink>): Promise<SocialLink> => {
|
||||
const response = await axios.put(`${API_BASE_URL}/admin/social-links/${id}`, link, {
|
||||
withCredentials: true,
|
||||
});
|
||||
const response = await api.put(`/admin/social-links/${id}`, link);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const deleteSocialLink = async (id: number): Promise<void> => {
|
||||
await axios.delete(`${API_BASE_URL}/admin/social-links/${id}`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
await api.delete(`/admin/social-links/${id}`);
|
||||
};
|
||||
|
||||
export const reorderSocialLinks = async (orders: { id: number; display_order: number }[]): Promise<void> => {
|
||||
await axios.post(`${API_BASE_URL}/admin/social-links/reorder`, orders, {
|
||||
withCredentials: true,
|
||||
});
|
||||
await api.post(`/admin/social-links/reorder`, orders);
|
||||
};
|
||||
|
||||
export const seedDefaultNavigation = async (): Promise<{ message: string; count: number; seeded: boolean }> => {
|
||||
const response = await axios.post(`${API_BASE_URL}/admin/navigation/seed`, {}, {
|
||||
withCredentials: true,
|
||||
});
|
||||
const response = await api.post(`/admin/navigation/seed`, {});
|
||||
return response.data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user