From 3ee88b85cb80f528311f6cd00935ad13936d7337 Mon Sep 17 00:00:00 2001 From: evsalik Date: Sun, 16 Jun 2024 14:00:20 +0300 Subject: [PATCH] register user list and registration panel --- src/api/register.api.ts | 26 +++++++ src/api/userslist.api.ts | 22 ++++++ src/assets/icons/people.svg | 3 + src/components/admin-header.vue | 2 + src/pages/registration.page.vue | 118 +++++++++++++++++++++++++------- src/pages/userslist.page.vue | 36 ++++++++++ src/router/router.ts | 6 ++ 7 files changed, 189 insertions(+), 24 deletions(-) create mode 100644 src/api/register.api.ts create mode 100644 src/api/userslist.api.ts create mode 100644 src/assets/icons/people.svg create mode 100644 src/pages/userslist.page.vue diff --git a/src/api/register.api.ts b/src/api/register.api.ts new file mode 100644 index 0000000..b2a642d --- /dev/null +++ b/src/api/register.api.ts @@ -0,0 +1,26 @@ +import axios from 'axios'; +import { apiUrl } from '@/router/router'; + +interface RegisterResponse { + id: number; +} + +interface RegisterData { + last_name: string; + first_name: string; + middle_name: string; + place: number; + phone_number: string; + email: string; + password: string; +} + +export const registerUser = async (data: RegisterData): Promise => { + try { + const response = await axios.post(`${apiUrl}/api/v1/users/register/`, data); + return response.data; + } catch (error) { + console.error('Error during registration:', error); + throw new Error('Registration failed'); + } +}; diff --git a/src/api/userslist.api.ts b/src/api/userslist.api.ts new file mode 100644 index 0000000..4cfa5c8 --- /dev/null +++ b/src/api/userslist.api.ts @@ -0,0 +1,22 @@ +import axios from 'axios'; +import { apiUrl } from '@/router/router'; + +interface User { + id: number; + last_name: string; + first_name: string; + middle_name: string; + place: number; + phone_number: string; + email: string; +} + +export const getUsers = async (): Promise => { + try { + const response = await axios.get(`${apiUrl}/api/v1/users/`); + return response.data; + } catch (error) { + console.error('Error fetching users:', error); + throw new Error('Failed to fetch users'); + } +}; diff --git a/src/assets/icons/people.svg b/src/assets/icons/people.svg new file mode 100644 index 0000000..c4434d5 --- /dev/null +++ b/src/assets/icons/people.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/admin-header.vue b/src/components/admin-header.vue index 21e9f5e..1dbd9f3 100644 --- a/src/components/admin-header.vue +++ b/src/components/admin-header.vue @@ -21,6 +21,7 @@ +