diff --git a/WEB/src/api/auth/loginRequest.js b/WEB/src/api/auth/loginRequest.js index 2e81cb1..f49d27d 100644 --- a/WEB/src/api/auth/loginRequest.js +++ b/WEB/src/api/auth/loginRequest.js @@ -6,10 +6,13 @@ const loginUser = async (loginData) => { const response = await axios.post(`${CONFIG.BASE_URL}/auth/`, loginData, { withCredentials: true, }); - return response.data.access_token; + + const { access_token, user_id } = response.data; + + return { access_token, user_id }; } catch (error) { - if (error.status === 401) { - throw new Error("Неверное имя пользователя или пароль") + if (error.response?.status === 401) { + throw new Error("Неверное имя пользователя или пароль"); } throw new Error(error.message); diff --git a/WEB/src/api/contests/getContests.js b/WEB/src/api/contests/getContests.js new file mode 100644 index 0000000..01ca95e --- /dev/null +++ b/WEB/src/api/contests/getContests.js @@ -0,0 +1,18 @@ +import axios from "axios"; +import CONFIG from "@/core/config.js"; + +const fetchContests = async () => { + try { + const response = await axios.get(`${CONFIG.BASE_URL}/contests`, { + withCredentials: true, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Нет доступа к конкурсам (401)"); + } + throw new Error(error.message); + } +}; + +export default fetchContests; diff --git a/WEB/src/api/profiles/getUserProfile.js b/WEB/src/api/profiles/getUserProfile.js new file mode 100644 index 0000000..9070314 --- /dev/null +++ b/WEB/src/api/profiles/getUserProfile.js @@ -0,0 +1,17 @@ +import axios from 'axios' +import CONFIG from '../../core/config.js' + +const getUserProfile = async (user_id, token) => { + try { + const response = await axios.get(`${CONFIG.BASE_URL}/profiles/${user_id}/`, { + headers: { + Authorization: `Bearer ${token}` + } + }) + return response.data + } catch (error) { + throw new Error(error.response?.data?.detail || 'Ошибка получения профиля') + } +} + +export default getUserProfile diff --git a/WEB/src/api/projects/getProjects.js b/WEB/src/api/projects/getProjects.js new file mode 100644 index 0000000..d0c5fdf --- /dev/null +++ b/WEB/src/api/projects/getProjects.js @@ -0,0 +1,18 @@ +import axios from "axios"; +import CONFIG from "@/core/config.js"; + +const fetchProjects = async () => { + try { + const response = await axios.get(`${CONFIG.BASE_URL}/projects`, { + withCredentials: true, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Нет доступа к проектам (401)"); + } + throw new Error(error.message); + } +}; + +export default fetchProjects; diff --git a/WEB/src/api/teams/getTeams.js b/WEB/src/api/teams/getTeams.js new file mode 100644 index 0000000..b6b6650 --- /dev/null +++ b/WEB/src/api/teams/getTeams.js @@ -0,0 +1,24 @@ +import axios from "axios"; +import CONFIG from "@/core/config.js"; + +const fetchTeams = async () => { + try { + const token = localStorage.getItem("access_token"); + const response = await axios.get(`${CONFIG.BASE_URL}/teams`, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Нет доступа к командам (401)"); + } else if (error.response?.status === 403) { + throw new Error("Доступ запрещён (403)"); + } + throw new Error(error.message); + } +}; + +export default fetchTeams; diff --git a/WEB/src/api/teams/updateTeam.js b/WEB/src/api/teams/updateTeam.js new file mode 100644 index 0000000..3cfd514 --- /dev/null +++ b/WEB/src/api/teams/updateTeam.js @@ -0,0 +1,17 @@ +import axios from 'axios' +import CONFIG from '@/core/config.js' + +const updateTeam = async (team) => { + try { + const response = await axios.put( + `${CONFIG.BASE_URL}/teams/${team.id}`, + team, + { withCredentials: true } + ) + return response.data + } catch (error) { + throw new Error(error.response?.data?.detail || error.message) + } +} + +export default updateTeam diff --git a/WEB/src/api/users/getUsers.js b/WEB/src/api/users/getUsers.js new file mode 100644 index 0000000..5411f49 --- /dev/null +++ b/WEB/src/api/users/getUsers.js @@ -0,0 +1,18 @@ +import axios from "axios"; +import CONFIG from "@/core/config.js"; + +const fetchUsers = async () => { + try { + const response = await axios.get(`${CONFIG.BASE_URL}/users`, { + withCredentials: true, + }); + return response.data; + } catch (error) { + if (error.response?.status === 401) { + throw new Error("Нет доступа к пользователям (401)"); + } + throw new Error(error.message); + } +}; + +export default fetchUsers; diff --git a/WEB/src/main.js b/WEB/src/main.js index 337e9ff..31ad124 100644 --- a/WEB/src/main.js +++ b/WEB/src/main.js @@ -1,8 +1,33 @@ -import { createApp } from 'vue' +import {createApp} from 'vue' import App from './App.vue' -import { Quasar, Notify, Dialog, Loading, QInput, QBtn, QForm, QCard, QCardSection } from 'quasar' import router from './router' +import { + Quasar, + Notify, + Dialog, + Loading, + QInput, + QBtn, + QForm, + QCard, + QCardSection, + QLayout, + QPageContainer, + QPage, + QTabs, + QTab, + QTabPanels, + QTabPanel, + QHeader, + QTable, + QSeparator, + QCardActions, + QDialog, + QIcon +} from 'quasar' + + import '@quasar/extras/material-icons/material-icons.css' @@ -11,8 +36,13 @@ import 'quasar/src/css/index.sass' const app = createApp(App) app.use(Quasar, { - plugins: { Notify, Dialog, Loading }, // уведомления, диалоги, загрузка - components: { QInput, QBtn, QForm, QCard, QCardSection } // обязательно указать используемые компоненты + plugins: {Notify, Dialog, Loading}, + components: { + QInput, QBtn, QForm, QCard, QCardSection, + QLayout, QPageContainer, QPage, + QTabs, QTab, QTabPanels, QTabPanel, QHeader,QTable, + QSeparator, QCardActions, QDialog, QIcon + } }) app.use(router) diff --git a/WEB/src/pages/AdminPage.vue b/WEB/src/pages/AdminPage.vue index 638cd85..e412d94 100644 --- a/WEB/src/pages/AdminPage.vue +++ b/WEB/src/pages/AdminPage.vue @@ -1,912 +1,271 @@ - \ No newline at end of file + diff --git a/WEB/src/pages/HomePage.vue b/WEB/src/pages/HomePage.vue index 97c9d70..0e81331 100644 --- a/WEB/src/pages/HomePage.vue +++ b/WEB/src/pages/HomePage.vue @@ -1,17 +1,15 @@ +