mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-05 03:12:34 -06:00
добавил пользователей для сервера и роли
добавил инвайт-ссылки с ролью оператор для сервера добавил супер-админку для смены владельцев добавил уведомления о смене ролей на серверах добавил модалку для фото прям в черновике добавил UI для редактирования прав
This commit is contained in:
@@ -22,11 +22,21 @@ import type {
|
||||
AddContainerRequest,
|
||||
AddContainerResponse,
|
||||
DictionariesResponse,
|
||||
DraftSummary
|
||||
DraftSummary,
|
||||
ServerUser,
|
||||
UserRole
|
||||
} from './types';
|
||||
|
||||
// Базовый URL
|
||||
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8080/api';
|
||||
export const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:8080/api';
|
||||
|
||||
// Хелпер для получения полного URL картинки (убирает /api если путь статики идет от корня, или добавляет как есть)
|
||||
// В данном ТЗ сказано просто склеивать.
|
||||
export const getStaticUrl = (path: string | null | undefined): string => {
|
||||
if (!path) return '';
|
||||
if (path.startsWith('http')) return path;
|
||||
return `${API_BASE_URL}${path}`;
|
||||
};
|
||||
|
||||
// Телеграм объект
|
||||
const tg = window.Telegram?.WebApp;
|
||||
@@ -35,7 +45,7 @@ const tg = window.Telegram?.WebApp;
|
||||
export const UNAUTHORIZED_EVENT = 'rms_unauthorized';
|
||||
|
||||
const apiClient = axios.create({
|
||||
baseURL: API_URL,
|
||||
baseURL: API_BASE_URL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
@@ -203,4 +213,21 @@ export const api = {
|
||||
const { data } = await apiClient.get<ProductGroup[]>('/dictionaries/groups');
|
||||
return data;
|
||||
},
|
||||
|
||||
// --- Управление командой ---
|
||||
|
||||
getUsers: async (): Promise<ServerUser[]> => {
|
||||
const { data } = await apiClient.get<ServerUser[]>('/settings/users');
|
||||
return data;
|
||||
},
|
||||
|
||||
updateUserRole: async (userId: string, newRole: UserRole): Promise<{ status: string }> => {
|
||||
const { data } = await apiClient.patch<{ status: string }>(`/settings/users/${userId}`, { new_role: newRole });
|
||||
return data;
|
||||
},
|
||||
|
||||
removeUser: async (userId: string): Promise<{ status: string }> => {
|
||||
const { data } = await apiClient.delete<{ status: string }>(`/settings/users/${userId}`);
|
||||
return data;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user