diff --git a/web-app/src/api/set_content/AddSetContent.jsx b/web-app/src/api/set_content/AddSetContent.jsx new file mode 100644 index 0000000..a774ec7 --- /dev/null +++ b/web-app/src/api/set_content/AddSetContent.jsx @@ -0,0 +1,21 @@ +import axios from "axios"; +import CONFIG from "../../core/Config.jsx"; + + +const addSetContent = async (token, set_content) => { + try { + const response = await axios.post(`${CONFIG.BASE_URL}/set_content/`, set_content, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Ошибка авторизации: пользователь не найден или токен недействителен"); + } + throw new Error(error.message); + } +}; + +export default addSetContent; \ No newline at end of file diff --git a/web-app/src/api/set_content/DeleteSetContent.jsx b/web-app/src/api/set_content/DeleteSetContent.jsx new file mode 100644 index 0000000..e5fe7a9 --- /dev/null +++ b/web-app/src/api/set_content/DeleteSetContent.jsx @@ -0,0 +1,21 @@ +import axios from "axios"; +import CONFIG from "../../core/Config.jsx"; + + +const deleteSetContent = async (token, set_content_id) => { + try { + const response = await axios.delete(`${CONFIG.BASE_URL}/set_content/${set_content_id}/`, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Ошибка авторизации: пользователь не найден или токен недействителен"); + } + throw new Error(error.message); + } +}; + +export default deleteSetContent; \ No newline at end of file diff --git a/web-app/src/api/set_content/GetSetContentBySetId.jsx b/web-app/src/api/set_content/GetSetContentBySetId.jsx new file mode 100644 index 0000000..f35a131 --- /dev/null +++ b/web-app/src/api/set_content/GetSetContentBySetId.jsx @@ -0,0 +1,21 @@ +import axios from "axios"; +import CONFIG from "../../core/Config.jsx"; + + +const getSetContentBySetId = async (token, set_id) => { + try { + const response = await axios.get(`${CONFIG.BASE_URL}/set_content/${set_id}/`, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Ошибка авторизации: пользователь не найден или токен недействителен"); + } + throw new Error(error.message); + } +}; + +export default getSetContentBySetId; \ No newline at end of file diff --git a/web-app/src/api/set_content/UpdateSetContent.jsx b/web-app/src/api/set_content/UpdateSetContent.jsx new file mode 100644 index 0000000..6bda501 --- /dev/null +++ b/web-app/src/api/set_content/UpdateSetContent.jsx @@ -0,0 +1,21 @@ +import axios from "axios"; +import CONFIG from "../../core/Config.jsx"; + + +const updateSetContent = async (token, set_content) => { + try { + const response = await axios.put(`${CONFIG.BASE_URL}/set_content/${set_content.id}/`, set_content, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Ошибка авторизации: пользователь не найден или токен недействителен"); + } + throw new Error(error.message); + } +}; + +export default updateSetContent; \ No newline at end of file diff --git a/web-app/src/api/sets/AddSet.jsx b/web-app/src/api/sets/AddSet.jsx new file mode 100644 index 0000000..764925d --- /dev/null +++ b/web-app/src/api/sets/AddSet.jsx @@ -0,0 +1,21 @@ +import axios from "axios"; +import CONFIG from "../../core/Config.jsx"; + + +const AddSet = async (token, set) => { + try { + const response = await axios.post(`${CONFIG.API_URL}/sets`, set, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Ошибка авторизации: пользователь не найден или токен недействителен"); + } + throw new Error(error.message); + } +}; + +export default AddSet; \ No newline at end of file diff --git a/web-app/src/api/sets/DeleteSet.jsx b/web-app/src/api/sets/DeleteSet.jsx new file mode 100644 index 0000000..666ce50 --- /dev/null +++ b/web-app/src/api/sets/DeleteSet.jsx @@ -0,0 +1,20 @@ +import axios from "axios"; +import CONFIG from "../../core/Config.jsx"; + +const deleteSet = async (token, set_id) => { + try { + const response = await axios.delete(`${CONFIG.BASE_URL}/sets/${set_id}/`, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Ошибка авторизации: пользователь не найден или токен недействителен"); + } + throw new Error(error.message); + } +}; + +export default deleteSet; \ No newline at end of file diff --git a/web-app/src/api/sets/GetAllSets.jsx b/web-app/src/api/sets/GetAllSets.jsx new file mode 100644 index 0000000..fd52012 --- /dev/null +++ b/web-app/src/api/sets/GetAllSets.jsx @@ -0,0 +1,20 @@ +import axios from "axios"; +import CONFIG from "../../core/Config.jsx"; + +const getAllSets = async (token) => { + try { + const response = await axios.get(`${CONFIG.BASE_URL}/sets/`, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Ошибка авторизации: пользователь не найден или токен недействителен"); + } + throw new Error(error.message); + } +}; + +export default getAllSets; \ No newline at end of file diff --git a/web-app/src/api/sets/UpdateSet.jsx b/web-app/src/api/sets/UpdateSet.jsx new file mode 100644 index 0000000..83b9bb4 --- /dev/null +++ b/web-app/src/api/sets/UpdateSet.jsx @@ -0,0 +1,21 @@ +import axios from "axios"; +import CONFIG from "../../core/Config.jsx"; + + +const updateSet = async (token, set) => { + try { + const response = await axios.put(`${CONFIG.BASE_URL}/sets/${set.id}/`, set, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Ошибка авторизации: пользователь не найден или токен недействителен"); + } + throw new Error(error.message); + } +}; + +export default updateSet; \ No newline at end of file