-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from shampiniony/register
register user list and registration panel
- Loading branch information
Showing
7 changed files
with
189 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<RegisterResponse> => { | ||
try { | ||
const response = await axios.post<RegisterResponse>(`${apiUrl}/api/v1/users/register/`, data); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error during registration:', error); | ||
throw new Error('Registration failed'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<User[]> => { | ||
try { | ||
const response = await axios.get<User[]>(`${apiUrl}/api/v1/users/`); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error fetching users:', error); | ||
throw new Error('Failed to fetch users'); | ||
} | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<div class="flex justify-center items-center min-h-screen bg-white w-[100%]"> | ||
<div class="bg-white mt-5 p-8 rounded w-full max-w-lg mx-auto"> | ||
<h2 class="text-2xl font-bold mb-6 text-center">СПИСОК ПОЛЬЗОВАТЕЛЕЙ</h2> | ||
<ul v-if="users.length > 0" class="list-disc pl-5"> | ||
<li v-for="user in users" :key="user.id" class="mb-2"> | ||
{{ user.last_name }} {{ user.first_name }} {{ user.middle_name }} - {{ user.email }} - {{ user.phone_number }} | ||
</li> | ||
</ul> | ||
<p v-else>Пользователи не найдены</p> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref, onMounted } from 'vue'; | ||
import { getUsers } from '@/api/userslist.api'; | ||
const users = ref([]); | ||
onMounted(async () => { | ||
try { | ||
const fetchedUsers = await getUsers(); | ||
users.value = fetchedUsers; | ||
console.log('Fetched users:', users.value); | ||
} catch (error) { | ||
console.error('Error fetching users:', error); | ||
} | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.bg-logo-blue { | ||
background-color: #6193b1; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters