generated from moevm/nsql-clean-tempate
-
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.
- Loading branch information
1 parent
b55052c
commit a160988
Showing
10 changed files
with
648 additions
and
7 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,74 @@ | ||
<template> | ||
<div class="sidebar"> | ||
<div :class="{ active: isActive('/profile/dashboard') }"> | ||
<router-link to="/profile/dashboard"> | ||
<p> | ||
Мой профиль | ||
</p> | ||
</router-link> | ||
</div> | ||
<div :class="{ active: isActive('/profile/rents') }"> | ||
<router-link to="/profile/rents"> | ||
<p> | ||
Мои аренды | ||
</p> | ||
</router-link> | ||
</div> | ||
<div :class="{ active: isActive('/profile/edit') }"> | ||
<router-link to="/profile/edit"> | ||
<p> | ||
Редактировать профиль | ||
</p> | ||
</router-link> | ||
</div> | ||
<div :class="{ active: isActive('/profile/change-password') }"> | ||
<router-link to="/profile/change-password"> | ||
<p> | ||
Изменить пароль | ||
</p> | ||
</router-link> | ||
</div> | ||
<div @click="logoutUser"> | ||
<p> | ||
Выйти | ||
</p> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import {logoutUser} from "@/services/authService.js"; | ||
export default { | ||
name: "ProfileSideBar", | ||
methods: { | ||
logoutUser, | ||
isActive(route) { | ||
return this.$route.path === route; | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.sidebar { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
.sidebar div { | ||
padding: 8px; | ||
border-left: 3px solid rgba(0, 0, 0, 0.2); | ||
} | ||
.sidebar div.active { | ||
border-left: 3px solid #6A983C; | ||
} | ||
p { | ||
margin-left: 8px; | ||
cursor: pointer; | ||
color: black; | ||
font-size: 16px; | ||
} | ||
</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
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,56 @@ | ||
import axios from 'axios'; | ||
import { useToast } from 'vue-toastification' | ||
|
||
const toast = useToast() | ||
|
||
const API_URL = 'http://localhost:8000/api/clients'; | ||
|
||
|
||
export const getProfileData = async (userData) => { | ||
try{ | ||
const response = await axios.get(`${API_URL}/${localStorage.getItem('id')}/private`); | ||
return response.data | ||
} catch (error) { | ||
const errorMessage = error.response | ||
? error.response.data.message // Если есть ответ от сервера | ||
: error.message || 'Ошибка соединения'; | ||
toast.error(errorMessage) | ||
return "ERROR" | ||
} | ||
}; | ||
|
||
export const updateProfileData = async (profileData) => { | ||
try{ | ||
const response = await axios.patch(`${API_URL}/${localStorage.getItem('id')}`, profileData, { | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
toast.success("Данные успешно обновлены!") | ||
return "SUCCESS" | ||
} catch (error) { | ||
const errorMessage = error.response | ||
? error.response.data.message // Если есть ответ от сервера | ||
: error.message || 'Ошибка соединения'; | ||
toast.error(errorMessage) | ||
return "ERROR" | ||
} | ||
} | ||
|
||
export const changePassword = async (formData) => { | ||
try{ | ||
const response = await axios.patch(`${API_URL}/${localStorage.getItem('id')}/password`, formData, { | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
toast.success("Пароль успешно обновлен!") | ||
return "SUCCESS" | ||
} catch (error) { | ||
const errorMessage = error.response | ||
? error.response.data.message // Если есть ответ от сервера | ||
: error.message || 'Ошибка соединения'; | ||
toast.error(errorMessage) | ||
return "ERROR" | ||
} | ||
} |
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
Oops, something went wrong.